本文整理汇总了C++中FileSpec类的典型用法代码示例。如果您正苦于以下问题:C++ FileSpec类的具体用法?C++ FileSpec怎么用?C++ FileSpec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileSpec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
static bool
SkinnyMachOFileContainsArchAndUUID
(
const FileSpec &file_spec,
const ArchSpec *arch,
const lldb_private::UUID *uuid, // the UUID we are looking for
off_t file_offset,
DataExtractor& data,
uint32_t data_offset,
const uint32_t magic
)
{
assert(magic == HeaderMagic32 || magic == HeaderMagic32Swapped || magic == HeaderMagic64 || magic == HeaderMagic64Swapped);
if (magic == HeaderMagic32 || magic == HeaderMagic64)
data.SetByteOrder (lldb::endian::InlHostByteOrder());
else if (lldb::endian::InlHostByteOrder() == eByteOrderBig)
data.SetByteOrder (eByteOrderLittle);
else
data.SetByteOrder (eByteOrderBig);
uint32_t i;
const uint32_t cputype = data.GetU32(&data_offset); // cpu specifier
const uint32_t cpusubtype = data.GetU32(&data_offset); // machine specifier
data_offset+=4; // Skip mach file type
const uint32_t ncmds = data.GetU32(&data_offset); // number of load commands
const uint32_t sizeofcmds = data.GetU32(&data_offset); // the size of all the load commands
data_offset+=4; // Skip flags
// Check the architecture if we have a valid arch pointer
if (arch)
{
ArchSpec file_arch(eArchTypeMachO, cputype, cpusubtype);
if (!file_arch.IsCompatibleMatch(*arch))
return false;
}
// The file exists, and if a valid arch pointer was passed in we know
// if already matches, so we can return if we aren't looking for a specific
// UUID
if (uuid == NULL)
return true;
if (magic == HeaderMagic64Swapped || magic == HeaderMagic64)
data_offset += 4; // Skip reserved field for in mach_header_64
// Make sure we have enough data for all the load commands
if (magic == HeaderMagic64Swapped || magic == HeaderMagic64)
{
if (data.GetByteSize() < sizeof(struct mach_header_64) + sizeofcmds)
{
DataBufferSP data_buffer_sp (file_spec.ReadFileContents (file_offset, sizeof(struct mach_header_64) + sizeofcmds));
data.SetData (data_buffer_sp);
}
}
else
{
if (data.GetByteSize() < sizeof(struct mach_header) + sizeofcmds)
{
DataBufferSP data_buffer_sp (file_spec.ReadFileContents (file_offset, sizeof(struct mach_header) + sizeofcmds));
data.SetData (data_buffer_sp);
}
}
for (i=0; i<ncmds; i++)
{
const uint32_t cmd_offset = data_offset; // Save this data_offset in case parsing of the segment goes awry!
uint32_t cmd = data.GetU32(&data_offset);
uint32_t cmd_size = data.GetU32(&data_offset);
if (cmd == LoadCommandUUID)
{
lldb_private::UUID file_uuid (data.GetData(&data_offset, 16), 16);
if (file_uuid == *uuid)
return true;
// Emit some warning messages since the UUIDs do not match!
char path_buf[PATH_MAX];
path_buf[0] = '\0';
const char *path = file_spec.GetPath(path_buf, PATH_MAX) ? path_buf
: file_spec.GetFilename().AsCString();
StreamString ss_m_uuid, ss_o_uuid;
uuid->Dump(&ss_m_uuid);
file_uuid.Dump(&ss_o_uuid);
Host::SystemLog (Host::eSystemLogWarning,
"warning: UUID mismatch detected between binary (%s) and:\n\t'%s' (%s)\n",
ss_m_uuid.GetData(), path, ss_o_uuid.GetData());
return false;
}
data_offset = cmd_offset + cmd_size;
}
return false;
}
示例2:
FileSourceFactory::FileSourceFactory(const FileSpec & fileSpec)
: _fileName(fileSpec.getFileName())
{
}
示例3: data_buffer_sp
bool
UniversalMachOFileContainsArchAndUUID
(
const FileSpec &file_spec,
const ArchSpec *arch,
const lldb_private::UUID *uuid,
off_t file_offset,
DataExtractor& data,
uint32_t data_offset,
const uint32_t magic
)
{
assert(magic == UniversalMagic || magic == UniversalMagicSwapped);
// Universal mach-o files always have their headers encoded as BIG endian
data.SetByteOrder(eByteOrderBig);
uint32_t i;
const uint32_t nfat_arch = data.GetU32(&data_offset); // number of structs that follow
const uint32_t fat_header_and_arch_size = sizeof(struct fat_header) + nfat_arch * sizeof(struct fat_arch);
if (data.GetByteSize() < fat_header_and_arch_size)
{
DataBufferSP data_buffer_sp (file_spec.ReadFileContents (file_offset, fat_header_and_arch_size));
data.SetData (data_buffer_sp);
}
for (i=0; i<nfat_arch; i++)
{
cpu_type_t arch_cputype = data.GetU32(&data_offset); // cpu specifier (int)
cpu_subtype_t arch_cpusubtype = data.GetU32(&data_offset); // machine specifier (int)
uint32_t arch_offset = data.GetU32(&data_offset); // file offset to this object file
// uint32_t arch_size = data.GetU32(&data_offset); // size of this object file
// uint32_t arch_align = data.GetU32(&data_offset); // alignment as a power of 2
data_offset += 8; // Skip size and align as we don't need those
// Only process this slice if the cpu type/subtype matches
if (arch)
{
ArchSpec fat_arch(eArchTypeMachO, arch_cputype, arch_cpusubtype);
if (!fat_arch.IsExactMatch(*arch))
continue;
}
// Create a buffer with only the arch slice date in it
DataExtractor arch_data;
DataBufferSP data_buffer_sp (file_spec.ReadFileContents (file_offset + arch_offset, 0x1000));
arch_data.SetData(data_buffer_sp);
uint32_t arch_data_offset = 0;
uint32_t arch_magic = arch_data.GetU32(&arch_data_offset);
switch (arch_magic)
{
case HeaderMagic32:
case HeaderMagic32Swapped:
case HeaderMagic64:
case HeaderMagic64Swapped:
if (SkinnyMachOFileContainsArchAndUUID (file_spec, arch, uuid, file_offset + arch_offset, arch_data, arch_data_offset, arch_magic))
return true;
break;
}
}
return false;
}
示例4:
void SourceManager::File::CommonInitializer(const FileSpec &file_spec,
Target *target) {
if (!m_mod_time.IsValid()) {
if (target) {
m_source_map_mod_id = target->GetSourcePathMap().GetModificationID();
if (!file_spec.GetDirectory() && file_spec.GetFilename()) {
// If this is just a file name, lets see if we can find it in the
// target:
bool check_inlines = false;
SymbolContextList sc_list;
size_t num_matches =
target->GetImages().ResolveSymbolContextForFilePath(
file_spec.GetFilename().AsCString(), 0, check_inlines,
lldb::eSymbolContextModule | lldb::eSymbolContextCompUnit,
sc_list);
bool got_multiple = false;
if (num_matches != 0) {
if (num_matches > 1) {
SymbolContext sc;
FileSpec *test_cu_spec = NULL;
for (unsigned i = 0; i < num_matches; i++) {
sc_list.GetContextAtIndex(i, sc);
if (sc.comp_unit) {
if (test_cu_spec) {
if (test_cu_spec != static_cast<FileSpec *>(sc.comp_unit))
got_multiple = true;
break;
} else
test_cu_spec = sc.comp_unit;
}
}
}
if (!got_multiple) {
SymbolContext sc;
sc_list.GetContextAtIndex(0, sc);
m_file_spec = sc.comp_unit;
m_mod_time = m_file_spec.GetModificationTime();
}
}
}
// Try remapping if m_file_spec does not correspond to an existing file.
if (!m_file_spec.Exists()) {
FileSpec new_file_spec;
// Check target specific source remappings first, then fall back to
// modules objects can have individual path remappings that were
// detected
// when the debug info for a module was found.
// then
if (target->GetSourcePathMap().FindFile(m_file_spec, new_file_spec) ||
target->GetImages().FindSourceFile(m_file_spec, new_file_spec)) {
m_file_spec = new_file_spec;
m_mod_time = m_file_spec.GetModificationTime();
}
}
}
}
if (m_mod_time.IsValid())
m_data_sp = m_file_spec.ReadFileContents();
}
示例5: defined
bool
HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec)
{
file_spec.Clear();
#if defined(LLDB_DISABLE_PYTHON)
if (type == lldb::ePathTypePythonDir)
return false;
#endif
FileSpec *result = nullptr;
switch (type)
{
case lldb::ePathTypeLLDBShlibDir:
{
static std::once_flag g_once_flag;
static bool success = false;
std::call_once(g_once_flag, []() {
success = HostInfo::ComputeSharedLibraryDirectory (g_fields->m_lldb_so_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (log)
log->Printf("HostInfoBase::GetLLDBPath(ePathTypeLLDBShlibDir) => '%s'", g_fields->m_lldb_so_dir.GetPath().c_str());
});
if (success)
result = &g_fields->m_lldb_so_dir;
}
break;
case lldb::ePathTypeSupportExecutableDir:
{
static std::once_flag g_once_flag;
static bool success = false;
std::call_once(g_once_flag, []() {
success = HostInfo::ComputeSupportExeDirectory (g_fields->m_lldb_support_exe_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (log)
log->Printf("HostInfoBase::GetLLDBPath(ePathTypeSupportExecutableDir) => '%s'",
g_fields->m_lldb_support_exe_dir.GetPath().c_str());
});
if (success)
result = &g_fields->m_lldb_support_exe_dir;
}
break;
case lldb::ePathTypeHeaderDir:
{
static std::once_flag g_once_flag;
static bool success = false;
std::call_once(g_once_flag, []() {
success = HostInfo::ComputeHeaderDirectory (g_fields->m_lldb_headers_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (log)
log->Printf("HostInfoBase::GetLLDBPath(ePathTypeHeaderDir) => '%s'", g_fields->m_lldb_headers_dir.GetPath().c_str());
});
if (success)
result = &g_fields->m_lldb_headers_dir;
}
break;
case lldb::ePathTypePythonDir:
{
static std::once_flag g_once_flag;
static bool success = false;
std::call_once(g_once_flag, []() {
success = HostInfo::ComputePythonDirectory (g_fields->m_lldb_python_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (log)
log->Printf("HostInfoBase::GetLLDBPath(ePathTypePythonDir) => '%s'", g_fields->m_lldb_python_dir.GetPath().c_str());
});
if (success)
result = &g_fields->m_lldb_python_dir;
}
break;
case lldb::ePathTypeClangDir:
{
static std::once_flag g_once_flag;
static bool success = false;
std::call_once(g_once_flag, []() {
success = HostInfo::ComputeClangDirectory (g_fields->m_lldb_clang_resource_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (log)
log->Printf("HostInfoBase::GetLLDBPath(ePathTypeClangResourceDir) => '%s'", g_fields->m_lldb_clang_resource_dir.GetPath().c_str());
});
if (success)
result = &g_fields->m_lldb_clang_resource_dir;
}
break;
case lldb::ePathTypeLLDBSystemPlugins:
{
static std::once_flag g_once_flag;
static bool success = false;
std::call_once(g_once_flag, []() {
success = HostInfo::ComputeSystemPluginsDirectory (g_fields->m_lldb_system_plugin_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (log)
log->Printf("HostInfoBase::GetLLDBPath(ePathTypeLLDBSystemPlugins) => '%s'",
g_fields->m_lldb_system_plugin_dir.GetPath().c_str());
});
if (success)
result = &g_fields->m_lldb_system_plugin_dir;
}
break;
case lldb::ePathTypeLLDBUserPlugins:
//.........这里部分代码省略.........
示例6:
bool
Host::GetBundleDirectory (const FileSpec &file, FileSpec &bundle)
{
bundle.Clear();
return false;
}
示例7: scoped_timer
Error
TargetList::CreateTarget
(
Debugger &debugger,
const FileSpec& file,
const ArchSpec& specified_arch,
bool get_dependent_files,
PlatformSP &platform_sp,
TargetSP &target_sp
)
{
Timer scoped_timer (__PRETTY_FUNCTION__,
"TargetList::CreateTarget (file = '%s/%s', arch = '%s')",
file.GetDirectory().AsCString(),
file.GetFilename().AsCString(),
specified_arch.GetArchitectureName());
Error error;
ArchSpec arch(specified_arch);
if (platform_sp)
{
if (arch.IsValid())
{
if (!platform_sp->IsCompatibleArchitecture(arch))
platform_sp = Platform::GetPlatformForArchitecture(specified_arch, &arch);
}
}
else if (arch.IsValid())
{
platform_sp = Platform::GetPlatformForArchitecture(specified_arch, &arch);
}
if (!platform_sp)
platform_sp = debugger.GetPlatformList().GetSelectedPlatform();
if (!arch.IsValid())
arch = specified_arch;
if (file)
{
ModuleSP exe_module_sp;
FileSpec resolved_file(file);
if (platform_sp)
{
FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths());
error = platform_sp->ResolveExecutable (file,
arch,
exe_module_sp,
executable_search_paths.GetSize() ? &executable_search_paths : NULL);
}
if (error.Success() && exe_module_sp)
{
if (exe_module_sp->GetObjectFile() == NULL)
{
if (arch.IsValid())
{
error.SetErrorStringWithFormat("\"%s%s%s\" doesn't contain architecture %s",
file.GetDirectory().AsCString(),
file.GetDirectory() ? "/" : "",
file.GetFilename().AsCString(),
arch.GetArchitectureName());
}
else
{
error.SetErrorStringWithFormat("unsupported file type \"%s%s%s\"",
file.GetDirectory().AsCString(),
file.GetDirectory() ? "/" : "",
file.GetFilename().AsCString());
}
return error;
}
target_sp.reset(new Target(debugger, arch, platform_sp));
target_sp->SetExecutableModule (exe_module_sp, get_dependent_files);
}
}
else
{
// No file was specified, just create an empty target with any arch
// if a valid arch was specified
target_sp.reset(new Target(debugger, arch, platform_sp));
}
if (target_sp)
{
target_sp->UpdateInstanceName();
Mutex::Locker locker(m_target_list_mutex);
m_selected_target_idx = m_target_list.size();
m_target_list.push_back(target_sp);
}
return error;
}
示例8:
bool
FileSystem::GetFileExists(const FileSpec &file_spec)
{
return file_spec.Exists();
}
示例9: GetSharedModuleList
Error
ModuleList::GetSharedModule
(
const FileSpec& in_file_spec,
const ArchSpec& arch,
const lldb_private::UUID *uuid_ptr,
const ConstString *object_name_ptr,
off_t object_offset,
ModuleSP &module_sp,
ModuleSP *old_module_sp_ptr,
bool *did_create_ptr,
bool always_create
)
{
ModuleList &shared_module_list = GetSharedModuleList ();
Mutex::Locker locker(shared_module_list.m_modules_mutex);
char path[PATH_MAX];
char uuid_cstr[64];
Error error;
module_sp.reset();
if (did_create_ptr)
*did_create_ptr = false;
if (old_module_sp_ptr)
old_module_sp_ptr->reset();
// First just try and get the file where it purports to be (path in
// in_file_spec), then check and uuid.
if (in_file_spec)
{
// Make sure no one else can try and get or create a module while this
// function is actively working on it by doing an extra lock on the
// global mutex list.
if (always_create == false)
{
ModuleList matching_module_list;
const size_t num_matching_modules = shared_module_list.FindModules (&in_file_spec, &arch, NULL, object_name_ptr, matching_module_list);
if (num_matching_modules > 0)
{
for (uint32_t module_idx = 0; module_idx < num_matching_modules; ++module_idx)
{
module_sp = matching_module_list.GetModuleAtIndex(module_idx);
if (uuid_ptr && uuid_ptr->IsValid())
{
// We found the module we were looking for.
if (module_sp->GetUUID() == *uuid_ptr)
return error;
}
else
{
// If we didn't have a UUID in mind when looking for the object file,
// then we should make sure the modification time hasn't changed!
TimeValue file_spec_mod_time(in_file_spec.GetModificationTime());
if (file_spec_mod_time.IsValid())
{
if (file_spec_mod_time == module_sp->GetModificationTime())
return error;
}
}
if (old_module_sp_ptr && !old_module_sp_ptr->get())
*old_module_sp_ptr = module_sp;
shared_module_list.Remove (module_sp);
module_sp.reset();
}
}
}
if (module_sp)
return error;
else
{
#if defined ENABLE_MODULE_SP_LOGGING
ModuleSP logging_module_sp (new Module (in_file_spec, arch, object_name_ptr, object_offset), ModuleSharedPtrLogger, (void *)ConstString("a.out").GetCString());
module_sp = logging_module_sp;
#else
module_sp.reset (new Module (in_file_spec, arch, object_name_ptr, object_offset));
#endif
// Make sure there are a module and an object file since we can specify
// a valid file path with an architecture that might not be in that file.
// By getting the object file we can guarantee that the architecture matches
if (module_sp && module_sp->GetObjectFile())
{
// If we get in here we got the correct arch, now we just need
// to verify the UUID if one was given
if (uuid_ptr && *uuid_ptr != module_sp->GetUUID())
module_sp.reset();
else
{
if (did_create_ptr)
*did_create_ptr = true;
shared_module_list.Append(module_sp);
return error;
}
}
}
//.........这里部分代码省略.........
示例10: if
static bool
SkinnyMachOFileContainsArchAndUUID
(
const FileSpec &file_spec,
const ArchSpec *arch,
const lldb_private::UUID *uuid, // the UUID we are looking for
off_t file_offset,
DataExtractor& data,
lldb::offset_t data_offset,
const uint32_t magic
)
{
assert(magic == MH_MAGIC || magic == MH_CIGAM || magic == MH_MAGIC_64 || magic == MH_CIGAM_64);
if (magic == MH_MAGIC || magic == MH_MAGIC_64)
data.SetByteOrder (lldb::endian::InlHostByteOrder());
else if (lldb::endian::InlHostByteOrder() == eByteOrderBig)
data.SetByteOrder (eByteOrderLittle);
else
data.SetByteOrder (eByteOrderBig);
uint32_t i;
const uint32_t cputype = data.GetU32(&data_offset); // cpu specifier
const uint32_t cpusubtype = data.GetU32(&data_offset); // machine specifier
data_offset+=4; // Skip mach file type
const uint32_t ncmds = data.GetU32(&data_offset); // number of load commands
const uint32_t sizeofcmds = data.GetU32(&data_offset); // the size of all the load commands
data_offset+=4; // Skip flags
// Check the architecture if we have a valid arch pointer
if (arch)
{
ArchSpec file_arch(eArchTypeMachO, cputype, cpusubtype);
if (!file_arch.IsCompatibleMatch(*arch))
return false;
}
// The file exists, and if a valid arch pointer was passed in we know
// if already matches, so we can return if we aren't looking for a specific
// UUID
if (uuid == NULL)
return true;
if (magic == MH_CIGAM_64 || magic == MH_MAGIC_64)
data_offset += 4; // Skip reserved field for in mach_header_64
// Make sure we have enough data for all the load commands
if (magic == MH_CIGAM_64 || magic == MH_MAGIC_64)
{
if (data.GetByteSize() < sizeof(struct mach_header_64) + sizeofcmds)
{
DataBufferSP data_buffer_sp (file_spec.ReadFileContents (file_offset, sizeof(struct mach_header_64) + sizeofcmds));
data.SetData (data_buffer_sp);
}
}
else
{
if (data.GetByteSize() < sizeof(struct mach_header) + sizeofcmds)
{
DataBufferSP data_buffer_sp (file_spec.ReadFileContents (file_offset, sizeof(struct mach_header) + sizeofcmds));
data.SetData (data_buffer_sp);
}
}
for (i=0; i<ncmds; i++)
{
const lldb::offset_t cmd_offset = data_offset; // Save this data_offset in case parsing of the segment goes awry!
uint32_t cmd = data.GetU32(&data_offset);
uint32_t cmd_size = data.GetU32(&data_offset);
if (cmd == LC_UUID)
{
lldb_private::UUID file_uuid (data.GetData(&data_offset, 16), 16);
if (file_uuid == *uuid)
return true;
return false;
}
data_offset = cmd_offset + cmd_size;
}
return false;
}
示例11: scoped_timer
Error
TargetList::CreateTarget
(
Debugger &debugger,
const FileSpec& file,
const ArchSpec& arch,
const UUID *uuid_ptr,
bool get_dependent_files,
TargetSP &target_sp
)
{
Timer scoped_timer (__PRETTY_FUNCTION__,
"TargetList::CreateTarget (file = '%s/%s', arch = '%s', uuid = %p)",
file.GetDirectory().AsCString(),
file.GetFilename().AsCString(),
arch.AsCString(),
uuid_ptr);
ModuleSP exe_module_sp;
FileSpec resolved_file(file);
if (!Host::ResolveExecutableInBundle (&resolved_file))
resolved_file = file;
Error error = ModuleList::GetSharedModule(resolved_file,
arch,
uuid_ptr,
NULL,
0,
exe_module_sp,
NULL,
NULL);
if (exe_module_sp)
{
target_sp.reset(new Target(debugger));
target_sp->SetExecutableModule (exe_module_sp, get_dependent_files);
if (target_sp.get())
{
Mutex::Locker locker(m_target_list_mutex);
m_current_target_idx = m_target_list.size();
m_target_list.push_back(target_sp);
}
// target_sp.reset(new Target);
// // Let the target resolve any funky bundle paths before we try and get
// // the object file...
// target_sp->SetExecutableModule (exe_module_sp, get_dependent_files);
// if (exe_module_sp->GetObjectFile() == NULL)
// {
// error.SetErrorStringWithFormat("%s%s%s: doesn't contain architecture %s",
// file.GetDirectory().AsCString(),
// file.GetDirectory() ? "/" : "",
// file.GetFilename().AsCString(),
// arch.AsCString());
// }
// else
// {
// if (target_sp.get())
// {
// error.Clear();
// Mutex::Locker locker(m_target_list_mutex);
// m_current_target_idx = m_target_list.size();
// m_target_list.push_back(target_sp);
// }
// }
}
else
{
target_sp.reset();
}
return error;
}
示例12:
bool
StringList::ReadFileLines (FileSpec &input_file)
{
return input_file.ReadFileLines (m_strings);
}
示例13: resolved_exe_file
Error
PlatformRemoteiOS::ResolveExecutable (const FileSpec &exe_file,
const ArchSpec &exe_arch,
lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr)
{
Error error;
// Nothing special to do here, just use the actual file and architecture
FileSpec resolved_exe_file (exe_file);
// If we have "ls" as the exe_file, resolve the executable loation based on
// the current path variables
// TODO: resolve bare executables in the Platform SDK
// if (!resolved_exe_file.Exists())
// resolved_exe_file.ResolveExecutableLocation ();
// Resolve any executable within a bundle on MacOSX
// TODO: verify that this handles shallow bundles, if not then implement one ourselves
Host::ResolveExecutableInBundle (resolved_exe_file);
if (resolved_exe_file.Exists())
{
if (exe_arch.IsValid())
{
ModuleSpec module_spec (resolved_exe_file, exe_arch);
error = ModuleList::GetSharedModule (module_spec,
exe_module_sp,
NULL,
NULL,
NULL);
if (exe_module_sp && exe_module_sp->GetObjectFile())
return error;
exe_module_sp.reset();
}
// No valid architecture was specified or the exact ARM slice wasn't
// found so ask the platform for the architectures that we should be
// using (in the correct order) and see if we can find a match that way
StreamString arch_names;
ArchSpec platform_arch;
for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, platform_arch); ++idx)
{
ModuleSpec module_spec (resolved_exe_file, platform_arch);
error = ModuleList::GetSharedModule (module_spec,
exe_module_sp,
NULL,
NULL,
NULL);
// Did we find an executable using one of the
if (error.Success())
{
if (exe_module_sp && exe_module_sp->GetObjectFile())
break;
else
error.SetErrorToGenericError();
}
if (idx > 0)
arch_names.PutCString (", ");
arch_names.PutCString (platform_arch.GetArchitectureName());
}
if (error.Fail() || !exe_module_sp)
{
error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
exe_file.GetPath().c_str(),
GetPluginName().GetCString(),
arch_names.GetString().c_str());
}
}
else
{
error.SetErrorStringWithFormat ("'%s' does not exist",
exe_file.GetPath().c_str());
}
return error;
}
示例14: resolved_exe_file
Error
PlatformWindows::ResolveExecutable (const FileSpec &exe_file,
const ArchSpec &exe_arch,
lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr)
{
Error error;
// Nothing special to do here, just use the actual file and architecture
char exe_path[PATH_MAX];
FileSpec resolved_exe_file (exe_file);
if (IsHost())
{
// if we cant resolve the executable loation based on the current path variables
if (!resolved_exe_file.Exists())
{
exe_file.GetPath(exe_path, sizeof(exe_path));
resolved_exe_file.SetFile(exe_path, true);
}
if (!resolved_exe_file.Exists())
resolved_exe_file.ResolveExecutableLocation ();
if (resolved_exe_file.Exists())
error.Clear();
else
{
exe_file.GetPath(exe_path, sizeof(exe_path));
error.SetErrorStringWithFormat("unable to find executable for '%s'", exe_path);
}
}
else
{
if (m_remote_platform_sp)
{
error = m_remote_platform_sp->ResolveExecutable (exe_file,
exe_arch,
exe_module_sp,
NULL);
}
else
{
// We may connect to a process and use the provided executable (Don't use local $PATH).
if (resolved_exe_file.Exists())
error.Clear();
else
error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", exe_path);
}
}
if (error.Success())
{
ModuleSpec module_spec (resolved_exe_file, exe_arch);
if (exe_arch.IsValid())
{
error = ModuleList::GetSharedModule (module_spec,
exe_module_sp,
NULL,
NULL,
NULL);
if (!exe_module_sp && exe_module_sp->GetObjectFile() == NULL)
{
exe_module_sp.reset();
error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s",
exe_file.GetPath().c_str(),
exe_arch.GetArchitectureName());
}
}
else
{
// No valid architecture was specified, ask the platform for
// the architectures that we should be using (in the correct order)
// and see if we can find a match that way
StreamString arch_names;
for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, module_spec.GetArchitecture()); ++idx)
{
error = ModuleList::GetSharedModule (module_spec,
exe_module_sp,
NULL,
NULL,
NULL);
// Did we find an executable using one of the
if (error.Success())
{
if (exe_module_sp && exe_module_sp->GetObjectFile())
break;
else
error.SetErrorToGenericError();
}
if (idx > 0)
arch_names.PutCString (", ");
arch_names.PutCString (module_spec.GetArchitecture().GetArchitectureName());
}
if (error.Fail() || !exe_module_sp)
{
error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
//.........这里部分代码省略.........
示例15: scoped_timer
Error
TargetList::CreateTargetInternal (Debugger &debugger,
const char *user_exe_path,
const ArchSpec& specified_arch,
bool get_dependent_files,
lldb::PlatformSP &platform_sp,
lldb::TargetSP &target_sp,
bool is_dummy_target)
{
Timer scoped_timer (__PRETTY_FUNCTION__,
"TargetList::CreateTarget (file = '%s', arch = '%s')",
user_exe_path,
specified_arch.GetArchitectureName());
Error error;
ArchSpec arch(specified_arch);
if (arch.IsValid())
{
if (!platform_sp || !platform_sp->IsCompatibleArchitecture(arch, false, NULL))
platform_sp = Platform::GetPlatformForArchitecture(specified_arch, &arch);
}
if (!platform_sp)
platform_sp = debugger.GetPlatformList().GetSelectedPlatform();
if (!arch.IsValid())
arch = specified_arch;
FileSpec file (user_exe_path, false);
if (!file.Exists() && user_exe_path && user_exe_path[0] == '~')
{
// we want to expand the tilde but we don't want to resolve any symbolic links
// so we can't use the FileSpec constructor's resolve flag
llvm::SmallString<64> unglobbed_path(user_exe_path);
FileSpec::ResolveUsername(unglobbed_path);
if (unglobbed_path.empty())
file = FileSpec(user_exe_path, false);
else
file = FileSpec(unglobbed_path.c_str(), false);
}
bool user_exe_path_is_bundle = false;
char resolved_bundle_exe_path[PATH_MAX];
resolved_bundle_exe_path[0] = '\0';
if (file)
{
if (file.GetFileType() == FileSpec::eFileTypeDirectory)
user_exe_path_is_bundle = true;
if (file.IsRelativeToCurrentWorkingDirectory() && user_exe_path)
{
// Ignore paths that start with "./" and "../"
if (!((user_exe_path[0] == '.' && user_exe_path[1] == '/') ||
(user_exe_path[0] == '.' && user_exe_path[1] == '.' && user_exe_path[2] == '/')))
{
char cwd[PATH_MAX];
if (getcwd (cwd, sizeof(cwd)))
{
std::string cwd_user_exe_path (cwd);
cwd_user_exe_path += '/';
cwd_user_exe_path += user_exe_path;
FileSpec cwd_file (cwd_user_exe_path.c_str(), false);
if (cwd_file.Exists())
file = cwd_file;
}
}
}
ModuleSP exe_module_sp;
if (platform_sp)
{
FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths());
ModuleSpec module_spec(file, arch);
error = platform_sp->ResolveExecutable (module_spec,
exe_module_sp,
executable_search_paths.GetSize() ? &executable_search_paths : NULL);
}
if (error.Success() && exe_module_sp)
{
if (exe_module_sp->GetObjectFile() == NULL)
{
if (arch.IsValid())
{
error.SetErrorStringWithFormat("\"%s\" doesn't contain architecture %s",
file.GetPath().c_str(),
arch.GetArchitectureName());
}
else
{
error.SetErrorStringWithFormat("unsupported file type \"%s\"",
file.GetPath().c_str());
}
return error;
}
target_sp.reset(new Target(debugger, arch, platform_sp, is_dummy_target));
target_sp->SetExecutableModule (exe_module_sp, get_dependent_files);
//.........这里部分代码省略.........