brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 28768ed Raw
50 lines · python
1"""2Test that hitting a UBSan issue while running user expression doesn't break the evaluation.3"""4 5import lldb6from lldbsuite.test.lldbtest import *7from lldbsuite.test.decorators import *8import lldbsuite.test.lldbutil as lldbutil9 10 11class UbsanUserExpressionTestCase(TestBase):12    @skipUnlessUndefinedBehaviorSanitizer13    def test(self):14        self.build()15        self.ubsan_tests()16 17    def setUp(self):18        # Call super's setUp().19        TestBase.setUp(self)20        self.line_breakpoint = line_number("main.c", "// breakpoint line")21 22    def ubsan_tests(self):23        # Load the test24        exe = self.getBuildArtifact("a.out")25        target = self.dbg.CreateTarget(exe)26        self.assertTrue(target, VALID_TARGET)27        self.registerSanitizerLibrariesWithTarget(target)28 29        self.runCmd("breakpoint set -f main.c -l %d" % self.line_breakpoint)30 31        self.runCmd("run")32 33        process = self.dbg.GetSelectedTarget().process34        thread = process.GetSelectedThread()35        frame = thread.GetSelectedFrame()36 37        self.expect(38            "thread list",39            STOPPED_DUE_TO_BREAKPOINT,40            substrs=["stopped", "stop reason = breakpoint"],41        )42 43        self.expect("expression foo()", substrs=["(int) $0 = 42"])44 45        self.expect(46            "thread list",47            STOPPED_DUE_TO_BREAKPOINT,48            substrs=["stopped", "stop reason = breakpoint"],49        )50