[Lldb-commits] [lldb] r246845 - Add a repro case for bug llvm.org/pr24702
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Fri Sep 4 03:21:15 PDT 2015
Author: labath
Date: Fri Sep 4 05:21:15 2015
New Revision: 246845
URL: http://llvm.org/viewvc/llvm-project?rev=246845&view=rev
Log:
Add a repro case for bug llvm.org/pr24702
Added:
lldb/trunk/test/functionalities/jitloader_gdb/
lldb/trunk/test/functionalities/jitloader_gdb/Makefile
lldb/trunk/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py
lldb/trunk/test/functionalities/jitloader_gdb/main.c
Added: lldb/trunk/test/functionalities/jitloader_gdb/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/jitloader_gdb/Makefile?rev=246845&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/jitloader_gdb/Makefile (added)
+++ lldb/trunk/test/functionalities/jitloader_gdb/Makefile Fri Sep 4 05:21:15 2015
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+C_SOURCES := main.c
+
+include $(LEVEL)/Makefile.rules
Added: lldb/trunk/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py?rev=246845&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py (added)
+++ lldb/trunk/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py Fri Sep 4 05:21:15 2015
@@ -0,0 +1,50 @@
+"""Test for the JITLoaderGDB interface"""
+
+import os
+import unittest2
+import lldb
+from lldbtest import *
+import lldbutil
+import re
+
+
+class JITLoaderGDBTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipTestIfFn(lambda x: True, "llvm.org/pr24702", "Skipped because the test crashes the test runner")
+ @unittest2.expectedFailure("llvm.org/pr24702")
+ @dsym_test
+ def test_bogus_values_with_dsym(self):
+ self.buildDsym()
+ self.bogus_values_test()
+
+ @skipTestIfFn(lambda x: True, "llvm.org/pr24702", "Skipped because the test crashes the test runner")
+ @unittest2.expectedFailure("llvm.org/pr24702")
+ @dwarf_test
+ def test_bogus_values_with_dwarf(self):
+ self.buildDwarf()
+ self.bogus_values_test()
+
+ def bogus_values_test(self):
+ """Test that we handle inferior misusing the GDB JIT interface"""
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # launch the process, do not stop at entry point.
+ process = target.LaunchSimple(None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The inferior will now pass bogus values over the interface. Make sure we don't crash.
+
+ self.assertEqual(process.GetState(), lldb.eStateExited)
+ self.assertEqual(process.GetExitStatus(), 0)
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
Added: lldb/trunk/test/functionalities/jitloader_gdb/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/jitloader_gdb/main.c?rev=246845&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/jitloader_gdb/main.c (added)
+++ lldb/trunk/test/functionalities/jitloader_gdb/main.c Fri Sep 4 05:21:15 2015
@@ -0,0 +1,44 @@
+#include <inttypes.h>
+
+// GDB JIT interface
+enum JITAction { JIT_NOACTION, JIT_REGISTER_FN, JIT_UNREGISTER_FN };
+
+struct JITCodeEntry
+{
+ struct JITCodeEntry* next;
+ struct JITCodeEntry* prev;
+ const char *symfile_addr;
+ uint64_t symfile_size;
+};
+
+struct JITDescriptor
+{
+ uint32_t version;
+ uint32_t action_flag;
+ struct JITCodeEntry* relevant_entry;
+ struct JITCodeEntry* first_entry;
+};
+
+struct JITDescriptor __jit_debug_descriptor = { 1, JIT_NOACTION, 0, 0 };
+
+void __jit_debug_register_code()
+{
+}
+// end GDB JIT interface
+
+struct JITCodeEntry entry;
+
+int main()
+{
+ // Create a code entry with a bogus size
+ entry.next = entry.prev = 0;
+ entry.symfile_addr = (char *)&entry;
+ entry.symfile_size = (uint64_t)47<<32;
+
+ __jit_debug_descriptor.relevant_entry = __jit_debug_descriptor.first_entry = &entry;
+ __jit_debug_descriptor.action_flag = JIT_REGISTER_FN;
+
+ __jit_debug_register_code();
+
+ return 0;
+}
More information about the lldb-commits
mailing list