LLDB mainline
SymbolLocatorDebugSymbols.cpp
Go to the documentation of this file.
1//===-- SymbolLocatorDebugSymbols.cpp -------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
12#include "lldb/Core/Debugger.h"
13#include "lldb/Core/Module.h"
17#include "lldb/Core/Progress.h"
18#include "lldb/Core/Section.h"
20#include "lldb/Host/Host.h"
21#include "lldb/Host/HostInfo.h"
23#include "lldb/Target/Target.h"
28#include "lldb/Utility/Log.h"
30#include "lldb/Utility/Timer.h"
31#include "lldb/Utility/UUID.h"
32
33#include "llvm/ADT/SmallSet.h"
34#include "llvm/Support/FileSystem.h"
35#include "llvm/Support/ThreadPool.h"
36
41
42#include "mach/machine.h"
43
44#include <CoreFoundation/CoreFoundation.h>
45
46#include <cstring>
47#include <dirent.h>
48#include <dlfcn.h>
49#include <memory>
50#include <optional>
51#include <pwd.h>
52
53using namespace lldb;
54using namespace lldb_private;
55
56namespace {
57struct DebugSymbolsDylibFunctions {
58 CFURLRef (*DBGCopyFullDSYMURLForUUID)(CFUUIDRef uuid,
59 CFURLRef exec_url) = nullptr;
60 CFDictionaryRef (*DBGCopyDSYMPropertyLists)(CFURLRef dsym_url) = nullptr;
61
62 DebugSymbolsDylibFunctions() {
63 void *handle = dlopen(
64 "/System/Library/PrivateFrameworks/DebugSymbols.framework/DebugSymbols",
65 RTLD_LAZY | RTLD_LOCAL);
66 if (handle) {
67 DBGCopyFullDSYMURLForUUID = (CFURLRef (*)(CFUUIDRef, CFURLRef))dlsym(
68 handle, "DBGCopyFullDSYMURLForUUID");
69 DBGCopyDSYMPropertyLists = (CFDictionaryRef (*)(CFURLRef))dlsym(
70 handle, "DBGCopyDSYMPropertyLists");
71 }
72 }
73
74 /// Returns true if all DebugSymbols functions were found in the framework.
75 bool FoundFunctions() const {
76 return DBGCopyFullDSYMURLForUUID != nullptr &&
77 DBGCopyDSYMPropertyLists != nullptr;
78 }
79};
80} // namespace
81
82static const DebugSymbolsDylibFunctions &GetDebugSymbolsDylibFunctions() {
83 // This is a static local to avoid race conditions.
84 static DebugSymbolsDylibFunctions g_functions;
85 return g_functions;
86}
87
89
91
98
102
104 return "DebugSymbols symbol locator.";
105}
106
110
112 const ModuleSpec &module_spec) {
113 Log *log = GetLog(LLDBLog::Host);
114 if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) {
115 LLDB_LOGF(log, "Spotlight lookup for .dSYM bundles is disabled.");
116 return {};
117 }
118 ModuleSpec return_module_spec;
119 return_module_spec = module_spec;
120 return_module_spec.GetFileSpec().Clear();
121 return_module_spec.GetSymbolFileSpec().Clear();
122
123 const UUID *uuid = module_spec.GetUUIDPtr();
124 const ArchSpec *arch = module_spec.GetArchitecturePtr();
125
126 int items_found = 0;
127
128 const DebugSymbolsDylibFunctions &dylib_functions =
130 if (!dylib_functions.FoundFunctions())
131 return {};
132
133 if (uuid && uuid->IsValid()) {
134 // Try and locate the dSYM file using DebugSymbols first
135 llvm::ArrayRef<uint8_t> module_uuid = uuid->GetBytes();
136 if (module_uuid.size() == 16) {
137 CFCReleaser<CFUUIDRef> module_uuid_ref(::CFUUIDCreateWithBytes(
138 NULL, module_uuid[0], module_uuid[1], module_uuid[2], module_uuid[3],
139 module_uuid[4], module_uuid[5], module_uuid[6], module_uuid[7],
140 module_uuid[8], module_uuid[9], module_uuid[10], module_uuid[11],
141 module_uuid[12], module_uuid[13], module_uuid[14], module_uuid[15]));
142
143 if (module_uuid_ref.get()) {
144 CFCReleaser<CFURLRef> exec_url;
145 const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
146 if (exec_fspec) {
147 char exec_cf_path[PATH_MAX];
148 if (exec_fspec->GetPath(exec_cf_path, sizeof(exec_cf_path)))
149 exec_url.reset(::CFURLCreateFromFileSystemRepresentation(
150 NULL, (const UInt8 *)exec_cf_path, strlen(exec_cf_path),
151 FALSE));
152 }
153
154 CFCReleaser<CFURLRef> dsym_url(
155 dylib_functions.DBGCopyFullDSYMURLForUUID(module_uuid_ref.get(),
156 exec_url.get()));
157 char path[PATH_MAX];
158
159 if (dsym_url.get()) {
160 if (::CFURLGetFileSystemRepresentation(
161 dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
162 LLDB_LOGF(log,
163 "DebugSymbols framework returned dSYM path of %s for "
164 "UUID %s -- looking for the dSYM",
165 path, uuid->GetAsString().c_str());
166 FileSpec dsym_filespec(path);
167 if (path[0] == '~')
168 FileSystem::Instance().Resolve(dsym_filespec);
169
170 if (FileSystem::Instance().IsDirectory(dsym_filespec)) {
172 dsym_filespec, uuid, arch);
173 ++items_found;
174 } else {
175 ++items_found;
176 }
177 return_module_spec.GetSymbolFileSpec() = dsym_filespec;
178 }
179
180 bool success = false;
181 if (log) {
182 if (::CFURLGetFileSystemRepresentation(
183 dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
184 LLDB_LOGF(log,
185 "DebugSymbols framework returned dSYM path of %s for "
186 "UUID %s -- looking for an exec file",
187 path, uuid->GetAsString().c_str());
188 }
189 }
190
192 dylib_functions.DBGCopyDSYMPropertyLists(dsym_url.get()));
193 CFDictionaryRef uuid_dict = NULL;
194 if (dict.get()) {
195 CFCString uuid_cfstr(uuid->GetAsString().c_str());
196 uuid_dict = static_cast<CFDictionaryRef>(
197 ::CFDictionaryGetValue(dict.get(), uuid_cfstr.get()));
198 }
199
200 // Check to see if we have the file on the local filesystem.
201 if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) {
202 ModuleSpec exe_spec;
203 exe_spec.GetFileSpec() = module_spec.GetFileSpec();
204 exe_spec.GetUUID() = module_spec.GetUUID();
205 ModuleSP module_sp;
206 module_sp = std::make_shared<Module>(exe_spec);
207 if (module_sp && module_sp->GetObjectFile() &&
208 module_sp->MatchesModuleSpec(exe_spec)) {
209 success = true;
210 return_module_spec.GetFileSpec() = module_spec.GetFileSpec();
211 LLDB_LOGF(log, "using original binary filepath %s for UUID %s",
212 module_spec.GetFileSpec().GetPath().c_str(),
213 uuid->GetAsString().c_str());
214 ++items_found;
215 }
216 }
217
218 // Check if the requested image is in our shared cache.
219 if (!success) {
220 SymbolSharedCacheUse sc_mode =
223 SharedCacheImageInfo image_info = HostInfo::GetSharedCacheImageInfo(
224 ConstString(module_spec.GetFileSpec().GetPath()), sc_mode);
225
226 // If we found it and it has the correct UUID, let's proceed with
227 // creating a module from the memory contents.
228 if (image_info.GetUUID() &&
229 (!module_spec.GetUUID() ||
230 module_spec.GetUUID() == image_info.GetUUID())) {
231 success = true;
232 return_module_spec.GetFileSpec() = module_spec.GetFileSpec();
233 LLDB_LOGF(log,
234 "using binary from shared cache for filepath %s for "
235 "UUID %s",
236 module_spec.GetFileSpec().GetPath().c_str(),
237 uuid->GetAsString().c_str());
238 ++items_found;
239 }
240 }
241
242 // Use the DBGSymbolRichExecutable filepath if present
243 if (!success && uuid_dict) {
244 CFStringRef exec_cf_path =
245 static_cast<CFStringRef>(::CFDictionaryGetValue(
246 uuid_dict, CFSTR("DBGSymbolRichExecutable")));
247 if (exec_cf_path && ::CFStringGetFileSystemRepresentation(
248 exec_cf_path, path, sizeof(path))) {
249 LLDB_LOGF(log, "plist bundle has exec path of %s for UUID %s",
250 path, uuid->GetAsString().c_str());
251 ++items_found;
252 FileSpec exec_filespec(path);
253 if (path[0] == '~')
254 FileSystem::Instance().Resolve(exec_filespec);
255 if (FileSystem::Instance().Exists(exec_filespec)) {
256 success = true;
257 return_module_spec.GetFileSpec() = exec_filespec;
258 }
259 }
260 }
261
262 // Look next to the dSYM for the binary file.
263 if (!success) {
264 if (::CFURLGetFileSystemRepresentation(
265 dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
266 char *dsym_extension_pos = ::strstr(path, ".dSYM");
267 if (dsym_extension_pos) {
268 *dsym_extension_pos = '\0';
269 LLDB_LOGF(log,
270 "Looking for executable binary next to dSYM "
271 "bundle with name with name %s",
272 path);
273 FileSpec file_spec(path);
274 FileSystem::Instance().Resolve(file_spec);
275 ModuleSpec matched_module_spec;
276 using namespace llvm::sys::fs;
277 switch (get_file_type(file_spec.GetPath())) {
278
279 case file_type::directory_file: // Bundle directory?
280 {
281 CFCBundle bundle(path);
282 CFCReleaser<CFURLRef> bundle_exe_url(
283 bundle.CopyExecutableURL());
284 if (bundle_exe_url.get()) {
285 if (::CFURLGetFileSystemRepresentation(bundle_exe_url.get(),
286 true, (UInt8 *)path,
287 sizeof(path) - 1)) {
288 FileSpec bundle_exe_file_spec(path);
289 FileSystem::Instance().Resolve(bundle_exe_file_spec);
290 if (ModuleSpecList module_specs =
292 bundle_exe_file_spec, 0, 0);
293 module_specs.FindMatchingModuleSpec(
294 module_spec, matched_module_spec)) {
295 ++items_found;
296 return_module_spec.GetFileSpec() = bundle_exe_file_spec;
297 LLDB_LOGF(log,
298 "Executable binary %s next to dSYM is "
299 "compatible; using",
300 path);
301 }
302 }
303 }
304 } break;
305
306 case file_type::fifo_file: // Forget pipes
307 case file_type::socket_file: // We can't process socket files
308 case file_type::file_not_found: // File doesn't exist...
309 case file_type::status_error:
310 break;
311
312 case file_type::type_unknown:
313 case file_type::regular_file:
314 case file_type::symlink_file:
315 case file_type::block_file:
316 case file_type::character_file:
317 if (ModuleSpecList module_specs =
319 module_specs.FindMatchingModuleSpec(
320 module_spec, matched_module_spec)) {
321 ++items_found;
322 return_module_spec.GetFileSpec() = file_spec;
323 LLDB_LOGF(log,
324 "Executable binary %s next to dSYM is "
325 "compatible; using",
326 path);
327 }
328 break;
329 }
330 }
331 }
332 }
333 }
334 }
335 }
336 }
337
338 if (items_found)
339 return return_module_spec;
340
341 return {};
342}
343
345 const FileSpec &dsym_bundle_fspec, const UUID *uuid, const ArchSpec *arch) {
346 std::string dsym_bundle_path = dsym_bundle_fspec.GetPath();
347 llvm::SmallString<128> buffer(dsym_bundle_path);
348 llvm::sys::path::append(buffer, "Contents", "Resources", "DWARF");
349
350 std::error_code EC;
351 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs =
353 llvm::vfs::recursive_directory_iterator Iter(*vfs, buffer.str(), EC);
354 llvm::vfs::recursive_directory_iterator End;
355 for (; Iter != End && !EC; Iter.increment(EC)) {
356 llvm::ErrorOr<llvm::vfs::Status> Status = vfs->status(Iter->path());
357 if (Status->isDirectory())
358 continue;
359
360 FileSpec dsym_fspec(Iter->path());
361 ModuleSpecList module_specs =
362 ObjectFile::GetModuleSpecifications(dsym_fspec, 0, 0);
363 if (module_specs.GetSize() > 0) {
364 ModuleSpec spec;
365 for (size_t i = 0; i < module_specs.GetSize(); ++i) {
366 bool got_spec = module_specs.GetModuleSpecAtIndex(i, spec);
367 assert(got_spec); // The call has side-effects so can't be inlined.
369 if ((uuid == nullptr ||
370 (spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
371 (arch == nullptr ||
372 (spec.GetArchitecturePtr() &&
373 spec.GetArchitecture().IsCompatibleMatch(*arch)))) {
374 return dsym_fspec;
375 }
376 }
377 }
378 }
379
380 return {};
381}
382
383static bool FileAtPathContainsArchAndUUID(const FileSpec &file_fspec,
384 const ArchSpec *arch,
385 const lldb_private::UUID *uuid) {
386 ModuleSpecList module_specs =
387 ObjectFile::GetModuleSpecifications(file_fspec, 0, 0);
388 if (module_specs.GetSize() > 0) {
389 ModuleSpec spec;
390 for (size_t i = 0; i < module_specs.GetSize(); ++i) {
391 bool got_spec = module_specs.GetModuleSpecAtIndex(i, spec);
393 assert(got_spec);
394 if ((uuid == nullptr || (spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
395 (arch == nullptr ||
396 (spec.GetArchitecturePtr() &&
397 spec.GetArchitecture().IsCompatibleMatch(*arch)))) {
398 return true;
399 }
400 }
401 }
402 return false;
403}
404
405// Given a binary exec_fspec, and a ModuleSpec with an architecture/uuid,
406// return true if there is a matching dSYM bundle next to the exec_fspec,
407// and return that value in dsym_fspec.
408// If there is a .dSYM.yaa compressed archive next to the exec_fspec,
409// call through PluginManager::DownloadObjectAndSymbolFile to download the
410// expanded/uncompressed dSYM and return that filepath in dsym_fspec.
411static bool LookForDsymNextToExecutablePath(const ModuleSpec &mod_spec,
412 const FileSpec &exec_fspec,
413 FileSpec &dsym_fspec) {
414 llvm::StringRef filename = exec_fspec.GetFilename();
415 FileSpec dsym_directory = exec_fspec;
416 dsym_directory.RemoveLastPathComponent();
417
418 std::string dsym_filename = filename.str();
419 dsym_filename += ".dSYM";
420 dsym_directory.AppendPathComponent(dsym_filename);
421 dsym_directory.AppendPathComponent("Contents");
422 dsym_directory.AppendPathComponent("Resources");
423 dsym_directory.AppendPathComponent("DWARF");
424
425 if (FileSystem::Instance().Exists(dsym_directory)) {
426
427 // See if the binary name exists in the dSYM DWARF
428 // subdir.
429 dsym_fspec = dsym_directory;
430 dsym_fspec.AppendPathComponent(filename);
431 if (FileSystem::Instance().Exists(dsym_fspec) &&
433 mod_spec.GetUUIDPtr())) {
434 return true;
435 }
436
437 // See if we have "../CF.framework" - so we'll look for
438 // CF.framework.dSYM/Contents/Resources/DWARF/CF
439 // We need to drop the last suffix after '.' to match
440 // 'CF' in the DWARF subdir.
441 std::string binary_name = filename.str();
442 auto last_dot = binary_name.find_last_of('.');
443 if (last_dot != std::string::npos) {
444 binary_name.erase(last_dot);
445 dsym_fspec = dsym_directory;
446 dsym_fspec.AppendPathComponent(binary_name);
447 if (FileSystem::Instance().Exists(dsym_fspec) &&
449 mod_spec.GetArchitecturePtr(),
450 mod_spec.GetUUIDPtr())) {
451 return true;
452 }
453 }
454 }
455
456 // See if we have a .dSYM.yaa next to this executable path.
457 FileSpec dsym_yaa_fspec = exec_fspec;
458 dsym_yaa_fspec.RemoveLastPathComponent();
459 std::string dsym_yaa_filename = filename.str();
460 dsym_yaa_filename += ".dSYM.yaa";
461 dsym_yaa_fspec.AppendPathComponent(dsym_yaa_filename);
462
463 if (FileSystem::Instance().Exists(dsym_yaa_fspec)) {
464 ModuleSpec mutable_mod_spec = mod_spec;
467 true) &&
468 FileSystem::Instance().Exists(mutable_mod_spec.GetSymbolFileSpec())) {
469 dsym_fspec = mutable_mod_spec.GetSymbolFileSpec();
470 return true;
471 }
472 }
473
474 return false;
475}
476
477// Given a ModuleSpec with a FileSpec and optionally uuid/architecture
478// filled in, look for a .dSYM bundle next to that binary. Returns true
479// if a .dSYM bundle is found, and that path is returned in the dsym_fspec
480// FileSpec.
481//
482// This routine looks a few directory layers above the given exec_path -
483// exec_path might be /System/Library/Frameworks/CF.framework/CF and the
484// dSYM might be /System/Library/Frameworks/CF.framework.dSYM.
485//
486// If there is a .dSYM.yaa compressed archive found next to the binary,
487// we'll call DownloadObjectAndSymbolFile to expand it into a plain .dSYM
488static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec,
489 FileSpec &dsym_fspec) {
490 Log *log = GetLog(LLDBLog::Host);
491 const FileSpec &exec_fspec = module_spec.GetFileSpec();
492 if (exec_fspec) {
493 if (::LookForDsymNextToExecutablePath(module_spec, exec_fspec,
494 dsym_fspec)) {
495 LLDB_LOGF(log, "dSYM with matching UUID & arch found at %s",
496 dsym_fspec.GetPath().c_str());
497 return true;
498 } else {
499 FileSpec parent_dirs = exec_fspec;
500
501 // Remove the binary name from the FileSpec
502 parent_dirs.RemoveLastPathComponent();
503
504 // Add a ".dSYM" name to each directory component of the path,
505 // stripping off components. e.g. we may have a binary like
506 // /S/L/F/Foundation.framework/Versions/A/Foundation and
507 // /S/L/F/Foundation.framework.dSYM
508 //
509 // so we'll need to start with
510 // /S/L/F/Foundation.framework/Versions/A, add the .dSYM part to the
511 // "A", and if that doesn't exist, strip off the "A" and try it again
512 // with "Versions", etc., until we find a dSYM bundle or we've
513 // stripped off enough path components that there's no need to
514 // continue.
515
516 for (int i = 0; i < 4; i++) {
517 // Does this part of the path have a "." character - could it be a
518 // bundle's top level directory?
519 llvm::StringRef fn = parent_dirs.GetFilename();
520 if (fn.empty())
521 break;
522 if (fn.contains('.')) {
523 if (::LookForDsymNextToExecutablePath(module_spec, parent_dirs,
524 dsym_fspec)) {
525 LLDB_LOGF(log, "dSYM with matching UUID & arch found at %s",
526 dsym_fspec.GetPath().c_str());
527 return true;
528 }
529 }
530 parent_dirs.RemoveLastPathComponent();
531 }
532 }
533 }
534 dsym_fspec.Clear();
535 return false;
536}
537
538static int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
539 ModuleSpec &return_module_spec) {
540 Log *log = GetLog(LLDBLog::Host);
541 if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) {
542 LLDB_LOGF(log, "Spotlight lookup for .dSYM bundles is disabled.");
543 return 0;
544 }
545
546 return_module_spec = module_spec;
547 return_module_spec.GetFileSpec().Clear();
548 return_module_spec.GetSymbolFileSpec().Clear();
549
550 const UUID *uuid = module_spec.GetUUIDPtr();
551 const ArchSpec *arch = module_spec.GetArchitecturePtr();
552
553 int items_found = 0;
554
555 const DebugSymbolsDylibFunctions &dylib_functions =
557 if (!dylib_functions.FoundFunctions())
558 return items_found;
559
560 if (uuid && uuid->IsValid()) {
561 // Try and locate the dSYM file using DebugSymbols first
562 llvm::ArrayRef<uint8_t> module_uuid = uuid->GetBytes();
563 if (module_uuid.size() == 16) {
564 CFCReleaser<CFUUIDRef> module_uuid_ref(::CFUUIDCreateWithBytes(
565 NULL, module_uuid[0], module_uuid[1], module_uuid[2], module_uuid[3],
566 module_uuid[4], module_uuid[5], module_uuid[6], module_uuid[7],
567 module_uuid[8], module_uuid[9], module_uuid[10], module_uuid[11],
568 module_uuid[12], module_uuid[13], module_uuid[14], module_uuid[15]));
569
570 if (module_uuid_ref.get()) {
571 CFCReleaser<CFURLRef> exec_url;
572 const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
573 if (exec_fspec) {
574 char exec_cf_path[PATH_MAX];
575 if (exec_fspec->GetPath(exec_cf_path, sizeof(exec_cf_path)))
576 exec_url.reset(::CFURLCreateFromFileSystemRepresentation(
577 NULL, (const UInt8 *)exec_cf_path, strlen(exec_cf_path),
578 FALSE));
579 }
580
581 CFCReleaser<CFURLRef> dsym_url(
582 dylib_functions.DBGCopyFullDSYMURLForUUID(module_uuid_ref.get(),
583 exec_url.get()));
584 char path[PATH_MAX];
585
586 if (dsym_url.get()) {
587 if (::CFURLGetFileSystemRepresentation(
588 dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
589 LLDB_LOGF(log,
590 "DebugSymbols framework returned dSYM path of %s for "
591 "UUID %s -- looking for the dSYM",
592 path, uuid->GetAsString().c_str());
593 FileSpec dsym_filespec(path);
594 if (path[0] == '~')
595 FileSystem::Instance().Resolve(dsym_filespec);
596
597 if (FileSystem::Instance().IsDirectory(dsym_filespec)) {
599 dsym_filespec, uuid, arch);
600 ++items_found;
601 } else {
602 ++items_found;
603 }
604 return_module_spec.GetSymbolFileSpec() = dsym_filespec;
605 }
606
607 bool success = false;
608 if (log) {
609 if (::CFURLGetFileSystemRepresentation(
610 dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
611 LLDB_LOGF(log,
612 "DebugSymbols framework returned dSYM path of %s for "
613 "UUID %s -- looking for an exec file",
614 path, uuid->GetAsString().c_str());
615 }
616 }
617
619 dylib_functions.DBGCopyDSYMPropertyLists(dsym_url.get()));
620 CFDictionaryRef uuid_dict = NULL;
621 if (dict.get()) {
622 CFCString uuid_cfstr(uuid->GetAsString().c_str());
623 uuid_dict = static_cast<CFDictionaryRef>(
624 ::CFDictionaryGetValue(dict.get(), uuid_cfstr.get()));
625 }
626
627 // Check to see if we have the file on the local filesystem.
628 if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) {
629 ModuleSpec exe_spec;
630 exe_spec.GetFileSpec() = module_spec.GetFileSpec();
631 exe_spec.GetUUID() = module_spec.GetUUID();
632 ModuleSP module_sp;
633 module_sp = std::make_shared<Module>(exe_spec);
634 if (module_sp && module_sp->GetObjectFile() &&
635 module_sp->MatchesModuleSpec(exe_spec)) {
636 success = true;
637 return_module_spec.GetFileSpec() = module_spec.GetFileSpec();
638 LLDB_LOGF(log, "using original binary filepath %s for UUID %s",
639 module_spec.GetFileSpec().GetPath().c_str(),
640 uuid->GetAsString().c_str());
641 ++items_found;
642 }
643 }
644
645 // Check if the requested image is in our shared cache.
646 if (!success) {
647 SymbolSharedCacheUse sc_mode =
650 SharedCacheImageInfo image_info = HostInfo::GetSharedCacheImageInfo(
651 ConstString(module_spec.GetFileSpec().GetPath()), sc_mode);
652
653 // If we found it and it has the correct UUID, let's proceed with
654 // creating a module from the memory contents.
655 if (image_info.GetUUID() &&
656 (!module_spec.GetUUID() ||
657 module_spec.GetUUID() == image_info.GetUUID())) {
658 success = true;
659 return_module_spec.GetFileSpec() = module_spec.GetFileSpec();
660 LLDB_LOGF(log,
661 "using binary from shared cache for filepath %s for "
662 "UUID %s",
663 module_spec.GetFileSpec().GetPath().c_str(),
664 uuid->GetAsString().c_str());
665 ++items_found;
666 }
667 }
668
669 // Use the DBGSymbolRichExecutable filepath if present
670 if (!success && uuid_dict) {
671 CFStringRef exec_cf_path =
672 static_cast<CFStringRef>(::CFDictionaryGetValue(
673 uuid_dict, CFSTR("DBGSymbolRichExecutable")));
674 if (exec_cf_path && ::CFStringGetFileSystemRepresentation(
675 exec_cf_path, path, sizeof(path))) {
676 LLDB_LOGF(log, "plist bundle has exec path of %s for UUID %s",
677 path, uuid->GetAsString().c_str());
678 ++items_found;
679 FileSpec exec_filespec(path);
680 if (path[0] == '~')
681 FileSystem::Instance().Resolve(exec_filespec);
682 if (FileSystem::Instance().Exists(exec_filespec)) {
683 success = true;
684 return_module_spec.GetFileSpec() = exec_filespec;
685 }
686 }
687 }
688
689 // Look next to the dSYM for the binary file.
690 if (!success) {
691 if (::CFURLGetFileSystemRepresentation(
692 dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
693 char *dsym_extension_pos = ::strstr(path, ".dSYM");
694 if (dsym_extension_pos) {
695 *dsym_extension_pos = '\0';
696 LLDB_LOGF(log,
697 "Looking for executable binary next to dSYM "
698 "bundle with name with name %s",
699 path);
700 FileSpec file_spec(path);
701 FileSystem::Instance().Resolve(file_spec);
702 ModuleSpec matched_module_spec;
703 using namespace llvm::sys::fs;
704 switch (get_file_type(file_spec.GetPath())) {
705
706 case file_type::directory_file: // Bundle directory?
707 {
708 CFCBundle bundle(path);
709 CFCReleaser<CFURLRef> bundle_exe_url(
710 bundle.CopyExecutableURL());
711 if (bundle_exe_url.get()) {
712 if (::CFURLGetFileSystemRepresentation(bundle_exe_url.get(),
713 true, (UInt8 *)path,
714 sizeof(path) - 1)) {
715 FileSpec bundle_exe_file_spec(path);
716 FileSystem::Instance().Resolve(bundle_exe_file_spec);
717 if (ModuleSpecList module_specs =
719 bundle_exe_file_spec, 0, 0);
720 module_specs.FindMatchingModuleSpec(
721 module_spec, matched_module_spec)) {
722 ++items_found;
723 return_module_spec.GetFileSpec() = bundle_exe_file_spec;
724 LLDB_LOGF(log,
725 "Executable binary %s next to dSYM is "
726 "compatible; using",
727 path);
728 }
729 }
730 }
731 } break;
732
733 case file_type::fifo_file: // Forget pipes
734 case file_type::socket_file: // We can't process socket files
735 case file_type::file_not_found: // File doesn't exist...
736 case file_type::status_error:
737 break;
738
739 case file_type::type_unknown:
740 case file_type::regular_file:
741 case file_type::symlink_file:
742 case file_type::block_file:
743 case file_type::character_file:
744 if (ModuleSpecList module_specs =
746 module_specs.FindMatchingModuleSpec(
747 module_spec, matched_module_spec)) {
748 ++items_found;
749 return_module_spec.GetFileSpec() = file_spec;
750 LLDB_LOGF(log,
751 "Executable binary %s next to dSYM is "
752 "compatible; using",
753 path);
754 }
755 break;
756 }
757 }
758 }
759 }
760 }
761 }
762 }
763 }
764
765 return items_found;
766}
767
769 const ModuleSpec &module_spec, const FileSpecList &default_search_paths) {
770 const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
771 const ArchSpec *arch = module_spec.GetArchitecturePtr();
772 const UUID *uuid = module_spec.GetUUIDPtr();
773
775 "LocateExecutableSymbolFileDsym (file = %s, arch = %s, uuid = %p)",
776 exec_fspec ? exec_fspec->GetFilename().nonEmptyOr("<NULL>").str().c_str()
777 : "<NULL>",
778 arch ? arch->GetArchitectureName() : "<NULL>", (const void *)uuid);
779
780 Progress progress(
781 "Locating external symbol file",
782 module_spec.GetFileSpec().GetFilename().nonEmptyOr("<Unknown>").str());
783
784 FileSpec symbol_fspec;
785 ModuleSpec dsym_module_spec;
786 // First try and find the dSYM in the same directory as the executable or in
787 // an appropriate parent directory
788 if (!LocateDSYMInVincinityOfExecutable(module_spec, symbol_fspec)) {
789 // We failed to easily find the dSYM above, so use DebugSymbols
790 LocateMacOSXFilesUsingDebugSymbols(module_spec, dsym_module_spec);
791 } else {
792 dsym_module_spec.GetSymbolFileSpec() = symbol_fspec;
793 }
794
795 return dsym_module_spec.GetSymbolFileSpec();
796}
797
798static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict,
799 ModuleSpec &module_spec,
800 Status &error,
801 const std::string &command) {
802 Log *log = GetLog(LLDBLog::Host);
803 bool success = false;
804 if (uuid_dict != NULL && CFGetTypeID(uuid_dict) == CFDictionaryGetTypeID()) {
805 std::string str;
806 CFStringRef cf_str;
807 CFDictionaryRef cf_dict;
808
809 cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
810 CFSTR("DBGError"));
811 if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
812 if (CFCString::FileSystemRepresentation(cf_str, str)) {
813 std::string errorstr = command;
814 errorstr += ":\n";
815 errorstr += str;
816 error = Status(errorstr);
817 }
818 }
819
820 cf_str = (CFStringRef)CFDictionaryGetValue(
821 (CFDictionaryRef)uuid_dict, CFSTR("DBGSymbolRichExecutable"));
822 if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
823 if (CFCString::FileSystemRepresentation(cf_str, str)) {
824 module_spec.GetFileSpec().SetFile(str.c_str(), FileSpec::Style::native);
826 LLDB_LOGF(log,
827 "From dsymForUUID plist: Symbol rich executable is at '%s'",
828 str.c_str());
829 }
830 }
831
832 cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
833 CFSTR("DBGDSYMPath"));
834 if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
835 if (CFCString::FileSystemRepresentation(cf_str, str)) {
836 module_spec.GetSymbolFileSpec().SetFile(str.c_str(),
837 FileSpec::Style::native);
839 success = true;
840 LLDB_LOGF(log, "From dsymForUUID plist: dSYM is at '%s'", str.c_str());
841 }
842 }
843
844 std::string DBGBuildSourcePath;
845 std::string DBGSourcePath;
846
847 // If DBGVersion 1 or DBGVersion missing, ignore DBGSourcePathRemapping.
848 // If DBGVersion 2, strip last two components of path remappings from
849 // entries to fix an issue with a specific set of
850 // DBGSourcePathRemapping entries that lldb worked
851 // with.
852 // If DBGVersion 3, trust & use the source path remappings as-is.
853 //
854 cf_dict = (CFDictionaryRef)CFDictionaryGetValue(
855 (CFDictionaryRef)uuid_dict, CFSTR("DBGSourcePathRemapping"));
856 if (cf_dict && CFGetTypeID(cf_dict) == CFDictionaryGetTypeID()) {
857 // If we see DBGVersion with a value of 2 or higher, this is a new style
858 // DBGSourcePathRemapping dictionary
859 bool new_style_source_remapping_dictionary = false;
860 bool do_truncate_remapping_names = false;
861 std::string original_DBGSourcePath_value = DBGSourcePath;
862 cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
863 CFSTR("DBGVersion"));
864 if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
865 std::string version;
867 if (!version.empty() && isdigit(version[0])) {
868 int version_number = atoi(version.c_str());
869 if (version_number > 1) {
870 new_style_source_remapping_dictionary = true;
871 }
872 if (version_number == 2) {
873 do_truncate_remapping_names = true;
874 }
875 }
876 }
877
878 CFIndex kv_pair_count = CFDictionaryGetCount((CFDictionaryRef)uuid_dict);
879 if (kv_pair_count > 0) {
880 CFStringRef *keys =
881 (CFStringRef *)malloc(kv_pair_count * sizeof(CFStringRef));
882 CFStringRef *values =
883 (CFStringRef *)malloc(kv_pair_count * sizeof(CFStringRef));
884 if (keys != nullptr && values != nullptr) {
885 CFDictionaryGetKeysAndValues((CFDictionaryRef)uuid_dict,
886 (const void **)keys,
887 (const void **)values);
888 }
889 for (CFIndex i = 0; i < kv_pair_count; i++) {
890 DBGBuildSourcePath.clear();
891 DBGSourcePath.clear();
892 if (keys[i] && CFGetTypeID(keys[i]) == CFStringGetTypeID()) {
893 CFCString::FileSystemRepresentation(keys[i], DBGBuildSourcePath);
894 }
895 if (values[i] && CFGetTypeID(values[i]) == CFStringGetTypeID()) {
896 CFCString::FileSystemRepresentation(values[i], DBGSourcePath);
897 }
898 if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty()) {
899 // In the "old style" DBGSourcePathRemapping dictionary, the
900 // DBGSourcePath values (the "values" half of key-value path pairs)
901 // were wrong. Ignore them and use the universal DBGSourcePath
902 // string from earlier.
903 if (new_style_source_remapping_dictionary &&
904 !original_DBGSourcePath_value.empty()) {
905 DBGSourcePath = original_DBGSourcePath_value;
906 }
907 if (DBGSourcePath[0] == '~') {
908 FileSpec resolved_source_path(DBGSourcePath.c_str());
909 FileSystem::Instance().Resolve(resolved_source_path);
910 DBGSourcePath = resolved_source_path.GetPath();
911 }
912 // With version 2 of DBGSourcePathRemapping, we can chop off the
913 // last two filename parts from the source remapping and get a more
914 // general source remapping that still works. Add this as another
915 // option in addition to the full source path remap.
916 module_spec.GetSourceMappingList().Append(DBGBuildSourcePath,
917 DBGSourcePath, true);
918 if (do_truncate_remapping_names) {
919 FileSpec build_path(DBGBuildSourcePath.c_str());
920 FileSpec source_path(DBGSourcePath.c_str());
921 build_path.RemoveLastPathComponent();
922 build_path.RemoveLastPathComponent();
923 source_path.RemoveLastPathComponent();
924 source_path.RemoveLastPathComponent();
925 module_spec.GetSourceMappingList().Append(
926 build_path.GetPath(), source_path.GetPath(), true);
927 }
928 }
929 }
930 if (keys)
931 free(keys);
932 if (values)
933 free(values);
934 }
935 }
936
937 // If we have a DBGBuildSourcePath + DBGSourcePath pair, append them to the
938 // source remappings list.
939
940 cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
941 CFSTR("DBGBuildSourcePath"));
942 if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
943 CFCString::FileSystemRepresentation(cf_str, DBGBuildSourcePath);
944 }
945
946 cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
947 CFSTR("DBGSourcePath"));
948 if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
949 CFCString::FileSystemRepresentation(cf_str, DBGSourcePath);
950 }
951
952 if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty()) {
953 if (DBGSourcePath[0] == '~') {
954 FileSpec resolved_source_path(DBGSourcePath.c_str());
955 FileSystem::Instance().Resolve(resolved_source_path);
956 DBGSourcePath = resolved_source_path.GetPath();
957 }
958 module_spec.GetSourceMappingList().Append(DBGBuildSourcePath,
959 DBGSourcePath, true);
960 }
961 }
962 return success;
963}
964
965/// It's expensive to check for the DBGShellCommands defaults setting. Only do
966/// it once per lldb run and cache the result.
967static llvm::StringRef GetDbgShellCommand() {
968 static std::once_flag g_once_flag;
969 static std::string g_dbgshell_command;
970 std::call_once(g_once_flag, [&]() {
971 CFTypeRef defaults_setting = CFPreferencesCopyAppValue(
972 CFSTR("DBGShellCommands"), CFSTR("com.apple.DebugSymbols"));
973 if (defaults_setting &&
974 CFGetTypeID(defaults_setting) == CFStringGetTypeID()) {
975 char buffer[PATH_MAX];
976 if (CFStringGetCString((CFStringRef)defaults_setting, buffer,
977 sizeof(buffer), kCFStringEncodingUTF8)) {
978 g_dbgshell_command = buffer;
979 }
980 }
981 if (defaults_setting) {
982 CFRelease(defaults_setting);
983 }
984 });
985 return g_dbgshell_command;
986}
987
988/// Get the dsymForUUID executable and cache the result so we don't end up
989/// stat'ing the binary over and over.
991 // The LLDB_APPLE_DSYMFORUUID_EXECUTABLE environment variable is used by the
992 // test suite to override the dsymForUUID location. Because we must be able
993 // to change the value within a single test, don't bother caching it.
994 if (const char *dsymForUUID_env =
995 getenv("LLDB_APPLE_DSYMFORUUID_EXECUTABLE")) {
996 FileSpec dsymForUUID_executable(dsymForUUID_env);
997 FileSystem::Instance().Resolve(dsymForUUID_executable);
998 if (FileSystem::Instance().Exists(dsymForUUID_executable))
999 return dsymForUUID_executable;
1000 }
1001
1002 static std::once_flag g_once_flag;
1003 static FileSpec g_dsymForUUID_executable;
1004 std::call_once(g_once_flag, [&]() {
1005 // Try the DBGShellCommand.
1006 llvm::StringRef dbgshell_command = GetDbgShellCommand();
1007 if (!dbgshell_command.empty()) {
1008 g_dsymForUUID_executable = FileSpec(dbgshell_command);
1009 FileSystem::Instance().Resolve(g_dsymForUUID_executable);
1010 if (FileSystem::Instance().Exists(g_dsymForUUID_executable))
1011 return;
1012 }
1013
1014 // Try dsymForUUID in /usr/local/bin
1015 {
1016 g_dsymForUUID_executable = FileSpec("/usr/local/bin/dsymForUUID");
1017 if (FileSystem::Instance().Exists(g_dsymForUUID_executable))
1018 return;
1019 }
1020
1021 // We couldn't find the dsymForUUID binary.
1022 g_dsymForUUID_executable = {};
1023 });
1024 return g_dsymForUUID_executable;
1025}
1026
1028 ModuleSpec &module_spec, Status &error, bool force_lookup,
1029 bool copy_executable) {
1030 const UUID *uuid_ptr = module_spec.GetUUIDPtr();
1031 const FileSpec *file_spec_ptr = module_spec.GetFileSpecPtr();
1032
1033 // If \a dbgshell_command is set, the user has specified
1034 // forced symbol lookup via that command. We'll get the
1035 // path back from GetDsymForUUIDExecutable() later.
1036 llvm::StringRef dbgshell_command = GetDbgShellCommand();
1037
1038 // If forced lookup isn't set, by the user's \a dbgshell_command or
1039 // by the \a force_lookup argument, exit this method.
1040 if (!force_lookup && dbgshell_command.empty())
1041 return false;
1042
1043 // We need a UUID or valid existing FileSpec.
1044 if (!uuid_ptr &&
1045 (!file_spec_ptr || !FileSystem::Instance().Exists(*file_spec_ptr)))
1046 return false;
1047
1048 // We need a dsymForUUID binary or an equivalent executable/script.
1049 FileSpec dsymForUUID_exe_spec = GetDsymForUUIDExecutable();
1050 if (!dsymForUUID_exe_spec)
1051 return false;
1052
1053 // Create the dsymForUUID command.
1054 const std::string dsymForUUID_exe_path = dsymForUUID_exe_spec.GetPath();
1055 const std::string uuid_str = uuid_ptr ? uuid_ptr->GetAsString() : "";
1056
1057 std::string lookup_arg = uuid_str;
1058 if (lookup_arg.empty())
1059 lookup_arg = file_spec_ptr ? file_spec_ptr->GetPath() : "";
1060 if (lookup_arg.empty())
1061 return false;
1062
1063 StreamString command;
1064 command << dsymForUUID_exe_path << " --ignoreNegativeCache ";
1065 if (copy_executable)
1066 command << "--copyExecutable ";
1067 command << lookup_arg;
1068
1069 // Log and report progress.
1070 std::string lookup_desc;
1071 if (uuid_ptr && file_spec_ptr)
1072 lookup_desc = llvm::formatv("{0} ({1})", file_spec_ptr->GetFilename(),
1073 uuid_ptr->GetAsString());
1074 else if (uuid_ptr)
1075 lookup_desc = uuid_ptr->GetAsString();
1076 else if (file_spec_ptr)
1077 lookup_desc = file_spec_ptr->GetFilename().str();
1078
1079 Log *log = GetLog(LLDBLog::Host);
1080 LLDB_LOG(log, "Calling {0} for {1} to find dSYM: {2}", dsymForUUID_exe_path,
1081 lookup_desc, command.GetString());
1082
1083 Progress progress("Downloading symbol file for", lookup_desc);
1084
1085 // Invoke dsymForUUID.
1086 int exit_status = -1;
1087 int signo = -1;
1088 std::string command_output;
1089 std::string error_output;
1091 command.GetData(),
1092 FileSpec(), // current working directory
1093 &exit_status, // Exit status
1094 &signo, // Signal int *
1095 &command_output, // Command output
1096 &error_output, // Command error output
1097 std::chrono::seconds(
1098 640), // Large timeout to allow for long dsym download times
1099 false); // Don't run in a shell (we don't need shell expansion)
1100
1101 if (error.Fail() || exit_status != 0 || command_output.empty()) {
1102 LLDB_LOGF(log,
1103 "'%s' failed (exit status: %d, error: '%s', stdout: '%s', "
1104 "stderr: '%s')",
1105 command.GetData(), exit_status, error.AsCString(),
1106 command_output.c_str(), error_output.c_str());
1107 return false;
1108 }
1109
1110 CFCData data(
1111 CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)command_output.data(),
1112 command_output.size(), kCFAllocatorNull));
1113
1115 (CFDictionaryRef)::CFPropertyListCreateWithData(
1116 NULL, data.get(), kCFPropertyListImmutable, NULL, NULL));
1117
1118 if (!plist.get()) {
1119 LLDB_LOGF(log, "'%s' failed: output is not a valid plist",
1120 command.GetData());
1121 LLDB_LOGF(log, "Response:\n%s\n", command_output.c_str());
1122 return false;
1123 }
1124
1125 if (CFGetTypeID(plist.get()) != CFDictionaryGetTypeID()) {
1126 LLDB_LOGF(log, "'%s' failed: output plist is not a valid CFDictionary",
1127 command.GetData());
1128 return false;
1129 }
1130
1131 if (!uuid_str.empty()) {
1132 CFCString uuid_cfstr(uuid_str.c_str());
1133 CFDictionaryRef uuid_dict =
1134 (CFDictionaryRef)CFDictionaryGetValue(plist.get(), uuid_cfstr.get());
1135 return GetModuleSpecInfoFromUUIDDictionary(uuid_dict, module_spec, error,
1136 command.GetData());
1137 }
1138
1139 if (const CFIndex num_values = ::CFDictionaryGetCount(plist.get())) {
1140 std::vector<CFStringRef> keys(num_values, NULL);
1141 std::vector<CFDictionaryRef> values(num_values, NULL);
1142 ::CFDictionaryGetKeysAndValues(plist.get(), NULL,
1143 (const void **)&values[0]);
1144 if (num_values == 1) {
1145 return GetModuleSpecInfoFromUUIDDictionary(values[0], module_spec, error,
1146 command.GetData());
1147 }
1148
1149 for (CFIndex i = 0; i < num_values; ++i) {
1150 ModuleSpec curr_module_spec;
1151 if (GetModuleSpecInfoFromUUIDDictionary(values[i], curr_module_spec,
1152 error, command.GetData())) {
1153 if (module_spec.GetArchitecture().IsCompatibleMatch(
1154 curr_module_spec.GetArchitecture())) {
1155 module_spec = curr_module_spec;
1156 return true;
1157 }
1158 }
1159 }
1160 }
1161
1162 return false;
1163}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition Log.h:375
#define LLDB_LOGF(log,...)
Definition Log.h:389
#define LLDB_PLUGIN_DEFINE(PluginName)
static llvm::StringRef GetDbgShellCommand()
It's expensive to check for the DBGShellCommands defaults setting.
static const DebugSymbolsDylibFunctions & GetDebugSymbolsDylibFunctions()
static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec, FileSpec &dsym_fspec)
static int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec, ModuleSpec &return_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)
static FileSpec GetDsymForUUIDExecutable()
Get the dsymForUUID executable and cache the result so we don't end up stat'ing the binary over and o...
static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict, ModuleSpec &module_spec, Status &error, const std::string &command)
#define LLDB_SCOPED_TIMERF(...)
Definition Timer.h:86
CFURLRef CopyExecutableURL() const
Definition CFCBundle.cpp:71
void reset(T ptr=NULL)
Definition CFCReleaser.h:86
static const char * FileSystemRepresentation(CFStringRef cf_str, std::string &str)
An architecture specification class.
Definition ArchSpec.h:32
bool IsCompatibleMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, CompatibleMatch).
Definition ArchSpec.h:596
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition ArchSpec.cpp:740
A uniqued constant string class.
Definition ConstString.h:40
A file collection class.
A file utility class.
Definition FileSpec.h:57
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition FileSpec.cpp:174
void AppendPathComponent(llvm::StringRef component)
Definition FileSpec.cpp:452
bool RemoveLastPathComponent()
Removes the last path component by replacing the current path with its parent.
Definition FileSpec.cpp:463
llvm::StringRef GetFilename() const
Filename string const get accessor.
Definition FileSpec.h:249
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition FileSpec.cpp:376
void Clear()
Clears the object state.
Definition FileSpec.cpp:261
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > GetVirtualFileSystem()
Definition FileSystem.h:205
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
static Status RunShellCommand(llvm::StringRef command, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, std::string *error_output, const Timeout< std::micro > &timeout, bool run_in_shell=true)
Run a shell command.
lldb::SymbolSharedCacheUse GetSharedCacheBinaryLoading() const
static ModuleListProperties & GetGlobalModuleListProperties()
bool GetModuleSpecAtIndex(size_t i, ModuleSpec &module_spec) const
Definition ModuleSpec.h:386
PathMappingList & GetSourceMappingList() const
Definition ModuleSpec.h:138
FileSpec & GetFileSpec()
Definition ModuleSpec.h:57
ArchSpec & GetArchitecture()
Definition ModuleSpec.h:93
FileSpec * GetFileSpecPtr()
Definition ModuleSpec.h:51
FileSpec & GetSymbolFileSpec()
Definition ModuleSpec.h:81
ArchSpec * GetArchitecturePtr()
Definition ModuleSpec.h:85
static ModuleSpecList GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset, lldb::offset_t file_size, lldb::DataExtractorSP=lldb::DataExtractorSP())
void Append(llvm::StringRef path, llvm::StringRef replacement, bool notify)
static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec, Status &error, bool force_lookup=true, bool copy_executable=true)
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
static FileSpec FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec, const UUID *uuid, const ArchSpec *arch)
A Progress indicator helper class.
Definition Progress.h:60
An error handling class.
Definition Status.h:118
const char * GetData() const
llvm::StringRef GetString() const
static std::optional< ModuleSpec > LocateExecutableObjectFile(const ModuleSpec &module_spec)
static lldb_private::SymbolLocator * CreateInstance()
static std::optional< FileSpec > LocateExecutableSymbolFile(const ModuleSpec &module_spec, const FileSpecList &default_search_paths)
static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec, Status &error, bool force_lookup, bool copy_executable)
static std::optional< FileSpec > FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec, const UUID *uuid, const ArchSpec *arch)
Represents UUID's of various sizes.
Definition UUID.h:27
llvm::ArrayRef< uint8_t > GetBytes() const
Definition UUID.h:66
std::string GetAsString(llvm::StringRef separator="-") const
Definition UUID.cpp:54
bool IsValid() const
Definition UUID.h:69
#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.
Definition Log.h:338
std::shared_ptr< lldb_private::Module > ModuleSP
#define PATH_MAX