Skip to content

Fix LLDB scripts by using the toplevel RBasic #13096

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

Merged
merged 2 commits into from
Apr 15, 2025

Conversation

etiennebarrie
Copy link
Contributor

@etiennebarrie etiennebarrie commented Apr 10, 2025

With @eightbitraptor we figured the issue I had in #13048 by using target.FindTypes instead and looking at the results.

target.FindFirstType("struct RBasic") was returning the yjit::cruby::autogened::RBasic type instead of struct RBasic and then somehow getting the flags always returned 0.

Explicitly asking for the toplevel namespace RBasic by prefixing with :: fixes that issue.

I also took the opportunity to fix the heap_page command by moving some parts of RbInspector into LLDBInterface and setting the result in the call method.

rbbt is still broken for me and dump_page just never returns or is very slow, but I still fixed the usage there for good measure.

Before

(lldb) rp str
bits: [     ]
T_NONE: No value
(lldb) old_rp str
bits: [     ]
T_NONE: (yjit::cruby::autogened::RBasic) *$1 = {
  flags = (__0 = 5259269)
  klass = (__0 = 4304792640)
}
(lldb) heap_page str
Traceback (most recent call last):
  File "/Users/etienne/src/github.com/ruby/ruby/misc/lldb_rb/rb_base_command.py", line 48, in __call__
    self.call(debugger, command, exe_ctx, result)
  File "/Users/etienne/src/github.com/ruby/ruby/misc/lldb_rb/commands/heap_page_command.py", line 17, in call
    self._append_expression(debugger, "(struct heap_page *) %0#x" % page.GetValueAsUnsigned(), result)
AttributeError: 'HeapPageCommand' object has no attribute '_append_expression'

After

(lldb) rp str
bits: [     ]
T_STRING: [UTF_8] [7BIT] (const char[6]) $1 = "string"
(lldb) old_rp str
bits: [     ]
T_STRING: [UTF_8] (const char[6]) $3 = "string"
(lldb) heap_page str
(struct heap_page *) $5 = 0x000000011e84b000
(struct heap_page) $6 = {
  slot_size = 40
  total_slots = 1638
# 

Copy link
Contributor

@eightbitraptor eightbitraptor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@@ -68,7 +68,7 @@ def vm_frame_magic(self, cfp):
return self.VM_FRAME_MAGIC_NAME.get(frame_type, "(none)")

def rb_iseq_path_str(self, iseq):
tRBasic = self.target.FindFirstType("struct RBasic").GetPointerType()
tRBasic = self.target.FindFirstType("::RBasic").GetPointerType()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had no idea you could reference constants like this! This is great.

This comment has been minimized.

Move _append_command_output and _append_expression to LLDBInterface, and
use it from HeapPageCommand after setting result.
`rp` and other commands were broken for me because they always showed
the object as a T_NONE.

The reason was that instead of returning the type `struct RBasic`,
FindFirstType("struct RBasic") was returning
`yjit::cruby::autogened::RBasic`.

Explicitly asking for the top-level RBasic by prefixing it with `::` is
enough to fix those commands.
@byroot byroot force-pushed the lldb-toplevel-rbasic branch from 67d9bf7 to e1f544c Compare April 15, 2025 02:51
@matzbot matzbot merged commit e1f544c into ruby:master Apr 15, 2025
69 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants