[Lldb-commits] [lldb] [lldb] Teach LocateExecutableSymbolFile to look into LOCALBASE on FreeBSD (PR #81355)
Gleb Popov via lldb-commits
lldb-commits at lists.llvm.org
Sat Feb 10 03:25:15 PST 2024
https://github.com/arrowd updated https://github.com/llvm/llvm-project/pull/81355
>From 6ef9c188bbfdb3fa9301060c2d8730b1099f5209 Mon Sep 17 00:00:00 2001
From: Gleb Popov <6yearold at gmail.com>
Date: Sat, 10 Feb 2024 14:15:49 +0300
Subject: [PATCH] [lldb] Teach LocateExecutableSymbolFile to look into
LOCALBASE on FreeBSD.
Relevant change on the FreeBSD side: https://reviews.freebsd.org/D43515
---
.../Default/SymbolLocatorDefault.cpp | 22 +++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp b/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp
index 6f0126b16cdc00..ce770c8ce7c6e3 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) {
+ 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
}
More information about the lldb-commits
mailing list