本文整理汇总了C++中ModuleSpec::GetArchitecturePtr方法的典型用法代码示例。如果您正苦于以下问题:C++ ModuleSpec::GetArchitecturePtr方法的具体用法?C++ ModuleSpec::GetArchitecturePtr怎么用?C++ ModuleSpec::GetArchitecturePtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleSpec
的用法示例。
在下文中一共展示了ModuleSpec::GetArchitecturePtr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scoped_timer
FileSpec
Symbols::LocateExecutableObjectFile (const ModuleSpec &module_spec)
{
const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
const ArchSpec *arch = module_spec.GetArchitecturePtr();
const UUID *uuid = module_spec.GetUUIDPtr();
Timer scoped_timer (__PRETTY_FUNCTION__,
"LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
arch ? arch->GetArchitectureName() : "<NULL>",
(void*)uuid);
FileSpec objfile_fspec;
ModuleSpecList module_specs;
ModuleSpec matched_module_spec;
if (exec_fspec &&
ObjectFile::GetModuleSpecifications(*exec_fspec, 0, 0, module_specs) &&
module_specs.FindMatchingModuleSpec(module_spec, matched_module_spec))
{
objfile_fspec = exec_fspec;
}
else
{
LocateMacOSXFilesUsingDebugSymbols (module_spec, &objfile_fspec, NULL);
}
return objfile_fspec;
}
示例2:
Error
PlatformDarwin::ResolveSymbolFile (Target &target,
const ModuleSpec &sym_spec,
FileSpec &sym_file)
{
Error error;
sym_file = sym_spec.GetSymbolFileSpec();
if (sym_file.Exists())
{
if (sym_file.GetFileType() == FileSpec::eFileTypeDirectory)
{
sym_file = Symbols::FindSymbolFileInBundle (sym_file,
sym_spec.GetUUIDPtr(),
sym_spec.GetArchitecturePtr());
}
}
else
{
if (sym_spec.GetUUID().IsValid())
{
}
}
return error;
}
示例3: sizeof
FileSpec
Symbols::FindSymbolFileInBundle (const FileSpec& dsym_bundle_fspec,
const lldb_private::UUID *uuid,
const ArchSpec *arch)
{
char path[PATH_MAX];
FileSpec dsym_fspec;
if (dsym_bundle_fspec.GetPath(path, sizeof(path)))
{
::strncat (path, "/Contents/Resources/DWARF", sizeof(path) - strlen(path) - 1);
lldb_utility::CleanUp <DIR *, int> dirp (opendir(path), NULL, closedir);
if (dirp.is_valid())
{
dsym_fspec.GetDirectory().SetCString(path);
struct dirent* dp;
while ((dp = readdir(dirp.get())) != NULL)
{
// Only search directories
if (dp->d_type == DT_DIR || dp->d_type == DT_UNKNOWN)
{
if (dp->d_namlen == 1 && dp->d_name[0] == '.')
continue;
if (dp->d_namlen == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.')
continue;
}
if (dp->d_type == DT_REG || dp->d_type == DT_UNKNOWN)
{
dsym_fspec.GetFilename().SetCString(dp->d_name);
ModuleSpecList module_specs;
if (ObjectFile::GetModuleSpecifications(dsym_fspec, 0, 0, module_specs))
{
ModuleSpec spec;
for (size_t i = 0; i < module_specs.GetSize(); ++i)
{
assert(module_specs.GetModuleSpecAtIndex(i, spec));
if ((uuid == NULL || (spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
(arch == NULL || (spec.GetArchitecturePtr() && spec.GetArchitecture().IsCompatibleMatch(*arch))))
{
return dsym_fspec;
}
}
}
}
}
}
}
dsym_fspec.Clear();
return dsym_fspec;
}
示例4: FindSymbolFileInBundle
FileSpec Symbols::FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec,
const lldb_private::UUID *uuid,
const ArchSpec *arch) {
char path[PATH_MAX];
if (dsym_bundle_fspec.GetPath(path, sizeof(path)) == 0)
return {};
::strncat(path, "/Contents/Resources/DWARF", sizeof(path) - strlen(path) - 1);
DIR *dirp = opendir(path);
if (!dirp)
return {};
// Make sure we close the directory before exiting this scope.
CleanUp cleanup_dir(closedir, dirp);
FileSpec dsym_fspec;
dsym_fspec.GetDirectory().SetCString(path);
struct dirent *dp;
while ((dp = readdir(dirp)) != NULL) {
// Only search directories
if (dp->d_type == DT_DIR || dp->d_type == DT_UNKNOWN) {
if (dp->d_namlen == 1 && dp->d_name[0] == '.')
continue;
if (dp->d_namlen == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.')
continue;
}
if (dp->d_type == DT_REG || dp->d_type == DT_UNKNOWN) {
dsym_fspec.GetFilename().SetCString(dp->d_name);
ModuleSpecList module_specs;
if (ObjectFile::GetModuleSpecifications(dsym_fspec, 0, 0, module_specs)) {
ModuleSpec spec;
for (size_t i = 0; i < module_specs.GetSize(); ++i) {
bool got_spec = module_specs.GetModuleSpecAtIndex(i, spec);
UNUSED_IF_ASSERT_DISABLED(got_spec);
assert(got_spec);
if ((uuid == NULL ||
(spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
(arch == NULL ||
(spec.GetArchitecturePtr() &&
spec.GetArchitecture().IsCompatibleMatch(*arch)))) {
return dsym_fspec;
}
}
}
}
}
return {};
}
示例5: FileAtPathContainsArchAndUUID
static bool FileAtPathContainsArchAndUUID(const FileSpec &file_fspec,
const ArchSpec *arch,
const lldb_private::UUID *uuid) {
ModuleSpecList module_specs;
if (ObjectFile::GetModuleSpecifications(file_fspec, 0, 0, module_specs)) {
ModuleSpec spec;
for (size_t i = 0; i < module_specs.GetSize(); ++i) {
assert(module_specs.GetModuleSpecAtIndex(i, spec));
if ((uuid == NULL || (spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
(arch == NULL || (spec.GetArchitecturePtr() &&
spec.GetArchitecture().IsCompatibleMatch(*arch)))) {
return true;
}
}
}
return false;
}
示例6: scoped_timer
FileSpec
Symbols::LocateExecutableObjectFile (const ModuleSpec &module_spec)
{
const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
const ArchSpec *arch = module_spec.GetArchitecturePtr();
const UUID *uuid = module_spec.GetUUIDPtr();
Timer scoped_timer (__PRETTY_FUNCTION__,
"LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
arch ? arch->GetArchitectureName() : "<NULL>",
uuid);
FileSpec objfile_fspec;
if (exec_fspec && FileAtPathContainsArchAndUUID (exec_fspec, arch, uuid))
objfile_fspec = exec_fspec;
else
LocateMacOSXFilesUsingDebugSymbols (module_spec, &objfile_fspec, NULL);
return objfile_fspec;
}
示例7: LocateExecutableObjectFile
ModuleSpec Symbols::LocateExecutableObjectFile(const ModuleSpec &module_spec) {
ModuleSpec result;
const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
const ArchSpec *arch = module_spec.GetArchitecturePtr();
const UUID *uuid = module_spec.GetUUIDPtr();
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(
func_cat, "LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString("<NULL>") : "<NULL>",
arch ? arch->GetArchitectureName() : "<NULL>", (const void *)uuid);
ModuleSpecList module_specs;
ModuleSpec matched_module_spec;
if (exec_fspec &&
ObjectFile::GetModuleSpecifications(*exec_fspec, 0, 0, module_specs) &&
module_specs.FindMatchingModuleSpec(module_spec, matched_module_spec)) {
result.GetFileSpec() = exec_fspec;
} else {
LocateMacOSXFilesUsingDebugSymbols(module_spec, result);
}
return result;
}
示例8: LocateExecutableSymbolFileDsym
FileSpec LocateExecutableSymbolFileDsym(const ModuleSpec &module_spec) {
const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
const ArchSpec *arch = module_spec.GetArchitecturePtr();
const UUID *uuid = module_spec.GetUUIDPtr();
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(
func_cat,
"LocateExecutableSymbolFileDsym (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString("<NULL>") : "<NULL>",
arch ? arch->GetArchitectureName() : "<NULL>", (const void *)uuid);
FileSpec symbol_fspec;
ModuleSpec dsym_module_spec;
// First try and find the dSYM in the same directory as the executable or in
// an appropriate parent directory
if (LocateDSYMInVincinityOfExecutable(module_spec, symbol_fspec) == false) {
// We failed to easily find the dSYM above, so use DebugSymbols
LocateMacOSXFilesUsingDebugSymbols(module_spec, dsym_module_spec);
} else {
dsym_module_spec.GetSymbolFileSpec() = symbol_fspec;
}
return dsym_module_spec.GetSymbolFileSpec();
}
示例9: strlen
static bool
LocateDSYMInVincinityOfExecutable (const ModuleSpec &module_spec, FileSpec &dsym_fspec)
{
const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
if (exec_fspec)
{
char path[PATH_MAX];
if (exec_fspec->GetPath(path, sizeof(path)))
{
// Make sure the module isn't already just a dSYM file...
if (strcasestr(path, ".dSYM/Contents/Resources/DWARF") == NULL)
{
size_t obj_file_path_length = strlen(path);
strlcat(path, ".dSYM/Contents/Resources/DWARF/", sizeof(path));
strlcat(path, exec_fspec->GetFilename().AsCString(), sizeof(path));
dsym_fspec.SetFile(path, false);
if (dsym_fspec.Exists() && FileAtPathContainsArchAndUUID (dsym_fspec, module_spec.GetArchitecturePtr(), module_spec.GetUUIDPtr()))
{
return true;
}
else
{
path[obj_file_path_length] = '\0';
char *last_dot = strrchr(path, '.');
while (last_dot != NULL && last_dot[0])
{
char *next_slash = strchr(last_dot, '/');
if (next_slash != NULL)
{
*next_slash = '\0';
strlcat(path, ".dSYM/Contents/Resources/DWARF/", sizeof(path));
strlcat(path, exec_fspec->GetFilename().AsCString(), sizeof(path));
dsym_fspec.SetFile(path, false);
if (dsym_fspec.Exists() && FileAtPathContainsArchAndUUID (dsym_fspec, module_spec.GetArchitecturePtr(), module_spec.GetUUIDPtr()))
return true;
else
{
*last_dot = '\0';
char *prev_slash = strrchr(path, '/');
if (prev_slash != NULL)
*prev_slash = '\0';
else
break;
}
}
else
{
break;
}
}
}
}
}
}
dsym_fspec.Clear();
return false;
}
示例10: uuid_cfstr
static int
LocateMacOSXFilesUsingDebugSymbols
(
const ModuleSpec &module_spec,
FileSpec *out_exec_fspec, // If non-NULL, try and find the executable
FileSpec *out_dsym_fspec // If non-NULL try and find the debug symbol file
)
{
int items_found = 0;
if (out_exec_fspec)
out_exec_fspec->Clear();
if (out_dsym_fspec)
out_dsym_fspec->Clear();
#if !defined (__arm__) // No DebugSymbols on the iOS devices
const UUID *uuid = module_spec.GetUUIDPtr();
const ArchSpec *arch = module_spec.GetArchitecturePtr();
if (uuid && uuid->IsValid())
{
// Try and locate the dSYM file using DebugSymbols first
const UInt8 *module_uuid = (const UInt8 *)uuid->GetBytes();
if (module_uuid != NULL)
{
CFCReleaser<CFUUIDRef> module_uuid_ref(::CFUUIDCreateWithBytes (NULL,
module_uuid[0],
module_uuid[1],
module_uuid[2],
module_uuid[3],
module_uuid[4],
module_uuid[5],
module_uuid[6],
module_uuid[7],
module_uuid[8],
module_uuid[9],
module_uuid[10],
module_uuid[11],
module_uuid[12],
module_uuid[13],
module_uuid[14],
module_uuid[15]));
if (module_uuid_ref.get())
{
CFCReleaser<CFURLRef> exec_url;
const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
if (exec_fspec)
{
char exec_cf_path[PATH_MAX];
if (exec_fspec->GetPath(exec_cf_path, sizeof(exec_cf_path)))
exec_url.reset(::CFURLCreateFromFileSystemRepresentation (NULL,
(const UInt8 *)exec_cf_path,
strlen(exec_cf_path),
FALSE));
}
CFCReleaser<CFURLRef> dsym_url (::DBGCopyFullDSYMURLForUUID(module_uuid_ref.get(), exec_url.get()));
char path[PATH_MAX];
if (dsym_url.get())
{
if (out_dsym_fspec)
{
if (::CFURLGetFileSystemRepresentation (dsym_url.get(), true, (UInt8*)path, sizeof(path)-1))
{
out_dsym_fspec->SetFile(path, false);
if (out_dsym_fspec->GetFileType () == FileSpec::eFileTypeDirectory)
{
*out_dsym_fspec = LocateDSYMMachFileInDSYMBundle (*out_dsym_fspec, uuid, arch);
if (*out_dsym_fspec)
++items_found;
}
else
{
++items_found;
}
}
}
CFCReleaser<CFDictionaryRef> dict(::DBGCopyDSYMPropertyLists (dsym_url.get()));
CFDictionaryRef uuid_dict = NULL;
if (dict.get())
{
char uuid_cstr_buf[64];
const char *uuid_cstr = uuid->GetAsCString (uuid_cstr_buf, sizeof(uuid_cstr_buf));
CFCString uuid_cfstr (uuid_cstr);
CFDictionaryRef uuid_dict = static_cast<CFDictionaryRef>(::CFDictionaryGetValue (dict.get(), uuid_cfstr.get()));
if (uuid_dict)
{
CFStringRef actual_src_cfpath = static_cast<CFStringRef>(::CFDictionaryGetValue (uuid_dict, CFSTR("DBGSourcePath")));
if (actual_src_cfpath)
{
CFStringRef build_src_cfpath = static_cast<CFStringRef>(::CFDictionaryGetValue (uuid_dict, CFSTR("DBGBuildSourcePath")));
if (build_src_cfpath)
{
//.........这里部分代码省略.........
示例11: if
int
LocateMacOSXFilesUsingDebugSymbols
(
const ModuleSpec &module_spec,
FileSpec *out_exec_fspec, // If non-NULL, try and find the executable
FileSpec *out_dsym_fspec // If non-NULL try and find the debug symbol file
)
{
int items_found = 0;
if (out_exec_fspec)
out_exec_fspec->Clear();
if (out_dsym_fspec)
out_dsym_fspec->Clear();
#if !defined (__arm__) && !defined (__arm64__) && !defined (__aarch64__) // No DebugSymbols on the iOS devices
const UUID *uuid = module_spec.GetUUIDPtr();
const ArchSpec *arch = module_spec.GetArchitecturePtr();
if (uuid && uuid->IsValid())
{
// Try and locate the dSYM file using DebugSymbols first
const UInt8 *module_uuid = (const UInt8 *)uuid->GetBytes();
if (module_uuid != NULL)
{
CFCReleaser<CFUUIDRef> module_uuid_ref(::CFUUIDCreateWithBytes (NULL,
module_uuid[0],
module_uuid[1],
module_uuid[2],
module_uuid[3],
module_uuid[4],
module_uuid[5],
module_uuid[6],
module_uuid[7],
module_uuid[8],
module_uuid[9],
module_uuid[10],
module_uuid[11],
module_uuid[12],
module_uuid[13],
module_uuid[14],
module_uuid[15]));
if (module_uuid_ref.get())
{
CFCReleaser<CFURLRef> exec_url;
const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (exec_fspec)
{
char exec_cf_path[PATH_MAX];
if (exec_fspec->GetPath(exec_cf_path, sizeof(exec_cf_path)))
exec_url.reset(::CFURLCreateFromFileSystemRepresentation (NULL,
(const UInt8 *)exec_cf_path,
strlen(exec_cf_path),
FALSE));
}
if (log)
{
std::string searching_for;
if (out_exec_fspec && out_dsym_fspec)
{
searching_for = "executable binary and dSYM";
}
else if (out_exec_fspec)
{
searching_for = "executable binary";
}
else
{
searching_for = "dSYM bundle";
}
log->Printf ("Calling DebugSymbols framework to locate dSYM bundle for UUID %s, searching for %s", uuid->GetAsString().c_str(), searching_for.c_str());
}
CFCReleaser<CFURLRef> dsym_url (::DBGCopyFullDSYMURLForUUID(module_uuid_ref.get(), exec_url.get()));
char path[PATH_MAX];
if (dsym_url.get())
{
if (out_dsym_fspec)
{
if (::CFURLGetFileSystemRepresentation (dsym_url.get(), true, (UInt8*)path, sizeof(path)-1))
{
if (log)
{
log->Printf ("DebugSymbols framework returned dSYM path of %s for UUID %s -- looking for the dSYM", path, uuid->GetAsString().c_str());
}
out_dsym_fspec->SetFile(path, path[0] == '~');
if (out_dsym_fspec->GetFileType () == FileSpec::eFileTypeDirectory)
{
*out_dsym_fspec = Symbols::FindSymbolFileInBundle (*out_dsym_fspec, uuid, arch);
if (*out_dsym_fspec)
++items_found;
}
else
{
//.........这里部分代码省略.........
示例12: LocateDSYMInVincinityOfExecutable
static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec,
FileSpec &dsym_fspec) {
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
if (exec_fspec) {
char path[PATH_MAX];
if (exec_fspec->GetPath(path, sizeof(path))) {
// Make sure the module isn't already just a dSYM file...
if (strcasestr(path, ".dSYM/Contents/Resources/DWARF") == NULL) {
if (log) {
if (module_spec.GetUUIDPtr() && module_spec.GetUUIDPtr()->IsValid()) {
log->Printf(
"Searching for dSYM bundle next to executable %s, UUID %s",
path, module_spec.GetUUIDPtr()->GetAsString().c_str());
} else {
log->Printf("Searching for dSYM bundle next to executable %s",
path);
}
}
size_t obj_file_path_length = strlen(path);
::strncat(path, ".dSYM/Contents/Resources/DWARF/",
sizeof(path) - strlen(path) - 1);
::strncat(path, exec_fspec->GetFilename().AsCString(),
sizeof(path) - strlen(path) - 1);
dsym_fspec.SetFile(path, false);
ModuleSpecList module_specs;
ModuleSpec matched_module_spec;
if (dsym_fspec.Exists() &&
FileAtPathContainsArchAndUUID(dsym_fspec,
module_spec.GetArchitecturePtr(),
module_spec.GetUUIDPtr())) {
if (log) {
log->Printf("dSYM with matching UUID & arch found at %s", path);
}
return true;
} else {
path[obj_file_path_length] = '\0';
char *last_dot = strrchr(path, '.');
while (last_dot != NULL && last_dot[0]) {
char *next_slash = strchr(last_dot, '/');
if (next_slash != NULL) {
*next_slash = '\0';
::strncat(path, ".dSYM/Contents/Resources/DWARF/",
sizeof(path) - strlen(path) - 1);
::strncat(path, exec_fspec->GetFilename().AsCString(),
sizeof(path) - strlen(path) - 1);
dsym_fspec.SetFile(path, false);
if (dsym_fspec.Exists() &&
FileAtPathContainsArchAndUUID(
dsym_fspec, module_spec.GetArchitecturePtr(),
module_spec.GetUUIDPtr())) {
if (log) {
log->Printf("dSYM with matching UUID & arch found at %s",
path);
}
return true;
} else {
*last_dot = '\0';
char *prev_slash = strrchr(path, '/');
if (prev_slash != NULL)
*prev_slash = '\0';
else
break;
}
} else {
break;
}
}
}
}
}
}
dsym_fspec.Clear();
return false;
}
示例13: LocateDSYMInVincinityOfExecutable
static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec,
FileSpec &dsym_fspec) {
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
if (exec_fspec) {
char path[PATH_MAX];
if (exec_fspec->GetPath(path, sizeof(path))) {
// Make sure the module isn't already just a dSYM file...
if (strcasestr(path, ".dSYM/Contents/Resources/DWARF") == NULL) {
if (log) {
if (module_spec.GetUUIDPtr() && module_spec.GetUUIDPtr()->IsValid()) {
log->Printf(
"Searching for dSYM bundle next to executable %s, UUID %s",
path, module_spec.GetUUIDPtr()->GetAsString().c_str());
} else {
log->Printf("Searching for dSYM bundle next to executable %s",
path);
}
}
::strncat(path, ".dSYM/Contents/Resources/DWARF/",
sizeof(path) - strlen(path) - 1);
::strncat(path, exec_fspec->GetFilename().AsCString(),
sizeof(path) - strlen(path) - 1);
dsym_fspec.SetFile(path, false);
ModuleSpecList module_specs;
ModuleSpec matched_module_spec;
if (dsym_fspec.Exists() &&
FileAtPathContainsArchAndUUID(dsym_fspec,
module_spec.GetArchitecturePtr(),
module_spec.GetUUIDPtr())) {
if (log) {
log->Printf("dSYM with matching UUID & arch found at %s", path);
}
return true;
} else {
FileSpec parent_dirs = exec_fspec;
// Remove the binary name from the FileSpec
parent_dirs.RemoveLastPathComponent();
// Add a ".dSYM" name to each directory component of the path,
// stripping off components. e.g. we may have a binary like
// /S/L/F/Foundation.framework/Versions/A/Foundation
// and
// /S/L/F/Foundation.framework.dSYM
//
// so we'll need to start with /S/L/F/Foundation.framework/Versions/A,
// add the .dSYM part to the "A", and if that doesn't exist, strip off
// the "A" and try it again with "Versions", etc., until we find a
// dSYM bundle or we've stripped off enough path components that
// there's no need to continue.
for (int i = 0; i < 4; i++) {
// Does this part of the path have a "." character - could it be a
// bundle's top level directory?
const char *fn = parent_dirs.GetFilename().AsCString();
if (fn == nullptr)
break;
if (::strchr(fn, '.') != nullptr) {
dsym_fspec = parent_dirs;
dsym_fspec.RemoveLastPathComponent();
// If the current directory name is "Foundation.framework", see if
// "Foundation.framework.dSYM/Contents/Resources/DWARF/Foundation"
// exists & has the right uuid.
std::string dsym_fn = fn;
dsym_fn += ".dSYM";
dsym_fspec.AppendPathComponent(dsym_fn.c_str());
dsym_fspec.AppendPathComponent("Contents");
dsym_fspec.AppendPathComponent("Resources");
dsym_fspec.AppendPathComponent("DWARF");
dsym_fspec.AppendPathComponent(
exec_fspec->GetFilename().AsCString());
if (dsym_fspec.Exists() &&
FileAtPathContainsArchAndUUID(
dsym_fspec, module_spec.GetArchitecturePtr(),
module_spec.GetUUIDPtr())) {
if (log) {
log->Printf("dSYM with matching UUID & arch found at %s",
dsym_fspec.GetPath().c_str());
}
return true;
}
}
parent_dirs.RemoveLastPathComponent();
}
}
}
}
}
dsym_fspec.Clear();
return false;
}
示例14: FileSpec
FileSpec
PlatformDarwin::LocateExecutableScriptingResource (const ModuleSpec &module_spec)
{
const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
const ArchSpec *arch = module_spec.GetArchitecturePtr();
const UUID *uuid = module_spec.GetUUIDPtr();
const char* module_directory = exec_fspec->GetDirectory().GetCString();
// NB some extensions might be meaningful and should not be stripped - "this.binary.file"
// should not lose ".file" but GetFileNameStrippingExtension() will do precisely that.
// Ideally, we should have a per-platform list of extensions (".exe", ".app", ".dSYM", ".framework")
// which should be stripped while leaving "this.binary.file" as-is.
const char* module_basename = exec_fspec->GetFileNameStrippingExtension().GetCString();
if (!module_directory || !module_basename)
return FileSpec();
Timer scoped_timer (__PRETTY_FUNCTION__,
"LocateExecutableScriptingResource (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
arch ? arch->GetArchitectureName() : "<NULL>",
uuid);
// FIXME: for Python, we cannot allow dots in the middle of the filenames we import.
// Theoretically, different scripting languages may have different sets of
// forbidden tokens in filenames, and that should be dealt with by each ScriptInterpreter.
// For now, we just replace dots with underscores, but if we ever support anything
// other than Python we will need to rework this
std::auto_ptr<char> module_basename_fixed_ap(new char[strlen(module_basename)+1]);
char* module_basename_fixed = module_basename_fixed_ap.get();
strcpy(module_basename_fixed, module_basename);
while (*module_basename_fixed)
{
if (*module_basename_fixed == '.')
*module_basename_fixed = '_';
module_basename_fixed++;
}
module_basename_fixed = module_basename_fixed_ap.get();
FileSpec symbol_fspec (Symbols::LocateExecutableSymbolFile(module_spec));
FileSpec script_fspec;
StreamString path_string;
if (symbol_fspec && symbol_fspec.Exists())
{
// for OSX we are going to be in .dSYM/Contents/Resources/DWARF/<basename>
// let us go to .dSYM/Contents/Resources/Python/<basename>.py and see if the file exists
path_string.Printf("%s/../Python/%s.py",symbol_fspec.GetDirectory().AsCString(""),module_basename_fixed);
script_fspec.SetFile(path_string.GetData(), true);
if (!script_fspec.Exists())
script_fspec.Clear();
}
// no symbols or symbols did not have a scripting resource
if (!symbol_fspec || !script_fspec)
{
path_string.Clear();
path_string.Printf("%s.framework",module_basename);
if (module_directory && strstr(module_directory, path_string.GetData()))
{
// we are going to be in foo.framework/Versions/X/foo
path_string.Clear();
// let's go to foo.framework/Versions/X/Resources/Python/foo.py
path_string.Printf("%s/Resources/Python/%s.py",module_directory,module_basename_fixed);
script_fspec.SetFile(path_string.GetData(), true);
if (!script_fspec.Exists())
script_fspec.Clear();
}
}
return script_fspec;
}
示例15: LocateMacOSXFilesUsingDebugSymbols
int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
ModuleSpec &return_module_spec) {
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) {
if (log)
log->Printf("Spotlight lookup for .dSYM bundles is disabled.");
return 0;
}
return_module_spec = module_spec;
return_module_spec.GetFileSpec().Clear();
return_module_spec.GetSymbolFileSpec().Clear();
int items_found = 0;
#if !defined(__arm__) && !defined(__arm64__) && \
!defined(__aarch64__) // No DebugSymbols on the iOS devices
const UUID *uuid = module_spec.GetUUIDPtr();
const ArchSpec *arch = module_spec.GetArchitecturePtr();
if (uuid && uuid->IsValid()) {
// Try and locate the dSYM file using DebugSymbols first
llvm::ArrayRef<uint8_t> module_uuid = uuid->GetBytes();
if (module_uuid.size() == 16) {
CFCReleaser<CFUUIDRef> module_uuid_ref(::CFUUIDCreateWithBytes(
NULL, module_uuid[0], module_uuid[1], module_uuid[2], module_uuid[3],
module_uuid[4], module_uuid[5], module_uuid[6], module_uuid[7],
module_uuid[8], module_uuid[9], module_uuid[10], module_uuid[11],
module_uuid[12], module_uuid[13], module_uuid[14], module_uuid[15]));
if (module_uuid_ref.get()) {
CFCReleaser<CFURLRef> exec_url;
const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
if (exec_fspec) {
char exec_cf_path[PATH_MAX];
if (exec_fspec->GetPath(exec_cf_path, sizeof(exec_cf_path)))
exec_url.reset(::CFURLCreateFromFileSystemRepresentation(
NULL, (const UInt8 *)exec_cf_path, strlen(exec_cf_path),
FALSE));
}
CFCReleaser<CFURLRef> dsym_url(
::DBGCopyFullDSYMURLForUUID(module_uuid_ref.get(), exec_url.get()));
char path[PATH_MAX];
if (dsym_url.get()) {
if (::CFURLGetFileSystemRepresentation(
dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
if (log) {
log->Printf("DebugSymbols framework returned dSYM path of %s for "
"UUID %s -- looking for the dSYM",
path, uuid->GetAsString().c_str());
}
FileSpec dsym_filespec(path);
if (path[0] == '~')
FileSystem::Instance().Resolve(dsym_filespec);
if (FileSystem::Instance().IsDirectory(dsym_filespec)) {
dsym_filespec =
Symbols::FindSymbolFileInBundle(dsym_filespec, uuid, arch);
++items_found;
} else {
++items_found;
}
return_module_spec.GetSymbolFileSpec() = dsym_filespec;
}
bool success = false;
if (log) {
if (::CFURLGetFileSystemRepresentation(
dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
log->Printf("DebugSymbols framework returned dSYM path of %s for "
"UUID %s -- looking for an exec file",
path, uuid->GetAsString().c_str());
}
}
CFCReleaser<CFDictionaryRef> dict(
::DBGCopyDSYMPropertyLists(dsym_url.get()));
CFDictionaryRef uuid_dict = NULL;
if (dict.get()) {
CFCString uuid_cfstr(uuid->GetAsString().c_str());
uuid_dict = static_cast<CFDictionaryRef>(
::CFDictionaryGetValue(dict.get(), uuid_cfstr.get()));
}
if (uuid_dict) {
CFStringRef exec_cf_path =
static_cast<CFStringRef>(::CFDictionaryGetValue(
uuid_dict, CFSTR("DBGSymbolRichExecutable")));
if (exec_cf_path && ::CFStringGetFileSystemRepresentation(
exec_cf_path, path, sizeof(path))) {
if (log) {
log->Printf("plist bundle has exec path of %s for UUID %s",
path, uuid->GetAsString().c_str());
}
++items_found;
FileSpec exec_filespec(path);
if (path[0] == '~')
FileSystem::Instance().Resolve(exec_filespec);
//.........这里部分代码省略.........