3394bb2d6aa75f280148f5b286f0ccd2c601b9f7
[openbsd] /
1 """
2 Test that step-inst over a crash behaves correctly.
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
11
12
13 class CrashDuringStepTestCase(TestBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16
17     def setUp(self):
18         TestBase.setUp(self)
19         self.breakpoint = line_number('main.cpp', '// Set breakpoint here')
20
21     # IO error due to breakpoint at invalid address
22     @expectedFailureAll(triple=re.compile('^mips'))
23     def test_step_inst_with(self):
24         """Test thread creation during step-inst handling."""
25         self.build(dictionary=self.getBuildFlags())
26         exe = self.getBuildArtifact("a.out")
27
28         target = self.dbg.CreateTarget(exe)
29         self.assertTrue(target and target.IsValid(), "Target is valid")
30
31         self.bp_num = lldbutil.run_break_set_by_file_and_line(
32             self, "main.cpp", self.breakpoint, num_expected_locations=1)
33
34         # Run the program.
35         process = target.LaunchSimple(
36             None, None, self.get_process_working_directory())
37         self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
38
39         # The stop reason should be breakpoint.
40         self.assertEqual(
41             process.GetState(),
42             lldb.eStateStopped,
43             PROCESS_STOPPED)
44         thread = lldbutil.get_stopped_thread(
45             process, lldb.eStopReasonBreakpoint)
46         self.assertTrue(thread.IsValid(), STOPPED_DUE_TO_BREAKPOINT)
47
48         # Keep stepping until the inferior crashes
49         while process.GetState() == lldb.eStateStopped and not lldbutil.is_thread_crashed(self, thread):
50             thread.StepInstruction(False)
51
52         self.assertEqual(
53             process.GetState(),
54             lldb.eStateStopped,
55             PROCESS_STOPPED)
56         self.assertTrue(
57             lldbutil.is_thread_crashed(
58                 self,
59                 thread),
60             "Thread has crashed")
61         process.Kill()