68f8c0360ff3e82d8817dc8fd34d9b8cc378b1be
[openbsd] /
1 """
2 Test that hitting a UBSan issue while running user expression doesn't break the evaluation.
3 """
4
5 import lldb
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test.decorators import *
8 import lldbsuite.test.lldbutil as lldbutil
9
10
11 class UbsanUserExpressionTestCase(TestBase):
12
13     mydir = TestBase.compute_mydir(__file__)
14
15     @skipUnlessUndefinedBehaviorSanitizer
16     def test(self):
17         self.build()
18         self.ubsan_tests()
19
20     def setUp(self):
21         # Call super's setUp().
22         TestBase.setUp(self)
23         self.line_breakpoint = line_number('main.c', '// breakpoint line')
24
25     def ubsan_tests(self):
26         # Load the test
27         exe = self.getBuildArtifact("a.out")
28         self.expect(
29             "file " + exe,
30             patterns=["Current executable set to .*a.out"])
31
32         self.runCmd("breakpoint set -f main.c -l %d" % self.line_breakpoint)
33
34         self.runCmd("run")
35
36         process = self.dbg.GetSelectedTarget().process
37         thread = process.GetSelectedThread()
38         frame = thread.GetSelectedFrame()
39
40         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
41                     substrs=['stopped', 'stop reason = breakpoint'])
42
43         self.expect("p foo()", substrs=["(int) $0 = 42"])
44
45         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
46                     substrs=['stopped', 'stop reason = breakpoint'])