ruby-changes:72174
From: Matt <ko1@a...>
Date: Thu, 16 Jun 2022 02:59:41 +0900 (JST)
Subject: [ruby-changes:72174] acee714ce0 (master): [ci skip] Print the rb_classext_t for a class, using an offset
https://git.ruby-lang.org/ruby.git/commit/?id=acee714ce0 From acee714ce0b6af0375be5d38293010a688b617e6 Mon Sep 17 00:00:00 2001 From: Matt Valentine-House <matt@e...> Date: Wed, 15 Jun 2022 14:06:36 +0100 Subject: [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 --- misc/lldb_cruby.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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): https://github.com/ruby/ruby/blob/trunk/misc/lldb_cruby.py#L716 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): https://github.com/ruby/ruby/blob/trunk/misc/lldb_cruby.py#L745 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.") -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/