-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Fix lldb debug scripts #13048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix lldb debug scripts #13048
Conversation
It's not really working for me. After a clean and rebuild: $ echo '"string".hash' > test.rb
$ make -C target/debug lldb
compiling ../../version.c
linking miniruby
lldb -o 'command script import -r ../../misc/lldb_cruby.py' miniruby -- ../../test.rb
(lldb) target create "miniruby"
Current executable set to '/Users/etienne/src/github.com/ruby/ruby/target/debug/miniruby' (arm64).
(lldb) settings set -- target.run-args "../../test.rb"
(lldb) command script import -r ../../misc/lldb_cruby.py
lldb scripts for ruby has been installed.
(lldb) b rb_str_hash_m Breakpoint 1: where = miniruby`rb_str_hash_m + 16 at string.c:4086:35, address = 0x0000000100304c60
(lldb) r
Process 86318 launched: '/Users/etienne/src/github.com/ruby/ruby/target/debug/miniruby' (arm64)
Process 86318 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100304c60 miniruby`rb_str_hash_m(str=4751833240) at string.c:4086:35
4083 static VALUE
4084 rb_str_hash_m(VALUE str)
4085 {
-> 4086 st_index_t hval = rb_str_hash(str);
4087 return ST2FIX(hval);
4088 }
4089
Target 0: (miniruby) stopped.
(lldb) rp str
bits: [ ]
T_NONE: No value
(lldb) ^D It's better than main which is crashing but not a whole lot. |
ok I had checked |
That's weird I just tested it and How is your Ruby configured? This is how I'm configuring
And my lldb output:
|
I used something like this: ../../configure --prefix=/Users/etienne/.ruby/debug --cache-file=../../config.cache --disable-shared --disable-install-doc --with-ext=openssl,psych,json,+ CFLAGS=-march=native --with-libyaml-dir=/opt/homebrew/opt/libyaml --with-openssl-dir=/opt/homebrew/opt/openssl@3 --with-gmp-dir=/opt/homebrew/opt/gmp --enable-debug-env 'optflags=-O0 -fno-omit-frame-pointer' I removed the CFLAGS and get the same results. The debugging configure flags come from: ruby/doc/contributing/building_ruby.md Line 257 in 36daa86
I tried with |
Can you go back to the commit before 0350290 and check that it works as expected? |
Also when I run lldb I'm using |
Arg sorry indeed I can't even get something to work in that case. Something must be wrong with my environment, I've used your configure options on a clean repo and I still get the same behavior. I tried on multiple computers (under macOS) too. I did just manage to make it work under lima using clang, though 👍 It does solve the issue in that case. cc @byroot |
In ruby#13008 `RVALUE` was removed without replacement. This means the lldb scripts that relied on `RVALUE` stopped working. I updated the ones that were using it just for the bytesize to use `slot_size` and then round to the nearest power of 40. We can't use `slot_size` directly because in debug mode it's `48` but `RVALUE` is `40` bytes. For the `as_type` method, I updated it to check the type. It's only used for `bignum` and `array` so that's a simple change. Lastly, for the `dump_page` method I replaced it with `struct free_slot` since that's looking at the freelist. `struct RVALUE` has been removed from all the scripts and I verified that `rp` is fixed. I'm not confident the `dump_page` method is fixed, the freelist looks off, but for now this gets us closer.
36daa86
to
b0d2192
Compare
✅ All Tests passed!✖️no tests failed ✔️61930 tests passed(3 flakes) |
In #13008
RVALUE
was removed without replacement. This means the lldb scripts that relied onRVALUE
stopped working.I updated the ones that were using it just for the bytesize to use
slot_size
and then round to the nearest power of 40. We can't useslot_size
directly because in debug mode it's48
butRVALUE
is40
bytes.For the
as_type
method, I updated it to check the type. It's only used forbignum
andarray
so that's a simple change.Lastly, for the
dump_page
method I replaced it withstruct free_slot
since that's looking at the freelist.struct RVALUE
has been removed from all the scripts and I verified thatrp
is fixed. I'm not confident thedump_page
method is fixed, the freelist looks off, but for now this gets us closer.