Skip to content

Commit 6ef9c18

Browse files
committed
[lldb] Teach LocateExecutableSymbolFile to look into LOCALBASE on FreeBSD.
Relevant change on the FreeBSD side: https://reviews.freebsd.org/D43515
1 parent 9308d66 commit 6ef9c18

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
#include "llvm/Support/FileSystem.h"
3737
#include "llvm/Support/ThreadPool.h"
3838

39+
#if defined(__FreeBSD__)
40+
#include <sys/sysctl.h>
41+
#endif
42+
3943
// From MacOSX system header "mach/machine.h"
4044
typedef int cpu_type_t;
4145
typedef int cpu_subtype_t;
@@ -141,6 +145,24 @@ std::optional<FileSpec> SymbolLocatorDefault::LocateExecutableSymbolFile(
141145
FileSystem::Instance().Resolve(file_spec);
142146
debug_file_search_paths.AppendIfUnique(file_spec);
143147
}
148+
#if defined(__FreeBSD__)
149+
// Add $LOCALBASE/lib/debug directory, where
150+
// LOCALBASE is usually /usr/local, but may be adjusted by the end user
151+
{
152+
int mib[2];
153+
char buf[PATH_MAX];
154+
size_t len = PATH_MAX;
155+
156+
mib[0] = CTL_USER;
157+
mib[1] = USER_LOCALBASE;
158+
if (::sysctl(mib, 2, buf, &len, NULL, 0) == 0) {
159+
std::string localbase(buf);
160+
FileSpec file_spec(localbase + "/lib/debug");
161+
FileSystem::Instance().Resolve(file_spec);
162+
debug_file_search_paths.AppendIfUnique(file_spec);
163+
}
164+
}
165+
#endif // __FreeBSD__
144166
#endif
145167
#endif // _WIN32
146168
}

0 commit comments

Comments
 (0)