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] New directory structure

Push the newly refactored lldb files into a sub-directory so that we're
not cluttering up the misc directory
This commit is contained in:
Matt Valentine-House 2022-07-13 18:14:44 +01:00 committed by Peter Zhu
parent a4ef2f1672
commit b26aec9daa
Notes: git 2022-08-19 02:26:11 +09:00
6 changed files with 11 additions and 6 deletions

View file

@ -0,0 +1,26 @@
import lldb
from lldb_rb.constants import *
from lldb_rb.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")