diff --git a/pwndbg/gdblib/vmmap.py b/pwndbg/gdblib/vmmap.py index b9eea02fb..ee5cfae92 100644 --- a/pwndbg/gdblib/vmmap.py +++ b/pwndbg/gdblib/vmmap.py @@ -450,6 +450,9 @@ def kernel_vmmap_via_page_tables(): return tuple(retpages) +monitor_info_mem_not_warned = True + + def kernel_vmmap_via_monitor_info_mem(): """ Returns Linux memory maps information by parsing `monitor info mem` output @@ -469,6 +472,7 @@ def kernel_vmmap_via_monitor_info_mem(): # ffff90358009b000-ffff903582200000 0000000002165000 -rw # ffff903582200000-ffff903582803000 0000000000603000 -r- """ + global monitor_info_mem_not_warned monitor_info_mem = None try: monitor_info_mem = gdb.execute("monitor info mem", to_string=True) @@ -505,7 +509,19 @@ def kernel_vmmap_via_monitor_info_mem(): start = int(line[:dash_idx], 16) end = int(line[dash_idx + 1 : space_idx], 16) size = int(line[space_idx + 1 : rspace_idx], 16) - assert end - start == size, "monitor info mem output didn't pass a sanity check" + if end - start != size and monitor_info_mem_not_warned: + print( + M.warn( + ( + "The vmmap output may be incorrect as `monitor info mem` output assertion/assumption\n" + "that end-start==size failed. The values are:\n" + "end=%#x; start=%#x; size=%#x; end-start=%#x\n" + "Note that this warning will not show up again in this Pwndbg/GDB session." + ) + % (end, start, size, end - start) + ) + ) + monitor_info_mem_not_warned = False perm = line[rspace_idx + 1 :] flags = 0