Add a repro case for bug llvm.org/pr24702

llvm-svn: 246845
This commit is contained in:
Pavel Labath 2015-09-04 10:21:15 +00:00
parent 1ba7dc38d0
commit cb405bf311
3 changed files with 99 additions and 0 deletions

View File

@ -0,0 +1,5 @@
LEVEL = ../../make
C_SOURCES := main.c
include $(LEVEL)/Makefile.rules

View File

@ -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()

View File

@ -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;
}