diff options
author | Matt Valentine-House <matt@eightbitraptor.com> | 2022-06-15 14:06:36 +0100 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2022-06-15 10:59:29 -0700 |
commit | acee714ce0b6af0375be5d38293010a688b617e6 (patch) | |
tree | a48fa668440de2e572cc60c39228f2c6ce4b000f /misc | |
parent | a327ce8b07e8778b838a5b82939bea9409cfa9f5 (diff) |
[ci skip] Print the rb_classext_t for a class, using an offset
Now that classes are using VWA, the RCLASS_PTR uses an offset to get the
rb_classext_t object. Doing this all the time in lldb is boring. So
script lldb to do it for us
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6024
Diffstat (limited to 'misc')
-rwxr-xr-x | misc/lldb_cruby.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/misc/lldb_cruby.py b/misc/lldb_cruby.py index a783b1b559..46fb764104 100755 --- a/misc/lldb_cruby.py +++ b/misc/lldb_cruby.py @@ -716,6 +716,24 @@ def rb_id2str(debugger, command, result, internal_dict): id_str = rb_ary_entry(target, ary, pos, result) lldb_inspect(debugger, target, result, id_str) +def rb_rclass_ext(debugger, command, result, internal_dict): + if not ('RUBY_Qfalse' in globals()): + lldb_init(debugger) + + target = debugger.GetSelectedTarget() + process = target.GetProcess() + thread = process.GetSelectedThread() + frame = thread.GetSelectedFrame() + + uintptr_t = target.FindFirstType("uintptr_t") + rclass_t = target.FindFirstType("struct RClass") + rclass_ext_t = target.FindFirstType("rb_classext_t") + + rclass_addr = target.EvaluateExpression(command).Cast(uintptr_t) + rclass_ext_addr = (rclass_addr.GetValueAsUnsigned() + rclass_t.GetByteSize()) + debugger.HandleCommand("p *(rb_classext_t *)%0#x" % rclass_ext_addr) + + def __lldb_init_module(debugger, internal_dict): debugger.HandleCommand("command script add -f lldb_cruby.lldb_rp rp") debugger.HandleCommand("command script add -f lldb_cruby.count_objects rb_count_objects") @@ -727,6 +745,7 @@ def __lldb_init_module(debugger, internal_dict): debugger.HandleCommand("command script add -f lldb_cruby.dump_page dump_page") debugger.HandleCommand("command script add -f lldb_cruby.dump_page_rvalue dump_page_rvalue") debugger.HandleCommand("command script add -f lldb_cruby.rb_id2str rb_id2str") + debugger.HandleCommand("command script add -f lldb_cruby.rb_rclass_ext rclass_ext") lldb_init(debugger) print("lldb scripts for ruby has been installed.") |