[Lldb-commits] [lldb] [lldb] Teach LocateExecutableSymbolFile to look into LOCALBASE on FreeBSD (PR #81355)

via lldb-commits lldb-commits at lists.llvm.org
Sat Feb 10 03:21:03 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Gleb Popov (arrowd)

<details>
<summary>Changes</summary>

Relevant change on the FreeBSD side: https://reviews.freebsd.org/D43515

@<!-- -->emaste @<!-- -->brooksdavis 

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


1 Files Affected:

- (modified) lldb/source/Symbol/LocateSymbolFile.cpp (+22) 


``````````diff
diff --git a/lldb/source/Symbol/LocateSymbolFile.cpp b/lldb/source/Symbol/LocateSymbolFile.cpp
index 0d0e5300668fc1..4f06518170ffc4 100644
--- a/lldb/source/Symbol/LocateSymbolFile.cpp
+++ b/lldb/source/Symbol/LocateSymbolFile.cpp
@@ -22,6 +22,10 @@
 
 #include "llvm/Support/FileSystem.h"
 
+#if defined(__FreeBSD__)
+#include <sys/sysctl.h>
+#endif
+
 // From MacOSX system header "mach/machine.h"
 typedef int cpu_type_t;
 typedef int cpu_subtype_t;
@@ -300,6 +304,24 @@ Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec,
       FileSystem::Instance().Resolve(file_spec);
       debug_file_search_paths.AppendIfUnique(file_spec);
     }
+#if defined(__FreeBSD__)
+    // Add $LOCALBASE/lib/debug directory, where
+    // LOCALBASE is usually /usr/local, but may be adjusted by the end user
+    {
+      int mib[2];
+      char buf[PATH_MAX];
+      size_t len = PATH_MAX;
+
+      mib[0] = CTL_USER;
+      mib[1] = USER_LOCALBASE;
+      if (::sysctl(mib, 2, buf, &len, NULL, 0) == 0) {
+        std::string localbase(buf);
+        FileSpec file_spec(localbase + "/lib/debug");
+        FileSystem::Instance().Resolve(file_spec);
+        debug_file_search_paths.AppendIfUnique(file_spec);
+      }
+    }
+#endif // __FreeBSD__
 #endif
 #endif // _WIN32
   }

``````````

</details>


https://github.com/llvm/llvm-project/pull/81355


More information about the lldb-commits mailing list