Alex Gutteridge wrote in post #962544:
Can you tell me how to call those two?...And do I need to write some
print statement within those one.??
Regards
There doesn't seem to be any mystery here, just search for GC_NOTIFY in
gc.c and set it to true rather than false. E.g.
#define GC_NOTIFY 0
becomes
#define GC_NOTIFY 1
That change alone prints "start garbage_collect()" whenever
garbage_collect() is run:
GUTTEA$ ./ruby -e 'GC.start'
start garbage_collect()
end garbage_collect()
Defining RUBY_MARK_FREE_DEBUG in gc.h gives lots more info as well:
GUTTEA$ ./ruby -e 'GC.start'
start garbage_collect()
mark: -> iseq (0x100624900)
require @ <internal:lib/rubygems/custom_require>
mark: -> iseq (0x100624cb0)
rescue in require @ <internal:lib/rubygems/custom_require>
mark: <- iseq (0x100624cb0)
mark: <- iseq (0x100624900)
mark: -> iseq (0x100612b90)
gem @ <internal:gem_prelude>
mark: <- iseq (0x100612b90)
mark: -> iseq (0x10060c950)
[.......]
I don't see any problem with adding your own debug statements as well if
you want:
static int
garbage_collect(rb_objspace_t *objspace)
{
struct gc_list *list;
rb_thread_t *th = GET_THREAD();
INIT_GC_PROF_PARAMS;
if (GC_NOTIFY) printf("start garbage_collect()\n");
printf("WoopWoop\n");
[....]
GUTTEA$ ./ruby -e 'GC.start'
start garbage_collect()
WoopWoop
[....]