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

via lldb-commits lldb-commits at lists.llvm.org
Wed May 1 07:18:59 PDT 2024


Author: Gleb Popov
Date: 2024-05-01T10:18:55-04:00
New Revision: f07a2edc64650f44bc592d74bb4c99ddde3772d3

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

LOG: [lldb] Teach LocateExecutableSymbolFile to look into LOCALBASE on FreeBSD (#81355)

FreeBSD ports will now install debuginfo under $LOCALBASE/lib/debug/, where $LOCALBASE is typically /usr/local. On FreeBSD search this path in addition to existing debug info paths.

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

Added: 
    

Modified: 
    lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp b/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp
index 6f0126b16cdc00..edb1d59cf42f88 100644
--- a/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp
+++ b/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp
@@ -36,6 +36,10 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/ThreadPool.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;
@@ -141,6 +145,24 @@ std::optional<FileSpec> SymbolLocatorDefault::LocateExecutableSymbolFile(
       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) {
+        FileSpec file_spec("/lib/debug");
+        file_spec.PrependPathComponent(StringRef(buf));
+        FileSystem::Instance().Resolve(file_spec);
+        debug_file_search_paths.AppendIfUnique(file_spec);
+      }
+    }
+#endif // __FreeBSD__
 #endif
 #endif // _WIN32
   }


        


More information about the lldb-commits mailing list