[Lldb-commits] [lldb] r267768 - Added a testcase for the IR interpreter, ensuring that it behaves like the JIT.

Sean Callanan via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 27 12:37:42 PDT 2016


Author: spyffe
Date: Wed Apr 27 14:37:42 2016
New Revision: 267768

URL: http://llvm.org/viewvc/llvm-project?rev=267768&view=rev
Log:
Added a testcase for the IR interpreter, ensuring that it behaves like the JIT.

<rdar://problem/25785338>

Added:
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/Makefile
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/TestIRInterpreter.py
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/main.c

Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/Makefile?rev=267768&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/Makefile (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/Makefile Wed Apr 27 14:37:42 2016
@@ -0,0 +1,7 @@
+LEVEL = ../../make
+
+default: a.out
+
+C_SOURCES := main.c
+
+include $(LEVEL)/Makefile.rules

Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/TestIRInterpreter.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/TestIRInterpreter.py?rev=267768&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/TestIRInterpreter.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/TestIRInterpreter.py Wed Apr 27 14:37:42 2016
@@ -0,0 +1,70 @@
+"""
+Test the IR interpreter
+"""
+
+from __future__ import print_function
+
+import unittest2
+
+import os, time
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class IRInterpreterTestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    def setUp(self):
+        # Call super's setUp().
+        TestBase.setUp(self)
+        # Find the line number to break for main.c.
+        self.line = line_number('main.c',
+                                '// Set breakpoint here')
+
+        # Disable confirmation prompt to avoid infinite wait
+        self.runCmd("settings set auto-confirm true")
+        self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm"))
+
+    def build_and_run(self):
+        """Test the IR interpreter"""
+        self.build()
+
+        self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+        lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=False)
+
+        self.runCmd("run", RUN_SUCCEEDED)
+
+    @add_test_categories(['pyapi'])
+    def test_ir_interpreter(self):
+        self.build_and_run()
+
+        options = lldb.SBExpressionOptions()
+        options.SetLanguage(lldb.eLanguageTypeC_plus_plus)
+
+        set_up_expressions = ["int $i = 9", "int $j = 3", "int $k = 5"]
+
+        expressions = ["$i + $j",
+                       "$i - $j",
+                       "$i * $j",
+                       "$i / $j",
+                       "$i % $k",
+                       "$i << $j",
+                       "$i & $j",
+                       "$i | $j",
+                       "$i ^ $j"]
+
+        for expression in set_up_expressions:
+            self.frame().EvaluateExpression(expression, options)
+
+        for expression in expressions:
+            interp_expression   = expression
+            jit_expression      = "(int)getpid(); " + expression
+
+            interp_result       = self.frame().EvaluateExpression(interp_expression, options).GetValueAsSigned()
+            jit_result          = self.frame().EvaluateExpression(jit_expression, options).GetValueAsSigned()
+
+            self.assertEqual(interp_result, jit_result, "While evaluating " + expression)
+

Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/main.c?rev=267768&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/main.c (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter/main.c Wed Apr 27 14:37:42 2016
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main()
+{
+    printf("This is a dummy\n"); // Set breakpoint here   
+    return 0;
+}




More information about the lldb-commits mailing list