diff --git a/llvm/test/ExecutionEngine/JITLink/X86/MachO_gdb_jit_debuginfo_register.s b/llvm/test/ExecutionEngine/JITLink/X86/MachO_gdb_jit_debuginfo_register.s index 968b7c9794c9..1d0c813aed54 100644 --- a/llvm/test/ExecutionEngine/JITLink/X86/MachO_gdb_jit_debuginfo_register.s +++ b/llvm/test/ExecutionEngine/JITLink/X86/MachO_gdb_jit_debuginfo_register.s @@ -1,6 +1,7 @@ # REQUIRES: system-darwin && asserts # RUN: llvm-mc -triple=x86_64-apple-macosx10.9 -filetype=obj -o %t %s -# RUN: llvm-jitlink -debug-only=orc -noexec %t 2>&1 | FileCheck %s +# RUN: llvm-jitlink -debug-only=orc -debugger-support -noexec %t 2>&1 \ +# RUN: | FileCheck %s # # Check that presence of a "__DWARF" section triggers the # GDBJITDebugInfoRegistrationPlugin. diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp index 81c1e94b6b13..202b459a6078 100644 --- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp @@ -101,6 +101,11 @@ static cl::list InputArgv("args", cl::Positional, cl::ZeroOrMore, cl::PositionalEatsArgs, cl::cat(JITLinkCategory)); +static cl::opt + DebuggerSupport("debugger-support", + cl::desc("Enable debugger suppport (default = !-noexec)"), + cl::init(true), cl::Hidden, cl::cat(JITLinkCategory)); + static cl::opt NoProcessSymbols("no-process-syms", cl::desc("Do not resolve to llvm-jitlink process symbols"), @@ -990,7 +995,7 @@ Session::Session(std::unique_ptr EPC, Error &Err) auto &TT = ES.getExecutorProcessControl().getTargetTriple(); - if (TT.isOSBinFormatMachO()) + if (DebuggerSupport && TT.isOSBinFormatMachO()) ObjLayer.addPlugin(ExitOnErr( GDBJITDebugInfoRegistrationPlugin::Create(this->ES, *MainJD, TT))); @@ -1011,11 +1016,13 @@ Session::Session(std::unique_ptr EPC, Error &Err) Err = P.takeError(); return; } - } else if (!NoExec && !TT.isOSWindows() && !TT.isOSBinFormatMachO()) { - ObjLayer.addPlugin(std::make_unique( - ES, ExitOnErr(EPCEHFrameRegistrar::Create(this->ES)))); - ObjLayer.addPlugin(std::make_unique( - ES, ExitOnErr(createJITLoaderGDBRegistrar(this->ES)))); + } else if (!TT.isOSWindows() && !TT.isOSBinFormatMachO()) { + if (!NoExec) + ObjLayer.addPlugin(std::make_unique( + ES, ExitOnErr(EPCEHFrameRegistrar::Create(this->ES)))); + if (DebuggerSupport) + ObjLayer.addPlugin(std::make_unique( + ES, ExitOnErr(createJITLoaderGDBRegistrar(this->ES)))); } ObjLayer.addPlugin(std::make_unique(*this)); @@ -1206,6 +1213,10 @@ static Error sanitizeArguments(const Triple &TT, const char *ArgV0) { if (EntryPointName.empty()) EntryPointName = TT.getObjectFormat() == Triple::MachO ? "_main" : "main"; + // Disable debugger support by default in noexec tests. + if (DebuggerSupport.getNumOccurrences() == 0 && NoExec) + DebuggerSupport = false; + // If -slab-allocate is passed, check that we're not trying to use it in // -oop-executor or -oop-executor-connect mode. //