brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · d7ab89e Raw
52 lines · python
1"""Test that lldb works correctly on compile units form different languages."""2 3 4import re5import lldb6from lldbsuite.test.lldbtest import *7 8 9class MixedLanguagesTestCase(TestBase):10    def test_language_of_frame(self):11        """Test that the language defaults to the language of the current frame."""12        self.build()13        exe = self.getBuildArtifact("a.out")14        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)15 16        # Execute the cleanup function during test case tear down17        # to restore the frame format.18        def cleanup():19            self.runCmd(20                "settings set frame-format %s" % self.format_string, check=False21            )22 23        self.addTearDownHook(cleanup)24        self.runCmd("settings show frame-format")25        m = re.match(r'^frame-format \(format-string\) = "(.*)"$', self.res.GetOutput())26        self.assertTrue(m, "Bad settings string")27        self.format_string = m.group(1)28 29        # Change the default format to print the language.30        format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\\`${function.name}{${function.pc-offset}}}{, lang=${language}}\n"31        self.runCmd("settings set frame-format %s" % format_string)32        self.expect(33            "settings show frame-format",34            SETTING_MSG("frame-format"),35            substrs=[format_string],36        )37 38        # Run to BP at main (in main.c) and test that the language is C.39        self.runCmd("breakpoint set -n main")40        self.runCmd("run")41        self.expect("thread backtrace", substrs=["`main", "lang=c"])42        # Make sure evaluation of C++11 fails.43        self.expect("expr foo != nullptr", error=True, substrs=["error"])44 45        # Run to BP at foo (in foo.cpp) and test that the language is C++.46        self.runCmd("breakpoint set -n foo")47        self.runCmd("continue")48        self.expect("thread backtrace", substrs=["`::foo()", "lang=c++"])49        # Make sure we can evaluate an expression requiring C++1150        # (note: C++11 is enabled by default for C++).51        self.expect("expr foo != nullptr", patterns=["true"])52