1678c513e50b17ead3245480a0e5a709054c1057
[openbsd] /
1 """
2 Test that the debugger handles loops in std::list (which can appear as a result of e.g. memory
3 corruption).
4 """
5
6
7
8 import lldb
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
12
13
14 class LibcxxListDataFormatterTestCase(TestBase):
15
16     mydir = TestBase.compute_mydir(__file__)
17     NO_DEBUG_INFO_TESTCASE = True
18
19     @add_test_categories(["libc++"])
20     @expectedFailureAndroid(bugnumber="llvm.org/pr32592")
21     def test_with_run_command(self):
22         self.build()
23         exe = self.getBuildArtifact("a.out")
24         target = self.dbg.CreateTarget(exe)
25         self.assertTrue(target and target.IsValid(), "Target is valid")
26
27         file_spec = lldb.SBFileSpec("main.cpp", False)
28         breakpoint1 = target.BreakpointCreateBySourceRegex(
29             '// Set break point at this line.', file_spec)
30         self.assertTrue(breakpoint1 and breakpoint1.IsValid())
31         breakpoint2 = target.BreakpointCreateBySourceRegex(
32             '// Set second break point at this line.', file_spec)
33         self.assertTrue(breakpoint2 and breakpoint2.IsValid())
34
35         # Run the program, it should stop at breakpoint 1.
36         process = target.LaunchSimple(
37             None, None, self.get_process_working_directory())
38         self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
39         self.assertEqual(
40             len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint1)), 1)
41
42         # verify our list is displayed correctly
43         self.expect(
44             "frame variable *numbers_list",
45             substrs=[
46                 '[0] = 1',
47                 '[1] = 2',
48                 '[2] = 3',
49                 '[3] = 4',
50                 '[5] = 6'])
51
52         # Continue to breakpoint 2.
53         process.Continue()
54         self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
55         self.assertEqual(
56             len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint2)), 1)
57
58         # The list is now inconsistent. However, we should be able to get the first three
59         # elements at least (and most importantly, not crash).
60         self.expect(
61             "frame variable *numbers_list",
62             substrs=[
63                 '[0] = 1',
64                 '[1] = 2',
65                 '[2] = 3'])
66
67         # Run to completion.
68         process.Continue()
69         self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED)