================ @@ -0,0 +1,130 @@ +""" +Test that saved memory regions is byte-wise 1:1 with the live process. Specifically +that the memory regions that will be populated in the Memory64List are the same byte for byte. +""" + +import os +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class ProcessSaveCoreMinidump64bTestCase(TestBase): + def verify_minidump( + self, + core_proc, + live_proc, + options, + ): + """Verify that the minidump is the same byte for byte as the live process.""" + # Get the memory regions we saved off in this core, we can't compare to the core + # because we pull from /proc/pid/maps, so even ranges that don't get mapped in will show up + # as ranges in the minidump. + # + # Instead, we have an API that returns to us the number of regions we planned to save from the live process + # and we compare those + memory_regions_to_compare = options.GetMemoryRegionsToSave() + + for region in memory_regions_to_compare: + start_addr = region.GetRegionBase() + end_addr = region.GetRegionEnd() + actual_process_read_error = lldb.SBError() + actual = live_proc.ReadMemory( + start_addr, end_addr - start_addr, actual_process_read_error + ) + expected_process_read_error = lldb.SBError() + expected = core_proc.ReadMemory( + start_addr, end_addr - start_addr, expected_process_read_error + ) + + # Both processes could fail to read a given memory region, so if they both pass + # compare, then we'll fail them if the core differs from the live process. + if ( + actual_process_read_error.Success() + and expected_process_read_error.Success() + ): + self.assertEqual( + actual, expected, "Bytes differ between live process and core" + ) + + # Now we check if the error is the same, error isn't abnormal but they should fail for the same reason + self.assertTrue( ---------------- dmpots wrote:
Can we simplify this to ``` self.assertEqual( actual_process_read_error.Success(), expected_process_read_error.Success(), f"Address range {hex(start_addr)} - {hex(end_addr)} mismatch in read results success between live process and core. Live: {actual_process_read_error.Success()}, Core: {expected_process_read_error.Success()}, ) ``` https://github.com/llvm/llvm-project/pull/146777 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits