[Lldb-commits] [lldb] [LLDB][SBSaveCore] Add selectable memory regions to SBSaveCore (PR #105442)

via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 20 15:10:46 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r c4bf949171a72383d5ba4d2b587d4cc496aacebb...001ed7aa004480e052d5aecf29c7ce8132c60d24 lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
``````````

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- TestProcessSaveCoreMinidump.py	2024-08-20 21:58:44.000000 +0000
+++ TestProcessSaveCoreMinidump.py	2024-08-20 22:10:20.400779 +0000
@@ -317,11 +317,10 @@
             self.assertState(process.GetState(), lldb.eStateStopped)
 
             memory_region = lldb.SBMemoryRegionInfo()
             memory_list = process.GetMemoryRegions()
             memory_list.GetMemoryRegionAtIndex(0, memory_region)
-            
 
             # This is almost identical to the single thread test case because
             # minidump defaults to stacks only, so we want to see if the
             # default options work as expected.
             options = lldb.SBSaveCoreOptions()
@@ -329,41 +328,44 @@
             options.SetOutputFile(file_spec)
             options.SetPluginName("minidump")
             options.AddMemoryRegionToSave(memory_region)
             options.SetStyle(lldb.eSaveCoreCustom)
             error = process.SaveCore(options)
-            print (f"Error: {error.GetCString()}")
+            print(f"Error: {error.GetCString()}")
             self.assertTrue(error.Success(), error.GetCString())
 
             core_target = self.dbg.CreateTarget(None)
             core_proc = target.LoadCore(one_region_file)
             core_memory_list = core_proc.GetMemoryRegions()
             # Note because the /proc/pid maps are included on linux, we can't
             # depend on size for validation, so we'll ensure the first region
             # is present and then assert we fail on the second.
             core_memory_region = lldb.SBMemoryRegionInfo()
             core_memory_list.GetMemoryRegionAtIndex(0, core_memory_region)
-            self.assertEqual(core_memory_region.GetRegionBase(), memory_region.GetRegionBase())
-            self.assertEqual(core_memory_region.GetRegionEnd(), memory_region.GetRegionEnd())
-            
+            self.assertEqual(
+                core_memory_region.GetRegionBase(), memory_region.GetRegionBase()
+            )
+            self.assertEqual(
+                core_memory_region.GetRegionEnd(), memory_region.GetRegionEnd()
+            )
+
             region_two = lldb.SBMemoryRegionInfo()
             core_memory_list.GetMemoryRegionAtIndex(1, region_two)
             err = lldb.SBError()
             content = core_proc.ReadMemory(region_two.GetRegionBase(), 1, err)
             self.assertTrue(err.Fail(), "Should fail to read memory")
 
-
         finally:
             self.assertTrue(self.dbg.DeleteTarget(target))
             if os.path.isfile(one_region_file):
                 os.unlink(one_region_file)
 
     @skipUnlessArch("x86_64")
     @skipUnlessPlatform(["linux"])
     def test_save_minidump_custom_save_style(self):
-        """Test that verifies a custom and unspecified save style fails for 
-            containing no data to save"""
+        """Test that verifies a custom and unspecified save style fails for
+        containing no data to save"""
 
         self.build()
         exe = self.getBuildArtifact("a.out")
         custom_file = self.getBuildArtifact("core.custom.dmp")
         try:
@@ -378,11 +380,13 @@
             options.SetPluginName("minidump")
             options.SetStyle(lldb.eSaveCoreCustom)
 
             error = process.SaveCore(options)
             self.assertTrue(error.Fail())
-            self.assertEqual(error.GetCString(), "no valid address ranges found for core style")
+            self.assertEqual(
+                error.GetCString(), "no valid address ranges found for core style"
+            )
 
         finally:
             self.assertTrue(self.dbg.DeleteTarget(target))
             if os.path.isfile(custom_file):
                 os.unlink(custom_file)

``````````

</details>


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


More information about the lldb-commits mailing list