XRay 1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ ruby$target:::ruby-probe
2
+ {
3
+ printf("%d cpu: %d - %s '%s'", timestamp, cpu, copyinstr(arg0), copyinstr(arg1))
4
+ }
data/gdb_macros ADDED
@@ -0,0 +1,567 @@
1
+ # Copy this file into you home directory as '.gdbinit'.
2
+ #
3
+ # GDB will then load these macros automatically.
4
+
5
+ ###################################################################
6
+ # Jamis Buck's Tricks
7
+ ###################################################################
8
+
9
+ define rb_bt
10
+ set $ary = (int)backtrace(-1)
11
+ set $count = *($ary+8)
12
+ set $index = 0
13
+ while $index < $count
14
+ x/1s *((int)rb_ary_entry($ary, $index)+12)
15
+ set $index = $index + 1
16
+ end
17
+ end
18
+ document rb_bt
19
+ Print the ruby stack trace interpreting backtrace as a Ruby array of string.
20
+ end
21
+
22
+ define rb_raise
23
+ call rb_raise((int)rb_eException, "Forced exception from GDB to get a valid ruby stack trace")
24
+ end
25
+ document rb_raise
26
+ Raise a Ruby exception from gdb.
27
+ end
28
+
29
+ ###################################################################
30
+ # Mauricio Fernandez's Ruby macros (Eigenclass.org)
31
+ ###################################################################
32
+
33
+ define eval
34
+ call(rb_p(rb_eval_string_protect($arg0,(int*)0)))
35
+ end
36
+ document eval
37
+ Evaluate an arbitrary Ruby expression from current gdb context.
38
+ end
39
+
40
+ define redirect_stdout
41
+ call rb_eval_string("$_old_stdout, $stdout = $stdout, File.open('/tmp/ruby-debug.' + Process.pid.to_s, 'a'); $stdout.sync = true")
42
+ end
43
+ document redirect_stdout
44
+ Hijack Ruby $stdout and redirect it to /tmp/ruby-debug-<pid>.
45
+ Useful to redirect ruby macro output to a separate file.
46
+ end
47
+
48
+ define restore_stdout
49
+ call rb_eval_string("$stdout = $_old_stdout")
50
+ end
51
+ document restore_stdout
52
+ Restore Ruby $stdout to its original value after hijacking it with
53
+ redirect_stdout.
54
+ end
55
+
56
+ define rb_finish
57
+ call rb_eval_string_protect("set_trace_func lambda{|event, file, line, id, binding, classname| if /return/ =~ event; sleep 0; set_trace_func(nil) end}",(int*)0)
58
+ tbreak rb_f_sleep
59
+ cont
60
+ end
61
+ document rb_finish
62
+ Execute the current Ruby method until it returns and interrupts the
63
+ process at a safe point (the rb_f_sleep function). You should
64
+ always call this macro before evaling Ruby code in gdb.
65
+ end
66
+
67
+ define rb_object_counts
68
+ call rb_eval_string_protect("counts = Hash.new{|h,k| h[k] = 0}; ObjectSpace.each_object{|o| counts[o.class] += 1}; counts.sort_by{|k,c| c}.reverse.each{|k,c| puts '%7d %s' % [c, k] } ",(int*)0)
69
+ end
70
+ document rb_object_counts
71
+ Count and print all living objects by type.
72
+ end
73
+
74
+ define rb_locals
75
+ eval "local_variables.map{|x| puts '%s = %s' % [x, eval(x)]}; nil"
76
+ end
77
+ document rb_locals
78
+ Print local variables and their values.
79
+ end
80
+
81
+ define rp
82
+ if ($arg0 & 0x1)
83
+ echo T_FIXNUM\n
84
+ print (long)$arg0 >> 1
85
+ else
86
+ if ($arg0 == 0)
87
+ echo T_FALSE\n
88
+ else
89
+ if ($arg0 == 2)
90
+ echo T_TRUE\n
91
+ else
92
+ if ($arg0 == 4)
93
+ echo T_NIL\n
94
+ else
95
+ if ($arg0 == 6)
96
+ echo T_UNDEF\n
97
+ else
98
+ if (($arg0 & 0xff) == 0x0e)
99
+ echo T_SYMBOL\n
100
+ output $arg0 >> 8
101
+ echo \n
102
+ call rb_id2name($arg0 >> 8)
103
+ else
104
+ set $rbasic = (struct RBasic*)$arg0
105
+ # output $rbasic
106
+ # echo \ =\
107
+ # output *$rbasic
108
+ # echo \n
109
+ set $flags = (*$rbasic).flags & 0x3f
110
+ if ($flags == 0x01)
111
+ echo T_NIL\n
112
+ echo impossible\n
113
+ else
114
+ if ($flags == 0x02)
115
+ echo T_OBJECT\n
116
+ print *(struct RObject*)$rbasic
117
+ else
118
+ if ($flags == 0x03)
119
+ echo T_CLASS\n
120
+ # rb_classname($arg0)
121
+ else
122
+ if ($flags == 0x04)
123
+ echo T_ICLASS\n
124
+ print *(struct RClass*)$rbasic
125
+ else
126
+ if ($flags == 0x05)
127
+ echo T_MODULE\n
128
+ print *(struct RClass*)$rbasic
129
+ else
130
+ if ($flags == 0x06)
131
+ echo T_FLOAT\n
132
+ print *(struct RFloat*)$rbasic
133
+ else
134
+ if ($flags == 0x07)
135
+ echo T_STRING\n
136
+ print *(struct RString*)$rbasic
137
+ else
138
+ if ($flags == 0x08)
139
+ echo T_REGEXP\n
140
+ print *(struct RRegexp*)$rbasic
141
+ else
142
+ if ($flags == 0x09)
143
+ echo T_ARRAY\n
144
+ print *(struct RArray*)$rbasic
145
+ else
146
+ if ($flags == 0x0a)
147
+ echo T_FIXNUM\n
148
+ echo impossible\n
149
+ else
150
+ if ($flags == 0x0b)
151
+ echo T_HASH\n
152
+ print *(struct RHash*)$rbasic
153
+ else
154
+ if ($flags == 0x0c)
155
+ echo T_STRUCT\n
156
+ print *(struct RStruct*)$rbasic
157
+ else
158
+ if ($flags == 0x0d)
159
+ echo T_BIGNUM\n
160
+ print *(struct RBignum*)$rbasic
161
+ else
162
+ if ($flags == 0x0e)
163
+ echo T_FILE\n
164
+ print *(struct RFile*)$rbasic
165
+ else
166
+ if ($flags == 0x20)
167
+ echo T_TRUE\n
168
+ echo impossible\n
169
+ else
170
+ if ($flags == 0x21)
171
+ echo T_FALSE\n
172
+ echo impossible\n
173
+ else
174
+ if ($flags == 0x22)
175
+ echo T_DATA\n
176
+ print *(struct RData*)$rbasic
177
+ else
178
+ if ($flags == 0x23)
179
+ echo T_MATCH\n
180
+ print *(struct RMatch*)$rbasic
181
+ else
182
+ if ($flags == 0x24)
183
+ echo T_SYMBOL\n
184
+ echo impossible\n
185
+ else
186
+ if ($flags == 0x3c)
187
+ echo T_UNDEF\n
188
+ echo impossible\n
189
+ else
190
+ if ($flags == 0x3d)
191
+ echo T_VARMAP\n
192
+ else
193
+ if ($flags == 0x3e)
194
+ echo T_SCOPE\n
195
+ else
196
+ if ($flags == 0x3f)
197
+ echo T_NODE\n
198
+ print (NODE*)$arg0
199
+ else
200
+ echo Unknown\n
201
+ end
202
+ end
203
+ end
204
+ end
205
+ end
206
+ end
207
+ end
208
+ end
209
+ end
210
+ end
211
+ end
212
+ end
213
+ end
214
+ end
215
+ end
216
+ end
217
+ end
218
+ end
219
+ end
220
+ end
221
+ end
222
+ end
223
+ end
224
+
225
+ end
226
+ end
227
+ end
228
+ end
229
+ end
230
+ end
231
+ end
232
+
233
+ define nd_type
234
+ print nodetype($arg0)
235
+ end
236
+
237
+ define nd_file
238
+ print ((NODE*)$arg0)->nd_file
239
+ end
240
+
241
+ define nd_line
242
+ print nodeline($arg0)
243
+ end
244
+
245
+ # ruby node �Υ��Ф�ɽ��
246
+
247
+ define nd_head
248
+ print "u1.node"
249
+ what $arg0.u1.node
250
+ p $arg0.u1.node
251
+ end
252
+
253
+ define nd_alen
254
+ print "u2.argc"
255
+ what $arg0.u2.argc
256
+ p $arg0.u2.argc
257
+ end
258
+
259
+ define nd_next
260
+ print "u3.node"
261
+ what $arg0.u3.node
262
+ p $arg0.u3.node
263
+ end
264
+
265
+
266
+ define nd_cond
267
+ print "u1.node"
268
+ what $arg0.u1.node
269
+ p $arg0.u1.node
270
+ end
271
+
272
+ define nd_body
273
+ print "u2.node"
274
+ what $arg0.u2.node
275
+ p $arg0.u2.node
276
+ end
277
+
278
+ define nd_else
279
+ print "u3.node"
280
+ what $arg0.u3.node
281
+ p $arg0.u3.node
282
+ end
283
+
284
+
285
+ define nd_orig
286
+ print "u3.value"
287
+ what $arg0.u3.value
288
+ p $arg0.u3.value
289
+ end
290
+
291
+
292
+ define nd_resq
293
+ print "u2.node"
294
+ what $arg0.u2.node
295
+ p $arg0.u2.node
296
+ end
297
+
298
+ define nd_ensr
299
+ print "u3.node"
300
+ what $arg0.u3.node
301
+ p $arg0.u3.node
302
+ end
303
+
304
+
305
+ define nd_1st
306
+ print "u1.node"
307
+ what $arg0.u1.node
308
+ p $arg0.u1.node
309
+ end
310
+
311
+ define nd_2nd
312
+ print "u2.node"
313
+ what $arg0.u2.node
314
+ p $arg0.u2.node
315
+ end
316
+
317
+
318
+ define nd_stts
319
+ print "u1.node"
320
+ what $arg0.u1.node
321
+ p $arg0.u1.node
322
+ end
323
+
324
+
325
+ define nd_entry
326
+ print "u3.entry"
327
+ what $arg0.u3.entry
328
+ p $arg0.u3.entry
329
+ end
330
+
331
+ define nd_vid
332
+ print "u1.id"
333
+ what $arg0.u1.id
334
+ p $arg0.u1.id
335
+ end
336
+
337
+ define nd_cflag
338
+ print "u2.id"
339
+ what $arg0.u2.id
340
+ p $arg0.u2.id
341
+ end
342
+
343
+ define nd_cval
344
+ print "u3.value"
345
+ what $arg0.u3.value
346
+ p $arg0.u3.value
347
+ end
348
+
349
+
350
+ define nd_cnt
351
+ print "u3.cnt"
352
+ what $arg0.u3.cnt
353
+ p $arg0.u3.cnt
354
+ end
355
+
356
+ define nd_tbl
357
+ print "u1.tbl"
358
+ what $arg0.u1.tbl
359
+ p $arg0.u1.tbl
360
+ end
361
+
362
+
363
+ define nd_var
364
+ print "u1.node"
365
+ what $arg0.u1.node
366
+ p $arg0.u1.node
367
+ end
368
+
369
+ define nd_ibdy
370
+ print "u2.node"
371
+ what $arg0.u2.node
372
+ p $arg0.u2.node
373
+ end
374
+
375
+ define nd_iter
376
+ print "u3.node"
377
+ what $arg0.u3.node
378
+ p $arg0.u3.node
379
+ end
380
+
381
+
382
+ define nd_value
383
+ print "u2.node"
384
+ what $arg0.u2.node
385
+ p $arg0.u2.node
386
+ end
387
+
388
+ define nd_aid
389
+ print "u3.id"
390
+ what $arg0.u3.id
391
+ p $arg0.u3.id
392
+ end
393
+
394
+
395
+ define nd_lit
396
+ print "u1.value"
397
+ what $arg0.u1.value
398
+ p $arg0.u1.value
399
+ end
400
+
401
+
402
+ define nd_frml
403
+ print "u1.node"
404
+ what $arg0.u1.node
405
+ p $arg0.u1.node
406
+ end
407
+
408
+ define nd_rest
409
+ print "u2.argc"
410
+ what $arg0.u2.argc
411
+ p $arg0.u2.argc
412
+ end
413
+
414
+ define nd_opt
415
+ print "u1.node"
416
+ what $arg0.u1.node
417
+ p $arg0.u1.node
418
+ end
419
+
420
+
421
+ define nd_recv
422
+ print "u1.node"
423
+ what $arg0.u1.node
424
+ p $arg0.u1.node
425
+ end
426
+
427
+ define nd_mid
428
+ print "u2.id"
429
+ what $arg0.u2.id
430
+ p $arg0.u2.id
431
+ end
432
+
433
+ define nd_args
434
+ print "u3.node"
435
+ what $arg0.u3.node
436
+ p $arg0.u3.node
437
+ end
438
+
439
+
440
+ define nd_noex
441
+ print "u1.id"
442
+ what $arg0.u1.id
443
+ p $arg0.u1.id
444
+ end
445
+
446
+ define nd_defn
447
+ print "u3.node"
448
+ what $arg0.u3.node
449
+ p $arg0.u3.node
450
+ end
451
+
452
+
453
+ define nd_old
454
+ print "u1.id"
455
+ what $arg0.u1.id
456
+ p $arg0.u1.id
457
+ end
458
+
459
+ define nd_new
460
+ print "u2.id"
461
+ what $arg0.u2.id
462
+ p $arg0.u2.id
463
+ end
464
+
465
+
466
+ define nd_cfnc
467
+ print "u1.cfunc"
468
+ what $arg0.u1.cfunc
469
+ p $arg0.u1.cfunc
470
+ end
471
+
472
+ define nd_argc
473
+ print "u2.argc"
474
+ what $arg0.u2.argc
475
+ p $arg0.u2.argc
476
+ end
477
+
478
+
479
+ define nd_cname
480
+ print "u1.id"
481
+ what $arg0.u1.id
482
+ p $arg0.u1.id
483
+ end
484
+
485
+ define nd_super
486
+ print "u3.node"
487
+ what $arg0.u3.node
488
+ p $arg0.u3.node
489
+ end
490
+
491
+
492
+ define nd_modl
493
+ print "u1.id"
494
+ what $arg0.u1.id
495
+ p $arg0.u1.id
496
+ end
497
+
498
+ define nd_clss
499
+ print "u1.value"
500
+ what $arg0.u1.value
501
+ p $arg0.u1.value
502
+ end
503
+
504
+
505
+ define nd_beg
506
+ print "u1.node"
507
+ what $arg0.u1.node
508
+ p $arg0.u1.node
509
+ end
510
+
511
+ define nd_end
512
+ print "u2.node"
513
+ what $arg0.u2.node
514
+ p $arg0.u2.node
515
+ end
516
+
517
+ define nd_state
518
+ print "u3.state"
519
+ what $arg0.u3.state
520
+ p $arg0.u3.state
521
+ end
522
+
523
+ define nd_rval
524
+ print "u2.value"
525
+ what $arg0.u2.value
526
+ p $arg0.u2.value
527
+ end
528
+
529
+
530
+ define nd_nth
531
+ print "u2.argc"
532
+ what $arg0.u2.argc
533
+ p $arg0.u2.argc
534
+ end
535
+
536
+
537
+ define nd_tag
538
+ print "u1.id"
539
+ what $arg0.u1.id
540
+ p $arg0.u1.id
541
+ end
542
+
543
+ define nd_tval
544
+ print "u2.value"
545
+ what $arg0.u2.value
546
+ p $arg0.u2.value
547
+ end
548
+
549
+ define rb_p
550
+ call rb_p($arg0)
551
+ end
552
+
553
+ define rb_id2name
554
+ call rb_id2name($arg0)
555
+ end
556
+
557
+ define rb_classname
558
+ call classname($arg0)
559
+ rb_p $
560
+ p *(struct RClass*)$arg0
561
+ end
562
+
563
+ define rb_backtrace
564
+ call rb_backtrace()
565
+ end
566
+
567
+ echo **** Loaded Ruby Macros Successfully ****\n