1 """Test that lldb works correctly on compile units form different languages."""
7 from lldbsuite
.test
.lldbtest
import *
10 class MixedLanguagesTestCase(TestBase
):
12 mydir
= TestBase
.compute_mydir(__file__
)
14 def test_language_of_frame(self
):
15 """Test that the language defaults to the language of the current frame."""
17 exe
= self
.getBuildArtifact("a.out")
18 self
.runCmd("file " + exe
, CURRENT_EXECUTABLE_SET
)
20 # Execute the cleanup function during test case tear down
21 # to restore the frame format.
24 "settings set frame-format %s" %
25 self
.format_string
, check
=False)
26 self
.addTearDownHook(cleanup
)
27 self
.runCmd("settings show frame-format")
29 '^frame-format \(format-string\) = "(.*)\"$',
31 self
.assertTrue(m
, "Bad settings string")
32 self
.format_string
= m
.group(1)
34 # Change the default format to print the language.
35 format_string
= "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\`${function.name}{${function.pc-offset}}}{, lang=${language}}\n"
36 self
.runCmd("settings set frame-format %s" % format_string
)
37 self
.expect("settings show frame-format", SETTING_MSG("frame-format"),
38 substrs
=[format_string
])
40 # Run to BP at main (in main.c) and test that the language is C.
41 self
.runCmd("breakpoint set -n main")
43 self
.expect("thread backtrace",
44 substrs
=["`main", "lang=c"])
45 # Make sure evaluation of C++11 fails.
46 self
.expect("expr foo != nullptr", error
=True,
49 # Run to BP at foo (in foo.cpp) and test that the language is C++.
50 self
.runCmd("breakpoint set -n foo")
51 self
.runCmd("continue")
52 self
.expect("thread backtrace",
53 substrs
=["`::foo()", "lang=c++"])
54 # Make sure we can evaluate an expression requiring C++11
55 # (note: C++11 is enabled by default for C++).
56 self
.expect("expr foo != nullptr",