2 Test saving a core file (or mini dump).
5 from __future__ import print_function
10 from lldbsuite.test.decorators import *
11 from lldbsuite.test.lldbtest import *
12 from lldbsuite.test import lldbutil
15 class ProcessSaveCoreTestCase(TestBase):
17 mydir = TestBase.compute_mydir(__file__)
19 @not_remote_testsuite_ready
21 def test_cannot_save_core_unless_process_stopped(self):
22 """Test that SaveCore fails if the process isn't stopped."""
24 exe = os.path.join(os.getcwd(), "a.out")
25 core = os.path.join(os.getcwd(), "core.dmp")
26 target = self.dbg.CreateTarget(exe)
27 process = target.LaunchSimple(
28 None, None, self.get_process_working_directory())
29 self.assertNotEqual(process.GetState(), lldb.eStateStopped)
30 error = process.SaveCore(core)
31 self.assertTrue(error.Fail())
33 @not_remote_testsuite_ready
35 def test_save_windows_mini_dump(self):
36 """Test that we can save a Windows mini dump."""
38 exe = os.path.join(os.getcwd(), "a.out")
39 core = os.path.join(os.getcwd(), "core.dmp")
41 target = self.dbg.CreateTarget(exe)
42 breakpoint = target.BreakpointCreateByName("bar")
43 process = target.LaunchSimple(
44 None, None, self.get_process_working_directory())
45 self.assertEqual(process.GetState(), lldb.eStateStopped)
46 self.assertTrue(process.SaveCore(core))
47 self.assertTrue(os.path.isfile(core))
48 self.assertTrue(process.Kill().Success())
50 # To verify, we'll launch with the mini dump, and ensure that we see
51 # the executable in the module list.
52 target = self.dbg.CreateTarget(None)
53 process = target.LoadCore(core)
55 target.GetModuleAtIndex(i).GetFileSpec() for i in range(
56 0, target.GetNumModules())]
60 f.GetFilename()) for f in files]
61 self.assertTrue(exe in paths)
64 # Clean up the mini dump file.
65 self.assertTrue(self.dbg.DeleteTarget(target))
66 if (os.path.isfile(core)):