gdbdump 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,916 @@
1
+ define hook-run
2
+ set $color_type = 0
3
+ set $color_highlite = 0
4
+ set $color_end = 0
5
+ end
6
+
7
+ define ruby_gdb_init
8
+ if !$color_type
9
+ set $color_type = "\033[31m"
10
+ end
11
+ if !$color_highlite
12
+ set $color_highlite = "\033[36m"
13
+ end
14
+ if !$color_end
15
+ set $color_end = "\033[m"
16
+ end
17
+ if ruby_dummy_gdb_enums.special_consts
18
+ end
19
+ end
20
+
21
+ # set prompt \033[36m(gdb)\033[m\040
22
+
23
+ define rp
24
+ ruby_gdb_init
25
+ if (VALUE)($arg0) & RUBY_FIXNUM_FLAG
26
+ printf "FIXNUM: %ld\n", (long)($arg0) >> 1
27
+ else
28
+ if ((VALUE)($arg0) & ~(~(VALUE)0<<RUBY_SPECIAL_SHIFT)) == RUBY_SYMBOL_FLAG
29
+ set $id = (($arg0) >> RUBY_SPECIAL_SHIFT)
30
+ printf "%sSYMBOL%s: ", $color_type, $color_end
31
+ rp_id $id
32
+ else
33
+ if ($arg0) == RUBY_Qfalse
34
+ echo false\n
35
+ else
36
+ if ($arg0) == RUBY_Qtrue
37
+ echo true\n
38
+ else
39
+ if ($arg0) == RUBY_Qnil
40
+ echo nil\n
41
+ else
42
+ if ($arg0) == RUBY_Qundef
43
+ echo undef\n
44
+ else
45
+ if (VALUE)($arg0) & RUBY_IMMEDIATE_MASK
46
+ if ((VALUE)($arg0) & RUBY_FLONUM_MASK) == RUBY_FLONUM_FLAG
47
+ printf "%sFLONUM%s: %g\n", $color_type, $color_end, (double)rb_float_value($arg0)
48
+ else
49
+ echo immediate\n
50
+ end
51
+ else
52
+ set $flags = ((struct RBasic*)($arg0))->flags
53
+ if ($flags & RUBY_FL_PROMOTED) == RUBY_FL_PROMOTED
54
+ printf "[PROMOTED] "
55
+ end
56
+ if ($flags & RUBY_T_MASK) == RUBY_T_NONE
57
+ printf "%sT_NONE%s: ", $color_type, $color_end
58
+ print (struct RBasic *)($arg0)
59
+ else
60
+ if ($flags & RUBY_T_MASK) == RUBY_T_NIL
61
+ printf "%sT_NIL%s: ", $color_type, $color_end
62
+ print (struct RBasic *)($arg0)
63
+ else
64
+ if ($flags & RUBY_T_MASK) == RUBY_T_OBJECT
65
+ printf "%sT_OBJECT%s: ", $color_type, $color_end
66
+ print (struct RObject *)($arg0)
67
+ else
68
+ if ($flags & RUBY_T_MASK) == RUBY_T_CLASS
69
+ printf "%sT_CLASS%s%s: ", $color_type, ($flags & RUBY_FL_SINGLETON) ? "*" : "", $color_end
70
+ rp_class $arg0
71
+ else
72
+ if ($flags & RUBY_T_MASK) == RUBY_T_ICLASS
73
+ printf "%sT_ICLASS%s: ", $color_type, $color_end
74
+ rp_class $arg0
75
+ else
76
+ if ($flags & RUBY_T_MASK) == RUBY_T_MODULE
77
+ printf "%sT_MODULE%s: ", $color_type, $color_end
78
+ rp_class $arg0
79
+ else
80
+ if ($flags & RUBY_T_MASK) == RUBY_T_FLOAT
81
+ printf "%sT_FLOAT%s: %.16g ", $color_type, $color_end, (((struct RFloat*)($arg0))->float_value)
82
+ print (struct RFloat *)($arg0)
83
+ else
84
+ if ($flags & RUBY_T_MASK) == RUBY_T_STRING
85
+ printf "%sT_STRING%s: ", $color_type, $color_end
86
+ rp_string $arg0 $flags
87
+ else
88
+ if ($flags & RUBY_T_MASK) == RUBY_T_REGEXP
89
+ set $regsrc = ((struct RRegexp*)($arg0))->src
90
+ set $rsflags = ((struct RBasic*)$regsrc)->flags
91
+ printf "%sT_REGEXP%s: ", $color_type, $color_end
92
+ set print address off
93
+ output (char *)(($rsflags & RUBY_FL_USER1) ? \
94
+ ((struct RString*)$regsrc)->as.heap.ptr : \
95
+ ((struct RString*)$regsrc)->as.ary)
96
+ set print address on
97
+ printf " len:%ld ", ($rsflags & RUBY_FL_USER1) ? \
98
+ ((struct RString*)$regsrc)->as.heap.len : \
99
+ (($rsflags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
100
+ if $flags & RUBY_FL_USER6
101
+ printf "(none) "
102
+ end
103
+ if $flags & RUBY_FL_USER5
104
+ printf "(literal) "
105
+ end
106
+ if $flags & RUBY_FL_USER4
107
+ printf "(fixed) "
108
+ end
109
+ printf "encoding:%d ", ($flags & RUBY_ENCODING_MASK) >> RUBY_ENCODING_SHIFT
110
+ print (struct RRegexp *)($arg0)
111
+ else
112
+ if ($flags & RUBY_T_MASK) == RUBY_T_ARRAY
113
+ if ($flags & RUBY_FL_USER1)
114
+ set $len = (($flags & (RUBY_FL_USER3|RUBY_FL_USER4)) >> (RUBY_FL_USHIFT+3))
115
+ printf "%sT_ARRAY%s: len=%ld ", $color_type, $color_end, $len
116
+ printf "(embed) "
117
+ if ($len == 0)
118
+ printf "{(empty)} "
119
+ else
120
+ output/x *((VALUE*)((struct RArray*)($arg0))->as.ary) @ $len
121
+ printf " "
122
+ end
123
+ else
124
+ set $len = ((struct RArray*)($arg0))->as.heap.len
125
+ printf "%sT_ARRAY%s: len=%ld ", $color_type, $color_end, $len
126
+ if ($flags & RUBY_FL_USER2)
127
+ printf "(shared) shared="
128
+ output/x ((struct RArray*)($arg0))->as.heap.aux.shared
129
+ printf " "
130
+ else
131
+ printf "(ownership) capa=%ld ", ((struct RArray*)($arg0))->as.heap.aux.capa
132
+ end
133
+ if ($len == 0)
134
+ printf "{(empty)} "
135
+ else
136
+ output/x *((VALUE*)((struct RArray*)($arg0))->as.heap.ptr) @ $len
137
+ printf " "
138
+ end
139
+ end
140
+ print (struct RArray *)($arg0)
141
+ else
142
+ if ($flags & RUBY_T_MASK) == RUBY_T_FIXNUM
143
+ printf "%sT_FIXNUM%s: ", $color_type, $color_end
144
+ print (struct RBasic *)($arg0)
145
+ else
146
+ if ($flags & RUBY_T_MASK) == RUBY_T_HASH
147
+ printf "%sT_HASH%s: ", $color_type, $color_end,
148
+ if ((struct RHash *)($arg0))->ntbl
149
+ printf "len=%ld ", ((struct RHash *)($arg0))->ntbl->num_entries
150
+ end
151
+ print (struct RHash *)($arg0)
152
+ else
153
+ if ($flags & RUBY_T_MASK) == RUBY_T_STRUCT
154
+ printf "%sT_STRUCT%s: len=%ld ", $color_type, $color_end, \
155
+ (($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) ? \
156
+ ($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) >> (RUBY_FL_USHIFT+1) : \
157
+ ((struct RStruct *)($arg0))->as.heap.len)
158
+ print (struct RStruct *)($arg0)
159
+ x/xw (($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) ? \
160
+ ((struct RStruct *)($arg0))->as.ary : \
161
+ ((struct RStruct *)($arg0))->as.heap.ptr)
162
+ else
163
+ if ($flags & RUBY_T_MASK) == RUBY_T_BIGNUM
164
+ printf "%sT_BIGNUM%s: sign=%d len=%ld ", $color_type, $color_end, \
165
+ (($flags & RUBY_FL_USER1) != 0), \
166
+ (($flags & RUBY_FL_USER2) ? \
167
+ ($flags & (RUBY_FL_USER5|RUBY_FL_USER4|RUBY_FL_USER3)) >> (RUBY_FL_USHIFT+3) : \
168
+ ((struct RBignum*)($arg0))->as.heap.len)
169
+ if $flags & RUBY_FL_USER2
170
+ printf "(embed) "
171
+ end
172
+ print (struct RBignum *)($arg0)
173
+ x/xw (($flags & RUBY_FL_USER2) ? \
174
+ ((struct RBignum*)($arg0))->as.ary : \
175
+ ((struct RBignum*)($arg0))->as.heap.digits)
176
+ else
177
+ if ($flags & RUBY_T_MASK) == RUBY_T_RATIONAL
178
+ printf "%sT_RATIONAL%s: ", $color_type, $color_end
179
+ print (struct RRational *)($arg0)
180
+ else
181
+ if ($flags & RUBY_T_MASK) == RUBY_T_COMPLEX
182
+ printf "%sT_COMPLEX%s: ", $color_type, $color_end
183
+ print (struct RComplex *)($arg0)
184
+ else
185
+ if ($flags & RUBY_T_MASK) == RUBY_T_FILE
186
+ printf "%sT_FILE%s: ", $color_type, $color_end
187
+ print (struct RFile *)($arg0)
188
+ output *((struct RFile *)($arg0))->fptr
189
+ printf "\n"
190
+ else
191
+ if ($flags & RUBY_T_MASK) == RUBY_T_TRUE
192
+ printf "%sT_TRUE%s: ", $color_type, $color_end
193
+ print (struct RBasic *)($arg0)
194
+ else
195
+ if ($flags & RUBY_T_MASK) == RUBY_T_FALSE
196
+ printf "%sT_FALSE%s: ", $color_type, $color_end
197
+ print (struct RBasic *)($arg0)
198
+ else
199
+ if ($flags & RUBY_T_MASK) == RUBY_T_DATA
200
+ if ((struct RTypedData *)($arg0))->typed_flag == 1
201
+ printf "%sT_DATA%s(%s): ", $color_type, $color_end, ((struct RTypedData *)($arg0))->type->wrap_struct_name
202
+ print (struct RTypedData *)($arg0)
203
+ else
204
+ printf "%sT_DATA%s: ", $color_type, $color_end
205
+ print (struct RData *)($arg0)
206
+ end
207
+ else
208
+ if ($flags & RUBY_T_MASK) == RUBY_T_MATCH
209
+ printf "%sT_MATCH%s: ", $color_type, $color_end
210
+ print (struct RMatch *)($arg0)
211
+ else
212
+ if ($flags & RUBY_T_MASK) == RUBY_T_SYMBOL
213
+ printf "%sT_SYMBOL%s: ", $color_type, $color_end
214
+ print (struct RSymbol *)($arg0)
215
+ set $id_type = ((struct RSymbol *)($arg0))->id & RUBY_ID_SCOPE_MASK
216
+ if $id_type == RUBY_ID_LOCAL
217
+ printf "l"
218
+ else
219
+ if $id_type == RUBY_ID_INSTANCE
220
+ printf "i"
221
+ else
222
+ if $id_type == RUBY_ID_GLOBAL
223
+ printf "G"
224
+ else
225
+ if $id_type == RUBY_ID_ATTRSET
226
+ printf "a"
227
+ else
228
+ if $id_type == RUBY_ID_CONST
229
+ printf "C"
230
+ else
231
+ if $id_type == RUBY_ID_CLASS
232
+ printf "c"
233
+ else
234
+ printf "j"
235
+ end
236
+ end
237
+ end
238
+ end
239
+ end
240
+ end
241
+ set $id_fstr = ((struct RSymbol *)($arg0))->fstr
242
+ rp_string $id_fstr
243
+ else
244
+ if ($flags & RUBY_T_MASK) == RUBY_T_UNDEF
245
+ printf "%sT_UNDEF%s: ", $color_type, $color_end
246
+ print (struct RBasic *)($arg0)
247
+ else
248
+ if ($flags & RUBY_T_MASK) == RUBY_T_NODE
249
+ printf "%sT_NODE%s(", $color_type, $color_end
250
+ output (enum node_type)(($flags&RUBY_NODE_TYPEMASK)>>RUBY_NODE_TYPESHIFT)
251
+ printf "): "
252
+ print *(NODE *)($arg0)
253
+ else
254
+ if ($flags & RUBY_T_MASK) == RUBY_T_ZOMBIE
255
+ printf "%sT_ZOMBIE%s: ", $color_type, $color_end
256
+ print (struct RData *)($arg0)
257
+ else
258
+ printf "%sunknown%s: ", $color_type, $color_end
259
+ print (struct RBasic *)($arg0)
260
+ end
261
+ end
262
+ end
263
+ end
264
+ end
265
+ end
266
+ end
267
+ end
268
+ end
269
+ end
270
+ end
271
+ end
272
+ end
273
+ end
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
+ document rp
294
+ Print a Ruby's VALUE.
295
+ end
296
+
297
+ define rp_id
298
+ set $id = (ID)$arg0
299
+ if $id == '!' || $id == '+' || $id == '-' || $id == '*' || $id == '/' || $id == '%' || $id == '<' || $id == '>' || $id == '`'
300
+ printf "(:%c)\n", $id
301
+ else
302
+ if $id == idDot2
303
+ printf "(:..)\n"
304
+ else
305
+ if $id == idDot3
306
+ printf "(:...)\n"
307
+ else
308
+ if $id == idUPlus
309
+ printf "(:+@)\n"
310
+ else
311
+ if $id == idUMinus
312
+ printf "(:-@)\n"
313
+ else
314
+ if $id == idPow
315
+ printf "(:**)\n"
316
+ else
317
+ if $id == idCmp
318
+ printf "(:<=>)\n"
319
+ else
320
+ if $id == idLTLT
321
+ printf "(:<<)\n"
322
+ else
323
+ if $id == idLE
324
+ printf "(:<=)\n"
325
+ else
326
+ if $id == idGE
327
+ printf "(:>=)\n"
328
+ else
329
+ if $id == idEq
330
+ printf "(:==)\n"
331
+ else
332
+ if $id == idEqq
333
+ printf "(:===)\n"
334
+ else
335
+ if $id == idNeq
336
+ printf "(:!=)\n"
337
+ else
338
+ if $id == idEqTilde
339
+ printf "(:=~)\n"
340
+ else
341
+ if $id == idNeqTilde
342
+ printf "(:!~)\n"
343
+ else
344
+ if $id == idAREF
345
+ printf "(:[])\n"
346
+ else
347
+ if $id == idASET
348
+ printf "(:[]=)\n"
349
+ else
350
+ if $id <= tLAST_OP_ID
351
+ printf "O"
352
+ else
353
+ set $id_type = $id & RUBY_ID_SCOPE_MASK
354
+ if $id_type == RUBY_ID_LOCAL
355
+ printf "l"
356
+ else
357
+ if $id_type == RUBY_ID_INSTANCE
358
+ printf "i"
359
+ else
360
+ if $id_type == RUBY_ID_GLOBAL
361
+ printf "G"
362
+ else
363
+ if $id_type == RUBY_ID_ATTRSET
364
+ printf "a"
365
+ else
366
+ if $id_type == RUBY_ID_CONST
367
+ printf "C"
368
+ else
369
+ if $id_type == RUBY_ID_CLASS
370
+ printf "c"
371
+ else
372
+ printf "j"
373
+ end
374
+ end
375
+ end
376
+ end
377
+ end
378
+ end
379
+ end
380
+ printf "(%ld): ", $id
381
+ set $str = lookup_id_str($id)
382
+ if $str
383
+ rp_string $str
384
+ else
385
+ echo undef\n
386
+ end
387
+ end
388
+ end
389
+ end
390
+ end
391
+ end
392
+ end
393
+ end
394
+ end
395
+ end
396
+ end
397
+ end
398
+ end
399
+ end
400
+ end
401
+ end
402
+ end
403
+ end
404
+ end
405
+ document rp_id
406
+ Print an ID.
407
+ end
408
+
409
+ define rp_string
410
+ set $flags = ((struct RBasic*)($arg0))->flags
411
+ set print address off
412
+ output (char *)(($flags & RUBY_FL_USER1) ? \
413
+ ((struct RString*)($arg0))->as.heap.ptr : \
414
+ ((struct RString*)($arg0))->as.ary)
415
+ set print address on
416
+ printf " bytesize:%ld ", ($flags & RUBY_FL_USER1) ? \
417
+ ((struct RString*)($arg0))->as.heap.len : \
418
+ (($flags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
419
+ if !($flags & RUBY_FL_USER1)
420
+ printf "(embed) "
421
+ else
422
+ if ($flags & RUBY_FL_USER2)
423
+ printf "(shared) "
424
+ end
425
+ if ($flags & RUBY_FL_USER3)
426
+ printf "(assoc) "
427
+ end
428
+ end
429
+ printf "encoding:%d ", ($flags & RUBY_ENCODING_MASK) >> RUBY_ENCODING_SHIFT
430
+ if ($flags & RUBY_ENC_CODERANGE_MASK) == 0
431
+ printf "coderange:unknown "
432
+ else
433
+ if ($flags & RUBY_ENC_CODERANGE_MASK) == RUBY_ENC_CODERANGE_7BIT
434
+ printf "coderange:7bit "
435
+ else
436
+ if ($flags & RUBY_ENC_CODERANGE_MASK) == RUBY_ENC_CODERANGE_VALID
437
+ printf "coderange:valid "
438
+ else
439
+ printf "coderange:broken "
440
+ end
441
+ end
442
+ end
443
+ print (struct RString *)($arg0)
444
+ end
445
+ document rp_string
446
+ Print the content of a String.
447
+ end
448
+
449
+ define rp_class
450
+ printf "(struct RClass *) %p", (void*)$arg0
451
+ if ((struct RClass *)($arg0))->ptr.origin != $arg0
452
+ printf " -> %p", ((struct RClass *)($arg0))->ptr.origin
453
+ end
454
+ printf "\n"
455
+ rb_classname $arg0
456
+ print *(struct RClass *)($arg0)
457
+ print *((struct RClass *)($arg0))->ptr
458
+ end
459
+ document rp_class
460
+ Print the content of a Class/Module.
461
+ end
462
+
463
+ define nd_type
464
+ print (enum node_type)((((NODE*)($arg0))->flags&RUBY_NODE_TYPEMASK)>>RUBY_NODE_TYPESHIFT)
465
+ end
466
+ document nd_type
467
+ Print a Ruby' node type.
468
+ end
469
+
470
+ define nd_file
471
+ print ((NODE*)($arg0))->nd_file
472
+ end
473
+ document nd_file
474
+ Print the source file name of a node.
475
+ end
476
+
477
+ define nd_line
478
+ print ((unsigned int)((((NODE*)($arg0))->flags>>RUBY_NODE_LSHIFT)&RUBY_NODE_LMASK))
479
+ end
480
+ document nd_line
481
+ Print the source line number of a node.
482
+ end
483
+
484
+ # Print members of ruby node.
485
+
486
+ define nd_head
487
+ printf "%su1.node%s: ", $color_highlite, $color_end
488
+ rp ($arg0).u1.node
489
+ end
490
+
491
+ define nd_alen
492
+ printf "%su2.argc%s: ", $color_highlite, $color_end
493
+ p ($arg0).u2.argc
494
+ end
495
+
496
+ define nd_next
497
+ printf "%su3.node%s: ", $color_highlite, $color_end
498
+ rp ($arg0).u3.node
499
+ end
500
+
501
+
502
+ define nd_cond
503
+ printf "%su1.node%s: ", $color_highlite, $color_end
504
+ rp ($arg0).u1.node
505
+ end
506
+
507
+ define nd_body
508
+ printf "%su2.node%s: ", $color_highlite, $color_end
509
+ rp ($arg0).u2.node
510
+ end
511
+
512
+ define nd_else
513
+ printf "%su3.node%s: ", $color_highlite, $color_end
514
+ rp ($arg0).u3.node
515
+ end
516
+
517
+
518
+ define nd_orig
519
+ printf "%su3.value%s: ", $color_highlite, $color_end
520
+ rp ($arg0).u3.value
521
+ end
522
+
523
+
524
+ define nd_resq
525
+ printf "%su2.node%s: ", $color_highlite, $color_end
526
+ rp ($arg0).u2.node
527
+ end
528
+
529
+ define nd_ensr
530
+ printf "%su3.node%s: ", $color_highlite, $color_end
531
+ rp ($arg0).u3.node
532
+ end
533
+
534
+
535
+ define nd_1st
536
+ printf "%su1.node%s: ", $color_highlite, $color_end
537
+ rp ($arg0).u1.node
538
+ end
539
+
540
+ define nd_2nd
541
+ printf "%su2.node%s: ", $color_highlite, $color_end
542
+ rp ($arg0).u2.node
543
+ end
544
+
545
+
546
+ define nd_stts
547
+ printf "%su1.node%s: ", $color_highlite, $color_end
548
+ rp ($arg0).u1.node
549
+ end
550
+
551
+
552
+ define nd_entry
553
+ printf "%su3.entry%s: ", $color_highlite, $color_end
554
+ p ($arg0).u3.entry
555
+ end
556
+
557
+ define nd_vid
558
+ printf "%su1.id%s: ", $color_highlite, $color_end
559
+ p ($arg0).u1.id
560
+ end
561
+
562
+ define nd_cflag
563
+ printf "%su2.id%s: ", $color_highlite, $color_end
564
+ p ($arg0).u2.id
565
+ end
566
+
567
+ define nd_cval
568
+ printf "%su3.value%s: ", $color_highlite, $color_end
569
+ rp ($arg0).u3.value
570
+ end
571
+
572
+
573
+ define nd_cnt
574
+ printf "%su3.cnt%s: ", $color_highlite, $color_end
575
+ p ($arg0).u3.cnt
576
+ end
577
+
578
+ define nd_tbl
579
+ printf "%su1.tbl%s: ", $color_highlite, $color_end
580
+ p ($arg0).u1.tbl
581
+ end
582
+
583
+
584
+ define nd_var
585
+ printf "%su1.node%s: ", $color_highlite, $color_end
586
+ rp ($arg0).u1.node
587
+ end
588
+
589
+ define nd_ibdy
590
+ printf "%su2.node%s: ", $color_highlite, $color_end
591
+ rp ($arg0).u2.node
592
+ end
593
+
594
+ define nd_iter
595
+ printf "%su3.node%s: ", $color_highlite, $color_end
596
+ rp ($arg0).u3.node
597
+ end
598
+
599
+
600
+ define nd_value
601
+ printf "%su2.node%s: ", $color_highlite, $color_end
602
+ rp ($arg0).u2.node
603
+ end
604
+
605
+ define nd_aid
606
+ printf "%su3.id%s: ", $color_highlite, $color_end
607
+ p ($arg0).u3.id
608
+ end
609
+
610
+
611
+ define nd_lit
612
+ printf "%su1.value%s: ", $color_highlite, $color_end
613
+ rp ($arg0).u1.value
614
+ end
615
+
616
+
617
+ define nd_frml
618
+ printf "%su1.node%s: ", $color_highlite, $color_end
619
+ rp ($arg0).u1.node
620
+ end
621
+
622
+ define nd_rest
623
+ printf "%su2.argc%s: ", $color_highlite, $color_end
624
+ p ($arg0).u2.argc
625
+ end
626
+
627
+ define nd_opt
628
+ printf "%su1.node%s: ", $color_highlite, $color_end
629
+ rp ($arg0).u1.node
630
+ end
631
+
632
+
633
+ define nd_recv
634
+ printf "%su1.node%s: ", $color_highlite, $color_end
635
+ rp ($arg0).u1.node
636
+ end
637
+
638
+ define nd_mid
639
+ printf "%su2.id%s: ", $color_highlite, $color_end
640
+ p ($arg0).u2.id
641
+ end
642
+
643
+ define nd_args
644
+ printf "%su3.node%s: ", $color_highlite, $color_end
645
+ rp ($arg0).u3.node
646
+ end
647
+
648
+
649
+ define nd_noex
650
+ printf "%su1.id%s: ", $color_highlite, $color_end
651
+ p ($arg0).u1.id
652
+ end
653
+
654
+ define nd_defn
655
+ printf "%su3.node%s: ", $color_highlite, $color_end
656
+ rp ($arg0).u3.node
657
+ end
658
+
659
+
660
+ define nd_old
661
+ printf "%su1.id%s: ", $color_highlite, $color_end
662
+ p ($arg0).u1.id
663
+ end
664
+
665
+ define nd_new
666
+ printf "%su2.id%s: ", $color_highlite, $color_end
667
+ p ($arg0).u2.id
668
+ end
669
+
670
+
671
+ define nd_cfnc
672
+ printf "%su1.cfunc%s: ", $color_highlite, $color_end
673
+ p ($arg0).u1.cfunc
674
+ end
675
+
676
+ define nd_argc
677
+ printf "%su2.argc%s: ", $color_highlite, $color_end
678
+ p ($arg0).u2.argc
679
+ end
680
+
681
+
682
+ define nd_cname
683
+ printf "%su1.id%s: ", $color_highlite, $color_end
684
+ p ($arg0).u1.id
685
+ end
686
+
687
+ define nd_super
688
+ printf "%su3.node%s: ", $color_highlite, $color_end
689
+ rp ($arg0).u3.node
690
+ end
691
+
692
+
693
+ define nd_modl
694
+ printf "%su1.id%s: ", $color_highlite, $color_end
695
+ p ($arg0).u1.id
696
+ end
697
+
698
+ define nd_clss
699
+ printf "%su1.value%s: ", $color_highlite, $color_end
700
+ rp ($arg0).u1.value
701
+ end
702
+
703
+
704
+ define nd_beg
705
+ printf "%su1.node%s: ", $color_highlite, $color_end
706
+ rp ($arg0).u1.node
707
+ end
708
+
709
+ define nd_end
710
+ printf "%su2.node%s: ", $color_highlite, $color_end
711
+ rp ($arg0).u2.node
712
+ end
713
+
714
+ define nd_state
715
+ printf "%su3.state%s: ", $color_highlite, $color_end
716
+ p ($arg0).u3.state
717
+ end
718
+
719
+ define nd_rval
720
+ printf "%su2.value%s: ", $color_highlite, $color_end
721
+ rp ($arg0).u2.value
722
+ end
723
+
724
+
725
+ define nd_nth
726
+ printf "%su2.argc%s: ", $color_highlite, $color_end
727
+ p ($arg0).u2.argc
728
+ end
729
+
730
+
731
+ define nd_tag
732
+ printf "%su1.id%s: ", $color_highlite, $color_end
733
+ p ($arg0).u1.id
734
+ end
735
+
736
+ define nd_tval
737
+ printf "%su2.value%s: ", $color_highlite, $color_end
738
+ rp ($arg0).u2.value
739
+ end
740
+
741
+ define nd_tree
742
+ set $buf = (struct RString *)rb_str_buf_new(0)
743
+ call dump_node((VALUE)($buf), rb_str_new(0, 0), 0, ($arg0))
744
+ printf "%s\n", $buf->as.heap.ptr
745
+ end
746
+
747
+ define rb_p
748
+ call rb_p($arg0)
749
+ end
750
+
751
+ define rb_numtable_entry
752
+ set $rb_numtable_tbl = $arg0
753
+ set $rb_numtable_id = (st_data_t)$arg1
754
+ set $rb_numtable_key = 0
755
+ set $rb_numtable_rec = 0
756
+ if $rb_numtable_tbl->entries_packed
757
+ set $rb_numtable_p = $rb_numtable_tbl->as.packed.bins
758
+ while $rb_numtable_p && $rb_numtable_p < $rb_numtable_tbl->as.packed.bins+$rb_numtable_tbl->num_entries
759
+ if $rb_numtable_p.k == $rb_numtable_id
760
+ set $rb_numtable_key = $rb_numtable_p.k
761
+ set $rb_numtable_rec = $rb_numtable_p.v
762
+ set $rb_numtable_p = 0
763
+ else
764
+ set $rb_numtable_p = $rb_numtable_p + 1
765
+ end
766
+ end
767
+ else
768
+ set $rb_numtable_p = $rb_numtable_tbl->as.big.bins[st_numhash($rb_numtable_id) % $rb_numtable_tbl->num_bins]
769
+ while $rb_numtable_p
770
+ if $rb_numtable_p->key == $rb_numtable_id
771
+ set $rb_numtable_key = $rb_numtable_p->key
772
+ set $rb_numtable_rec = $rb_numtable_p->record
773
+ set $rb_numtable_p = 0
774
+ else
775
+ set $rb_numtable_p = $rb_numtable_p->next
776
+ end
777
+ end
778
+ end
779
+ end
780
+
781
+ define rb_id2name
782
+ ruby_gdb_init
783
+ printf "%sID%s: ", $color_type, $color_end
784
+ rp_id $arg0
785
+ end
786
+ document rb_id2name
787
+ Print the name of id
788
+ end
789
+
790
+ define rb_method_entry
791
+ set $rb_method_entry_klass = (struct RClass *)$arg0
792
+ set $rb_method_entry_id = (ID)$arg1
793
+ set $rb_method_entry_me = (rb_method_entry_t *)0
794
+ while !$rb_method_entry_me && $rb_method_entry_klass
795
+ rb_numtable_entry $rb_method_entry_klass->m_tbl_wrapper->tbl $rb_method_entry_id
796
+ set $rb_method_entry_me = (rb_method_entry_t *)$rb_numtable_rec
797
+ if !$rb_method_entry_me
798
+ set $rb_method_entry_klass = (struct RClass *)RCLASS_SUPER($rb_method_entry_klass)
799
+ end
800
+ end
801
+ if $rb_method_entry_me
802
+ print *$rb_method_entry_klass
803
+ print *$rb_method_entry_me
804
+ else
805
+ echo method not found\n
806
+ end
807
+ end
808
+ document rb_method_entry
809
+ Search method entry by class and id
810
+ end
811
+
812
+ define rb_classname
813
+ # up to 128bit int
814
+ set $rb_classname_permanent = "0123456789ABCDEF"
815
+ set $rb_classname = classname($arg0, $rb_classname_permanent)
816
+ if $rb_classname != RUBY_Qnil
817
+ rp $rb_classname
818
+ else
819
+ echo anonymous class/module\n
820
+ end
821
+ end
822
+
823
+ define rb_ancestors
824
+ set $rb_ancestors_module = $arg0
825
+ while $rb_ancestors_module
826
+ rp_class $rb_ancestors_module
827
+ set $rb_ancestors_module = RCLASS_SUPER($rb_ancestors_module)
828
+ end
829
+ end
830
+ document rb_ancestors
831
+ Print ancestors.
832
+ end
833
+
834
+ define rb_backtrace
835
+ call rb_backtrace()
836
+ end
837
+
838
+ define iseq
839
+ if ruby_dummy_gdb_enums.special_consts
840
+ end
841
+ if ($arg0)->type == ISEQ_ELEMENT_NONE
842
+ echo [none]\n
843
+ end
844
+ if ($arg0)->type == ISEQ_ELEMENT_LABEL
845
+ print *(LABEL*)($arg0)
846
+ end
847
+ if ($arg0)->type == ISEQ_ELEMENT_INSN
848
+ print *(INSN*)($arg0)
849
+ if ((INSN*)($arg0))->insn_id != YARVINSN_jump
850
+ set $i = 0
851
+ set $operand_size = ((INSN*)($arg0))->operand_size
852
+ set $operands = ((INSN*)($arg0))->operands
853
+ while $i < $operand_size
854
+ rp $operands[$i++]
855
+ end
856
+ end
857
+ end
858
+ if ($arg0)->type == ISEQ_ELEMENT_ADJUST
859
+ print *(ADJUST*)($arg0)
860
+ end
861
+ end
862
+
863
+ define rb_ps
864
+ rb_ps_vm ruby_current_vm
865
+ end
866
+ document rb_ps
867
+ Dump all threads and their callstacks
868
+ end
869
+
870
+ define rb_ps_vm
871
+ print $ps_vm = (rb_vm_t*)$arg0
872
+ set $ps_threads = (st_table*)$ps_vm->living_threads
873
+ if $ps_threads->entries_packed
874
+ set $ps_threads_i = 0
875
+ while $ps_threads_i < $ps_threads->num_entries
876
+ set $ps_threads_key = (st_data_t)$ps_threads->as.packed.entries[$ps_threads_i].key
877
+ set $ps_threads_val = (st_data_t)$ps_threads->as.packed.entries[$ps_threads_i].val
878
+ rb_ps_thread $ps_threads_key $ps_threads_val
879
+ set $ps_threads_i = $ps_threads_i + 1
880
+ end
881
+ else
882
+ set $ps_threads_ptr = (st_table_entry*)$ps_threads->head
883
+ while $ps_threads_ptr
884
+ set $ps_threads_key = (st_data_t)$ps_threads_ptr->key
885
+ set $ps_threads_val = (st_data_t)$ps_threads_ptr->record
886
+ rb_ps_thread $ps_threads_key $ps_threads_val
887
+ set $ps_threads_ptr = (st_table_entry*)$ps_threads_ptr->fore
888
+ end
889
+ end
890
+ end
891
+ document rb_ps_vm
892
+ Dump all threads in a (rb_vm_t*) and their callstacks
893
+ end
894
+
895
+ define rb_ps_thread
896
+ set $ps_thread = (struct RTypedData*)$arg0
897
+ set $ps_thread_id = $arg1
898
+ print $ps_thread_th = (rb_thread_t*)$ps_thread->data
899
+ end
900
+
901
+ # Details: https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/MachineInstructionsTraceWithGDB
902
+ define trace_machine_instructions
903
+ set logging on
904
+ set height 0
905
+ set width 0
906
+ display/i $pc
907
+ while !$exit_code
908
+ info line *$pc
909
+ si
910
+ end
911
+ end
912
+
913
+ define SDR
914
+ call rb_vmdebug_stack_dump_raw_current()
915
+ end
916
+