35#include "llvm/ADT/SmallSet.h"
36#include "llvm/Support/FileSystem.h"
37#include "llvm/Support/ThreadPool.h"
39#if defined(__FreeBSD__)
40#include <sys/sysctl.h>
66 return "Default symbol locator.";
79 "LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)",
103 return symbol_file_spec;
106 "Locating external symbol file",
109 FileSpecList debug_file_search_paths = default_search_paths;
134#if defined(__NetBSD__)
137 FileSpec file_spec(
"/usr/libdata/debug");
144 FileSpec file_spec(
"/usr/lib/debug");
148#if defined(__FreeBSD__)
157 mib[1] = USER_LOCALBASE;
158 if (::sysctl(mib, 2, buf, &len, NULL, 0) == 0) {
170 std::string uuid_str;
176 std::transform(uuid_str.begin(), uuid_str.end(), uuid_str.begin(),
178 uuid_str.insert(2, 1,
'/');
179 uuid_str = uuid_str +
".debug";
182 size_t num_directories = debug_file_search_paths.
GetSize();
183 for (
size_t idx = 0; idx < num_directories; ++idx) {
189 std::vector<std::string> files;
190 std::string dirname = dirspec.
GetPath();
192 if (!uuid_str.empty())
193 files.push_back(dirname +
"/.build-id/" + uuid_str);
195 files.push_back(dirname +
"/" +
197 files.push_back(dirname +
"/.debug/" +
203 files.push_back(dirname + file_dir.
AsCString() +
"/" +
207 const uint32_t num_files = files.size();
208 for (
size_t idx_file = 0; idx_file < num_files; ++idx_file) {
209 const std::string &filename = files[idx_file];
213 if (llvm::sys::fs::equivalent(file_spec.
GetPath(),
219 const size_t num_specs =
222 bool valid_mspec =
false;
223 if (num_specs == 2) {
234 assert(num_specs <= 1 &&
235 "Symbol Vendor supports only a single architecture");
236 if (num_specs == 1) {
259 bool copy_executable) {
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_PLUGIN_DEFINE(PluginName)
#define LLDB_SCOPED_TIMERF(...)
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
bool IsEmpty() const
Test for empty string.
const char * GetCString() const
Get the string value as a C string.
const FileSpec & GetFileSpecAtIndex(size_t idx) const
Get file at index.
size_t GetSize() const
Get the number of files in the file list.
bool AppendIfUnique(const FileSpec &file)
Append a FileSpec object if unique.
const ConstString & GetFilename() const
Filename string const get accessor.
const ConstString & GetDirectory() const
Directory string const get accessor.
bool IsAbsolute() const
Returns true if the filespec represents an absolute path.
void PrependPathComponent(llvm::StringRef component)
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
Status ResolveSymbolicLink(const FileSpec &src, FileSpec &dst)
bool Exists(const FileSpec &file_spec) const
Returns whether the given file exists.
static FileSystem & Instance()
static ModuleListProperties & GetGlobalModuleListProperties()
bool GetModuleSpecAtIndex(size_t i, ModuleSpec &module_spec) const
bool FindMatchingModuleSpec(const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const
ArchSpec & GetArchitecture()
FileSpec & GetSymbolFileSpec()
ArchSpec * GetArchitecturePtr()
static size_t GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset, lldb::offset_t file_size, ModuleSpecList &specs, lldb::DataBufferSP data_sp=lldb::DataBufferSP())
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A Progress indicator helper class.
static llvm::StringRef GetPluginNameStatic()
static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec, Status &error, bool force_lookup, bool copy_executable)
static llvm::StringRef GetPluginDescriptionStatic()
static std::optional< FileSpec > LocateExecutableSymbolFile(const ModuleSpec &module_spec, const FileSpecList &default_search_paths)
static std::optional< ModuleSpec > LocateExecutableObjectFile(const ModuleSpec &module_spec)
static lldb_private::SymbolLocator * CreateInstance()
std::string GetAsString(llvm::StringRef separator="-") const
A class that represents a running process on the host machine.