[llvm-jitlink] Add an explicit -debugger-support option.

Commit 69be352a19 restricted the MachO debugger support testcase to run on
Darwin only, but we still need to disable debugger support by default for
other noexec tests.

This patch introduces a -debugger-support option to llvm-jitlink that is
on-by-default when executing code, and off-by-default for noexec tests. This
should prevent regression tests from trying (and failing) to set up MachO
debugging support when running on non-Darwin platforms.

to explicitly enable/disable support.
This commit is contained in:
Lang Hames 2021-11-14 15:42:45 -08:00
parent 6438a52df1
commit 55751f5f63
2 changed files with 19 additions and 7 deletions

View File

@ -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.

View File

@ -101,6 +101,11 @@ static cl::list<std::string> InputArgv("args", cl::Positional,
cl::ZeroOrMore, cl::PositionalEatsArgs,
cl::cat(JITLinkCategory));
static cl::opt<bool>
DebuggerSupport("debugger-support",
cl::desc("Enable debugger suppport (default = !-noexec)"),
cl::init(true), cl::Hidden, cl::cat(JITLinkCategory));
static cl::opt<bool>
NoProcessSymbols("no-process-syms",
cl::desc("Do not resolve to llvm-jitlink process symbols"),
@ -990,7 +995,7 @@ Session::Session(std::unique_ptr<ExecutorProcessControl> 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<ExecutorProcessControl> EPC, Error &Err)
Err = P.takeError();
return;
}
} else if (!NoExec && !TT.isOSWindows() && !TT.isOSBinFormatMachO()) {
ObjLayer.addPlugin(std::make_unique<EHFrameRegistrationPlugin>(
ES, ExitOnErr(EPCEHFrameRegistrar::Create(this->ES))));
ObjLayer.addPlugin(std::make_unique<DebugObjectManagerPlugin>(
ES, ExitOnErr(createJITLoaderGDBRegistrar(this->ES))));
} else if (!TT.isOSWindows() && !TT.isOSBinFormatMachO()) {
if (!NoExec)
ObjLayer.addPlugin(std::make_unique<EHFrameRegistrationPlugin>(
ES, ExitOnErr(EPCEHFrameRegistrar::Create(this->ES))));
if (DebuggerSupport)
ObjLayer.addPlugin(std::make_unique<DebugObjectManagerPlugin>(
ES, ExitOnErr(createJITLoaderGDBRegistrar(this->ES))));
}
ObjLayer.addPlugin(std::make_unique<JITLinkSessionPlugin>(*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.
//