Skip to content

Commit 09de016

Browse files
Add example with minimal debug-info and re-enable MachO test
1 parent c6edfcf commit 09de016

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "gtest/gtest.h"
1414

1515
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
16+
#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
1617
#include "llvm/IR/LLVMContext.h"
1718
#include "llvm/IR/Module.h"
1819
#include "llvm/IRReader/IRReader.h"
@@ -211,6 +212,20 @@ constexpr StringRef SumExample =
211212
}
212213
)";
213214

215+
constexpr StringRef SumDebugExample =
216+
R"(
217+
define i32 @sum(i32 %x, i32 %y) {
218+
entry:
219+
%r = add nsw i32 %x, %y
220+
ret i32 %r
221+
}
222+
!llvm.module.flags = !{!0}
223+
!llvm.dbg.cu = !{!1}
224+
!0 = !{i32 2, !"Debug Info Version", i32 3}
225+
!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, emissionKind: FullDebug)
226+
!2 = !DIFile(filename: "sum.c", directory: "/tmp")
227+
)";
228+
214229
} // end anonymous namespace.
215230

216231
// Consumes the given error ref and returns the string error message.
@@ -522,7 +537,7 @@ struct jit_descriptor {
522537
// We put information about the JITed function in this global, which the
523538
// debugger reads. Make sure to specify the version statically, because the
524539
// debugger checks the version before we can set it during runtime.
525-
struct jit_descriptor __jit_debug_descriptor;
540+
extern struct jit_descriptor __jit_debug_descriptor;
526541

527542
static void *findLastDebugDescriptorEntryPtr() {
528543
struct jit_code_entry *Last = __jit_debug_descriptor.first_entry;
@@ -532,17 +547,22 @@ static void *findLastDebugDescriptorEntryPtr() {
532547
}
533548
}
534549

535-
#if defined(_AIX) or not defined(__ELF__)
550+
#if defined(_AIX) or not(defined(__ELF__) or defined(__MACH__))
536551
TEST_F(OrcCAPITestBase, DISABLED_EnableDebugSupport) {
537552
#else
553+
static LLVM_ATTRIBUTE_USED void linkComponents() {
554+
errs() << "Linking in runtime functions\n"
555+
<< (void *)&llvm_orc_registerJITLoaderGDBWrapper << '\n'
556+
<< (void *)&llvm_orc_registerJITLoaderGDBAllocAction << '\n';
557+
}
538558
TEST_F(OrcCAPITestBase, EnableDebugSupport) {
539559
#endif
540560
if (LLVMErrorRef E = LLVMOrcLLJITEnableDebugSupport(Jit))
541561
FAIL() << "Error testing LLJIT debug support (triple = " << TargetTriple
542562
<< "): " << toString(E);
543563

544564
void *Before = findLastDebugDescriptorEntryPtr();
545-
LLVMMemoryBufferRef ObjBuffer = createTestObject(SumExample, "sum.ll");
565+
LLVMMemoryBufferRef ObjBuffer = createTestObject(SumDebugExample, "sum.ll");
546566
LLVMOrcObjectLayerRef ObjLayer = LLVMOrcLLJITGetObjLinkingLayer(Jit);
547567
if (LLVMErrorRef E =
548568
LLVMOrcObjectLayerAddObjectFile(ObjLayer, MainDylib, ObjBuffer))

0 commit comments

Comments
 (0)