diff options
author | Eileen <[email protected]> | 2025-04-08 12:52:49 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2025-04-08 12:52:49 -0400 |
commit | 5aa05f179c028981950cb5f40112ce058c5a40cd (patch) | |
tree | 4966db1302f4f90acd9d631f884697f6b36a982a /misc/lldb_cruby.py | |
parent | b68fe530f1880ed314099b61a70e3c0b1ee7cf6d (diff) |
Fix lldb debug scripts (#13048)
In ruby/ruby#13008 `RVALUE` was removed without replacement. This means
the lldb scripts that relied on `RVALUE` stopped working.
I updated the ones that were using it just for the bytesize to use
`slot_size` and then round to the nearest power of 40. We can't use
`slot_size` directly because in debug mode it's `48` but `RVALUE` is
`40` bytes.
For the `as_type` method, I updated it to check the type. It's only used
for `bignum` and `array` so that's a simple change.
Lastly, for the `dump_page` method I replaced it with `struct free_slot`
since that's looking at the freelist.
`struct RVALUE` has been removed from all the scripts and I verified
that `rp` is fixed. I'm not confident the `dump_page` method is fixed,
the freelist looks off, but for now this gets us closer.
Notes
Notes:
Merged-By: eileencodes <[email protected]>
Diffstat (limited to 'misc/lldb_cruby.py')
-rwxr-xr-x | misc/lldb_cruby.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/misc/lldb_cruby.py b/misc/lldb_cruby.py index 0707bb42d3..c539b17564 100755 --- a/misc/lldb_cruby.py +++ b/misc/lldb_cruby.py @@ -14,6 +14,7 @@ import sys import shlex import platform import glob +import math from lldb_rb.constants import * @@ -270,7 +271,6 @@ def lldb_inspect(debugger, target, result, val): print('immediate(%x)' % num, file=result) else: tRBasic = target.FindFirstType("struct RBasic").GetPointerType() - tRValue = target.FindFirstType("struct RVALUE") val = val.Cast(tRBasic) flags = val.GetValueForExpressionPath("->flags").GetValueAsUnsigned() @@ -524,10 +524,11 @@ def rb_backtrace(debugger, command, result, internal_dict): bt.print_bt(val) def dump_bits(target, result, page, object_address, end = "\n"): - tRValue = target.FindFirstType("struct RVALUE") + slot_size = page.GetChildMemberWithName("heap").GetChildMemberWithName("slot_size").unsigned + byte_size = 40 ** math.floor(math.log(slot_size, 40)) tUintPtr = target.FindFirstType("uintptr_t") # bits_t - num_in_page = (object_address & HEAP_PAGE_ALIGN_MASK) // tRValue.GetByteSize(); + num_in_page = (object_address & HEAP_PAGE_ALIGN_MASK) // byte_size; bits_bitlength = tUintPtr.GetByteSize() * 8 bitmap_index = num_in_page // bits_bitlength bitmap_offset = num_in_page & (bits_bitlength - 1) @@ -550,7 +551,6 @@ class HeapPageIter: self.slot_size = page.GetChildMemberWithName('heap').GetChildMemberWithName('slot_size').unsigned self.counter = 0 self.tRBasic = target.FindFirstType("struct RBasic") - self.tRValue = target.FindFirstType("struct RVALUE") def is_valid(self): heap_page_header_size = self.target.FindFirstType("struct heap_page_header").GetByteSize() @@ -582,14 +582,13 @@ def dump_page_internal(page, target, process, thread, frame, result, debugger, h freelist = [] fl_start = page.GetChildMemberWithName('freelist').GetValueAsUnsigned() - tRVALUE = target.FindFirstType("struct RVALUE") + free_slot = target.FindFirstType("struct free_slot") while fl_start > 0: freelist.append(fl_start) obj_addr = lldb.SBAddress(fl_start, target) - obj = target.CreateValueFromAddress("object", obj_addr, tRVALUE) - fl_start = obj.GetChildMemberWithName("as").GetChildMemberWithName("free").GetChildMemberWithName("next").GetValueAsUnsigned() - + obj = target.CreateValueFromAddress("object", obj_addr, free_slot) + fl_start = obj.GetChildMemberWithName("next").GetValueAsUnsigned() page_iter = HeapPageIter(page, target) if page_iter.is_valid(): |