13
13
#include " gtest/gtest.h"
14
14
15
15
#include " llvm/ExecutionEngine/Orc/CompileUtils.h"
16
+ #include " llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
16
17
#include " llvm/IR/LLVMContext.h"
17
18
#include " llvm/IR/Module.h"
18
19
#include " llvm/IRReader/IRReader.h"
@@ -211,6 +212,20 @@ constexpr StringRef SumExample =
211
212
}
212
213
)" ;
213
214
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
+
214
229
} // end anonymous namespace.
215
230
216
231
// Consumes the given error ref and returns the string error message.
@@ -522,7 +537,7 @@ struct jit_descriptor {
522
537
// We put information about the JITed function in this global, which the
523
538
// debugger reads. Make sure to specify the version statically, because the
524
539
// 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;
526
541
527
542
static void *findLastDebugDescriptorEntryPtr () {
528
543
struct jit_code_entry *Last = __jit_debug_descriptor.first_entry ;
@@ -532,17 +547,22 @@ static void *findLastDebugDescriptorEntryPtr() {
532
547
}
533
548
}
534
549
535
- #if defined(_AIX) or not defined(__ELF__)
550
+ #if defined(_AIX) or not( defined(__ELF__) or defined(__MACH__) )
536
551
TEST_F (OrcCAPITestBase, DISABLED_EnableDebugSupport) {
537
552
#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
+ }
538
558
TEST_F (OrcCAPITestBase, EnableDebugSupport) {
539
559
#endif
540
560
if (LLVMErrorRef E = LLVMOrcLLJITEnableDebugSupport (Jit))
541
561
FAIL () << " Error testing LLJIT debug support (triple = " << TargetTriple
542
562
<< " ): " << toString (E);
543
563
544
564
void *Before = findLastDebugDescriptorEntryPtr ();
545
- LLVMMemoryBufferRef ObjBuffer = createTestObject (SumExample , " sum.ll" );
565
+ LLVMMemoryBufferRef ObjBuffer = createTestObject (SumDebugExample , " sum.ll" );
546
566
LLVMOrcObjectLayerRef ObjLayer = LLVMOrcLLJITGetObjLinkingLayer (Jit);
547
567
if (LLVMErrorRef E =
548
568
LLVMOrcObjectLayerAddObjectFile (ObjLayer, MainDylib, ObjBuffer))
0 commit comments