本文整理汇总了C++中ArchSpec::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ ArchSpec::IsValid方法的具体用法?C++ ArchSpec::IsValid怎么用?C++ ArchSpec::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArchSpec
的用法示例。
在下文中一共展示了ArchSpec::IsValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool
PlatformWindows::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
{
// From macosx;s plugin code. For FreeBSD we may want to support more archs.
if (idx == 0)
{
arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
return arch.IsValid();
}
else if (idx == 1)
{
ArchSpec platform_arch (Host::GetArchitecture (Host::eSystemDefaultArchitecture));
ArchSpec platform_arch64 (Host::GetArchitecture (Host::eSystemDefaultArchitecture64));
if (platform_arch.IsExactMatch(platform_arch64))
{
// This freebsd platform supports both 32 and 64 bit. Since we already
// returned the 64 bit arch for idx == 0, return the 32 bit arch
// for idx == 1
arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture32);
return arch.IsValid();
}
}
return false;
}
示例2:
bool
PlatformAppleWatchSimulator::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
{
static const ArchSpec platform_arch(HostInfo::GetArchitecture(HostInfo::eArchKind64));
if (idx == 0)
{
arch = platform_arch;
if (arch.IsValid())
{
arch.GetTriple().setOS (llvm::Triple::WatchOS);
return true;
}
}
return false;
}
示例3: GetSupportedArchitectureAtIndex
bool PlatformOpenBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
ArchSpec &arch) {
if (IsHost()) {
ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
if (hostArch.GetTriple().isOSOpenBSD()) {
if (idx == 0) {
arch = hostArch;
return arch.IsValid();
}
}
} else {
if (m_remote_platform_sp)
return m_remote_platform_sp->GetSupportedArchitectureAtIndex(idx, arch);
llvm::Triple triple;
// Set the OS to OpenBSD
triple.setOS(llvm::Triple::OpenBSD);
// Set the architecture
switch (idx) {
case 0:
triple.setArchName("x86_64");
break;
case 1:
triple.setArchName("i386");
break;
case 2:
triple.setArchName("aarch64");
break;
case 3:
triple.setArchName("arm");
break;
default:
return false;
}
// Leave the vendor as "llvm::Triple:UnknownVendor" and don't specify the
// vendor by calling triple.SetVendorName("unknown") so that it is a
// "unspecified unknown". This means when someone calls
// triple.GetVendorName() it will return an empty string which indicates
// that the vendor can be set when two architectures are merged
// Now set the triple into "arch" and return true
arch.SetTriple(triple);
return true;
}
return false;
}
示例4: arch
void
Platform::GetStatus (Stream &strm)
{
uint32_t major = UINT32_MAX;
uint32_t minor = UINT32_MAX;
uint32_t update = UINT32_MAX;
std::string s;
strm.Printf (" Platform: %s\n", GetShortPluginName());
ArchSpec arch (GetSystemArchitecture());
if (arch.IsValid())
{
if (!arch.GetTriple().str().empty())
strm.Printf(" Triple: %s\n", arch.GetTriple().str().c_str());
}
if (GetOSVersion(major, minor, update))
{
strm.Printf("OS Version: %u", major);
if (minor != UINT32_MAX)
strm.Printf(".%u", minor);
if (update != UINT32_MAX)
strm.Printf(".%u", update);
if (GetOSBuildString (s))
strm.Printf(" (%s)", s.c_str());
strm.EOL();
}
if (GetOSKernelDescription (s))
strm.Printf(" Kernel: %s\n", s.c_str());
if (IsHost())
{
strm.Printf(" Hostname: %s\n", GetHostname());
}
else
{
const bool is_connected = IsConnected();
if (is_connected)
strm.Printf(" Hostname: %s\n", GetHostname());
strm.Printf(" Connected: %s\n", is_connected ? "yes" : "no");
}
}
示例5: module_sp
ObjectFileSP
ObjectContainerUniversalMachO::GetObjectFile(const FileSpec *file) {
uint32_t arch_idx = 0;
ArchSpec arch;
// If the module hasn't specified an architecture yet, set it to the default
// architecture:
ModuleSP module_sp(GetModule());
if (module_sp) {
if (!module_sp->GetArchitecture().IsValid()) {
arch = Target::GetDefaultArchitecture();
if (!arch.IsValid())
arch.SetTriple(LLDB_ARCH_DEFAULT);
} else
arch = module_sp->GetArchitecture();
ArchSpec curr_arch;
// First, try to find an exact match for the Arch of the Target.
for (arch_idx = 0; arch_idx < m_header.nfat_arch; ++arch_idx) {
if (GetArchitectureAtIndex(arch_idx, curr_arch) &&
arch.IsExactMatch(curr_arch))
break;
}
// Failing an exact match, try to find a compatible Arch of the Target.
if (arch_idx >= m_header.nfat_arch) {
for (arch_idx = 0; arch_idx < m_header.nfat_arch; ++arch_idx) {
if (GetArchitectureAtIndex(arch_idx, curr_arch) &&
arch.IsCompatibleMatch(curr_arch))
break;
}
}
if (arch_idx < m_header.nfat_arch) {
DataBufferSP data_sp;
lldb::offset_t data_offset = 0;
return ObjectFile::FindPlugin(
module_sp, file, m_offset + m_fat_archs[arch_idx].offset,
m_fat_archs[arch_idx].size, data_sp, data_offset);
}
}
return ObjectFileSP();
}
示例6: ResolveProcessArchitecture
Error NativeProcessProtocol::ResolveProcessArchitecture(lldb::pid_t pid,
ArchSpec &arch) {
// Grab process info for the running process.
ProcessInstanceInfo process_info;
if (!Host::GetProcessInfo(pid, process_info))
return Error("failed to get process info");
// Resolve the executable module.
ModuleSpecList module_specs;
if (!ObjectFile::GetModuleSpecifications(process_info.GetExecutableFile(), 0,
0, module_specs))
return Error("failed to get module specifications");
lldbassert(module_specs.GetSize() == 1);
arch = module_specs.GetModuleSpecRefAtIndex(0).GetArchitecture();
if (arch.IsValid())
return Error();
else
return Error("failed to retrieve a valid architecture from the exe module");
}
示例7: locker
ObjectContainerBSDArchive::Archive::shared_ptr
ObjectContainerBSDArchive::Archive::FindCachedArchive (const FileSpec &file, const ArchSpec &arch, const TimeValue &time, lldb::offset_t file_offset)
{
Mutex::Locker locker(Archive::GetArchiveCacheMutex ());
shared_ptr archive_sp;
Archive::Map &archive_map = Archive::GetArchiveCache ();
Archive::Map::iterator pos = archive_map.find (file);
// Don't cache a value for "archive_map.end()" below since we might
// delete an archive entry...
while (pos != archive_map.end() && pos->first == file)
{
bool match = true;
if (arch.IsValid() && pos->second->GetArchitecture().IsCompatibleMatch(arch) == false)
match = false;
else if (file_offset != LLDB_INVALID_OFFSET && pos->second->GetFileOffset() != file_offset)
match = false;
if (match)
{
if (pos->second->GetModificationTime() == time)
{
return pos->second;
}
else
{
// We have a file at the same path with the same architecture
// whose modification time doesn't match. It doesn't make sense
// for us to continue to use this BSD archive since we cache only
// the object info which consists of file time info and also the
// file offset and file size of any contianed objects. Since
// this information is now out of date, we won't get the correct
// information if we go and extract the file data, so we should
// remove the old and outdated entry.
archive_map.erase (pos);
pos = archive_map.find (file);
continue; // Continue to next iteration so we don't increment pos below...
}
}
++pos;
}
return archive_sp;
}
示例8:
PlatformSP
Platform::Create (const ArchSpec &arch, ArchSpec *platform_arch_ptr, Error &error)
{
lldb::PlatformSP platform_sp;
if (arch.IsValid())
{
uint32_t idx;
PlatformCreateInstance create_callback;
// First try exact arch matches across all platform plug-ins
bool exact = true;
for (idx = 0; (create_callback = PluginManager::GetPlatformCreateCallbackAtIndex (idx)); ++idx)
{
if (create_callback)
{
platform_sp.reset(create_callback(false, &arch));
if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, exact, platform_arch_ptr))
return platform_sp;
}
}
// Next try compatible arch matches across all platform plug-ins
exact = false;
for (idx = 0; (create_callback = PluginManager::GetPlatformCreateCallbackAtIndex (idx)); ++idx)
{
if (create_callback)
{
platform_sp.reset(create_callback(false, &arch));
if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, exact, platform_arch_ptr))
return platform_sp;
}
}
}
else
error.SetErrorString ("invalid platform name");
if (platform_arch_ptr)
platform_arch_ptr->Clear();
platform_sp.reset();
return platform_sp;
}
示例9: resolved_exe_file
Error
PlatformKalimba::ResolveExecutable (const FileSpec &exe_file,
const ArchSpec &exe_arch,
lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr)
{
Error error;
char exe_path[PATH_MAX];
FileSpec resolved_exe_file (exe_file);
if (!resolved_exe_file.Exists())
{
exe_file.GetPath(exe_path, sizeof(exe_path));
error.SetErrorStringWithFormat("unable to find executable for '%s'", 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 (error.Fail())
{
// If we failed, it may be because the vendor and os aren't known. If that is the
// case, try setting them to the host architecture and give it another try.
llvm::Triple &module_triple = module_spec.GetArchitecture().GetTriple();
bool is_vendor_specified = (module_triple.getVendor() != llvm::Triple::UnknownVendor);
bool is_os_specified = (module_triple.getOS() != llvm::Triple::UnknownOS);
if (!is_vendor_specified || !is_os_specified)
{
const llvm::Triple &host_triple = Host::GetArchitecture (Host::eSystemDefaultArchitecture).GetTriple();
if (!is_vendor_specified)
module_triple.setVendorName (host_triple.getVendorName());
if (!is_os_specified)
module_triple.setOSName (host_triple.getOSName());
error = ModuleList::GetSharedModule (module_spec,
exe_module_sp,
NULL,
NULL,
NULL);
}
}
// TODO find out why exe_module_sp might be 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",
exe_file.GetPath().c_str(),
GetPluginName().GetCString(),
arch_names.GetString().c_str());
}
}
}
return error;
}
示例10: data
//.........这里部分代码省略.........
for (uint32_t i=0; i<num_sections; ++i)
{
Section *section = section_list->GetSectionAtIndex (i).get();
if (section)
{
lldb::addr_t section_vm_addr = section->GetFileAddress();
FileRange file_range (section->GetFileOffset(), section->GetFileSize());
VMRangeToFileOffset::Entry range_entry (section_vm_addr,
section->GetByteSize(),
file_range);
if (vm_addr > section_vm_addr)
ranges_are_sorted = false;
vm_addr = section->GetFileAddress();
VMRangeToFileOffset::Entry *last_entry = m_core_aranges.Back();
// printf ("LC_SEGMENT[%u] arange=[0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), frange=[0x%8.8x - 0x%8.8x)\n",
// i,
// range_entry.GetRangeBase(),
// range_entry.GetRangeEnd(),
// range_entry.data.GetRangeBase(),
// range_entry.data.GetRangeEnd());
if (last_entry &&
last_entry->GetRangeEnd() == range_entry.GetRangeBase() &&
last_entry->data.GetRangeEnd() == range_entry.data.GetRangeBase())
{
last_entry->SetRangeEnd (range_entry.GetRangeEnd());
last_entry->data.SetRangeEnd (range_entry.data.GetRangeEnd());
//puts("combine");
}
else
{
m_core_aranges.Append(range_entry);
}
}
}
if (!ranges_are_sorted)
{
m_core_aranges.Sort();
}
if (m_dyld_addr == LLDB_INVALID_ADDRESS || m_mach_kernel_addr == LLDB_INVALID_ADDRESS)
{
// We need to locate the main executable in the memory ranges
// we have in the core file. We need to search for both a user-process dyld binary
// and a kernel binary in memory; we must look at all the pages in the binary so
// we don't miss one or the other. If we find a user-process dyld binary, stop
// searching -- that's the one we'll prefer over the mach kernel.
const size_t num_core_aranges = m_core_aranges.GetSize();
for (size_t i=0; i<num_core_aranges && m_dyld_addr == LLDB_INVALID_ADDRESS; ++i)
{
const VMRangeToFileOffset::Entry *entry = m_core_aranges.GetEntryAtIndex(i);
lldb::addr_t section_vm_addr_start = entry->GetRangeBase();
lldb::addr_t section_vm_addr_end = entry->GetRangeEnd();
for (lldb::addr_t section_vm_addr = section_vm_addr_start;
section_vm_addr < section_vm_addr_end;
section_vm_addr += 0x1000)
{
GetDynamicLoaderAddress (section_vm_addr);
}
}
}
// If we found both a user-process dyld and a kernel binary, we need to decide
// which to prefer.
if (GetCorefilePreference() == eKernelCorefile)
{
if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS)
{
m_dyld_plugin_name = DynamicLoaderDarwinKernel::GetPluginNameStatic();
}
else if (m_dyld_addr != LLDB_INVALID_ADDRESS)
{
m_dyld_plugin_name = DynamicLoaderMacOSXDYLD::GetPluginNameStatic();
}
}
else
{
if (m_dyld_addr != LLDB_INVALID_ADDRESS)
{
m_dyld_plugin_name = DynamicLoaderMacOSXDYLD::GetPluginNameStatic();
}
else if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS)
{
m_dyld_plugin_name = DynamicLoaderDarwinKernel::GetPluginNameStatic();
}
}
// Even if the architecture is set in the target, we need to override
// it to match the core file which is always single arch.
ArchSpec arch (m_core_module_sp->GetArchitecture());
if (arch.GetCore() == ArchSpec::eCore_x86_32_i486)
{
arch.SetTriple ("i386", m_target.GetPlatform().get());
}
if (arch.IsValid())
m_target.SetArchitecture(arch);
return error;
}
示例11: locker
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;
}
}
}
//.........这里部分代码省略.........
示例12: scoped_timer
bool
CommandObjectFile::Execute
(
CommandInterpreter &interpreter,
Args& command,
CommandReturnObject &result
)
{
const char *file_path = command.GetArgumentAtIndex(0);
Timer scoped_timer(__PRETTY_FUNCTION__, "(dbg) file '%s'", file_path);
const int argc = command.GetArgumentCount();
if (argc == 1)
{
FileSpec file_spec (file_path);
if (! file_spec.Exists())
{
result.AppendErrorWithFormat ("File '%s' does not exist.\n", file_path);
result.SetStatus (eReturnStatusFailed);
return result.Succeeded();
}
TargetSP target_sp;
ArchSpec arch;
if (m_options.m_arch.IsValid())
arch = m_options.m_arch;
else
{
arch = lldb_private::GetDefaultArchitecture ();
if (!arch.IsValid())
arch = LLDB_ARCH_DEFAULT;
}
Debugger &debugger = interpreter.GetDebugger();
Error error = debugger.GetTargetList().CreateTarget (debugger, file_spec, arch, NULL, true, target_sp);
if (error.Fail() && !m_options.m_arch.IsValid())
{
if (arch == LLDB_ARCH_DEFAULT_32BIT)
arch = LLDB_ARCH_DEFAULT_64BIT;
else
arch = LLDB_ARCH_DEFAULT_32BIT;
error = debugger.GetTargetList().CreateTarget (debugger, file_spec, arch, NULL, true, target_sp);
}
if (target_sp)
{
debugger.GetTargetList().SetCurrentTarget(target_sp.get());
result.AppendMessageWithFormat ("Current executable set to '%s' (%s).\n", file_path, arch.AsCString());
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
else
{
result.AppendError(error.AsCString());
result.SetStatus (eReturnStatusFailed);
}
}
else
{
result.AppendErrorWithFormat("'%s' takes exactly one executable path argument.\n", m_cmd_name.c_str());
result.SetStatus (eReturnStatusFailed);
}
return result.Succeeded();
}
示例13: arch
//----------------------------------------------------------------------
// Process Control
//----------------------------------------------------------------------
Error
ProcessElfCore::DoLoadCore ()
{
Error error;
if (!m_core_module_sp)
{
error.SetErrorString ("invalid core module");
return error;
}
ObjectFileELF *core = (ObjectFileELF *)(m_core_module_sp->GetObjectFile());
if (core == NULL)
{
error.SetErrorString ("invalid core object file");
return error;
}
const uint32_t num_segments = core->GetProgramHeaderCount();
if (num_segments == 0)
{
error.SetErrorString ("core file has no sections");
return error;
}
SetCanJIT(false);
m_thread_data_valid = true;
bool ranges_are_sorted = true;
lldb::addr_t vm_addr = 0;
/// Walk through segments and Thread and Address Map information.
/// PT_NOTE - Contains Thread and Register information
/// PT_LOAD - Contains a contiguous range of Process Address Space
for(uint32_t i = 1; i <= num_segments; i++)
{
const elf::ELFProgramHeader *header = core->GetProgramHeaderByIndex(i);
assert(header != NULL);
DataExtractor data = core->GetSegmentDataByIndex(i);
// Parse thread contexts and auxv structure
if (header->p_type == llvm::ELF::PT_NOTE)
ParseThreadContextsFromNoteSegment(header, data);
// PT_LOAD segments contains address map
if (header->p_type == llvm::ELF::PT_LOAD)
{
lldb::addr_t last_addr = AddAddressRangeFromLoadSegment(header);
if (vm_addr > last_addr)
ranges_are_sorted = false;
vm_addr = last_addr;
}
}
if (!ranges_are_sorted)
m_core_aranges.Sort();
// Even if the architecture is set in the target, we need to override
// it to match the core file which is always single arch.
ArchSpec arch (m_core_module_sp->GetArchitecture());
if (arch.IsValid())
m_target.SetArchitecture(arch);
return error;
}
示例14: resolved_exe_file
Error
PlatformLinux::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 have "ls" as the exe_file, resolve the executable location 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);
// TODO find out why exe_module_sp might be NULL
if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL)
{
exe_module_sp.reset();
error.SetErrorStringWithFormat ("'%s%s%s' doesn't contain the architecture %s",
exe_file.GetDirectory().AsCString(""),
exe_file.GetDirectory() ? "/" : "",
exe_file.GetFilename().AsCString(""),
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());
//.........这里部分代码省略.........
示例15: arch
//----------------------------------------------------------------------
// Process Control
//----------------------------------------------------------------------
Error
ProcessElfCore::DoLoadCore ()
{
Error error;
if (!m_core_module_sp)
{
error.SetErrorString ("invalid core module");
return error;
}
ObjectFileELF *core = (ObjectFileELF *)(m_core_module_sp->GetObjectFile());
if (core == NULL)
{
error.SetErrorString ("invalid core object file");
return error;
}
const uint32_t num_segments = core->GetProgramHeaderCount();
if (num_segments == 0)
{
error.SetErrorString ("core file has no segments");
return error;
}
SetCanJIT(false);
m_thread_data_valid = true;
bool ranges_are_sorted = true;
lldb::addr_t vm_addr = 0;
/// Walk through segments and Thread and Address Map information.
/// PT_NOTE - Contains Thread and Register information
/// PT_LOAD - Contains a contiguous range of Process Address Space
for(uint32_t i = 1; i <= num_segments; i++)
{
const elf::ELFProgramHeader *header = core->GetProgramHeaderByIndex(i);
assert(header != NULL);
DataExtractor data = core->GetSegmentDataByIndex(i);
// Parse thread contexts and auxv structure
if (header->p_type == llvm::ELF::PT_NOTE)
ParseThreadContextsFromNoteSegment(header, data);
// PT_LOAD segments contains address map
if (header->p_type == llvm::ELF::PT_LOAD)
{
lldb::addr_t last_addr = AddAddressRangeFromLoadSegment(header);
if (vm_addr > last_addr)
ranges_are_sorted = false;
vm_addr = last_addr;
}
}
if (!ranges_are_sorted)
{
m_core_aranges.Sort();
m_core_range_infos.Sort();
}
// Even if the architecture is set in the target, we need to override
// it to match the core file which is always single arch.
ArchSpec arch (m_core_module_sp->GetArchitecture());
if (arch.IsValid())
GetTarget().SetArchitecture(arch);
SetUnixSignals(UnixSignals::Create(GetArchitecture()));
// Core files are useless without the main executable. See if we can locate the main
// executable using data we found in the core file notes.
lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
if (!exe_module_sp)
{
// The first entry in the NT_FILE might be our executable
if (!m_nt_file_entries.empty())
{
ModuleSpec exe_module_spec;
exe_module_spec.GetArchitecture() = arch;
exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path.GetCString(), false);
if (exe_module_spec.GetFileSpec())
{
exe_module_sp = GetTarget().GetSharedModule(exe_module_spec);
if (exe_module_sp)
GetTarget().SetExecutableModule(exe_module_sp, false);
}
}
}
return error;
}