1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ci-skip][Feature #18910][lldb] Port rclass_ext to new LLDB Framework

This commit is contained in:
Matt Valentine-House 2022-07-13 13:19:41 +01:00 committed by Peter Zhu
parent 281bcc8e64
commit a4ef2f1672
Notes: git 2022-08-19 02:26:12 +09:00
2 changed files with 14 additions and 19 deletions

View file

@ -0,0 +1,14 @@
from rb_base_command import RbBaseCommand
class RclassExtCommand(RbBaseCommand):
program = "rclass_ext"
help_string = "retrieves and prints the rb_classext_struct for the VALUE pointer passed in"
def call(self, debugger, command, exe_ctx, result):
uintptr_t = self.target.FindFirstType("uintptr_t")
rclass_t = self.target.FindFirstType("struct RClass")
rclass_ext_t = self.target.FindFirstType("rb_classext_t")
rclass_addr = self.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)

View file

@ -711,23 +711,6 @@ def rb_id2str(debugger, command, result, internal_dict):
pos = (num % ID_ENTRY_UNIT) * ID_ENTRY_SIZE pos = (num % ID_ENTRY_UNIT) * ID_ENTRY_SIZE
id_str = rb_ary_entry(target, ary, pos, result) id_str = rb_ary_entry(target, ary, pos, result)
lldb_inspect(debugger, target, result, id_str) 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)
# END FUNCTION STYLE DECLS # END FUNCTION STYLE DECLS
@ -758,7 +741,5 @@ 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 dump_page")
debugger.HandleCommand("command script add -f lldb_cruby.dump_page_rvalue dump_page_rvalue") 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_id2str rb_id2str")
debugger.HandleCommand("command script add -f lldb_cruby.rb_rclass_ext rclass_ext")
lldb_init(debugger) lldb_init(debugger)
print("lldb scripts for ruby has been installed.") print("lldb scripts for ruby has been installed.")