[Lldb-commits] [lldb] [LLDB/Coredump] Only take the Pthread from stack start to the stackpointer + red_zone (PR #92002)

via lldb-commits lldb-commits at lists.llvm.org
Mon May 13 21:55:27 PDT 2024


================
@@ -36,17 +35,37 @@ def verify_core_file(
             self.assertEqual(module_file_name, expected_file_name)
             self.assertEqual(module.GetUUIDString(), expected.GetUUIDString())
 
+        red_zone = process.GetTarget().GetStackRedZoneSize()
         for thread_idx in range(process.GetNumThreads()):
             thread = process.GetThreadAtIndex(thread_idx)
             self.assertTrue(thread.IsValid())
             thread_id = thread.GetThreadID()
             self.assertIn(thread_id, expected_threads)
+            frame = thread.GetFrameAtIndex(0)
+            sp_region = lldb.SBMemoryRegionInfo()
+            sp = frame.GetSP()
+            err = process.GetMemoryRegionInfo(sp, sp_region)
+            self.assertTrue(err.Success(), err.GetCString())
+            error = lldb.SBError()
+            # Try to read at the end of the stack red zone and succeed
+            process.ReadMemory(sp_region.GetRegionEnd() - 1, 1, error)
+            self.assertTrue(error.Success(), error.GetCString())
+            # Try to read just past the red zone and fail
+            process.ReadMemory(sp_region.GetRegionEnd() + 1, 1, error)
+            # Try to read from the base of the stack
----------------
jeffreytan81 wrote:

1. For checking top of the stack + red zone, isn't it GetRegionBase() because stack grows toward lower address?
2. This function is used by not only stack only option but all options so I am not sure implementation details of stack-only dump uses red zone making sense here.
3. Even for stack-only dump, I am not sure this is testing anything related with red zone, it simply tests that dump does not contain memory outside its memory region...


https://github.com/llvm/llvm-project/pull/92002


More information about the lldb-commits mailing list