Skip to content

Commit f07a2ed

Browse files
authored
[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
1 parent cfca977 commit f07a2ed

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 LOCALBASE is
150+
// 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+
FileSpec file_spec("/lib/debug");
160+
file_spec.PrependPathComponent(StringRef(buf));
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)