From f64bb9fc848814c3ad1f559fc3e1e0043a905b72 Mon Sep 17 00:00:00 2001 From: Matt Valentine-House Date: Tue, 27 Apr 2021 12:17:55 +0100 Subject: [PATCH] lldb: dump_page_rvalue - dump a heap page containing an RVALUE rather than having to do this in a two step process: 1. heap_page obj 2. dump_page $2 (or whatever lldb variable heap_page set) we can now just dump_page_rvalue obj --- misc/lldb_cruby.py | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/misc/lldb_cruby.py b/misc/lldb_cruby.py index 748d8aacf6..2b5359da03 100755 --- a/misc/lldb_cruby.py +++ b/misc/lldb_cruby.py @@ -552,19 +552,10 @@ class HeapPageIter: raise StopIteration -def dump_page(debugger, command, result, internal_dict): +def dump_page_internal(page, target, process, thread, frame, result, debugger): if not ('RUBY_Qfalse' in globals()): lldb_init(debugger) - target = debugger.GetSelectedTarget() - process = target.GetProcess() - thread = process.GetSelectedThread() - frame = thread.GetSelectedFrame() - - tHeapPageP = target.FindFirstType("struct heap_page").GetPointerType() - page = frame.EvaluateExpression(command) - page = page.Cast(tHeapPageP) - ruby_type_map = ruby_types(debugger) freelist = [] @@ -593,6 +584,34 @@ def dump_page(debugger, command, result, internal_dict): print(result_str, file=result) +def dump_page(debugger, command, result, internal_dict): + target = debugger.GetSelectedTarget() + process = target.GetProcess() + thread = process.GetSelectedThread() + frame = thread.GetSelectedFrame() + + tHeapPageP = target.FindFirstType("struct heap_page").GetPointerType() + page = frame.EvaluateExpression(command) + page = page.Cast(tHeapPageP) + + dump_page_internal(page, target, process, thread, frame, result, debugger) + + +def dump_page_rvalue(debugger, command, 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) + + dump_page_internal(page, target, process, thread, frame, result, debugger) + + + def rb_type(flags, ruby_types): flType = flags & RUBY_T_MASK return "%-10s" % (ruby_types.get(flType, ("%0#x" % flType))) @@ -623,6 +642,7 @@ def __lldb_init_module(debugger, internal_dict): 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") + debugger.HandleCommand("command script add -f lldb_cruby.dump_page_rvalue dump_page_rvalue") lldb_init(debugger) print("lldb scripts for ruby has been installed.")