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

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 14 15:46:06 PST 2021


Author: Lang Hames
Date: 2021-11-14T15:46:00-08:00
New Revision: 55751f5f6303582ef683dabc151fcd4ccab6780b

URL: https://github.com/llvm/llvm-project/commit/55751f5f6303582ef683dabc151fcd4ccab6780b
DIFF: https://github.com/llvm/llvm-project/commit/55751f5f6303582ef683dabc151fcd4ccab6780b.diff

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

Commit 69be352a196 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.

Added: 
    

Modified: 
    llvm/test/ExecutionEngine/JITLink/X86/MachO_gdb_jit_debuginfo_register.s
    llvm/tools/llvm-jitlink/llvm-jitlink.cpp

Removed: 
    


################################################################################
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 968b7c9794c94..1d0c813aed544 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 81c1e94b6b135..202b459a6078f 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -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.
   //


        


More information about the llvm-commits mailing list