2 Test saving a core file (or mini dump).
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
13 class ProcessSaveCoreTestCase(TestBase):
15 mydir = TestBase.compute_mydir(__file__)
17 @not_remote_testsuite_ready
19 def test_cannot_save_core_unless_process_stopped(self):
20 """Test that SaveCore fails if the process isn't stopped."""
22 exe = self.getBuildArtifact("a.out")
23 core = self.getBuildArtifact("core.dmp")
24 target = self.dbg.CreateTarget(exe)
25 process = target.LaunchSimple(
26 None, None, self.get_process_working_directory())
27 self.assertNotEqual(process.GetState(), lldb.eStateStopped)
28 error = process.SaveCore(core)
29 self.assertTrue(error.Fail())
31 @not_remote_testsuite_ready
33 def test_save_windows_mini_dump(self):
34 """Test that we can save a Windows mini dump."""
36 exe = self.getBuildArtifact("a.out")
37 core = self.getBuildArtifact("core.dmp")
39 target = self.dbg.CreateTarget(exe)
40 breakpoint = target.BreakpointCreateByName("bar")
41 process = target.LaunchSimple(
42 None, None, self.get_process_working_directory())
43 self.assertEqual(process.GetState(), lldb.eStateStopped)
44 self.assertTrue(process.SaveCore(core))
45 self.assertTrue(os.path.isfile(core))
46 self.assertTrue(process.Kill().Success())
48 # To verify, we'll launch with the mini dump, and ensure that we see
49 # the executable in the module list.
50 target = self.dbg.CreateTarget(None)
51 process = target.LoadCore(core)
53 target.GetModuleAtIndex(i).GetFileSpec() for i in range(
54 0, target.GetNumModules())]
58 f.GetFilename()) for f in files]
59 self.assertTrue(exe in paths)
62 # Clean up the mini dump file.
63 self.assertTrue(self.dbg.DeleteTarget(target))
64 if (os.path.isfile(core)):