2 Test the IR interpreter
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
14 class IRInterpreterTestCase(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
17 NO_DEBUG_INFO_TESTCASE = True
20 # Call super's setUp().
22 # Find the line number to break for main.c.
23 self.line = line_number('main.c',
24 '// Set breakpoint here')
26 # Disable confirmation prompt to avoid infinite wait
27 self.runCmd("settings set auto-confirm true")
29 lambda: self.runCmd("settings clear auto-confirm"))
31 def build_and_run(self):
32 """Test the IR interpreter"""
35 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
37 lldbutil.run_break_set_by_file_and_line(
38 self, "main.c", self.line, num_expected_locations=1, loc_exact=False)
40 self.runCmd("run", RUN_SUCCEEDED)
42 @add_test_categories(['pyapi'])
43 # getpid() is POSIX, among other problems, see bug
46 bugnumber="http://llvm.org/pr21765")
47 @expectedFailureNetBSD
51 bugnumber="llvm.org/pr27868")
52 def test_ir_interpreter(self):
55 options = lldb.SBExpressionOptions()
56 options.SetLanguage(lldb.eLanguageTypeC_plus_plus)
58 set_up_expressions = ["int $i = 9", "int $j = 3", "int $k = 5"]
60 expressions = ["$i + $j",
70 for expression in set_up_expressions:
71 self.frame().EvaluateExpression(expression, options)
73 for expression in expressions:
74 interp_expression = expression
75 jit_expression = "(int)getpid(); " + expression
77 interp_result = self.frame().EvaluateExpression(
78 interp_expression, options).GetValueAsSigned()
79 jit_result = self.frame().EvaluateExpression(
80 jit_expression, options).GetValueAsSigned()
88 def test_type_conversions(self):
89 target = self.dbg.GetDummyTarget()
90 short_val = target.EvaluateExpression("(short)-1")
91 self.assertEqual(short_val.GetValueAsSigned(), -1)
92 long_val = target.EvaluateExpression("(long) "+ short_val.GetName())
93 self.assertEqual(long_val.GetValueAsSigned(), -1)