I tried something like this in array.c
rb_ary_initialize(int argc, VALUE *argv, VALUE ary)
{
long len;
int ln;
int *ar;
VALUE size, val;
switch (TYPE(ary)) {
case T_FIXNUM:
break;
case T_STRING:
break;
case T_ARRAY:
ar=RARRAY(ary);
ln=RARRAY_LEN(ary);
printf(“ln: %d\n”,ln);
ar=RARRAY_PTR(ary);
break;
default:
rb_raise(rb_eTypeError, “not valid value”);
break;
}
gdb ./ruby
(gdb)run
ctrl+c
(gdb)break array.c:rb_ary_initialize
(gdb)continue
arr=Array.new(3)
arr[0]=5
arr[1]=7
ctrl+d
(gdb)next
But i can’t understand how to print the value using printf(); in
array.c:rb_ary_initialize function doing some casting.
Can anyone post reply with example to do it?
https://github.com/ruby/ruby/blob/trunk/README.EXT#L125
https://github.com/ruby/ruby/blob/trunk/array.c#L569
Thanks.