diff options
author | Matt Valentine-House <matt@eightbitraptor.com> | 2022-07-13 13:18:45 +0100 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2022-08-18 13:25:32 -0400 |
commit | 281bcc8e64accac2d3ab465abde4962de725857d (patch) | |
tree | 7667246669e220943fae7a51d59c6d160a095daa /misc | |
parent | f1ccfa0c2c200c9443fbfc3f1ac3acbdd3e35559 (diff) |
[ci-skip][Feature #18910][lldb] Port heap_page command to new LLDB framework
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6129
Diffstat (limited to 'misc')
-rw-r--r-- | misc/commands/heap_page_command.py | 26 | ||||
-rwxr-xr-x | misc/lldb_cruby.py | 14 |
2 files changed, 26 insertions, 14 deletions
diff --git a/misc/commands/heap_page_command.py b/misc/commands/heap_page_command.py new file mode 100644 index 0000000000..ee502a40b8 --- /dev/null +++ b/misc/commands/heap_page_command.py @@ -0,0 +1,26 @@ +import lldb + +from constants import * +from rb_base_command import RbBaseCommand + +class HeapPageCommand(RbBaseCommand): + program = "heap_page" + help_string = "prints out 'struct heap_page' for a VALUE pointer in the page" + + def call(self, debugger, command, exe_ctx, result): + self.t_heap_page_body = self.target.FindFirstType("struct heap_page_body") + self.t_heap_page_ptr = self.target.FindFirstType("struct heap_page").GetPointerType() + + page = self._get_page(self.frame.EvaluateExpression(command)) + page.Cast(self.t_heap_page_ptr) + + self._append_command_output(debugger, "p (struct heap_page *) %0#x" % page.GetValueAsUnsigned(), result) + self._append_command_output(debugger, "p *(struct heap_page *) %0#x" % page.GetValueAsUnsigned(), result) + + def _get_page(self, val): + addr = val.GetValueAsUnsigned() + page_addr = addr & ~(HEAP_PAGE_ALIGN_MASK) + address = lldb.SBAddress(page_addr, self.target) + body = self.target.CreateValueFromAddress("page", address, self.t_heap_page_body) + + return body.GetValueForExpressionPath("->header.page") diff --git a/misc/lldb_cruby.py b/misc/lldb_cruby.py index de8628754c..5106f78881 100755 --- a/misc/lldb_cruby.py +++ b/misc/lldb_cruby.py @@ -469,19 +469,6 @@ def check_bits(page, bitmap_name, bitmap_index, bitmap_bit, v): else: return ' ' -def heap_page(debugger, command, ctx, result, internal_dict): - target = debugger.GetSelectedTarget() - process = target.GetProcess() - thread = process.GetSelectedThread() - frame = thread.GetSelectedFrame() - - val = frame.EvaluateExpression(command) - page = get_page(lldb, target, val) - page_type = target.FindFirstType("struct heap_page").GetPointerType() - page.Cast(page_type) - append_command_output(debugger, "p (struct heap_page *) %0#x" % page.GetValueAsUnsigned(), result) - append_command_output(debugger, "p *(struct heap_page *) %0#x" % page.GetValueAsUnsigned(), result) - def heap_page_body(debugger, command, ctx, result, internal_dict): target = debugger.GetSelectedTarget() process = target.GetProcess() @@ -766,7 +753,6 @@ def __lldb_init_module(debugger, internal_dict): debugger.HandleCommand("command script add -f lldb_cruby.count_objects rb_count_objects") debugger.HandleCommand("command script add -f lldb_cruby.stack_dump_raw SDR") debugger.HandleCommand("command script add -f lldb_cruby.dump_node dump_node") - debugger.HandleCommand("command script add -f lldb_cruby.heap_page heap_page") debugger.HandleCommand("command script add -f lldb_cruby.heap_page_body heap_page_body") debugger.HandleCommand("command script add -f lldb_cruby.rb_backtrace rbbt") debugger.HandleCommand("command script add -f lldb_cruby.dump_page dump_page") |