Fix regression with `lldb` after changes in Value.__len__ (#3018)

pull/3016/head^2
patryk4815 7 months ago committed by GitHub
parent b638ec56da
commit aa524de27a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -100,10 +100,10 @@ def npcplist() -> int:
# index 0 should always exist
if zone.type.has_field("per_cpu_pageset"):
lists = zone["per_cpu_pageset"]["lists"]
return len(lists)
return lists.type.array_len
if zone.type.has_field("pageset"):
lists = zone["pageset"]["pcp"]["lists"]
return len(lists)
return lists.type.array_len
return 0

@ -113,7 +113,7 @@ parser.add_argument(
def static_str_arr(name: str) -> List[str]:
arr = pwndbg.aglib.symbol.lookup_symbol(name).dereference()
return [arr[i].string() for i in range(len(arr))]
return [arr[i].string() for i in range(arr.type.array_len)]
def check_find(counter: int, physmap_addr: int, pba: ParsedBuddyArgs, cbp: CurrentBuddyParams):
@ -258,7 +258,7 @@ def print_pcp_set(pba: ParsedBuddyArgs, cbp: CurrentBuddyParams):
def print_free_area(pba: ParsedBuddyArgs, cbp: CurrentBuddyParams):
free_area = pba.zone["free_area"]
cbp.sections[1] = ("free_area", None)
for order in range(len(free_area)):
for order in range(free_area.type.array_len):
if pba.order is not None and pba.order != order:
continue
cbp.freelists = free_area[order]["free_list"]

@ -24,7 +24,7 @@ X86_MSRS = {
}
COMMON_MSRS = {"x86": X86_MSRS, "x86-64": X86_MSRS}
COMMON_MSRS = {"i386": X86_MSRS, "x86-64": X86_MSRS}
def parse_msr(msr: str, arch: str) -> Optional[int]:
@ -82,7 +82,7 @@ def x86_msr_write(msr: int, write_value: int) -> None:
def msr_read(msr: int) -> None:
arch = pwndbg.aglib.arch.name
if arch == "x86" or arch == "x86-64":
if arch == "i386" or arch == "x86-64":
x86_msr_read(msr)
else:
print(f"{arch} not supported")
@ -91,7 +91,7 @@ def msr_read(msr: int) -> None:
def msr_write(msr: int, write_value: int) -> None:
arch = pwndbg.aglib.arch.name
if arch == "x86" or arch == "x86-64":
if arch == "i386" or arch == "x86-64":
x86_msr_write(msr, write_value)
else:
print(f"{arch} not supported")

@ -674,6 +674,15 @@ class Type:
"""
raise NotImplementedError()
@property
def array_len(self) -> int:
"""
Get array length of this type.
"""
if self.code == pwndbg.dbg_mod.TypeCode.ARRAY:
return self.sizeof // self.target().sizeof
return 0
@property
def sizeof(self) -> int:
"""
@ -955,12 +964,6 @@ class Value:
"""
raise NotImplementedError()
def __len__(self) -> int:
"""
Return len(self).
"""
raise NotImplementedError()
class CommandHandle:
"""

@ -1271,15 +1271,6 @@ class GDBValue(pwndbg.dbg_mod.Value):
except gdb.error as e:
raise pwndbg.dbg_mod.Error(e)
@override
def __len__(self):
try:
if self.type.code == pwndbg.dbg_mod.TypeCode.ARRAY:
return self.type.sizeof // self.type.target().sizeof
return self.type.sizeof
except gdb.error as e:
raise pwndbg.dbg_mod.Error(e)
def _gdb_event_class_from_event_type(ty: pwndbg.dbg_mod.EventType) -> Any:
"""

@ -75,7 +75,7 @@ def test_command_slab_contains():
@pytest.mark.skipif(
pwndbg.aglib.arch.name not in ["x86", "x86-64"],
pwndbg.aglib.arch.name not in ["i386", "x86-64"],
reason="function page_offset is only implemented for x86",
)
def test_x64_extra_registers_under_kernel_mode():
@ -105,7 +105,7 @@ def get_slab_object_address():
@pytest.mark.skipif(
pwndbg.aglib.arch.name not in ["x86", "x86-64"],
pwndbg.aglib.arch.name not in ["i386", "x86-64"],
reason="Unsupported architecture: msr tests only work on x86 and x86-64",
)
def test_command_msr_read():
@ -115,7 +115,7 @@ def test_command_msr_read():
@pytest.mark.skipif(
pwndbg.aglib.arch.name not in ["x86", "x86-64"],
pwndbg.aglib.arch.name not in ["i386", "x86-64"],
reason="Unsupported architecture: msr tests only work on x86 and x86-64",
)
def test_command_msr_write():
@ -130,7 +130,7 @@ def test_command_msr_write():
@pytest.mark.skipif(not pwndbg.aglib.kernel.has_debug_syms(), reason="test requires debug symbols")
@pytest.mark.skipif(
pwndbg.aglib.arch.name not in ["x86", "x86-64"],
pwndbg.aglib.arch.name not in ["i386", "x86-64"],
reason="function page_offset is only implemented for x86",
)
def test_command_buddydump():

Loading…
Cancel
Save