27#include "llvm/ADT/SmallSet.h"
28#include "llvm/Support/FileSystem.h"
29#include "llvm/Support/ThreadPool.h"
60 for (
size_t i = 0; i < module_specs.
GetSize(); ++i) {
86 FileSpec dsym_directory = exec_fspec;
89 std::string dsym_filename = filename.
AsCString();
90 dsym_filename +=
".dSYM";
100 dsym_fspec = dsym_directory;
112 std::string binary_name(filename.
AsCString());
113 auto last_dot = binary_name.find_last_of(
'.');
114 if (last_dot != std::string::npos) {
115 binary_name.erase(last_dot);
116 dsym_fspec = dsym_directory;
128 FileSpec dsym_yaa_fspec = exec_fspec;
130 std::string dsym_yaa_filename = filename.
AsCString();
131 dsym_yaa_filename +=
".dSYM.yaa";
167 LLDB_LOGF(log,
"dSYM with matching UUID & arch found at %s",
189 for (
int i = 0; i < 4; i++) {
195 if (::strchr(fn,
'.') !=
nullptr) {
199 LLDB_LOGF(log,
"dSYM with matching UUID & arch found at %s",
219 "LocateExecutableSymbolFileDsym (file = %s, arch = %s, uuid = %p)",
243 "LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)",
268 return symbol_file_spec;
271 "Locating external symbol file for {0}",
274 FileSpecList debug_file_search_paths = default_search_paths;
299#if defined(__NetBSD__)
302 FileSpec file_spec(
"/usr/libdata/debug");
309 FileSpec file_spec(
"/usr/lib/debug");
317 std::string uuid_str;
323 std::transform(uuid_str.begin(), uuid_str.end(), uuid_str.begin(),
325 uuid_str.insert(2, 1,
'/');
326 uuid_str = uuid_str +
".debug";
329 size_t num_directories = debug_file_search_paths.
GetSize();
330 for (
size_t idx = 0; idx < num_directories; ++idx) {
336 std::vector<std::string> files;
337 std::string dirname = dirspec.
GetPath();
339 if (!uuid_str.empty())
340 files.push_back(dirname +
"/.build-id/" + uuid_str);
342 files.push_back(dirname +
"/" +
344 files.push_back(dirname +
"/.debug/" +
350 files.push_back(dirname + file_dir.
AsCString() +
"/" +
354 const uint32_t num_files = files.size();
355 for (
size_t idx_file = 0; idx_file < num_files; ++idx_file) {
356 const std::string &filename = files[idx_file];
360 if (llvm::sys::fs::equivalent(file_spec.
GetPath(),
366 const size_t num_specs =
369 bool valid_mspec =
false;
370 if (num_specs == 2) {
381 assert(num_specs <= 1 &&
382 "Symbol Vendor supports only a single architecture");
383 if (num_specs == 1) {
407 static llvm::SmallSet<UUID, 8> g_seen_uuids;
408 static std::mutex g_mutex;
411 std::lock_guard<std::mutex> guard(g_mutex);
412 if (g_seen_uuids.count(uuid))
414 g_seen_uuids.insert(uuid);
432#if !defined(__APPLE__)
443 bool copy_executable) {
static llvm::raw_ostream & error(Stream &strm)
int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec, ModuleSpec &return_module_spec)
static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec, FileSpec &dsym_fspec)
static FileSpec LocateExecutableSymbolFileDsym(const ModuleSpec &module_spec)
static bool FileAtPathContainsArchAndUUID(const FileSpec &file_fspec, const ArchSpec *arch, const lldb_private::UUID *uuid)
static bool LookForDsymNextToExecutablePath(const ModuleSpec &mod_spec, const FileSpec &exec_fspec, FileSpec &dsym_fspec)
#define LLDB_LOGF(log,...)
#define LLDB_SCOPED_TIMERF(...)
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool IsCompatibleMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, CompatibleMatch).
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.
static llvm::ThreadPool & GetThreadPool()
Shared thread poll. Use only with ThreadPoolTaskGroup.
static void ReportSymbolChange(const ModuleSpec &module_spec)
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.
void AppendPathComponent(llvm::StringRef component)
const ConstString & GetFilename() const
Filename string const get accessor.
bool RemoveLastPathComponent()
Removes the last path component by replacing the current path with its parent.
const ConstString & GetDirectory() const
Directory string const get accessor.
bool IsAbsolute() const
Returns true if the filespec represents an absolute path.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void Clear()
Clears the object state.
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 * GetFileSpecPtr()
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())
A Progress indicator helper class.
static void DownloadSymbolFileAsync(const UUID &uuid)
Locate the symbol file for the given UUID on a background thread.
static FileSpec LocateExecutableSymbolFile(const ModuleSpec &module_spec, const FileSpecList &default_search_paths)
static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec, Status &error, bool force_lookup=true, bool copy_executable=true)
static ModuleSpec LocateExecutableObjectFile(const ModuleSpec &module_spec)
static FileSpec FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec, const lldb_private::UUID *uuid, const ArchSpec *arch)
std::string GetAsString(llvm::StringRef separator="-") const
#define UNUSED_IF_ASSERT_DISABLED(x)
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.