gdbdump 0.1.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ vendor/ruby/2.3.1/../2.3.0/gdbinit
@@ -0,0 +1 @@
1
+ vendor/ruby/2.3.2/../2.3.0/gdbinit
@@ -0,0 +1 @@
1
+ vendor/ruby/2.3.3/../2.3.0/gdbinit
@@ -0,0 +1 @@
1
+ vendor/ruby/2.3.4/../2.3.0/gdbinit
@@ -0,0 +1,1215 @@
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))->basic
67
+ if ($flags & ROBJECT_EMBED)
68
+ print/x *((VALUE*)((struct RObject*)($arg0))->as.ary) @ (ROBJECT_EMBED_LEN_MAX+0)
69
+ else
70
+ print (((struct RObject *)($arg0))->as.heap)
71
+ print/x *(((struct RObject*)($arg0))->as.heap.ivptr) @ (((struct RObject*)($arg0))->as.heap.numiv)
72
+ end
73
+ else
74
+ if ($flags & RUBY_T_MASK) == RUBY_T_CLASS
75
+ printf "%sT_CLASS%s%s: ", $color_type, ($flags & RUBY_FL_SINGLETON) ? "*" : "", $color_end
76
+ rp_class $arg0
77
+ else
78
+ if ($flags & RUBY_T_MASK) == RUBY_T_ICLASS
79
+ printf "%sT_ICLASS%s: ", $color_type, $color_end
80
+ rp_class $arg0
81
+ else
82
+ if ($flags & RUBY_T_MASK) == RUBY_T_MODULE
83
+ printf "%sT_MODULE%s: ", $color_type, $color_end
84
+ rp_class $arg0
85
+ else
86
+ if ($flags & RUBY_T_MASK) == RUBY_T_FLOAT
87
+ printf "%sT_FLOAT%s: %.16g ", $color_type, $color_end, (((struct RFloat*)($arg0))->float_value)
88
+ print (struct RFloat *)($arg0)
89
+ else
90
+ if ($flags & RUBY_T_MASK) == RUBY_T_STRING
91
+ printf "%sT_STRING%s: ", $color_type, $color_end
92
+ rp_string $arg0 $flags
93
+ else
94
+ if ($flags & RUBY_T_MASK) == RUBY_T_REGEXP
95
+ set $regsrc = ((struct RRegexp*)($arg0))->src
96
+ set $rsflags = ((struct RBasic*)$regsrc)->flags
97
+ printf "%sT_REGEXP%s: ", $color_type, $color_end
98
+ set print address off
99
+ output (char *)(($rsflags & RUBY_FL_USER1) ? \
100
+ ((struct RString*)$regsrc)->as.heap.ptr : \
101
+ ((struct RString*)$regsrc)->as.ary)
102
+ set print address on
103
+ printf " len:%ld ", ($rsflags & RUBY_FL_USER1) ? \
104
+ ((struct RString*)$regsrc)->as.heap.len : \
105
+ (($rsflags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
106
+ if $flags & RUBY_FL_USER6
107
+ printf "(none) "
108
+ end
109
+ if $flags & RUBY_FL_USER5
110
+ printf "(literal) "
111
+ end
112
+ if $flags & RUBY_FL_USER4
113
+ printf "(fixed) "
114
+ end
115
+ printf "encoding:%d ", ($flags & RUBY_ENCODING_MASK) >> RUBY_ENCODING_SHIFT
116
+ print (struct RRegexp *)($arg0)
117
+ else
118
+ if ($flags & RUBY_T_MASK) == RUBY_T_ARRAY
119
+ if ($flags & RUBY_FL_USER1)
120
+ set $len = (($flags & (RUBY_FL_USER3|RUBY_FL_USER4)) >> (RUBY_FL_USHIFT+3))
121
+ printf "%sT_ARRAY%s: len=%ld ", $color_type, $color_end, $len
122
+ printf "(embed) "
123
+ if ($len == 0)
124
+ printf "{(empty)} "
125
+ else
126
+ output/x *((VALUE*)((struct RArray*)($arg0))->as.ary) @ $len
127
+ printf " "
128
+ end
129
+ else
130
+ set $len = ((struct RArray*)($arg0))->as.heap.len
131
+ printf "%sT_ARRAY%s: len=%ld ", $color_type, $color_end, $len
132
+ if ($flags & RUBY_FL_USER2)
133
+ printf "(shared) shared="
134
+ output/x ((struct RArray*)($arg0))->as.heap.aux.shared
135
+ printf " "
136
+ else
137
+ printf "(ownership) capa=%ld ", ((struct RArray*)($arg0))->as.heap.aux.capa
138
+ end
139
+ if ($len == 0)
140
+ printf "{(empty)} "
141
+ else
142
+ output/x *((VALUE*)((struct RArray*)($arg0))->as.heap.ptr) @ $len
143
+ printf " "
144
+ end
145
+ end
146
+ print (struct RArray *)($arg0)
147
+ else
148
+ if ($flags & RUBY_T_MASK) == RUBY_T_FIXNUM
149
+ printf "%sT_FIXNUM%s: ", $color_type, $color_end
150
+ print (struct RBasic *)($arg0)
151
+ else
152
+ if ($flags & RUBY_T_MASK) == RUBY_T_HASH
153
+ printf "%sT_HASH%s: ", $color_type, $color_end,
154
+ if ((struct RHash *)($arg0))->ntbl
155
+ printf "len=%ld ", ((struct RHash *)($arg0))->ntbl->num_entries
156
+ end
157
+ print (struct RHash *)($arg0)
158
+ else
159
+ if ($flags & RUBY_T_MASK) == RUBY_T_STRUCT
160
+ printf "%sT_STRUCT%s: len=%ld ", $color_type, $color_end, \
161
+ (($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) ? \
162
+ ($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) >> (RUBY_FL_USHIFT+1) : \
163
+ ((struct RStruct *)($arg0))->as.heap.len)
164
+ print (struct RStruct *)($arg0)
165
+ x/xw (($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) ? \
166
+ ((struct RStruct *)($arg0))->as.ary : \
167
+ ((struct RStruct *)($arg0))->as.heap.ptr)
168
+ else
169
+ if ($flags & RUBY_T_MASK) == RUBY_T_BIGNUM
170
+ printf "%sT_BIGNUM%s: sign=%d len=%ld ", $color_type, $color_end, \
171
+ (($flags & RUBY_FL_USER1) != 0), \
172
+ (($flags & RUBY_FL_USER2) ? \
173
+ ($flags & (RUBY_FL_USER5|RUBY_FL_USER4|RUBY_FL_USER3)) >> (RUBY_FL_USHIFT+3) : \
174
+ ((struct RBignum*)($arg0))->as.heap.len)
175
+ if $flags & RUBY_FL_USER2
176
+ printf "(embed) "
177
+ end
178
+ print (struct RBignum *)($arg0)
179
+ x/xw (($flags & RUBY_FL_USER2) ? \
180
+ ((struct RBignum*)($arg0))->as.ary : \
181
+ ((struct RBignum*)($arg0))->as.heap.digits)
182
+ else
183
+ if ($flags & RUBY_T_MASK) == RUBY_T_RATIONAL
184
+ printf "%sT_RATIONAL%s: ", $color_type, $color_end
185
+ print (struct RRational *)($arg0)
186
+ else
187
+ if ($flags & RUBY_T_MASK) == RUBY_T_COMPLEX
188
+ printf "%sT_COMPLEX%s: ", $color_type, $color_end
189
+ print (struct RComplex *)($arg0)
190
+ else
191
+ if ($flags & RUBY_T_MASK) == RUBY_T_FILE
192
+ printf "%sT_FILE%s: ", $color_type, $color_end
193
+ print (struct RFile *)($arg0)
194
+ output *((struct RFile *)($arg0))->fptr
195
+ printf "\n"
196
+ else
197
+ if ($flags & RUBY_T_MASK) == RUBY_T_TRUE
198
+ printf "%sT_TRUE%s: ", $color_type, $color_end
199
+ print (struct RBasic *)($arg0)
200
+ else
201
+ if ($flags & RUBY_T_MASK) == RUBY_T_FALSE
202
+ printf "%sT_FALSE%s: ", $color_type, $color_end
203
+ print (struct RBasic *)($arg0)
204
+ else
205
+ if ($flags & RUBY_T_MASK) == RUBY_T_DATA
206
+ if ((struct RTypedData *)($arg0))->typed_flag == 1
207
+ printf "%sT_DATA%s(%s): ", $color_type, $color_end, ((struct RTypedData *)($arg0))->type->wrap_struct_name
208
+ print (struct RTypedData *)($arg0)
209
+ else
210
+ printf "%sT_DATA%s: ", $color_type, $color_end
211
+ print (struct RData *)($arg0)
212
+ end
213
+ else
214
+ if ($flags & RUBY_T_MASK) == RUBY_T_MATCH
215
+ printf "%sT_MATCH%s: ", $color_type, $color_end
216
+ print (struct RMatch *)($arg0)
217
+ else
218
+ if ($flags & RUBY_T_MASK) == RUBY_T_SYMBOL
219
+ printf "%sT_SYMBOL%s: ", $color_type, $color_end
220
+ print (struct RSymbol *)($arg0)
221
+ set $id_type = ((struct RSymbol *)($arg0))->id & RUBY_ID_SCOPE_MASK
222
+ if $id_type == RUBY_ID_LOCAL
223
+ printf "l"
224
+ else
225
+ if $id_type == RUBY_ID_INSTANCE
226
+ printf "i"
227
+ else
228
+ if $id_type == RUBY_ID_GLOBAL
229
+ printf "G"
230
+ else
231
+ if $id_type == RUBY_ID_ATTRSET
232
+ printf "a"
233
+ else
234
+ if $id_type == RUBY_ID_CONST
235
+ printf "C"
236
+ else
237
+ if $id_type == RUBY_ID_CLASS
238
+ printf "c"
239
+ else
240
+ printf "j"
241
+ end
242
+ end
243
+ end
244
+ end
245
+ end
246
+ end
247
+ set $id_fstr = ((struct RSymbol *)($arg0))->fstr
248
+ rp_string $id_fstr
249
+ else
250
+ if ($flags & RUBY_T_MASK) == RUBY_T_UNDEF
251
+ printf "%sT_UNDEF%s: ", $color_type, $color_end
252
+ print (struct RBasic *)($arg0)
253
+ else
254
+ if ($flags & RUBY_T_MASK) == RUBY_T_IMEMO
255
+ printf "%sT_IMEMO%s(", $color_type, $color_end
256
+ output (enum imemo_type)(($flags>>RUBY_FL_USHIFT)&imemo_mask)
257
+ printf "): "
258
+ rp_imemo $arg0
259
+ else
260
+ if ($flags & RUBY_T_MASK) == RUBY_T_NODE
261
+ printf "%sT_NODE%s(", $color_type, $color_end
262
+ output (enum node_type)(($flags&RUBY_NODE_TYPEMASK)>>RUBY_NODE_TYPESHIFT)
263
+ printf "): "
264
+ print *(NODE *)($arg0)
265
+ else
266
+ if ($flags & RUBY_T_MASK) == RUBY_T_ZOMBIE
267
+ printf "%sT_ZOMBIE%s: ", $color_type, $color_end
268
+ print (struct RData *)($arg0)
269
+ else
270
+ printf "%sunknown%s: ", $color_type, $color_end
271
+ print (struct RBasic *)($arg0)
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
+ 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
+ document rp
307
+ Print a Ruby's VALUE.
308
+ end
309
+
310
+ define rp_id
311
+ set $id = (ID)$arg0
312
+ if $id == '!' || $id == '+' || $id == '-' || $id == '*' || $id == '/' || $id == '%' || $id == '<' || $id == '>' || $id == '`'
313
+ printf "(:%c)\n", $id
314
+ else
315
+ if $id == idDot2
316
+ printf "(:..)\n"
317
+ else
318
+ if $id == idDot3
319
+ printf "(:...)\n"
320
+ else
321
+ if $id == idUPlus
322
+ printf "(:+@)\n"
323
+ else
324
+ if $id == idUMinus
325
+ printf "(:-@)\n"
326
+ else
327
+ if $id == idPow
328
+ printf "(:**)\n"
329
+ else
330
+ if $id == idCmp
331
+ printf "(:<=>)\n"
332
+ else
333
+ if $id == idLTLT
334
+ printf "(:<<)\n"
335
+ else
336
+ if $id == idLE
337
+ printf "(:<=)\n"
338
+ else
339
+ if $id == idGE
340
+ printf "(:>=)\n"
341
+ else
342
+ if $id == idEq
343
+ printf "(:==)\n"
344
+ else
345
+ if $id == idEqq
346
+ printf "(:===)\n"
347
+ else
348
+ if $id == idNeq
349
+ printf "(:!=)\n"
350
+ else
351
+ if $id == idEqTilde
352
+ printf "(:=~)\n"
353
+ else
354
+ if $id == idNeqTilde
355
+ printf "(:!~)\n"
356
+ else
357
+ if $id == idAREF
358
+ printf "(:[])\n"
359
+ else
360
+ if $id == idASET
361
+ printf "(:[]=)\n"
362
+ else
363
+ if $id <= tLAST_OP_ID
364
+ printf "O"
365
+ else
366
+ set $id_type = $id & RUBY_ID_SCOPE_MASK
367
+ if $id_type == RUBY_ID_LOCAL
368
+ printf "l"
369
+ else
370
+ if $id_type == RUBY_ID_INSTANCE
371
+ printf "i"
372
+ else
373
+ if $id_type == RUBY_ID_GLOBAL
374
+ printf "G"
375
+ else
376
+ if $id_type == RUBY_ID_ATTRSET
377
+ printf "a"
378
+ else
379
+ if $id_type == RUBY_ID_CONST
380
+ printf "C"
381
+ else
382
+ if $id_type == RUBY_ID_CLASS
383
+ printf "c"
384
+ else
385
+ printf "j"
386
+ end
387
+ end
388
+ end
389
+ end
390
+ end
391
+ end
392
+ end
393
+ printf "(%ld): ", $id
394
+ set $str = lookup_id_str($id)
395
+ if $str
396
+ rp_string $str
397
+ else
398
+ echo undef\n
399
+ end
400
+ end
401
+ end
402
+ end
403
+ end
404
+ end
405
+ end
406
+ end
407
+ end
408
+ end
409
+ end
410
+ end
411
+ end
412
+ end
413
+ end
414
+ end
415
+ end
416
+ end
417
+ end
418
+ document rp_id
419
+ Print an ID.
420
+ end
421
+
422
+ define output_string
423
+ set $flags = ((struct RBasic*)($arg0))->flags
424
+ printf "%s", (char *)(($flags & RUBY_FL_USER1) ? \
425
+ ((struct RString*)($arg0))->as.heap.ptr : \
426
+ ((struct RString*)($arg0))->as.ary)
427
+ end
428
+
429
+ define rp_string
430
+ set $flags = ((struct RBasic*)($arg0))->flags
431
+ set print address off
432
+ output (char *)(($flags & RUBY_FL_USER1) ? \
433
+ ((struct RString*)($arg0))->as.heap.ptr : \
434
+ ((struct RString*)($arg0))->as.ary)
435
+ set print address on
436
+ printf " bytesize:%ld ", ($flags & RUBY_FL_USER1) ? \
437
+ ((struct RString*)($arg0))->as.heap.len : \
438
+ (($flags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
439
+ if !($flags & RUBY_FL_USER1)
440
+ printf "(embed) "
441
+ else
442
+ if ($flags & RUBY_FL_USER2)
443
+ printf "(shared) "
444
+ end
445
+ if ($flags & RUBY_FL_USER3)
446
+ printf "(assoc) "
447
+ end
448
+ end
449
+ printf "encoding:%d ", ($flags & RUBY_ENCODING_MASK) >> RUBY_ENCODING_SHIFT
450
+ if ($flags & RUBY_ENC_CODERANGE_MASK) == 0
451
+ printf "coderange:unknown "
452
+ else
453
+ if ($flags & RUBY_ENC_CODERANGE_MASK) == RUBY_ENC_CODERANGE_7BIT
454
+ printf "coderange:7bit "
455
+ else
456
+ if ($flags & RUBY_ENC_CODERANGE_MASK) == RUBY_ENC_CODERANGE_VALID
457
+ printf "coderange:valid "
458
+ else
459
+ printf "coderange:broken "
460
+ end
461
+ end
462
+ end
463
+ print (struct RString *)($arg0)
464
+ end
465
+ document rp_string
466
+ Print the content of a String.
467
+ end
468
+
469
+ define rp_class
470
+ printf "(struct RClass *) %p", (void*)$arg0
471
+ if ((struct RClass *)($arg0))->ptr.origin_ != $arg0
472
+ printf " -> %p", ((struct RClass *)($arg0))->ptr.origin_
473
+ end
474
+ printf "\n"
475
+ rb_classname $arg0
476
+ print/x *(struct RClass *)($arg0)
477
+ print *((struct RClass *)($arg0))->ptr
478
+ end
479
+ document rp_class
480
+ Print the content of a Class/Module.
481
+ end
482
+
483
+ define rp_imemo
484
+ set $flags = (enum imemo_type)((((struct RBasic *)($arg0))->flags >> RUBY_FL_USHIFT) & imemo_mask)
485
+ if $flags == imemo_cref
486
+ printf "(rb_cref_t *) %p\n", (void*)$arg0
487
+ print *(rb_cref_t *)$arg0
488
+ else
489
+ if $flags == imemo_svar
490
+ printf "(struct vm_svar *) %p\n", (void*)$arg0
491
+ print *(struct vm_svar *)$arg0
492
+ else
493
+ if $flags == imemo_throw_data
494
+ printf "(struct vm_throw_data *) %p\n", (void*)$arg0
495
+ print *(struct vm_throw_data *)$arg0
496
+ else
497
+ if $flags == imemo_ifunc
498
+ printf "(struct vm_ifunc *) %p\n", (void*)$arg0
499
+ print *(struct vm_ifunc *)$arg0
500
+ else
501
+ if $flags == imemo_memo
502
+ printf "(struct MEMO *) %p\n", (void*)$arg0
503
+ print *(struct MEMO *)$arg0
504
+ else
505
+ if $flags == imemo_ment
506
+ printf "(rb_method_entry_t *) %p\n", (void*)$arg0
507
+ print *(rb_method_entry_t *)$arg0
508
+ else
509
+ if $flags == imemo_iseq
510
+ printf "(rb_iseq_t *) %p\n", (void*)$arg0
511
+ print *(rb_iseq_t *)$arg0
512
+ else
513
+ printf "(struct RIMemo *) %p\n", (void*)$arg0
514
+ print *(struct RIMemo *)$arg0
515
+ end
516
+ end
517
+ end
518
+ end
519
+ end
520
+ end
521
+ end
522
+ end
523
+ document rp_imemo
524
+ Print the content of a memo
525
+ end
526
+
527
+ define nd_type
528
+ print (enum node_type)((((NODE*)($arg0))->flags&RUBY_NODE_TYPEMASK)>>RUBY_NODE_TYPESHIFT)
529
+ end
530
+ document nd_type
531
+ Print a Ruby' node type.
532
+ end
533
+
534
+ define nd_file
535
+ print ((NODE*)($arg0))->nd_file
536
+ end
537
+ document nd_file
538
+ Print the source file name of a node.
539
+ end
540
+
541
+ define nd_line
542
+ print ((unsigned int)((((NODE*)($arg0))->flags>>RUBY_NODE_LSHIFT)&RUBY_NODE_LMASK))
543
+ end
544
+ document nd_line
545
+ Print the source line number of a node.
546
+ end
547
+
548
+ # Print members of ruby node.
549
+
550
+ define nd_head
551
+ printf "%su1.node%s: ", $color_highlite, $color_end
552
+ rp ($arg0).u1.node
553
+ end
554
+
555
+ define nd_alen
556
+ printf "%su2.argc%s: ", $color_highlite, $color_end
557
+ p ($arg0).u2.argc
558
+ end
559
+
560
+ define nd_next
561
+ printf "%su3.node%s: ", $color_highlite, $color_end
562
+ rp ($arg0).u3.node
563
+ end
564
+
565
+
566
+ define nd_cond
567
+ printf "%su1.node%s: ", $color_highlite, $color_end
568
+ rp ($arg0).u1.node
569
+ end
570
+
571
+ define nd_body
572
+ printf "%su2.node%s: ", $color_highlite, $color_end
573
+ rp ($arg0).u2.node
574
+ end
575
+
576
+ define nd_else
577
+ printf "%su3.node%s: ", $color_highlite, $color_end
578
+ rp ($arg0).u3.node
579
+ end
580
+
581
+
582
+ define nd_orig
583
+ printf "%su3.value%s: ", $color_highlite, $color_end
584
+ rp ($arg0).u3.value
585
+ end
586
+
587
+
588
+ define nd_resq
589
+ printf "%su2.node%s: ", $color_highlite, $color_end
590
+ rp ($arg0).u2.node
591
+ end
592
+
593
+ define nd_ensr
594
+ printf "%su3.node%s: ", $color_highlite, $color_end
595
+ rp ($arg0).u3.node
596
+ end
597
+
598
+
599
+ define nd_1st
600
+ printf "%su1.node%s: ", $color_highlite, $color_end
601
+ rp ($arg0).u1.node
602
+ end
603
+
604
+ define nd_2nd
605
+ printf "%su2.node%s: ", $color_highlite, $color_end
606
+ rp ($arg0).u2.node
607
+ end
608
+
609
+
610
+ define nd_stts
611
+ printf "%su1.node%s: ", $color_highlite, $color_end
612
+ rp ($arg0).u1.node
613
+ end
614
+
615
+
616
+ define nd_entry
617
+ printf "%su3.entry%s: ", $color_highlite, $color_end
618
+ p ($arg0).u3.entry
619
+ end
620
+
621
+ define nd_vid
622
+ printf "%su1.id%s: ", $color_highlite, $color_end
623
+ p ($arg0).u1.id
624
+ end
625
+
626
+ define nd_cflag
627
+ printf "%su2.id%s: ", $color_highlite, $color_end
628
+ p ($arg0).u2.id
629
+ end
630
+
631
+ define nd_cval
632
+ printf "%su3.value%s: ", $color_highlite, $color_end
633
+ rp ($arg0).u3.value
634
+ end
635
+
636
+
637
+ define nd_cnt
638
+ printf "%su3.cnt%s: ", $color_highlite, $color_end
639
+ p ($arg0).u3.cnt
640
+ end
641
+
642
+ define nd_tbl
643
+ printf "%su1.tbl%s: ", $color_highlite, $color_end
644
+ p ($arg0).u1.tbl
645
+ end
646
+
647
+
648
+ define nd_var
649
+ printf "%su1.node%s: ", $color_highlite, $color_end
650
+ rp ($arg0).u1.node
651
+ end
652
+
653
+ define nd_ibdy
654
+ printf "%su2.node%s: ", $color_highlite, $color_end
655
+ rp ($arg0).u2.node
656
+ end
657
+
658
+ define nd_iter
659
+ printf "%su3.node%s: ", $color_highlite, $color_end
660
+ rp ($arg0).u3.node
661
+ end
662
+
663
+
664
+ define nd_value
665
+ printf "%su2.node%s: ", $color_highlite, $color_end
666
+ rp ($arg0).u2.node
667
+ end
668
+
669
+ define nd_aid
670
+ printf "%su3.id%s: ", $color_highlite, $color_end
671
+ p ($arg0).u3.id
672
+ end
673
+
674
+
675
+ define nd_lit
676
+ printf "%su1.value%s: ", $color_highlite, $color_end
677
+ rp ($arg0).u1.value
678
+ end
679
+
680
+
681
+ define nd_frml
682
+ printf "%su1.node%s: ", $color_highlite, $color_end
683
+ rp ($arg0).u1.node
684
+ end
685
+
686
+ define nd_rest
687
+ printf "%su2.argc%s: ", $color_highlite, $color_end
688
+ p ($arg0).u2.argc
689
+ end
690
+
691
+ define nd_opt
692
+ printf "%su1.node%s: ", $color_highlite, $color_end
693
+ rp ($arg0).u1.node
694
+ end
695
+
696
+
697
+ define nd_recv
698
+ printf "%su1.node%s: ", $color_highlite, $color_end
699
+ rp ($arg0).u1.node
700
+ end
701
+
702
+ define nd_mid
703
+ printf "%su2.id%s: ", $color_highlite, $color_end
704
+ p ($arg0).u2.id
705
+ end
706
+
707
+ define nd_args
708
+ printf "%su3.node%s: ", $color_highlite, $color_end
709
+ rp ($arg0).u3.node
710
+ end
711
+
712
+
713
+ define nd_noex
714
+ printf "%su1.id%s: ", $color_highlite, $color_end
715
+ p ($arg0).u1.id
716
+ end
717
+
718
+ define nd_defn
719
+ printf "%su3.node%s: ", $color_highlite, $color_end
720
+ rp ($arg0).u3.node
721
+ end
722
+
723
+
724
+ define nd_old
725
+ printf "%su1.id%s: ", $color_highlite, $color_end
726
+ p ($arg0).u1.id
727
+ end
728
+
729
+ define nd_new
730
+ printf "%su2.id%s: ", $color_highlite, $color_end
731
+ p ($arg0).u2.id
732
+ end
733
+
734
+
735
+ define nd_cfnc
736
+ printf "%su1.cfunc%s: ", $color_highlite, $color_end
737
+ p ($arg0).u1.cfunc
738
+ end
739
+
740
+ define nd_argc
741
+ printf "%su2.argc%s: ", $color_highlite, $color_end
742
+ p ($arg0).u2.argc
743
+ end
744
+
745
+
746
+ define nd_cname
747
+ printf "%su1.id%s: ", $color_highlite, $color_end
748
+ p ($arg0).u1.id
749
+ end
750
+
751
+ define nd_super
752
+ printf "%su3.node%s: ", $color_highlite, $color_end
753
+ rp ($arg0).u3.node
754
+ end
755
+
756
+
757
+ define nd_modl
758
+ printf "%su1.id%s: ", $color_highlite, $color_end
759
+ p ($arg0).u1.id
760
+ end
761
+
762
+ define nd_clss
763
+ printf "%su1.value%s: ", $color_highlite, $color_end
764
+ rp ($arg0).u1.value
765
+ end
766
+
767
+
768
+ define nd_beg
769
+ printf "%su1.node%s: ", $color_highlite, $color_end
770
+ rp ($arg0).u1.node
771
+ end
772
+
773
+ define nd_end
774
+ printf "%su2.node%s: ", $color_highlite, $color_end
775
+ rp ($arg0).u2.node
776
+ end
777
+
778
+ define nd_state
779
+ printf "%su3.state%s: ", $color_highlite, $color_end
780
+ p ($arg0).u3.state
781
+ end
782
+
783
+ define nd_rval
784
+ printf "%su2.value%s: ", $color_highlite, $color_end
785
+ rp ($arg0).u2.value
786
+ end
787
+
788
+
789
+ define nd_nth
790
+ printf "%su2.argc%s: ", $color_highlite, $color_end
791
+ p ($arg0).u2.argc
792
+ end
793
+
794
+
795
+ define nd_tag
796
+ printf "%su1.id%s: ", $color_highlite, $color_end
797
+ p ($arg0).u1.id
798
+ end
799
+
800
+ define nd_tval
801
+ printf "%su2.value%s: ", $color_highlite, $color_end
802
+ rp ($arg0).u2.value
803
+ end
804
+
805
+ define nd_tree
806
+ set $buf = (struct RString *)rb_str_buf_new(0)
807
+ call dump_node((VALUE)($buf), rb_str_new(0, 0), 0, ($arg0))
808
+ printf "%s\n", $buf->as.heap.ptr
809
+ end
810
+
811
+ define rb_p
812
+ call rb_p($arg0)
813
+ end
814
+
815
+ define rb_numtable_entry
816
+ set $rb_numtable_tbl = $arg0
817
+ set $rb_numtable_id = (st_data_t)$arg1
818
+ set $rb_numtable_key = 0
819
+ set $rb_numtable_rec = 0
820
+ if $rb_numtable_tbl->entries_packed
821
+ set $rb_numtable_p = $rb_numtable_tbl->as.packed.bins
822
+ while $rb_numtable_p && $rb_numtable_p < $rb_numtable_tbl->as.packed.bins+$rb_numtable_tbl->num_entries
823
+ if $rb_numtable_p.k == $rb_numtable_id
824
+ set $rb_numtable_key = $rb_numtable_p.k
825
+ set $rb_numtable_rec = $rb_numtable_p.v
826
+ set $rb_numtable_p = 0
827
+ else
828
+ set $rb_numtable_p = $rb_numtable_p + 1
829
+ end
830
+ end
831
+ else
832
+ set $rb_numtable_p = $rb_numtable_tbl->as.big.bins[st_numhash($rb_numtable_id) % $rb_numtable_tbl->num_bins]
833
+ while $rb_numtable_p
834
+ if $rb_numtable_p->key == $rb_numtable_id
835
+ set $rb_numtable_key = $rb_numtable_p->key
836
+ set $rb_numtable_rec = $rb_numtable_p->record
837
+ set $rb_numtable_p = 0
838
+ else
839
+ set $rb_numtable_p = $rb_numtable_p->next
840
+ end
841
+ end
842
+ end
843
+ end
844
+
845
+ define rb_id2name
846
+ ruby_gdb_init
847
+ printf "%sID%s: ", $color_type, $color_end
848
+ rp_id $arg0
849
+ end
850
+ document rb_id2name
851
+ Print the name of id
852
+ end
853
+
854
+ define rb_method_entry
855
+ set $rb_method_entry_klass = (struct RClass *)$arg0
856
+ set $rb_method_entry_id = (ID)$arg1
857
+ set $rb_method_entry_me = (rb_method_entry_t *)0
858
+ while !$rb_method_entry_me && $rb_method_entry_klass
859
+ rb_numtable_entry $rb_method_entry_klass->m_tbl_wrapper->tbl $rb_method_entry_id
860
+ set $rb_method_entry_me = (rb_method_entry_t *)$rb_numtable_rec
861
+ if !$rb_method_entry_me
862
+ set $rb_method_entry_klass = (struct RClass *)RCLASS_SUPER($rb_method_entry_klass)
863
+ end
864
+ end
865
+ if $rb_method_entry_me
866
+ print *$rb_method_entry_klass
867
+ print *$rb_method_entry_me
868
+ else
869
+ echo method not found\n
870
+ end
871
+ end
872
+ document rb_method_entry
873
+ Search method entry by class and id
874
+ end
875
+
876
+ define rb_classname
877
+ # up to 128bit int
878
+ set $rb_classname = rb_mod_name($arg0)
879
+ if $rb_classname != RUBY_Qnil
880
+ rp $rb_classname
881
+ else
882
+ echo anonymous class/module\n
883
+ end
884
+ end
885
+
886
+ define rb_ancestors
887
+ set $rb_ancestors_module = $arg0
888
+ while $rb_ancestors_module
889
+ rp_class $rb_ancestors_module
890
+ set $rb_ancestors_module = RCLASS_SUPER($rb_ancestors_module)
891
+ end
892
+ end
893
+ document rb_ancestors
894
+ Print ancestors.
895
+ end
896
+
897
+ define rb_backtrace
898
+ call rb_backtrace()
899
+ end
900
+
901
+ define iseq
902
+ if ruby_dummy_gdb_enums.special_consts
903
+ end
904
+ if ($arg0)->type == ISEQ_ELEMENT_NONE
905
+ echo [none]\n
906
+ end
907
+ if ($arg0)->type == ISEQ_ELEMENT_LABEL
908
+ print *(LABEL*)($arg0)
909
+ end
910
+ if ($arg0)->type == ISEQ_ELEMENT_INSN
911
+ print *(INSN*)($arg0)
912
+ if ((INSN*)($arg0))->insn_id != YARVINSN_jump
913
+ set $i = 0
914
+ set $operand_size = ((INSN*)($arg0))->operand_size
915
+ set $operands = ((INSN*)($arg0))->operands
916
+ while $i < $operand_size
917
+ rp $operands[$i++]
918
+ end
919
+ end
920
+ end
921
+ if ($arg0)->type == ISEQ_ELEMENT_ADJUST
922
+ print *(ADJUST*)($arg0)
923
+ end
924
+ end
925
+
926
+ define rb_ps
927
+ rb_ps_vm ruby_current_vm
928
+ end
929
+ document rb_ps
930
+ Dump all threads and their callstacks
931
+ end
932
+
933
+ define rb_ps_vm
934
+ print $ps_vm = (rb_vm_t*)$arg0
935
+ set $ps_thread_ln = $ps_vm->living_threads.n.next
936
+ set $ps_thread_ln_last = $ps_vm->living_threads.n.prev
937
+ while 1
938
+ set $ps_thread_th = (rb_thread_t *)$ps_thread_ln
939
+ set $ps_thread = (VALUE)($ps_thread_th->self)
940
+ rb_ps_thread $ps_thread
941
+ if $ps_thread_ln == $ps_thread_ln_last
942
+ loop_break
943
+ end
944
+ set $ps_thread_ln = $ps_thread_ln->next
945
+ end
946
+ end
947
+ document rb_ps_vm
948
+ Dump all threads in a (rb_vm_t*) and their callstacks
949
+ end
950
+
951
+ define print_lineno
952
+ set $cfp = $arg0
953
+ set $iseq = $cfp->iseq
954
+ set $pos = $cfp->pc - $iseq->body->iseq_encoded
955
+ if $pos != 0
956
+ set $pos = $pos - 1
957
+ end
958
+
959
+ set $i = 0
960
+ set $size = $iseq->body->line_info_size
961
+ set $table = $iseq->body->line_info_table
962
+ #printf "size: %d\n", $size
963
+ if $size == 0
964
+ else
965
+ set $i = 1
966
+ while $i < $size
967
+ #printf "table[%d]: position: %d, line: %d, pos: %d\n", $i, $table[$i].position, $table[$i].line_no, $pos
968
+ if $table[$i].position > $pos
969
+ loop_break
970
+ end
971
+ set $i = $i + 1
972
+ if $table[$i].position == $pos
973
+ loop_break
974
+ end
975
+ end
976
+ printf "%d", $table[$i-1].line_no
977
+ end
978
+ end
979
+
980
+ define check_method_entry
981
+ # get $immeo and $can_be_svar and return $me
982
+ set $imemo = (struct RBasic *)$arg0
983
+ set $can_be_svar = $arg1
984
+ if $imemo != RUBY_Qfalse
985
+ set $type = ($imemo->flags >> 12) & 0x07
986
+ if $type == imemo_ment
987
+ set $me = (rb_callable_method_entry_t *)$imemo
988
+ else
989
+ if $type == imemo_svar
990
+ set $imemo == ((struct vm_svar *)$imemo)->cref_or_me
991
+ check_method_entry $imemo 0
992
+ end
993
+ end
994
+ end
995
+ end
996
+
997
+ define output_id
998
+ set $id = $arg0
999
+ # rb_id_to_serial
1000
+ if $id > tLAST_OP_ID
1001
+ set $serial = (rb_id_serial_t)($id >> RUBY_ID_SCOPE_SHIFT)
1002
+ else
1003
+ set $serial = (rb_id_serial_t)$id
1004
+ end
1005
+ if $serial && $serial <= global_symbols.last_id
1006
+ set $idx = $serial / ID_ENTRY_UNIT
1007
+ set $ids = (struct RArray *)global_symbols.ids
1008
+ set $flags = $ids->basic.flags
1009
+ if ($flags & RUBY_FL_USER1)
1010
+ set $idsptr = $ids->as.ary
1011
+ set $idslen = (($flags & (RUBY_FL_USER3|RUBY_FL_USER4)) >> (RUBY_FL_USHIFT+3))
1012
+ else
1013
+ set $idsptr = $ids->as.heap.ptr
1014
+ set $idslen = $ids->as.heap.len
1015
+ end
1016
+ if $idx < $idslen
1017
+ set $t = 0
1018
+ set $ary = (struct RArray *)$idsptr[$idx]
1019
+ if $ary != RUBY_Qnil
1020
+ set $flags = $ary->basic.flags
1021
+ if ($flags & RUBY_FL_USER1)
1022
+ set $aryptr = $ary->as.ary
1023
+ set $arylen = (($flags & (RUBY_FL_USER3|RUBY_FL_USER4)) >> (RUBY_FL_USHIFT+3))
1024
+ else
1025
+ set $aryptr = $ary->as.heap.ptr
1026
+ set $arylen = $ary->as.heap.len
1027
+ end
1028
+ set $result = $aryptr[($serial % ID_ENTRY_UNIT) * ID_ENTRY_SIZE + $t]
1029
+ output_string $result
1030
+ end
1031
+ end
1032
+ end
1033
+ end
1034
+
1035
+ define rb_ps_thread
1036
+ set $ps_thread = (struct RTypedData*)$arg0
1037
+ set $ps_thread_th = (rb_thread_t*)$ps_thread->data
1038
+ printf "* #<Thread:%p rb_thread_t:%p native_thread:%p>\n", \
1039
+ $ps_thread, $ps_thread_th, $ps_thread_th->thread_id
1040
+ set $cfp = $ps_thread_th->cfp
1041
+ set $cfpend = (rb_control_frame_t *)($ps_thread_th->stack + $ps_thread_th->stack_size)-1
1042
+ while $cfp < $cfpend
1043
+ if $cfp->iseq
1044
+ if $cfp->pc
1045
+ set $location = $cfp->iseq->body->location
1046
+ output_string $location.path
1047
+ printf ":"
1048
+ print_lineno $cfp
1049
+ printf ":in `"
1050
+ output_string $location.label
1051
+ printf "'\n"
1052
+ else
1053
+ printf "???.rb:???:in `???'\n"
1054
+ end
1055
+ else
1056
+ # if VM_FRAME_TYPE($cfp->flag) == VM_FRAME_MAGIC_CFUNC
1057
+ set $ep = $cfp->ep
1058
+ if ($ep[0] & 0xffff0001) == 0x55550001
1059
+ #define VM_ENV_FLAG_LOCAL 0x02
1060
+ #define VM_ENV_PREV_EP(ep) GC_GUARDED_PTR_REF(ep[VM_ENV_DATA_INDEX_SPECVAL])
1061
+ set $me = 0
1062
+ set $env_specval = $ep[-1]
1063
+ set $env_me_cref = $ep[-2]
1064
+ while ($env_specval & 0x02) != 0
1065
+ check_method_entry $env_me_cref 0
1066
+ if $me != 0
1067
+ loop_break
1068
+ end
1069
+ set $ep = $ep[0]
1070
+ set $env_specval = $ep[-1]
1071
+ set $env_me_cref = $ep[-2]
1072
+ end
1073
+ if $me == 0
1074
+ check_method_entry $env_me_cref 1
1075
+ end
1076
+ set print symbol-filename on
1077
+ output/a $me->def->body.cfunc.func
1078
+ set print symbol-filename off
1079
+ set $mid = $me->def->original_id
1080
+ printf ":in `"
1081
+ output_id $mid
1082
+ printf "'\n"
1083
+ else
1084
+ printf "unknown_frame:???:in `???'\n"
1085
+ end
1086
+ end
1087
+ set $cfp = $cfp + 1
1088
+ end
1089
+ end
1090
+
1091
+ define rb_count_objects
1092
+ set $objspace = ruby_current_vm->objspace
1093
+ set $counts_00 = 0
1094
+ set $counts_01 = 0
1095
+ set $counts_02 = 0
1096
+ set $counts_03 = 0
1097
+ set $counts_04 = 0
1098
+ set $counts_05 = 0
1099
+ set $counts_06 = 0
1100
+ set $counts_07 = 0
1101
+ set $counts_08 = 0
1102
+ set $counts_09 = 0
1103
+ set $counts_0a = 0
1104
+ set $counts_0b = 0
1105
+ set $counts_0c = 0
1106
+ set $counts_0d = 0
1107
+ set $counts_0e = 0
1108
+ set $counts_0f = 0
1109
+ set $counts_10 = 0
1110
+ set $counts_11 = 0
1111
+ set $counts_12 = 0
1112
+ set $counts_13 = 0
1113
+ set $counts_14 = 0
1114
+ set $counts_15 = 0
1115
+ set $counts_16 = 0
1116
+ set $counts_17 = 0
1117
+ set $counts_18 = 0
1118
+ set $counts_19 = 0
1119
+ set $counts_1a = 0
1120
+ set $counts_1b = 0
1121
+ set $counts_1c = 0
1122
+ set $counts_1d = 0
1123
+ set $counts_1e = 0
1124
+ set $counts_1f = 0
1125
+ set $total = 0
1126
+ set $i = 0
1127
+ while $i < $objspace->heap_pages.allocated_pages
1128
+ printf "\rcounting... %d/%d", $i, $objspace->heap_pages.allocated_pages
1129
+ set $page = $objspace->heap_pages.sorted[$i]
1130
+ set $p = $page->start
1131
+ set $pend = $p + $page->total_slots
1132
+ while $p < $pend
1133
+ set $flags = $p->as.basic.flags & 0x1f
1134
+ eval "set $counts_%02x = $counts_%02x + 1", $flags, $flags
1135
+ set $p = $p + 1
1136
+ end
1137
+ set $total = $total + $page->total_slots
1138
+ set $i = $i + 1
1139
+ end
1140
+ printf "\rTOTAL: %d, FREE: %d\n", $total, $counts_00
1141
+ printf "T_OBJECT: %d\n", $counts_01
1142
+ printf "T_CLASS: %d\n", $counts_02
1143
+ printf "T_MODULE: %d\n", $counts_03
1144
+ printf "T_FLOAT: %d\n", $counts_04
1145
+ printf "T_STRING: %d\n", $counts_05
1146
+ printf "T_REGEXP: %d\n", $counts_06
1147
+ printf "T_ARRAY: %d\n", $counts_07
1148
+ printf "T_HASH: %d\n", $counts_08
1149
+ printf "T_STRUCT: %d\n", $counts_09
1150
+ printf "T_BIGNUM: %d\n", $counts_0a
1151
+ printf "T_FILE: %d\n", $counts_0b
1152
+ printf "T_DATA: %d\n", $counts_0c
1153
+ printf "T_MATCH: %d\n", $counts_0d
1154
+ printf "T_COMPLEX: %d\n", $counts_0e
1155
+ printf "T_RATIONAL: %d\n", $counts_0f
1156
+ #printf "UNKNOWN_10: %d\n", $counts_10
1157
+ printf "T_NIL: %d\n", $counts_11
1158
+ printf "T_TRUE: %d\n", $counts_12
1159
+ printf "T_FALSE: %d\n", $counts_13
1160
+ printf "T_SYMBOL: %d\n", $counts_14
1161
+ printf "T_FIXNUM: %d\n", $counts_15
1162
+ printf "T_UNDEF: %d\n", $counts_16
1163
+ #printf "UNKNOWN_17: %d\n", $counts_17
1164
+ #printf "UNKNOWN_18: %d\n", $counts_18
1165
+ #printf "UNKNOWN_19: %d\n", $counts_19
1166
+ printf "T_IMEMO: %d\n", $counts_1a
1167
+ printf "T_NODE: %d\n", $counts_1b
1168
+ printf "T_ICLASS: %d\n", $counts_1c
1169
+ printf "T_ZOMBIE: %d\n", $counts_1d
1170
+ #printf "UNKNOWN_1E: %d\n", $counts_1e
1171
+ printf "T_MASK: %d\n", $counts_1f
1172
+ end
1173
+ document rb_count_objects
1174
+ Counts all objects grouped by type.
1175
+ end
1176
+
1177
+ # Details: https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/MachineInstructionsTraceWithGDB
1178
+ define trace_machine_instructions
1179
+ set logging on
1180
+ set height 0
1181
+ set width 0
1182
+ display/i $pc
1183
+ while !$exit_code
1184
+ info line *$pc
1185
+ si
1186
+ end
1187
+ end
1188
+
1189
+ define SDR
1190
+ call rb_vmdebug_stack_dump_raw_current()
1191
+ end
1192
+
1193
+ define rbi
1194
+ if ((LINK_ELEMENT*)$arg0)->type == ISEQ_ELEMENT_LABEL
1195
+ p *(LABEL*)$arg0
1196
+ else
1197
+ if ((LINK_ELEMENT*)$arg0)->type == ISEQ_ELEMENT_INSN
1198
+ p *(INSN*)$arg0
1199
+ else
1200
+ if ((LINK_ELEMENT*)$arg0)->type == ISEQ_ELEMENT_ADJUST
1201
+ p *(ADJUST*)$arg0
1202
+ else
1203
+ print *$arg0
1204
+ end
1205
+ end
1206
+ end
1207
+ end
1208
+
1209
+ define dump_node
1210
+ set $str = rb_parser_dump_tree($arg0, 0)
1211
+ set $flags = ((struct RBasic*)($str))->flags
1212
+ printf "%s", (char *)(($flags & RUBY_FL_USER1) ? \
1213
+ ((struct RString*)$str)->as.heap.ptr : \
1214
+ ((struct RString*)$str)->as.ary)
1215
+ end