[ci-skip][Feature #18910][lldb] Port heap_page command to new LLDB framework

This commit is contained in:
Matt Valentine-House 2022-07-13 13:18:45 +01:00 коммит произвёл Peter Zhu
Родитель f1ccfa0c2c
Коммит 281bcc8e64
2 изменённых файлов: 26 добавлений и 14 удалений

Просмотреть файл

@ -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")

Просмотреть файл

@ -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")