yurydelendik created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Based on 
https://gist.github.com/thlorenz/30bf0a3f67b1d97b2945#patching-and-rebuilding

The functionality was disabled at 
https://github.com/llvm/llvm-project/commit/521c2278abb16f0148cef1bd061cadb01ef43192


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D57689

Files:
  lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp


Index: lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
===================================================================
--- lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
+++ lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
@@ -59,9 +59,12 @@
 
 static constexpr PropertyDefinition g_properties[] = {
     {"enable-jit-breakpoint", OptionValue::eTypeBoolean, true, true, nullptr,
-     {}, "Enable breakpoint on __jit_debug_register_code."}};
+     {}, "Enable breakpoint on __jit_debug_register_code."},
+    {"enable-loader-for-darwin", OptionValue::eTypeBoolean, true, false, 
nullptr,
+     {}, "Enable process loader monitor for macOS - disabled there for "
+     "performance reasons."}};
 
-enum { ePropertyEnableJITBreakpoint };
+enum { ePropertyEnableJITBreakpoint, ePropertyEnableLoaderForDarwin };
 
 class PluginProperties : public Properties {
 public:
@@ -79,6 +82,12 @@
         nullptr, ePropertyEnableJITBreakpoint,
         g_properties[ePropertyEnableJITBreakpoint].default_uint_value != 0);
   }
+
+  bool GetEnableLoaderForDwarwin() const {
+    return m_collection_sp->GetPropertyAtIndexAsBoolean(
+        nullptr, ePropertyEnableLoaderForDarwin,
+        g_properties[ePropertyEnableLoaderForDarwin].default_uint_value != 0);
+  }
 };
 
 typedef std::shared_ptr<PluginProperties> JITLoaderGDBPropertiesSP;
@@ -401,7 +410,8 @@
 JITLoaderSP JITLoaderGDB::CreateInstance(Process *process, bool force) {
   JITLoaderSP jit_loader_sp;
   ArchSpec arch(process->GetTarget().GetArchitecture());
-  if (arch.GetTriple().getVendor() != llvm::Triple::Apple)
+  if (arch.GetTriple().getVendor() != llvm::Triple::Apple ||
+      GetGlobalPluginProperties()->GetEnableLoaderForDwarwin())
     jit_loader_sp.reset(new JITLoaderGDB(process));
   return jit_loader_sp;
 }


Index: lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
===================================================================
--- lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
+++ lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
@@ -59,9 +59,12 @@
 
 static constexpr PropertyDefinition g_properties[] = {
     {"enable-jit-breakpoint", OptionValue::eTypeBoolean, true, true, nullptr,
-     {}, "Enable breakpoint on __jit_debug_register_code."}};
+     {}, "Enable breakpoint on __jit_debug_register_code."},
+    {"enable-loader-for-darwin", OptionValue::eTypeBoolean, true, false, nullptr,
+     {}, "Enable process loader monitor for macOS - disabled there for "
+     "performance reasons."}};
 
-enum { ePropertyEnableJITBreakpoint };
+enum { ePropertyEnableJITBreakpoint, ePropertyEnableLoaderForDarwin };
 
 class PluginProperties : public Properties {
 public:
@@ -79,6 +82,12 @@
         nullptr, ePropertyEnableJITBreakpoint,
         g_properties[ePropertyEnableJITBreakpoint].default_uint_value != 0);
   }
+
+  bool GetEnableLoaderForDwarwin() const {
+    return m_collection_sp->GetPropertyAtIndexAsBoolean(
+        nullptr, ePropertyEnableLoaderForDarwin,
+        g_properties[ePropertyEnableLoaderForDarwin].default_uint_value != 0);
+  }
 };
 
 typedef std::shared_ptr<PluginProperties> JITLoaderGDBPropertiesSP;
@@ -401,7 +410,8 @@
 JITLoaderSP JITLoaderGDB::CreateInstance(Process *process, bool force) {
   JITLoaderSP jit_loader_sp;
   ArchSpec arch(process->GetTarget().GetArchitecture());
-  if (arch.GetTriple().getVendor() != llvm::Triple::Apple)
+  if (arch.GetTriple().getVendor() != llvm::Triple::Apple ||
+      GetGlobalPluginProperties()->GetEnableLoaderForDwarwin())
     jit_loader_sp.reset(new JITLoaderGDB(process));
   return jit_loader_sp;
 }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to