Skip to content

Resolve C function names when sampling#282

Merged
jvns merged 27 commits intorbspy:masterfrom
acj:resolve-c-function-names
Feb 19, 2021
Merged

Resolve C function names when sampling#282
jvns merged 27 commits intorbspy:masterfrom
acj:resolve-c-function-names

Conversation

@acj
Copy link
Copy Markdown
Member

@acj acj commented Feb 9, 2021

As noted in #110, rbspy currently lumps all C functions into a single bucket. It would be very useful to separate them so that we can understand which C functions are consuming the most time.

This PR is mostly a port of the print_id function from ruby's .gdbinit script, which takes a ruby method ID and returns the corresponding name as a string. The memory-walking logic is complex but has been very reliable in my testing so far.

I wasn't able to locate the global symbol table for 2.6 or older, so support is currently limited to 2.7.x (and newer, hopefully). It may be possible to expand this with more investigation -- I probably missed something. I haven't tried rubies newer than 2.7.2 yet.

Here's a sample from tracing a simple puma server when it's under load:

Summary of profiling data so far:
% self  % total  name
 25.45    25.45  <c function> - sleep
 13.64    13.64  <c function> - expand_path
 11.82    49.09  <c function> - unknown
  3.64    20.91  block in <class:Base> - /Users/acj/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/sinatra-2.1.0/lib/sinatra/base.rb
  3.64     4.55  <c function> - select
  3.64     3.64  <c function> - syswrite
  2.73     2.73  <c function> - write
  2.73     2.73  <c function> - peeraddr
  1.82    74.55  block in spawn_thread - /Users/acj/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/puma-5.2.1/lib/puma/thread_pool.rb
  1.82    43.64  call - /Users/acj/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/sinatra-2.1.0/lib/sinatra/base.rb
  1.82    41.82  call - /Users/acj/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/logger.rb
  1.82    30.91  call! - /Users/acj/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/sinatra-2.1.0/lib/sinatra/base.rb
  1.82     2.73  append - /Users/acj/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/puma-5.2.1/lib/puma/io_buffer.rb
  1.82     2.73  <c function> - each
  1.82     1.82  <c function> - exist?
  1.82     1.82  <c function> - close
  0.91    48.18  block in handle_request - /Users/acj/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/puma-5.2.1/lib/puma/request.rb
  0.91    46.36  with_force_shutdown - /Users/acj/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/puma-5.2.1/lib/puma/thread_pool.rb
  0.91    43.64  call - /Users/acj/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/head.rb
  0.91    37.27  call - /Users/acj/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/rack-protection-2.1.0/lib/rack/protection/frame_options.rb

and when running infinite.rb:

Summary of profiling data so far:
% self  % total  name
100.00   100.00  <c function> - sleep
  0.00   100.00  ccc - ci/ruby-programs/infinite.rb
  0.00   100.00  block in <main> - ci/ruby-programs/infinite.rb
  0.00   100.00  bbb - ci/ruby-programs/infinite.rb
  0.00   100.00  aaa - ci/ruby-programs/infinite.rb
  0.00   100.00  <main> - ci/ruby-programs/infinite.rb
  0.00   100.00  <c function> - loop

I noticed that gdb is also able to print the raw C symbol name and its location in the source file. I don't know whether it's possible for rbspy to get that info, but it would be nice to have. Maybe the remoteprocess crate can do the symbol resolution part since we have the memory address.

TODO

  • Clean up confusing variable names in memory-walking code
  • Clean up duplicated logic
  • Add support for older ruby versions where possible
  • Try newer ruby versions (e.g. 3.x) -- blocked by Add support for ruby 3.0.0 #285
  • Add tests
  • Add Windows support, if possible
  • Address CI failures on cross builds

Fixes #110

@ilyazub
Copy link
Copy Markdown

ilyazub commented Feb 9, 2021

@acj Thanks for trying to solve this problem 👍

It still prints long sleep, unknown for Puma and for Nokogiri on this branch.

Summary of profiling data so far:
% self  % total  name
100.00   100.00  <c function> - unknown # should be sleep
  0.00   100.00  pow - ./tmp/infinite.rb
  0.00   100.00  main - ./tmp/infinite.rb
  0.00   100.00  b - ./tmp/infinite.rb
  0.00   100.00  a - ./tmp/infinite.rb
  0.00   100.00  <main> - ./tmp/infinite.rb
Summary of profiling data so far:
% self  % total  name
100.00   100.00  <c function> - unknown
  0.00    53.44  block in start! - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/puma-4.3.6/lib/puma/thread_pool.rb
  0.00    26.32  run_internal - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/puma-4.3.6/lib/puma/reactor.rb
  0.00    26.32  block in run_in_thread - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/puma-4.3.6/lib/puma/reactor.rb
  0.00    13.56  run - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/puma-4.3.6/lib/puma/launcher.rb
  0.00    13.56  run - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/puma-4.3.6/lib/puma/cluster.rb
  0.00    13.56  run - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/puma-4.3.6/lib/puma/cli.rb
  0.00    13.56  <top (required)> - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/puma-4.3.6/bin/puma
  0.00    13.56  <main> - /home/ilyazub/.rbenv/versions/2.7.2/bin/puma
  0.00     6.48  block in start - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/puma-4.3.6/lib/puma/plugin/tmp_restart.rb
  0.00     6.48  block (2 levels) in fire_background - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/puma-4.3.6/lib/puma/plugin.rb
  0.00     0.20  block in worker - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/puma-4.3.6/lib/puma/cluster.rb
Summary of profiling data so far:
% self  % total  name
 96.79   100.00  <c function> - unknown
  0.80     0.80  [] - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/css/parser_extras.rb
  0.40    94.78  block (3 levels) in <main> - ./tmp/slow_search_parse.rb
  0.40     5.62  css_rules_to_xpath - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/xml/searchable.rb
  0.40     2.01  xpath_for - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/css.rb
  0.40     1.61  xpath_for - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/css/parser_extras.rb
  0.40     0.40  libxml2? - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/version/info.rb
  0.40     0.40  <top (required)> - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/xslt/stylesheet.rb
  0.00   100.00  <main> - ./tmp/slow_search_parse.rb
  0.00    97.99  block in <main> - ./tmp/slow_search_parse.rb
  0.00    96.79  css_internal - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/xml/searchable.rb
  0.00    96.79  css - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/xml/searchable.rb
  0.00    94.78  each - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/xml/node_set.rb
  0.00    94.78  block in each - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/xml/node_set.rb
  0.00    94.78  block (2 levels) in <main> - ./tmp/slow_search_parse.rb
  0.00    94.38  at_css - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/xml/searchable.rb
  0.00    91.57  xpath_internal - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/xml/searchable.rb
  0.00    91.57  xpath_impl - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/xml/searchable.rb
  0.00     6.02  xpath_query_from_css_rule - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/xml/searchable.rb
  0.00     5.22  block in css_rules_to_xpath - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.0-x86_64-linux/lib/nokogiri/xml/searchable.rb

I use ruby 2.7.2 installed via rbenv with default CFLAGS.

$ ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]

$ ruby -rrbconfig -e 'puts RbConfig::CONFIG["CFLAGS"]'
-O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable  -fPIC

perf record and flamegraph crate are able to see the C-part of this performance profile.

image

cargo test passes.

test result: ok. 19 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

How to find a cause of the problem?

@acj
Copy link
Copy Markdown
Member Author

acj commented Feb 10, 2021

@ilyazub Thanks for trying it out. I can repro the behavior you're seeing with rbenv (ruby 2.7.2, rbenv with default flags, Linux 5.4.0 x64_64). The ruby binary needs to have debug symbols for this to work, and the rbenv build doesn't seem to include them by default.

I'm able to resolve C symbols on Linux when I compile ruby from source with ./configure optflags=-Og:

$ ./configure optflags=-Og && make && make install
$ /usr/local/bin/ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ /usr/local/bin/ruby ci/ruby-programs/infinite.rb &
[1] 172536
$ sudo cargo run -- record --pid $(pgrep ruby)
Time since start: 29s. Press Ctrl+C to stop.
Summary of profiling data so far:
% self  % total  name
100.00   100.00  <c function> - sleep
  0.00   100.00  ccc - ci/ruby-programs/infinite.rb
  0.00   100.00  block in <main> - ci/ruby-programs/infinite.rb
  0.00   100.00  bbb - ci/ruby-programs/infinite.rb
  0.00   100.00  aaa - ci/ruby-programs/infinite.rb
  0.00   100.00  <main> - ci/ruby-programs/infinite.rb
  0.00   100.00  <c function> - loop

But it doesn't work with rbenv even if I pass the same full set of flags using RUBY_CFLAGS. I noticed that rbenv (or maybe ruby-build?) adds -fPIC to the flags even if I don't specify it, which could be a factor.

# Ruby built from source (shown above)
$ /usr/local/bin/ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ /usr/local/bin/ruby -rrbconfig -e 'puts RbConfig::CONFIG["CFLAGS"]'
-Og -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable

# Build 2.7.2 using rbenv, passing the same set of flags shown above
$ RUBY_CFLAGS="-Og -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable" rbenv install 2.7.2

# We picked up -fPIC somehow, but otherwise the same flags
$ ~/.rbenv/versions/2.7.2/bin/ruby -rrbconfig -e 'puts RbConfig::CONFIG["CFLAGS"]'
 -Og -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC

# But no ruby_global_symbols (and not many other symbols either), so we can't resolve C symbols
$ nm ~/.rbenv/versions/2.7.2/bin/ruby | grep global_sym
$ 

It would be neat if we could find a heuristic to locate the global symbols address like rbspy does for ruby_current_thread.

If you still have trouble after compiling with debug symbols (if you can), please try running rbspy with RUST_LOG=debug which will be noisy but should give you useful diagnostic info. I tried to return clear and useful errors in the memory-walking code so that we can understand where it's failing.

@jvns
Copy link
Copy Markdown
Collaborator

jvns commented Feb 10, 2021

@acj This is amazing! I've been wanting to do this for years and never had any idea how to start, it's so exciting to see that this is possible!! I spent a bunch of time this morning trying to understand how this works and had a blast.

I'm not sure that the ruby_global_symbols symbol actually gets stripped -- on my machine even though my ruby binary is stripped, when I run nm ~/.rbenv/versions/2.7.2/lib/libruby.so.2.7 I see the ruby_global_symbols symbol, it's just in the libruby shared object file and not in the ruby binary itself.

I'm confused about why ruby_global_symbols would be in the ruby binary on Mac and not on Linux though -- on a Mac is there no libruby.so.2.7 file?

@jvns
Copy link
Copy Markdown
Collaborator

jvns commented Feb 10, 2021

Oops, ignore everything I said in that last comment -- the binary I thought was stripped wasn't, and I didn't remember that symbol_addr checks both the ruby and the libruby symbol tables for the symbol. I'm re-learning a lot of things about how rbspy works today :)

@jvns
Copy link
Copy Markdown
Collaborator

jvns commented Feb 10, 2021

Is this ruby_global_symbols data structure a hash table? I spent some time trying to read the Ruby source code to understand what it is today but couldn't quite work it out.

@acj
Copy link
Copy Markdown
Member Author

acj commented Feb 10, 2021

had a blast

@jvns I'm glad to hear that! This has been fun to work on. Lots of little puzzles to sort out.

when I run nm ~/.rbenv/versions/2.7.2/lib/libruby.so.2.7 I see the ruby_global_symbols symbol, it's just in the libruby shared object file and not in the ruby binary itself.

Ahhhh, okay. I see the same thing in my rbenv setup on Linux, and on macOS I see the _ruby_global_symbols entry in ~/.asdf/installs/ruby/2.7.2/lib/libruby.2.7.dylib. Thanks for calling this out.

In that case, I'm not sure why we can't find the global symbols in rbenv builds. Maybe the libruby part of the lookup is failing? I'll poke at this a bit more.

Is this ruby_global_symbols data structure a hash table?

I think that's the gist of it, yeah. Its type is rb_symbols_t, which seems to contain a hash table. But for this code path we only need a couple of its fields and don't really interact with the hash table itself (afaict).

@acj
Copy link
Copy Markdown
Member Author

acj commented Feb 11, 2021

Okay, I think I found the problem. My implementation of get_ruby_global_symbols_address on Linux wasn't looking at libruby, unlike the macOS implementation. I'm able to resolve C symbols using an rbenv-installed ruby with the default CFLAGS now. Whew.

@ilyazub, could you please try again?

@jvns
Copy link
Copy Markdown
Collaborator

jvns commented Feb 11, 2021

I tested it on Linux and it works for me now! 🎉

Time since start: 19s. Press Ctrl+C to stop.
Summary of profiling data so far:
% self  % total  name
 99.49    99.49  <c function> - sleep
  0.39     0.39  <c function> - require
  0.13     0.13  <c function> - read
  0.00    99.49  ccc - /home/bork/work/rbspy/ci/ruby-programs/infinite.rb

@ilyazub
Copy link
Copy Markdown

ilyazub commented Feb 12, 2021

@acj It works! Thank you! 🤝

$ cargo run -- record -- ruby ./ci/ruby-programs/infinite.rb

Time since start: 9s. Press Ctrl+C to stop.
Summary of profiling data so far:
% self  % total  name
 98.97    98.97  <c function> - sleep
  1.03     1.03  <c function> - require
  0.00    98.97  ccc - ./ci/ruby-programs/infinite.rb
  0.00    98.97  block in <main> - ./ci/ruby-programs/infinite.rb
  0.00    98.97  bbb - ./ci/ruby-programs/infinite.rb
  0.00    98.97  aaa - ./ci/ruby-programs/infinite.rb
  0.00    98.97  <main> - ./ci/ruby-programs/infinite.rb
  0.00    98.97  <c function> - loop
  0.00     1.03  <top (required)> - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb
  0.00     1.03  <top (required)> - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/2.7.0/rubygems.rb
  0.00     1.03  <top (required)> - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/2.7.0/monitor.rb
  0.00     1.03  <c function> - unknown
$ cargo run -- record -- ruby ../work/tmp/slow_search_parse.rb ../work/tmp/big_shopping.html

Time since start: 3s. Press Ctrl+C to stop.
Summary of profiling data so far:
% self  % total  name
 63.16    63.16  <c function> - evaluate
 15.79    15.79  <c function> - file?
 10.53    10.53  <c function> - require
  5.26     5.26  <c function> - readline
  5.26     5.26  <c function> - read_memory
  0.00   100.00  <main> - ../work/tmp/slow_search_parse.rb
  0.00    63.16  xpath_internal - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.1-x86_64-linux/lib/nokogiri/xml/searchable.rb
  0.00    63.16  xpath_impl - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.1-x86_64-linux/lib/nokogiri/xml/searchable.rb
  0.00    63.16  css_internal - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.1-x86_64-linux/lib/nokogiri/xml/searchable.rb
  0.00    63.16  css - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.1-x86_64-linux/lib/nokogiri/xml/searchable.rb
  0.00    63.16  block in <main> - ../work/tmp/slow_search_parse.rb
  0.00    63.16  <c function> - times
  0.00    52.63  each - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.1-x86_64-linux/lib/nokogiri/xml/node_set.rb
  0.00    52.63  block in each - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.1-x86_64-linux/lib/nokogiri/xml/node_set.rb
  0.00    52.63  block (3 levels) in <main> - ../work/tmp/slow_search_parse.rb
  0.00    52.63  block (2 levels) in <main> - ../work/tmp/slow_search_parse.rb
  0.00    52.63  at_css - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.11.1-x86_64-linux/lib/nokogiri/xml/searchable.rb
  0.00    42.11  <c function> - upto
  0.00    31.58  require - /home/ilyazub/.rbenv/versions/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb
  0.00    31.58  <c function> - unknown

acj added 6 commits February 15, 2021 15:33
This works on Linux but fails on macOS because _global_symbols isn't available. The symbols _global_symbols.{0,1,2,3} are available but don't seem to work.
This also anticipates unit tests that will need to pass an arbitrary global symbols address.
@acj acj force-pushed the resolve-c-function-names branch from 590cbf3 to 7fe9ac9 Compare February 15, 2021 20:40
@jvns
Copy link
Copy Markdown
Collaborator

jvns commented Feb 17, 2021

the macos test failure here might be spurious, I've been seeing some failures on master too (at https://github.com/rbspy/rbspy/actions)

@acj
Copy link
Copy Markdown
Member Author

acj commented Feb 19, 2021

@jvns I think this is ready. It works on 2.7.x for all three platforms, and back to at least 2.5.x on Linux. Support for older rubies may be possible with more effort. (Help wanted/welcome if anyone is interested!) Ruby 3.x is an important target, so I'll focus on that next.

The failing macOS and Windows tests do seem to be spurious. I can repro them consistently on my laptop with asdf-installed ruby 2.7.2, but the tests pass consistently if I hack ruby_binary_path_str to point directly at the binary (~/.asdf/installs/ruby/2.7.2/bin/ruby). Not sure what to make of that. Maybe it's related to the several levels of fork/exec that happen when ruby is invoked using asdf or rbenv. CI behavior makes it seem like a race condition, though...

edit: I just remembered that FreeBSD support was added a while back. I'll give that a try tomorrow to make sure the build isn't broken.

@acj acj marked this pull request as ready for review February 19, 2021 01:42
@jvns
Copy link
Copy Markdown
Collaborator

jvns commented Feb 19, 2021

This looks awesome to me -- I'm happy to merge it whenever you say it's ready.

The only thing I noticed is that it looks like the new ruby bindings were generated on a Mac (there's a bunch of darwin in there) and previously they were generated on Linux. I don't know if that's a problem though because it needs to work on all platforms anyway and it's not clear that bindings generated on linux are "better" than bindings generated on a mac.

Also, I've been adding people as maintainers when they make significant contributions (which this DEFINITELY is!!), so I'd be happy to make you a maintainer if you'd like! There aren't any responsibilities associated with being a maintainer, it just means you can merge changes and make releases if you want. Let me know :)

@acj
Copy link
Copy Markdown
Member Author

acj commented Feb 19, 2021

Thanks! That sounds good to me. There are incremental improvements I'd like to make on C symbols support, and I'm happy to help out with code reviews and such.

The only thing I noticed is that it looks like the new ruby bindings were generated on a Mac

Ah, good point. I haven't had any trouble with the updated bindings, but if we run into trouble I can regenerate them on Linux.

CI looks happy, so I think we're good to merge. Thanks again for all your help with this.

@jvns jvns merged commit 4bce219 into rbspy:master Feb 19, 2021
@acj acj deleted the resolve-c-function-names branch February 19, 2021 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Say what particular C function is being sampled

3 participants