2 Test that the debugger handles loops in std::list (which can appear as a result of e.g. memory
6 from __future__ import print_function
13 from lldbsuite.test.decorators import *
14 from lldbsuite.test.lldbtest import *
15 from lldbsuite.test import lldbutil
18 class LibcxxListDataFormatterTestCase(TestBase):
20 mydir = TestBase.compute_mydir(__file__)
22 @skipIf(compiler="gcc")
23 @skipIfWindows # libc++ not ported to Windows yet
24 @add_test_categories(["pyapi"])
25 @skipIfDarwin # rdar://25499635
26 def test_with_run_command(self):
28 exe = os.path.join(os.getcwd(), "a.out")
29 target = self.dbg.CreateTarget(exe)
30 self.assertTrue(target and target.IsValid(), "Target is valid")
32 file_spec = lldb.SBFileSpec("main.cpp", False)
33 breakpoint1 = target.BreakpointCreateBySourceRegex(
34 '// Set break point at this line.', file_spec)
35 self.assertTrue(breakpoint1 and breakpoint1.IsValid())
36 breakpoint2 = target.BreakpointCreateBySourceRegex(
37 '// Set second break point at this line.', file_spec)
38 self.assertTrue(breakpoint2 and breakpoint2.IsValid())
40 # Run the program, it should stop at breakpoint 1.
41 process = target.LaunchSimple(
42 None, None, self.get_process_working_directory())
43 lldbutil.skip_if_library_missing(
44 self, target, lldbutil.PrintableRegex("libc\+\+"))
45 self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
47 len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint1)), 1)
49 # verify our list is displayed correctly
51 "frame variable *numbers_list",
59 # Continue to breakpoint 2.
61 self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
63 len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint2)), 1)
65 # The list is now inconsistent. However, we should be able to get the first three
66 # elements at least (and most importantly, not crash).
68 "frame variable *numbers_list",
76 self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED)