llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/187792.diff


3 Files Affected:

- (modified) lldb/include/lldb/Target/Target.h (+2) 
- (modified) lldb/source/Target/Target.cpp (+16-1) 
- (modified) lldb/source/Target/TargetProperties.td (+3) 


``````````diff
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 7907ed2f1a5f6..bbfe27adb1d81 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -278,6 +278,8 @@ class TargetProperties : public Properties {
 
   bool GetDebugUtilityExpression() const;
 
+  bool GetLoadFormattersFromUserBinaries() const;
+
 private:
   std::optional<bool>
   GetExperimentalPropertyValue(size_t prop_idx,
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 296a18f89dba2..3e691bd787833 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -44,6 +44,7 @@
 #include "lldb/Interpreter/Property.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/ObjectFile.h"
+#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Target/ABI.h"
 #include "lldb/Target/ExecutionContext.h"
@@ -1542,6 +1543,13 @@ Module *Target::GetExecutableModulePointer() {
   return GetExecutableModule().get();
 }
 
+static bool IsSystemBinary(const ModuleSP &module_sp) {
+  if (auto *objfile = module_sp->GetObjectFile())
+    if (auto *macho = llvm::dyn_cast<ObjectFileMachO>(objfile))
+      return macho->IsSharedCacheBinary();
+  return false;
+}
+
 static void LoadScriptingResourceForModule(const ModuleSP &module_sp,
                                            Target *target) {
   Status error;
@@ -1861,7 +1869,8 @@ void Target::ModulesDidLoad(ModuleList &module_list) {
       ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
       LoadScriptingResourceForModule(module_sp, this);
       LoadTypeSummariesForModule(module_sp);
-      LoadFormattersForModule(module_sp);
+      if (GetLoadFormattersFromUserBinaries() || IsSystemBinary(module_sp))
+        LoadFormattersForModule(module_sp);
     }
     m_breakpoint_list.UpdateBreakpoints(module_list, true, false);
     m_internal_breakpoint_list.UpdateBreakpoints(module_list, true, false);
@@ -5256,6 +5265,12 @@ void TargetProperties::SetDebugUtilityExpression(bool 
debug) {
   SetPropertyAtIndex(idx, debug);
 }
 
+bool TargetProperties::GetLoadFormattersFromUserBinaries() const {
+  const uint32_t idx = ePropertyLoadFormattersFromUserBinaries;
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
+}
+
 // Target::TargetEventData
 
 Target::TargetEventData::TargetEventData(const lldb::TargetSP &target_sp)
diff --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index 2361314d506ac..15619f036afdb 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -176,6 +176,9 @@ let Definition = "target", Path = "target" in {
   def UseFastStepping: Property<"use-fast-stepping", "Boolean">,
     DefaultTrue,
     Desc<"Use a fast stepping algorithm based on running from branch to branch 
rather than instruction single-stepping.">;
+  def LoadFormattersFromUserBinaries: 
Property<"load-formatters-from-user-binaries", "Boolean">,
+    DefaultTrue,
+    Desc<"Load formatter bytecode embedded in user (non-system) binaries.">;
   def LoadScriptFromSymbolFile: Property<"load-script-from-symbol-file", 
"Enum">,
     DefaultEnumValue<"eLoadScriptFromSymFileWarn">,
     EnumValues<"OptionEnumValues(g_load_script_from_sym_file_values)">,

``````````

</details>


https://github.com/llvm/llvm-project/pull/187792
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to