* 2022-01-18 [ci skip]
[ruby-80x24.org.git] / .gdbinit
blob8979e8b47c5ab10512751c5405cff4b14ae64a69
1 set startup-with-shell off
3 define hook-run
4   set $color_type = 0
5   set $color_highlite = 0
6   set $color_end = 0
7 end
9 define ruby_gdb_init
10   if !$color_type
11     set $color_type = "\033[31m"
12   end
13   if !$color_highlite
14     set $color_highlite = "\033[36m"
15   end
16   if !$color_end
17     set $color_end = "\033[m"
18   end
19   if ruby_dummy_gdb_enums.special_consts
20   end
21 end
23 # set prompt \033[36m(gdb)\033[m\040
25 define rp
26   ruby_gdb_init
27   if (VALUE)($arg0) & RUBY_FIXNUM_FLAG
28     printf "FIXNUM: %ld\n", (long)($arg0) >> 1
29   else
30   if ((VALUE)($arg0) & ~(~(VALUE)0<<RUBY_SPECIAL_SHIFT)) == RUBY_SYMBOL_FLAG
31     set $id = (($arg0) >> RUBY_SPECIAL_SHIFT)
32     printf "%sSYMBOL%s: ", $color_type, $color_end
33     rp_id $id
34   else
35   if ($arg0) == RUBY_Qfalse
36     echo false\n
37   else
38   if ($arg0) == RUBY_Qtrue
39     echo true\n
40   else
41   if ($arg0) == RUBY_Qnil
42     echo nil\n
43   else
44   if ($arg0) == RUBY_Qundef
45     echo undef\n
46   else
47   if (VALUE)($arg0) & RUBY_IMMEDIATE_MASK
48     if ((VALUE)($arg0) & RUBY_FLONUM_MASK) == RUBY_FLONUM_FLAG
49       printf "%sFLONUM%s: %g\n", $color_type, $color_end, (double)rb_float_value($arg0)
50     else
51       echo immediate\n
52     end
53   else
54   set $flags = ((struct RBasic*)($arg0))->flags
55   if ($flags & RUBY_FL_PROMOTED) == RUBY_FL_PROMOTED
56     printf "[PROMOTED] "
57   end
58   if ($flags & RUBY_T_MASK) == RUBY_T_NONE
59     printf "%sT_NONE%s: ", $color_type, $color_end
60     print (struct RBasic *)($arg0)
61   else
62   if ($flags & RUBY_T_MASK) == RUBY_T_NIL
63     printf "%sT_NIL%s: ", $color_type, $color_end
64     print (struct RBasic *)($arg0)
65   else
66   if ($flags & RUBY_T_MASK) == RUBY_T_OBJECT
67     printf "%sT_OBJECT%s: ", $color_type, $color_end
68     print ((struct RObject *)($arg0))->basic
69     if ($flags & ROBJECT_EMBED)
70       print/x *((VALUE*)((struct RObject*)($arg0))->as.ary) @ (ROBJECT_EMBED_LEN_MAX+0)
71     else
72       print (((struct RObject *)($arg0))->as.heap)
73       if (((struct RObject*)($arg0))->as.heap.numiv) > 0
74         print/x *(((struct RObject*)($arg0))->as.heap.ivptr) @ (((struct RObject*)($arg0))->as.heap.numiv)
75       end
76     end
77   else
78   if ($flags & RUBY_T_MASK) == RUBY_T_CLASS
79     printf "%sT_CLASS%s%s: ", $color_type, ($flags & RUBY_FL_SINGLETON) ? "*" : "", $color_end
80     rp_class $arg0
81   else
82   if ($flags & RUBY_T_MASK) == RUBY_T_ICLASS
83     printf "%sT_ICLASS%s: ", $color_type, $color_end
84     rp_class $arg0
85   else
86   if ($flags & RUBY_T_MASK) == RUBY_T_MODULE
87     printf "%sT_MODULE%s: ", $color_type, $color_end
88     rp_class $arg0
89   else
90   if ($flags & RUBY_T_MASK) == RUBY_T_FLOAT
91     printf "%sT_FLOAT%s: %.16g ", $color_type, $color_end, (((struct RFloat*)($arg0))->float_value)
92     print (struct RFloat *)($arg0)
93   else
94   if ($flags & RUBY_T_MASK) == RUBY_T_STRING
95     printf "%sT_STRING%s: ", $color_type, $color_end
96     rp_string $arg0 $flags
97   else
98   if ($flags & RUBY_T_MASK) == RUBY_T_REGEXP
99     set $regsrc = ((struct RRegexp*)($arg0))->src
100     set $rsflags = ((struct RBasic*)$regsrc)->flags
101     printf "%sT_REGEXP%s: ", $color_type, $color_end
102     set $len = ($rsflags & RUBY_FL_USER1) ? \
103             ((struct RString*)$regsrc)->as.heap.len : \
104             (($rsflags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
105     set print address off
106     output *(char *)(($rsflags & RUBY_FL_USER1) ? \
107             ((struct RString*)$regsrc)->as.heap.ptr : \
108             ((struct RString*)$regsrc)->as.ary) @ $len
109     set print address on
110     printf " len:%ld ", $len
111     if $flags & RUBY_FL_USER6
112       printf "(none) "
113     end
114     if $flags & RUBY_FL_USER5
115       printf "(literal) "
116     end
117     if $flags & RUBY_FL_USER4
118       printf "(fixed) "
119     end
120     printf "encoding:%d ", ($flags & RUBY_ENCODING_MASK) >> RUBY_ENCODING_SHIFT
121     print (struct RRegexp *)($arg0)
122   else
123   if ($flags & RUBY_T_MASK) == RUBY_T_ARRAY
124     if ($flags & RUBY_FL_USER1)
125       set $len = (($flags & (RUBY_FL_USER3|RUBY_FL_USER4)) >> (RUBY_FL_USHIFT+3))
126       printf "%sT_ARRAY%s: len=%ld ", $color_type, $color_end, $len
127       printf "(embed) "
128       if ($len == 0)
129         printf "{(empty)} "
130       else
131         print/x *((VALUE*)((struct RArray*)($arg0))->as.ary) @ $len
132         printf " "
133       end
134     else
135       set $len = ((struct RArray*)($arg0))->as.heap.len
136       printf "%sT_ARRAY%s: len=%ld ", $color_type, $color_end, $len
137       if ($flags & RUBY_FL_USER2)
138         printf "(shared) shared="
139         output/x ((struct RArray*)($arg0))->as.heap.aux.shared_root
140         printf " "
141       else
142         printf "(ownership) capa=%ld ", ((struct RArray*)($arg0))->as.heap.aux.capa
143       end
144       if ($len == 0)
145         printf "{(empty)} "
146       else
147         print/x *((VALUE*)((struct RArray*)($arg0))->as.heap.ptr) @ $len
148         printf " "
149       end
150     end
151     print (struct RArray *)($arg0)
152   else
153   if ($flags & RUBY_T_MASK) == RUBY_T_FIXNUM
154     printf "%sT_FIXNUM%s: ", $color_type, $color_end
155     print (struct RBasic *)($arg0)
156   else
157   if ($flags & RUBY_T_MASK) == RUBY_T_HASH
158     printf "%sT_HASH%s: ", $color_type, $color_end,
159     if (((struct RHash *)($arg0))->basic.flags & RHASH_ST_TABLE_FLAG)
160       printf "st len=%ld ", ((struct RHash *)($arg0))->as.st->num_entries
161     else
162       printf "li len=%ld bound=%ld ", \
163         ((((struct RHash *)($arg0))->basic.flags & RHASH_AR_TABLE_SIZE_MASK) >> RHASH_AR_TABLE_SIZE_SHIFT), \
164         ((((struct RHash *)($arg0))->basic.flags & RHASH_AR_TABLE_BOUND_MASK) >> RHASH_AR_TABLE_BOUND_SHIFT)
165     end
166     print (struct RHash *)($arg0)
167   else
168   if ($flags & RUBY_T_MASK) == RUBY_T_STRUCT
169     set $len = (($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) ? \
170        ($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) >> (RUBY_FL_USHIFT+1) : \
171        ((struct RStruct *)($arg0))->as.heap.len)
172     printf "%sT_STRUCT%s: len=%ld ", $color_type, $color_end, $len
173     print (struct RStruct *)($arg0)
174     output/x *(($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) ? \
175               ((struct RStruct *)($arg0))->as.ary : \
176               ((struct RStruct *)($arg0))->as.heap.ptr) @ $len
177   else
178   if ($flags & RUBY_T_MASK) == RUBY_T_BIGNUM
179     rp_bignum $arg0
180   else
181   if ($flags & RUBY_T_MASK) == RUBY_T_RATIONAL
182     printf "%sT_RATIONAL%s: ", $color_type, $color_end
183     print (struct RRational *)($arg0)
184   else
185   if ($flags & RUBY_T_MASK) == RUBY_T_COMPLEX
186     printf "%sT_COMPLEX%s: ", $color_type, $color_end
187     print (struct RComplex *)($arg0)
188   else
189   if ($flags & RUBY_T_MASK) == RUBY_T_FILE
190     printf "%sT_FILE%s: ", $color_type, $color_end
191     print (struct RFile *)($arg0)
192     output *((struct RFile *)($arg0))->fptr
193     printf "\n"
194   else
195   if ($flags & RUBY_T_MASK) == RUBY_T_TRUE
196     printf "%sT_TRUE%s: ", $color_type, $color_end
197     print (struct RBasic *)($arg0)
198   else
199   if ($flags & RUBY_T_MASK) == RUBY_T_FALSE
200     printf "%sT_FALSE%s: ", $color_type, $color_end
201     print (struct RBasic *)($arg0)
202   else
203   if ($flags & RUBY_T_MASK) == RUBY_T_DATA
204     if ((struct RTypedData *)($arg0))->typed_flag == 1
205       printf "%sT_DATA%s(%s): ", $color_type, $color_end, ((struct RTypedData *)($arg0))->type->wrap_struct_name
206       print (struct RTypedData *)($arg0)
207     else
208       printf "%sT_DATA%s: ", $color_type, $color_end
209       print (struct RData *)($arg0)
210     end
211   else
212   if ($flags & RUBY_T_MASK) == RUBY_T_MATCH
213     printf "%sT_MATCH%s: ", $color_type, $color_end
214     print (struct RMatch *)($arg0)
215   else
216   if ($flags & RUBY_T_MASK) == RUBY_T_SYMBOL
217     printf "%sT_SYMBOL%s: ", $color_type, $color_end
218     print (struct RSymbol *)($arg0)
219     set $id_type = ((struct RSymbol *)($arg0))->id & RUBY_ID_SCOPE_MASK
220     if $id_type == RUBY_ID_LOCAL
221       printf "l"
222     else
223     if $id_type == RUBY_ID_INSTANCE
224       printf "i"
225     else
226     if $id_type == RUBY_ID_GLOBAL
227       printf "G"
228     else
229     if $id_type == RUBY_ID_ATTRSET
230       printf "a"
231     else
232     if $id_type == RUBY_ID_CONST
233       printf "C"
234     else
235     if $id_type == RUBY_ID_CLASS
236       printf "c"
237     else
238       printf "j"
239     end
240     end
241     end
242     end
243     end
244     end
245     set $id_fstr = ((struct RSymbol *)($arg0))->fstr
246     rp_string $id_fstr
247   else
248   if ($flags & RUBY_T_MASK) == RUBY_T_UNDEF
249     printf "%sT_UNDEF%s: ", $color_type, $color_end
250     print (struct RBasic *)($arg0)
251   else
252   if ($flags & RUBY_T_MASK) == RUBY_T_IMEMO
253     printf "%sT_IMEMO%s(", $color_type, $color_end
254     output (enum imemo_type)(($flags>>RUBY_FL_USHIFT)&RUBY_IMEMO_MASK)
255     printf "): "
256     rp_imemo $arg0
257   else
258   if ($flags & RUBY_T_MASK) == RUBY_T_NODE
259     printf "%sT_NODE%s(", $color_type, $color_end
260     output (enum node_type)(($flags&RUBY_NODE_TYPEMASK)>>RUBY_NODE_TYPESHIFT)
261     printf "): "
262     print *(NODE *)($arg0)
263   else
264   if ($flags & RUBY_T_MASK) == RUBY_T_ZOMBIE
265     printf "%sT_ZOMBIE%s: ", $color_type, $color_end
266     print (struct RData *)($arg0)
267   else
268   if ($flags & RUBY_T_MASK) == RUBY_T_MOVED
269     printf "%sT_MOVED%s: ", $color_type, $color_end
270     print *(struct RMoved *)$arg0
271   else
272     printf "%sunknown%s: ", $color_type, $color_end
273     print (struct RBasic *)($arg0)
274   end
275   end
276   end
277   end
278   end
279   end
280   end
281   end
282   end
283   end
284   end
285   end
286   end
287   end
288   end
289   end
290   end
291   end
292   end
293   end
294   end
295   end
296   end
297   end
298   end
299   end
300   end
301   end
302   end
303   end
304   end
305   end
306   end
307   end
309 document rp
310   Print a Ruby's VALUE.
313 define rp_id
314   set $id = (ID)$arg0
315   if $id == '!' || $id == '+' || $id == '-' || $id == '*' || $id == '/' || $id == '%' || $id == '<' || $id == '>' || $id == '`'
316     printf "(:%c)\n", $id
317   else
318   if $id == idDot2
319     printf "(:..)\n"
320   else
321   if $id == idDot3
322     printf "(:...)\n"
323   else
324   if $id == idUPlus
325     printf "(:+@)\n"
326   else
327   if $id == idUMinus
328     printf "(:-@)\n"
329   else
330   if $id == idPow
331     printf "(:**)\n"
332   else
333   if $id == idCmp
334     printf "(:<=>)\n"
335   else
336   if $id == idLTLT
337     printf "(:<<)\n"
338   else
339   if $id == idGTGT
340     printf "(:>>)\n"
341   else
342   if $id == idLE
343     printf "(:<=)\n"
344   else
345   if $id == idGE
346     printf "(:>=)\n"
347   else
348   if $id == idEq
349     printf "(:==)\n"
350   else
351   if $id == idEqq
352     printf "(:===)\n"
353   else
354   if $id == idNeq
355     printf "(:!=)\n"
356   else
357   if $id == idEqTilde
358     printf "(:=~)\n"
359   else
360   if $id == idNeqTilde
361     printf "(:!~)\n"
362   else
363   if $id == idAREF
364     printf "(:[])\n"
365   else
366   if $id == idASET
367     printf "(:[]=)\n"
368   else
369   if $id == idCOLON2
370     printf "(:'::')\n"
371   else
372   if $id == idANDOP
373     printf "(:&&)\n"
374   else
375   if $id == idOROP
376     printf "(:||)\n"
377   else
378   if $id == idANDDOT
379     printf "(:&.)\n"
380   else
381     if $id <= tLAST_OP_ID
382       printf "O"
383     else
384       set $id_type = $id & RUBY_ID_SCOPE_MASK
385       if $id_type == RUBY_ID_LOCAL
386         printf "l"
387       else
388       if $id_type == RUBY_ID_INSTANCE
389         printf "i"
390       else
391       if $id_type == RUBY_ID_GLOBAL
392         printf "G"
393       else
394       if $id_type == RUBY_ID_ATTRSET
395         printf "a"
396       else
397       if $id_type == RUBY_ID_CONST
398         printf "C"
399       else
400       if $id_type == RUBY_ID_CLASS
401         printf "c"
402       else
403         printf "j"
404       end
405       end
406       end
407       end
408       end
409       end
410     end
411     printf "(%ld): ", $id
412     print_id $id
413     echo \n
414   end
415   end
416   end
417   end
418   end
419   end
420   end
421   end
422   end
423   end
424   end
425   end
426   end
427   end
428   end
429   end
430   end
431   end
432   end
433   end
434   end
435   end
437 document rp_id
438   Print an ID.
441 define output_string
442   set $flags = ((struct RBasic*)($arg0))->flags
443   set $len = ($flags & RUBY_FL_USER1) ? \
444           ((struct RString*)($arg0))->as.heap.len : \
445           (($flags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
446   if $len > 0
447     output *(char *)(($flags & RUBY_FL_USER1) ? \
448             ((struct RString*)($arg0))->as.heap.ptr : \
449             ((struct RString*)($arg0))->as.ary) @ $len
450   else
451     output ""
452   end
455 define print_string
456   set $flags = ((struct RBasic*)($arg0))->flags
457   set $len = ($flags & RUBY_FL_USER1) ? \
458           ((struct RString*)($arg0))->as.heap.len : \
459           (($flags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
460   if $len > 0
461     printf "%s", *(char *)(($flags & RUBY_FL_USER1) ? \
462             ((struct RString*)($arg0))->as.heap.ptr : \
463             ((struct RString*)($arg0))->as.ary) @ $len
464   end
467 define rp_string
468   output_string $arg0
469   printf " bytesize:%ld ", $len
470   if !($flags & RUBY_FL_USER1)
471     printf "(embed) "
472   else
473     if ($flags & RUBY_FL_USER2)
474       printf "(shared) "
475     end
476     if ($flags & RUBY_FL_USER3)
477       printf "(assoc) "
478     end
479   end
480   printf "encoding:%d ", ($flags & RUBY_ENCODING_MASK) >> RUBY_ENCODING_SHIFT
481   if ($flags & RUBY_ENC_CODERANGE_MASK) == 0
482     printf "coderange:unknown "
483   else
484   if ($flags & RUBY_ENC_CODERANGE_MASK) == RUBY_ENC_CODERANGE_7BIT
485     printf "coderange:7bit "
486   else
487   if ($flags & RUBY_ENC_CODERANGE_MASK) == RUBY_ENC_CODERANGE_VALID
488     printf "coderange:valid "
489   else
490     printf "coderange:broken "
491   end
492   end
493   end
494   print (struct RString *)($arg0)
496 document rp_string
497   Print the content of a String.
500 define rp_bignum
501   set $flags = ((struct RBignum*)($arg0))->basic.flags
502   set $len = (($flags & RUBY_FL_USER2) ? \
503        ($flags & (RUBY_FL_USER5|RUBY_FL_USER4|RUBY_FL_USER3)) >> (RUBY_FL_USHIFT+3) : \
504        ((struct RBignum*)($arg0))->as.heap.len)
505   printf "%sT_BIGNUM%s: sign=%d len=%ld ", $color_type, $color_end, \
506          (($flags & RUBY_FL_USER1) != 0), $len
507   if $flags & RUBY_FL_USER2
508     printf "(embed) "
509   end
510   print (struct RBignum *)($arg0)
511   set $ptr = (($flags & RUBY_FL_USER2) ? \
512               ((struct RBignum*)($arg0))->as.ary : \
513               ((struct RBignum*)($arg0))->as.heap.digits)
514   set $len = $len-1
515   printf "0x%x", $ptr[$len]
516   while $len > 0
517     set $len = $len-1
518     set $val = $ptr[$len]
519     set $w = sizeof($ptr[0])
520     printf "_"
521     if $w > 8
522       printf "%.32x", $val
523     else
524     if $w > 4
525       printf "%.16x", $val
526     else
527     if $w > 2
528       printf "%.8x", $val
529     else
530     if $w > 1
531       printf "%.4x", $val
532     else
533       printf "%.2x", $val
534     end
535     end
536     end
537     end
538   end
539   printf "\n"
541 document rp_bignum
542   Print the content of a Bignum.
545 define rp_class
546   printf "(struct RClass *) %p", (void*)$arg0
547   if ((struct RClass *)($arg0))->ptr.origin_ != $arg0
548     printf " -> %p", ((struct RClass *)($arg0))->ptr.origin_
549   end
550   printf "\n"
551   rb_classname $arg0
552   print/x *(struct RClass *)($arg0)
553   print *((struct RClass *)($arg0))->ptr
555 document rp_class
556   Print the content of a Class/Module.
559 define rp_imemo
560   set $flags = (enum imemo_type)((((struct RBasic *)($arg0))->flags >> RUBY_FL_USHIFT) & RUBY_IMEMO_MASK)
561   if $flags == imemo_cref
562     printf "(rb_cref_t *) %p\n", (void*)$arg0
563     print *(rb_cref_t *)$arg0
564   else
565   if $flags == imemo_svar
566     printf "(struct vm_svar *) %p\n", (void*)$arg0
567     print *(struct vm_svar *)$arg0
568   else
569   if $flags == imemo_throw_data
570     printf "(struct vm_throw_data *) %p\n", (void*)$arg0
571     print *(struct vm_throw_data *)$arg0
572   else
573   if $flags == imemo_ifunc
574     printf "(struct vm_ifunc *) %p\n", (void*)$arg0
575     print *(struct vm_ifunc *)$arg0
576   else
577   if $flags == imemo_memo
578     printf "(struct MEMO *) %p\n", (void*)$arg0
579     print *(struct MEMO *)$arg0
580   else
581   if $flags == imemo_ment
582     printf "(rb_method_entry_t *) %p\n", (void*)$arg0
583     print *(rb_method_entry_t *)$arg0
584   else
585   if $flags == imemo_iseq
586     printf "(rb_iseq_t *) %p\n", (void*)$arg0
587     print *(rb_iseq_t *)$arg0
588   else
589     printf "(struct RIMemo *) %p\n", (void*)$arg0
590     print *(struct RIMemo *)$arg0
591   end
592   end
593   end
594   end
595   end
596   end
597   end
599 document rp_imemo
600   Print the content of a memo
603 define nd_type
604   print (enum node_type)((((NODE*)($arg0))->flags&RUBY_NODE_TYPEMASK)>>RUBY_NODE_TYPESHIFT)
606 document nd_type
607   Print a Ruby' node type.
610 define nd_file
611   print ((NODE*)($arg0))->nd_file
613 document nd_file
614   Print the source file name of a node.
617 define nd_line
618   print ((unsigned int)((((NODE*)($arg0))->flags>>RUBY_NODE_LSHIFT)&RUBY_NODE_LMASK))
620 document nd_line
621   Print the source line number of a node.
624 # Print members of ruby node.
626 define nd_head
627   printf "%su1.node%s: ", $color_highlite, $color_end
628   rp ($arg0).u1.node
631 define nd_alen
632   printf "%su2.argc%s: ", $color_highlite, $color_end
633   p ($arg0).u2.argc
636 define nd_next
637   printf "%su3.node%s: ", $color_highlite, $color_end
638   rp ($arg0).u3.node
642 define nd_cond
643   printf "%su1.node%s: ", $color_highlite, $color_end
644   rp ($arg0).u1.node
647 define nd_body
648   printf "%su2.node%s: ", $color_highlite, $color_end
649   rp ($arg0).u2.node
652 define nd_else
653   printf "%su3.node%s: ", $color_highlite, $color_end
654   rp ($arg0).u3.node
658 define nd_orig
659   printf "%su3.value%s: ", $color_highlite, $color_end
660   rp ($arg0).u3.value
664 define nd_resq
665   printf "%su2.node%s: ", $color_highlite, $color_end
666   rp ($arg0).u2.node
669 define nd_ensr
670   printf "%su3.node%s: ", $color_highlite, $color_end
671   rp ($arg0).u3.node
675 define nd_1st
676   printf "%su1.node%s: ", $color_highlite, $color_end
677   rp ($arg0).u1.node
680 define nd_2nd
681   printf "%su2.node%s: ", $color_highlite, $color_end
682   rp ($arg0).u2.node
686 define nd_stts
687   printf "%su1.node%s: ", $color_highlite, $color_end
688   rp ($arg0).u1.node
692 define nd_entry
693   printf "%su3.entry%s: ", $color_highlite, $color_end
694   p ($arg0).u3.entry
697 define nd_vid
698   printf "%su1.id%s: ", $color_highlite, $color_end
699   p ($arg0).u1.id
702 define nd_cflag
703   printf "%su2.id%s: ", $color_highlite, $color_end
704   p ($arg0).u2.id
707 define nd_cval
708   printf "%su3.value%s: ", $color_highlite, $color_end
709   rp ($arg0).u3.value
712 define nd_tbl
713   printf "%su1.tbl%s: ", $color_highlite, $color_end
714   p ($arg0).u1.tbl
718 define nd_var
719   printf "%su1.node%s: ", $color_highlite, $color_end
720   rp ($arg0).u1.node
723 define nd_ibdy
724   printf "%su2.node%s: ", $color_highlite, $color_end
725   rp ($arg0).u2.node
728 define nd_iter
729   printf "%su3.node%s: ", $color_highlite, $color_end
730   rp ($arg0).u3.node
734 define nd_value
735   printf "%su2.node%s: ", $color_highlite, $color_end
736   rp ($arg0).u2.node
739 define nd_aid
740   printf "%su3.id%s: ", $color_highlite, $color_end
741   p ($arg0).u3.id
745 define nd_lit
746   printf "%su1.value%s: ", $color_highlite, $color_end
747   rp ($arg0).u1.value
750 define nd_rest
751   printf "%su2.argc%s: ", $color_highlite, $color_end
752   p ($arg0).u2.argc
755 define nd_opt
756   printf "%su1.node%s: ", $color_highlite, $color_end
757   rp ($arg0).u1.node
761 define nd_recv
762   printf "%su1.node%s: ", $color_highlite, $color_end
763   rp ($arg0).u1.node
766 define nd_mid
767   printf "%su2.id%s: ", $color_highlite, $color_end
768   p ($arg0).u2.id
771 define nd_args
772   printf "%su3.node%s: ", $color_highlite, $color_end
773   rp ($arg0).u3.node
776 define nd_defn
777   printf "%su3.node%s: ", $color_highlite, $color_end
778   rp ($arg0).u3.node
782 define nd_old
783   printf "%su1.id%s: ", $color_highlite, $color_end
784   p ($arg0).u1.id
787 define nd_new
788   printf "%su2.id%s: ", $color_highlite, $color_end
789   p ($arg0).u2.id
793 define nd_cname
794   printf "%su1.id%s: ", $color_highlite, $color_end
795   p ($arg0).u1.id
798 define nd_super
799   printf "%su3.node%s: ", $color_highlite, $color_end
800   rp ($arg0).u3.node
804 define nd_modl
805   printf "%su1.id%s: ", $color_highlite, $color_end
806   p ($arg0).u1.id
809 define nd_clss
810   printf "%su1.value%s: ", $color_highlite, $color_end
811   rp ($arg0).u1.value
815 define nd_beg
816   printf "%su1.node%s: ", $color_highlite, $color_end
817   rp ($arg0).u1.node
820 define nd_end
821   printf "%su2.node%s: ", $color_highlite, $color_end
822   rp ($arg0).u2.node
825 define nd_state
826   printf "%su3.state%s: ", $color_highlite, $color_end
827   p ($arg0).u3.state
830 define nd_rval
831   printf "%su2.value%s: ", $color_highlite, $color_end
832   rp ($arg0).u2.value
836 define nd_nth
837   printf "%su2.argc%s: ", $color_highlite, $color_end
838   p ($arg0).u2.argc
842 define nd_tag
843   printf "%su1.id%s: ", $color_highlite, $color_end
844   p ($arg0).u1.id
847 define nd_tval
848   printf "%su2.value%s: ", $color_highlite, $color_end
849   rp ($arg0).u2.value
852 define nd_tree
853   set $buf = (struct RString *)rb_str_buf_new(0)
854   call dump_node((VALUE)($buf), rb_str_tmp_new(0), 0, ($arg0))
855   printf "%s\n", $buf->as.heap.ptr
858 define rb_p
859   call rb_p($arg0)
862 define rb_numtable_entry
863   set $rb_numtable_tbl = $arg0
864   set $rb_numtable_id = (st_data_t)$arg1
865   set $rb_numtable_key = 0
866   set $rb_numtable_rec = 0
867   if $rb_numtable_tbl->entries_packed
868     set $rb_numtable_p = $rb_numtable_tbl->as.packed.bins
869     while $rb_numtable_p && $rb_numtable_p < $rb_numtable_tbl->as.packed.bins+$rb_numtable_tbl->num_entries
870       if $rb_numtable_p.k == $rb_numtable_id
871         set $rb_numtable_key = $rb_numtable_p.k
872         set $rb_numtable_rec = $rb_numtable_p.v
873         set $rb_numtable_p = 0
874       else
875         set $rb_numtable_p = $rb_numtable_p + 1
876       end
877     end
878   else
879     set $rb_numtable_p = $rb_numtable_tbl->as.big.bins[st_numhash($rb_numtable_id) % $rb_numtable_tbl->num_bins]
880     while $rb_numtable_p
881       if $rb_numtable_p->key == $rb_numtable_id
882         set $rb_numtable_key = $rb_numtable_p->key
883         set $rb_numtable_rec = $rb_numtable_p->record
884         set $rb_numtable_p = 0
885       else
886         set $rb_numtable_p = $rb_numtable_p->next
887       end
888     end
889   end
892 define rb_id2name
893   ruby_gdb_init
894   printf "%sID%s: ", $color_type, $color_end
895   rp_id $arg0
897 document rb_id2name
898   Print the name of id
901 define rb_method_entry
902   set $rb_method_entry_klass = (struct RClass *)$arg0
903   set $rb_method_entry_id = (ID)$arg1
904   set $rb_method_entry_me = (rb_method_entry_t *)0
905   while !$rb_method_entry_me && $rb_method_entry_klass
906     rb_numtable_entry $rb_method_entry_klass->m_tbl_wrapper->tbl $rb_method_entry_id
907     set $rb_method_entry_me = (rb_method_entry_t *)$rb_numtable_rec
908     if !$rb_method_entry_me
909       set $rb_method_entry_klass = (struct RClass *)RCLASS_SUPER($rb_method_entry_klass)
910     end
911   end
912   if $rb_method_entry_me
913     print *$rb_method_entry_klass
914     print *$rb_method_entry_me
915   else
916     echo method not found\n
917   end
919 document rb_method_entry
920   Search method entry by class and id
923 define rb_classname
924   # up to 128bit int
925   set $rb_classname = rb_mod_name($arg0)
926   if $rb_classname != RUBY_Qnil
927     rp $rb_classname
928   else
929     echo anonymous class/module\n
930   end
933 define rb_ancestors
934   set $rb_ancestors_module = $arg0
935   while $rb_ancestors_module
936     rp_class $rb_ancestors_module
937     set $rb_ancestors_module = RCLASS_SUPER($rb_ancestors_module)
938   end
940 document rb_ancestors
941   Print ancestors.
944 define rb_backtrace
945   call rb_backtrace()
948 define iseq
949   if ruby_dummy_gdb_enums.special_consts
950   end
951   if ($arg0)->type == ISEQ_ELEMENT_NONE
952     echo [none]\n
953   end
954   if ($arg0)->type == ISEQ_ELEMENT_LABEL
955     print *(LABEL*)($arg0)
956   end
957   if ($arg0)->type == ISEQ_ELEMENT_INSN
958     print *(INSN*)($arg0)
959     if ((INSN*)($arg0))->insn_id != YARVINSN_jump
960       set $i = 0
961       set $operand_size = ((INSN*)($arg0))->operand_size
962       set $operands = ((INSN*)($arg0))->operands
963       while $i < $operand_size
964         rp $operands[$i++]
965       end
966     end
967   end
968   if ($arg0)->type == ISEQ_ELEMENT_ADJUST
969     print *(ADJUST*)($arg0)
970   end
973 define rb_ps
974   rb_ps_vm ruby_current_vm_ptr
976 document rb_ps
977 Dump all threads and their callstacks
980 define rb_ps_vm
981   print $ps_vm = (rb_vm_t*)$arg0
982   set $ps_thread_ln = $ps_vm->living_threads.n.next
983   set $ps_thread_ln_last = $ps_vm->living_threads.n.prev
984   while 1
985     set $ps_thread_th = (rb_thread_t *)$ps_thread_ln
986     set $ps_thread = (VALUE)($ps_thread_th->self)
987     rb_ps_thread $ps_thread
988     if $ps_thread_ln == $ps_thread_ln_last
989       loop_break
990     end
991     set $ps_thread_ln = $ps_thread_ln->next
992   end
994 document rb_ps_vm
995 Dump all threads in a (rb_vm_t*) and their callstacks
998 define print_lineno
999   set $cfp = $arg0
1000   set $iseq = $cfp->iseq
1001   set $pos = $cfp->pc - $iseq->body->iseq_encoded
1002   if $pos != 0
1003     set $pos = $pos - 1
1004   end
1006   set $index = 0
1007   set $size = $iseq->body->insns_info.size
1008   set $table = $iseq->body->insns_info.body
1009   set $positions = $iseq->body->insns_info.positions
1010   #printf "size: %d\n", $size
1011   if $size == 0
1012   else
1013   if $size == 1
1014     printf "%d", $table[0].line_no
1015   else
1016     if $positions
1017       # get_insn_info_linear_search
1018       set $index = 1
1019       while $index < $size
1020         #printf "table[%d]: position: %d, line: %d, pos: %d\n", $i, $positions[$i], $table[$i].line_no, $pos
1021         if $positions[$index] > $pos
1022           loop_break
1023         end
1024         set $index = $index + 1
1025         if $positions[$index] == $pos
1026           loop_break
1027         end
1028       end
1029     else
1030       # get_insn_info_succinct_bitvector
1031       set $sd = $iseq->body->insns_info.succ_index_table
1032       set $immediate_table_size = sizeof($sd->imm_part) / sizeof(uint64_t) * 9
1033       if $pos < $immediate_table_size
1034         set $i = $pos / 9
1035         set $j = $pos % 9
1036         set $index = ((int)($sd->imm_part[$i] >> ($j * 7))) & 0x7f
1037       else
1038         set $block_index = ($pos - $immediate_table_size) / 512
1039         set $block = &$sd->succ_part[$block_index]
1040         set $block_bit_index = ($pos - $immediate_table_size) % 512
1041         set $small_block_index = $block_bit_index / 64
1042         set $small_block_popcount = $small_block_index == 0 ? 0 : (((int)($block->small_block_ranks >> (($small_block_index - 1) * 9))) & 0x1ff)
1043         set $x = $block->bits[$small_block_index] << (63 - $block_bit_index % 64)
1044         set $x = ($x & 0x5555555555555555) + ($x >> 1 & 0x5555555555555555)
1045         set $x = ($x & 0x3333333333333333) + ($x >> 2 & 0x3333333333333333)
1046         set $x = ($x & 0x0707070707070707) + ($x >> 4 & 0x0707070707070707)
1047         set $x = ($x & 0x001f001f001f001f) + ($x >> 8 & 0x001f001f001f001f)
1048         set $x = ($x & 0x0000003f0000003f) + ($x >>16 & 0x0000003f0000003f)
1049         set $popcnt = ($x & 0x7f) + ($x >>32 & 0x7f)
1050         set $index = $block->rank + $small_block_popcount + $popcnt
1051       end
1052     end
1053     printf "%d", $table[$index-1].line_no
1054   end
1055   end
1058 define check_method_entry
1059   set $imemo = (struct RBasic *)$arg0
1060   if $imemo != RUBY_Qfalse
1061     set $type = ($imemo->flags >> 12) & 0x07
1062     if $type == imemo_ment
1063       set $me = (rb_callable_method_entry_t *)$imemo
1064     else
1065     if $type == imemo_svar
1066       set $imemo = ((struct vm_svar *)$imemo)->cref_or_me
1067       check_method_entry $imemo
1068     end
1069     end
1070   end
1073 define print_id
1074   set $id = $arg0
1075   # rb_id_to_serial
1076   if $id > tLAST_OP_ID
1077     set $serial = (rb_id_serial_t)($id >> RUBY_ID_SCOPE_SHIFT)
1078   else
1079     set $serial = (rb_id_serial_t)$id
1080   end
1081   if $serial && $serial <= ruby_global_symbols.last_id
1082     set $idx = $serial / ID_ENTRY_UNIT
1083     set $ids = (struct RArray *)ruby_global_symbols.ids
1084     set $flags = $ids->basic.flags
1085     if ($flags & RUBY_FL_USER1)
1086       set $idsptr = $ids->as.ary
1087       set $idslen = (($flags & (RUBY_FL_USER3|RUBY_FL_USER4)) >> (RUBY_FL_USHIFT+3))
1088     else
1089       set $idsptr = $ids->as.heap.ptr
1090       set $idslen = $ids->as.heap.len
1091     end
1092     if $idx < $idslen
1093       set $t = 0
1094       set $ary = (struct RArray *)$idsptr[$idx]
1095       if $ary != RUBY_Qnil
1096         set $flags = $ary->basic.flags
1097         if ($flags & RUBY_FL_USER1)
1098           set $aryptr = $ary->as.ary
1099           set $arylen = (($flags & (RUBY_FL_USER3|RUBY_FL_USER4)) >> (RUBY_FL_USHIFT+3))
1100         else
1101           set $aryptr = $ary->as.heap.ptr
1102           set $arylen = $ary->as.heap.len
1103         end
1104         set $result = $aryptr[($serial % ID_ENTRY_UNIT) * ID_ENTRY_SIZE + $t]
1105         if $result != RUBY_Qnil
1106           print_string $result
1107         else
1108           echo undef
1109         end
1110       end
1111     end
1112   end
1115 define print_pathobj
1116   set $flags = ((struct RBasic*)($arg0))->flags
1117   if ($flags & RUBY_T_MASK) == RUBY_T_STRING
1118     print_string $arg0
1119   end
1120   if ($flags & RUBY_T_MASK) == RUBY_T_ARRAY
1121     if $flags & RUBY_FL_USER1
1122       set $str = ((struct RArray*)($arg0))->as.ary[0]
1123     else
1124       set $str = ((struct RArray*)($arg0))->as.heap.ptr[0]
1125     end
1126     print_string $str
1127   end
1130 define rb_ps_thread
1131   set $ps_thread = (struct RTypedData*)$arg0
1132   set $ps_thread_th = (rb_thread_t*)$ps_thread->data
1133   printf "* #<Thread:%p rb_thread_t:%p native_thread:%p>\n", \
1134     $ps_thread, $ps_thread_th, $ps_thread_th->thread_id
1135   set $cfp = $ps_thread_th->ec->cfp
1136   set $cfpend = (rb_control_frame_t *)($ps_thread_th->ec->vm_stack + $ps_thread_th->ec->vm_stack_size)-1
1137   while $cfp < $cfpend
1138     if $cfp->iseq
1139       if !((VALUE)$cfp->iseq & RUBY_IMMEDIATE_MASK) && (((imemo_ifunc << RUBY_FL_USHIFT) | RUBY_T_IMEMO)==$cfp->iseq->flags & ((RUBY_IMEMO_MASK << RUBY_FL_USHIFT) | RUBY_T_MASK))
1140         printf "%d:ifunc ", $cfpend-$cfp
1141         set print symbol-filename on
1142         output/a $cfp->iseq.body
1143         set print symbol-filename off
1144         printf "\n"
1145       else
1146       if $cfp->pc
1147         set $location = $cfp->iseq->body->location
1148         printf "%d:", $cfpend-$cfp
1149         print_pathobj $location.pathobj
1150         printf ":"
1151         print_lineno $cfp
1152         printf ":in `"
1153         print_string $location.label
1154         printf "'\n"
1155       else
1156         printf "%d: ???.rb:???:in `???'\n", $cfpend-$cfp
1157       end
1158       end
1159     else
1160       # if VM_FRAME_TYPE($cfp->flag) == VM_FRAME_MAGIC_CFUNC
1161       set $ep = $cfp->ep
1162       if ($ep[0] & 0xffff0001) == 0x55550001
1163         #define VM_ENV_FLAG_LOCAL 0x02
1164         #define VM_ENV_PREV_EP(ep)   GC_GUARDED_PTR_REF(ep[VM_ENV_DATA_INDEX_SPECVAL])
1165         set $me = 0
1166         set $env_specval = $ep[-1]
1167         set $env_me_cref = $ep[-2]
1168         while ($env_specval & 0x02) != 0
1169           check_method_entry $env_me_cref
1170           if $me != 0
1171             loop_break
1172           end
1173           set $ep = $ep[0]
1174           set $env_specval = $ep[-1]
1175           set $env_me_cref = $ep[-2]
1176         end
1177         if $me == 0
1178           check_method_entry $env_me_cref
1179         end
1180         printf "%d:", $cfpend-$cfp
1181         set print symbol-filename on
1182         output/a $me->def->body.cfunc.func
1183         set print symbol-filename off
1184         set $mid = $me->def->original_id
1185         printf ":in `"
1186         print_id $mid
1187         printf "'\n"
1188       else
1189         printf "%d:unknown_frame:???:in `???'\n", $cfpend-$cfp
1190       end
1191     end
1192     set $cfp = $cfp + 1
1193   end
1196 define rb_count_objects
1197   set $objspace = ruby_current_vm_ptr->objspace
1198   set $counts_00 = 0
1199   set $counts_01 = 0
1200   set $counts_02 = 0
1201   set $counts_03 = 0
1202   set $counts_04 = 0
1203   set $counts_05 = 0
1204   set $counts_06 = 0
1205   set $counts_07 = 0
1206   set $counts_08 = 0
1207   set $counts_09 = 0
1208   set $counts_0a = 0
1209   set $counts_0b = 0
1210   set $counts_0c = 0
1211   set $counts_0d = 0
1212   set $counts_0e = 0
1213   set $counts_0f = 0
1214   set $counts_10 = 0
1215   set $counts_11 = 0
1216   set $counts_12 = 0
1217   set $counts_13 = 0
1218   set $counts_14 = 0
1219   set $counts_15 = 0
1220   set $counts_16 = 0
1221   set $counts_17 = 0
1222   set $counts_18 = 0
1223   set $counts_19 = 0
1224   set $counts_1a = 0
1225   set $counts_1b = 0
1226   set $counts_1c = 0
1227   set $counts_1d = 0
1228   set $counts_1e = 0
1229   set $counts_1f = 0
1230   set $total = 0
1231   set $i = 0
1232   while $i < $objspace->heap_pages.allocated_pages
1233     printf "\rcounting... %d/%d", $i, $objspace->heap_pages.allocated_pages
1234     set $page = $objspace->heap_pages.sorted[$i]
1235     set $p = $page->start
1236     set $pend = $p + $page->total_slots
1237     while $p < $pend
1238       set $flags = $p->as.basic.flags & 0x1f
1239       eval "set $counts_%02x = $counts_%02x + 1", $flags, $flags
1240       set $p = $p + 1
1241     end
1242     set $total = $total + $page->total_slots
1243     set $i = $i + 1
1244   end
1245   printf "\rTOTAL: %d, FREE: %d\n", $total, $counts_00
1246   printf "T_OBJECT: %d\n", $counts_01
1247   printf "T_CLASS: %d\n", $counts_02
1248   printf "T_MODULE: %d\n", $counts_03
1249   printf "T_FLOAT: %d\n", $counts_04
1250   printf "T_STRING: %d\n", $counts_05
1251   printf "T_REGEXP: %d\n", $counts_06
1252   printf "T_ARRAY: %d\n", $counts_07
1253   printf "T_HASH: %d\n", $counts_08
1254   printf "T_STRUCT: %d\n", $counts_09
1255   printf "T_BIGNUM: %d\n", $counts_0a
1256   printf "T_FILE: %d\n", $counts_0b
1257   printf "T_DATA: %d\n", $counts_0c
1258   printf "T_MATCH: %d\n", $counts_0d
1259   printf "T_COMPLEX: %d\n", $counts_0e
1260   printf "T_RATIONAL: %d\n", $counts_0f
1261   #printf "UNKNOWN_10: %d\n", $counts_10
1262   printf "T_NIL: %d\n", $counts_11
1263   printf "T_TRUE: %d\n", $counts_12
1264   printf "T_FALSE: %d\n", $counts_13
1265   printf "T_SYMBOL: %d\n", $counts_14
1266   printf "T_FIXNUM: %d\n", $counts_15
1267   printf "T_UNDEF: %d\n", $counts_16
1268   #printf "UNKNOWN_17: %d\n", $counts_17
1269   #printf "UNKNOWN_18: %d\n", $counts_18
1270   #printf "UNKNOWN_19: %d\n", $counts_19
1271   printf "T_IMEMO: %d\n", $counts_1a
1272   printf "T_NODE: %d\n", $counts_1b
1273   printf "T_ICLASS: %d\n", $counts_1c
1274   printf "T_ZOMBIE: %d\n", $counts_1d
1275   #printf "UNKNOWN_1E: %d\n", $counts_1e
1276   printf "T_MASK: %d\n", $counts_1f
1278 document rb_count_objects
1279   Counts all objects grouped by type.
1282 # Details: https://bugs.ruby-lang.org/projects/ruby-master/wiki/MachineInstructionsTraceWithGDB
1283 define trace_machine_instructions
1284   set logging on
1285   set height 0
1286   set width 0
1287   display/i $pc
1288   while !$exit_code
1289     info line *$pc
1290     si
1291   end
1294 define SDR
1295   call rb_vmdebug_stack_dump_raw_current()
1298 define rbi
1299   if ((LINK_ELEMENT*)$arg0)->type == ISEQ_ELEMENT_LABEL
1300     p *(LABEL*)$arg0
1301   else
1302   if ((LINK_ELEMENT*)$arg0)->type == ISEQ_ELEMENT_INSN
1303     p *(INSN*)$arg0
1304   else
1305   if ((LINK_ELEMENT*)$arg0)->type == ISEQ_ELEMENT_ADJUST
1306     p *(ADJUST*)$arg0
1307   else
1308     print *$arg0
1309   end
1310   end
1311   end
1314 define dump_node
1315   set $str = rb_parser_dump_tree($arg0, 0)
1316   set $flags = ((struct RBasic*)($str))->flags
1317   printf "%s", (char *)(($flags & RUBY_FL_USER1) ? \
1318                         ((struct RString*)$str)->as.heap.ptr : \
1319                         ((struct RString*)$str)->as.ary)
1322 define print_flags
1323   printf "RUBY_FL_WB_PROTECTED: %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_WB_PROTECTED ? "1" : "0"
1324   printf "RUBY_FL_PROMOTED0   : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_PROMOTED0 ? "1" : "0"
1325   printf "RUBY_FL_PROMOTED1   : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_PROMOTED1 ? "1" : "0"
1326   printf "RUBY_FL_FINALIZE    : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_FINALIZE ? "1" : "0"
1327   printf "RUBY_FL_SHAREABLE   : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_SHAREABLE ? "1" : "0"
1328   printf "RUBY_FL_EXIVAR      : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_EXIVAR ? "1" : "0"
1329   printf "RUBY_FL_FREEZE      : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_FREEZE ? "1" : "0"
1331   printf "RUBY_FL_USER0       : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER0 ? "1" : "0"
1332   printf "RUBY_FL_USER1       : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER1 ? "1" : "0"
1333   printf "RUBY_FL_USER2       : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER2 ? "1" : "0"
1334   printf "RUBY_FL_USER3       : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER3 ? "1" : "0"
1335   printf "RUBY_FL_USER4       : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER4 ? "1" : "0"
1336   printf "RUBY_FL_USER5       : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER5 ? "1" : "0"
1337   printf "RUBY_FL_USER6       : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER6 ? "1" : "0"
1338   printf "RUBY_FL_USER7       : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER7 ? "1" : "0"
1339   printf "RUBY_FL_USER8       : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER8 ? "1" : "0"
1340   printf "RUBY_FL_USER9       : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER9 ? "1" : "0"
1341   printf "RUBY_FL_USER10      : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER10 ? "1" : "0"
1342   printf "RUBY_FL_USER11      : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER11 ? "1" : "0"
1343   printf "RUBY_FL_USER12      : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER12 ? "1" : "0"
1344   printf "RUBY_FL_USER13      : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER13 ? "1" : "0"
1345   printf "RUBY_FL_USER14      : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER14 ? "1" : "0"
1346   printf "RUBY_FL_USER15      : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER15 ? "1" : "0"
1347   printf "RUBY_FL_USER16      : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER16 ? "1" : "0"
1348   printf "RUBY_FL_USER17      : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER17 ? "1" : "0"
1349   printf "RUBY_FL_USER18      : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER18 ? "1" : "0"