summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb
diff options
context:
space:
mode:
authorYury Delendik <ydelendik@mozilla.com>2019-03-05 14:23:53 +0000
committerYury Delendik <ydelendik@mozilla.com>2019-03-05 14:23:53 +0000
commitbc6b225d42928c1bf7cf8a6801304b1af8747d48 (patch)
tree2f587464f8bc5bf9f6a503f9561b8b693bff534f /lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb
parent401997db928eb5aff56b8daaf4cd676e102b05d7 (diff)
downloadbcm5719-llvm-bc6b225d42928c1bf7cf8a6801304b1af8747d48.tar.gz
bcm5719-llvm-bc6b225d42928c1bf7cf8a6801304b1af8747d48.zip
Adds property to force enabling of GDB JIT loader for MacOS
Summary: Based on https://gist.github.com/thlorenz/30bf0a3f67b1d97b2945#patching-and-rebuilding The functionality was disabled at https://github.com/llvm/llvm-project/commit/521c2278abb16f0148cef1bd061cadb01ef43192 Reviewers: jingham Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D57689 llvm-svn: 355402
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/Makefile8
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py78
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/simple.c20
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/simple.mk6
4 files changed, 112 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/Makefile
index 0d70f259501..f94c29bd44d 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/Makefile
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/Makefile
@@ -2,4 +2,12 @@ LEVEL = ../../make
C_SOURCES := main.c
+all: a.out simple
+
include $(LEVEL)/Makefile.rules
+
+simple:
+ $(MAKE) VPATH=$(VPATH) -f $(SRCDIR)/simple.mk
+
+clean::
+ $(MAKE) -f $(SRCDIR)/simple.mk clean \ No newline at end of file
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py b/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py
index 07f04b18bb9..e04c7577064 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py
@@ -10,6 +10,7 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
import re
+file_index = 0
class JITLoaderGDBTestCase(TestBase):
@@ -38,3 +39,80 @@ class JITLoaderGDBTestCase(TestBase):
self.assertEqual(process.GetState(), lldb.eStateExited)
self.assertEqual(process.GetExitStatus(), 0)
+
+ def gen_log_file(self):
+ global file_index
+ ++file_index
+ logfile = os.path.join(
+ self.getBuildDir(),
+ "jitintgdb-" + self.getArchitecture() + "-" +
+ str(file_index) + ".txt")
+
+ def cleanup():
+ if os.path.exists(logfile):
+ os.unlink(logfile)
+ self.addTearDownHook(cleanup)
+ return logfile
+
+ def test_jit_int_default(self):
+ self.expect("settings show plugin.jit-loader.gdb.enable",
+ substrs=["plugin.jit-loader.gdb.enable (enum) = default"])
+
+ def test_jit_int_on(self):
+ """Tests interface with 'enable' settings 'on'"""
+ self.build()
+ exe = self.getBuildArtifact("simple")
+
+ logfile = self.gen_log_file()
+ self.runCmd("log enable -f %s lldb jit" % (logfile))
+ self.runCmd("settings set plugin.jit-loader.gdb.enable on")
+ def cleanup():
+ self.runCmd("log disable lldb")
+ self.runCmd("settings set plugin.jit-loader.gdb.enable default")
+ self.addTearDownHook(cleanup)
+
+ # launch the process
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ self.assertEqual(process.GetState(), lldb.eStateExited)
+ self.assertEqual(process.GetExitStatus(), 0)
+
+ logcontent = ""
+ if os.path.exists(logfile):
+ logcontent = open(logfile).read()
+ self.assertIn(
+ "SetJITBreakpoint setting JIT breakpoint", logcontent)
+
+ def test_jit_int_off(self):
+ """Tests interface with 'enable' settings 'off'"""
+ self.build()
+ exe = self.getBuildArtifact("simple")
+
+ logfile = self.gen_log_file()
+ self.runCmd("log enable -f %s lldb jit" % (logfile))
+ self.runCmd("settings set plugin.jit-loader.gdb.enable off")
+ def cleanup():
+ self.runCmd("log disable lldb")
+ self.runCmd("settings set plugin.jit-loader.gdb.enable default")
+ self.addTearDownHook(cleanup)
+
+ # launch the process
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ self.assertEqual(process.GetState(), lldb.eStateExited)
+ self.assertEqual(process.GetExitStatus(), 0)
+
+ if os.path.exists(logfile):
+ logcontent = open(logfile).read()
+ self.assertNotIn(
+ "SetJITBreakpoint setting JIT breakpoint", logcontent)
+ else:
+ self.assertTrue(false)
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/simple.c b/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/simple.c
new file mode 100644
index 00000000000..77b1a2ad812
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/simple.c
@@ -0,0 +1,20 @@
+#include <inttypes.h>
+
+// GDB JIT interface stub
+struct
+{
+ uint32_t version;
+ uint32_t action_flag;
+ void* relevant_entry;
+ void* first_entry;
+} __jit_debug_descriptor = { 1, 0, 0, 0 };
+
+void __jit_debug_register_code()
+{
+}
+// end GDB JIT interface stub
+
+int main()
+{
+ return 0;
+}
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/simple.mk b/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/simple.mk
new file mode 100644
index 00000000000..9f0c165515a
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/simple.mk
@@ -0,0 +1,6 @@
+LEVEL = ../../make
+
+C_SOURCES := simple.c
+EXE = simple
+
+include $(LEVEL)/Makefile.rules
OpenPOWER on IntegriCloud