Skip to content

Instantly share code, notes, and snippets.

@jvns
Last active February 27, 2018 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvns/365502ee609ea51372530c52ade080ed to your computer and use it in GitHub Desktop.
Save jvns/365502ee609ea51372530c52ade080ed to your computer and use it in GitHub Desktop.
% self  % total  name
 68.90    68.90  sleeping - ci/ruby-programs/day.rb
 10.33    10.33  black_panther - ci/ruby-programs/day.rb
  6.99     6.99  learn - ci/ruby-programs/day.rb
  6.89     6.89  eat - ci/ruby-programs/day.rb
  6.89     6.89  clean - ci/ruby-programs/day.rb
  0.00   100.00  block in <main> - ci/ruby-programs/day.rb
  0.00   100.00  <main> - ci/ruby-programs/day.rb
  0.00   100.00  <c function> - unknown
  0.00    10.33  movies - ci/ruby-programs/day.rb

(gdb) p *((struct RString *) (ruby_current_thread->cfp)->iseq->body->location->path)
$23 = {basic = {flags = 542124037, klass = 11059400}, as = {heap = {len = 30, 
       ptr = 0xb6c650 "./my-program.rb", aux = {......
(gdb) p *((struct RString *) (ruby_current_thread->cfp)->iseq->body->location->label)
$24 = {basic = {flags = 546359301, klass = 11059400}, as = {heap = {len = 6381921, 
      ptr = 0x0, aux = {capa = 0, shared = 0}}, ary = "banana", '\000' <repeats 20 times>}}
graduate - recurse_center.rb line 2
keep_learning - recurse_center.rb line 6
start_learning - recurse_center.rb line 10
block in <main> - recurse_center.rb line 14
<main> - recurse_center.rb line 13
$ sudo rbspy snapshot --pid (pgrep -f recurse)
<main> - /home/bork/work/rbspy/ci/ruby-programs/recurse_center.rb line 13
block in <main> - /home/bork/work/rbspy/ci/ruby-programs/recurse_center.rb line 14
start_learning - /home/bork/work/rbspy/ci/ruby-programs/recurse_center.rb line 10
keep_learning - /home/bork/work/rbspy/ci/ruby-programs/recurse_center.rb line 6
graduate - /home/bork/work/rbspy/ci/ruby-programs/recurse_center.rb line 2
(gdb) p ruby_current_thread->cfp
$38 = (rb_control_frame_t *) 0x7f095e3cae10
(gdb) p ruby_current_thread
$39 = (rb_thread_t *) 0xa2d5d0
(gdb) x/20x ruby_current_thread
0xa2d5d0:	0x00a2d048	0x00000000	0x00a2d048	0x00000000
0xa2d5e0:	0x00a621b0	0x00000000	0x00a2cf20	0x00000000
0xa2d5f0:	0x5e2cb010	0x00007f09	0x00020000	0x00000000
0xa2d600:	0x5e3cae10	0x00007f09	0x00000000	0x00000000
0xa2d610:	0x00000008	0x00000000	0x00000000	0xffffffff
struct rb_thread_struct {
    struct list_node vmlt_node;
    VALUE self;
    rb_vm_t *vm;

    /* execution information */
    VALUE *stack;               /* must free, must mark */
    size_t stack_size;          /* size in word (byte size / sizeof(VALUE)) */
    rb_control_frame_t *cfp;
    int safe_level;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment