diff --git a/lldb/lit/Breakpoint/Inputs/jitbp.cpp b/lldb/lit/Breakpoint/Inputs/jitbp.cpp new file mode 100644 --- /dev/null +++ b/lldb/lit/Breakpoint/Inputs/jitbp.cpp @@ -0,0 +1,2 @@ +int jitbp() { return 0; } +int main() { return jitbp(); } diff --git a/lldb/lit/Breakpoint/jitbp_elf.test b/lldb/lit/Breakpoint/jitbp_elf.test new file mode 100644 --- /dev/null +++ b/lldb/lit/Breakpoint/jitbp_elf.test @@ -0,0 +1,13 @@ +# REQUIRES: target-x86_64, system-linux, native + +# RUN: %clang -g -S -emit-llvm -o %t.ll %p/Inputs/jitbp.cpp +# RUN: %lldb -b -o 'b jitbp' -o 'run -jit-kind=mcjit %t.ll' lli | FileCheck %s + +# CHECK: (lldb) target create "{{.*}}/lli" +# CHECK: (lldb) b jitbp +# CHECK: Breakpoint 1: no locations (pending). +# CHECK: (lldb) run -jit-kind=mcjit {{.*}}/jitbp_elf.test.tmp.ll +# CHECK: 1 location added to breakpoint 1 +# CHECK: Process {{.*}} stopped +# CHECK: JIT(0x{{.*}})`jitbp: +# CHECK: Process {{.*}} launched: {{.*}} diff --git a/lldb/lit/helper/toolchain.py b/lldb/lit/helper/toolchain.py --- a/lldb/lit/helper/toolchain.py +++ b/lldb/lit/helper/toolchain.py @@ -129,6 +129,6 @@ support_tools = ['yaml2obj', 'obj2yaml', 'llvm-pdbutil', 'llvm-mc', 'llvm-readobj', 'llvm-objdump', - 'llvm-objcopy'] + 'llvm-objcopy', 'lli'] additional_tool_dirs += [config.lldb_tools_dir, config.llvm_tools_dir] llvm_config.add_tool_substitutions(support_tools, additional_tool_dirs) diff --git a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp --- a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp +++ b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp @@ -327,6 +327,10 @@ FileSpec(jit_name), symbolfile_addr, symbolfile_size); if (module_sp && module_sp->GetObjectFile()) { + // Object formats (like ELF) have no representation for a JIT type. + // We will get it wrong, if we deduce it from the header. + module_sp->GetObjectFile()->SetType(ObjectFile::eTypeJIT); + // load the symbol table right away module_sp->GetObjectFile()->GetSymtab(); diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1865,7 +1865,7 @@ return; m_sections_up = llvm::make_unique(); - VMAddressProvider address_provider(CalculateType()); + VMAddressProvider address_provider(GetType()); size_t LoadID = 0; for (const auto &EnumPHdr : llvm::enumerate(ProgramHeaders())) {