[Lldb-commits] [PATCH] D57689: Adds property to force enabling of GDB JIT loader for MacOS

Yury Delendik via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 4 14:33:07 PST 2019


yurydelendik updated this revision to Diff 185164.
yurydelendik added a comment.

- Change to on/off/default property.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57689/new/

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
@@ -57,11 +57,29 @@
 
 namespace {
 
+enum EnableJITLoaderGDB {
+  eEnableJITLoaderGDBDefault,
+  eEnableJITLoaderGDBOn,
+  eEnableJITLoaderGDBOff,
+};
+
+static constexpr OptionEnumValueElement g_enable_jit_loader_gdb_enumerators[] = {
+    {eEnableJITLoaderGDBDefault, "default", "Enable JIT compilation interface "
+     "for all platforms except macOS"},
+    {eEnableJITLoaderGDBOn, "on", "Enable JIT compilation interface"},
+    {eEnableJITLoaderGDBOff, "off", "Disable JIT compilation interface"}
+ };
+
 static constexpr PropertyDefinition g_properties[] = {
+    {"enable", OptionValue::eTypeEnum, true,
+     eEnableJITLoaderGDBDefault, nullptr,
+     OptionEnumValues(g_enable_jit_loader_gdb_enumerators),
+     "Enable GDB's JIT compilation interface (default: enabled on "
+     "all platforms except macOS)"},
     {"enable-jit-breakpoint", OptionValue::eTypeBoolean, true, true, nullptr,
      {}, "Enable breakpoint on __jit_debug_register_code."}};
 
-enum { ePropertyEnableJITBreakpoint };
+enum { ePropertyEnable, ePropertyEnableJITBreakpoint };
 
 class PluginProperties : public Properties {
 public:
@@ -79,6 +97,12 @@
         nullptr, ePropertyEnableJITBreakpoint,
         g_properties[ePropertyEnableJITBreakpoint].default_uint_value != 0);
   }
+
+  EnableJITLoaderGDB GetEnable() const {
+    return (EnableJITLoaderGDB)m_collection_sp->GetPropertyAtIndexAsEnumeration(
+        nullptr, ePropertyEnable,
+        g_properties[ePropertyEnable].default_uint_value);
+  }
 };
 
 typedef std::shared_ptr<PluginProperties> JITLoaderGDBPropertiesSP;
@@ -400,8 +424,20 @@
 
 JITLoaderSP JITLoaderGDB::CreateInstance(Process *process, bool force) {
   JITLoaderSP jit_loader_sp;
-  ArchSpec arch(process->GetTarget().GetArchitecture());
-  if (arch.GetTriple().getVendor() != llvm::Triple::Apple)
+  bool enable;
+  switch (GetGlobalPluginProperties()->GetEnable()) {
+    case EnableJITLoaderGDB::eEnableJITLoaderGDBOn:
+      enable = true;
+      break;
+    case EnableJITLoaderGDB::eEnableJITLoaderGDBOff:
+      enable = false;
+      break;
+    case EnableJITLoaderGDB::eEnableJITLoaderGDBDefault:
+      ArchSpec arch(process->GetTarget().GetArchitecture());
+      enable = arch.GetTriple().getVendor() != llvm::Triple::Apple;
+      break;
+  }
+  if (enable)
     jit_loader_sp.reset(new JITLoaderGDB(process));
   return jit_loader_sp;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57689.185164.patch
Type: text/x-patch
Size: 2610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190204/7f2bf773/attachment.bin>


More information about the lldb-commits mailing list