本文整理汇总了C++中ArchSpec类的典型用法代码示例。如果您正苦于以下问题:C++ ArchSpec类的具体用法?C++ ArchSpec怎么用?C++ ArchSpec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArchSpec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNumArchitectures
void
ObjectContainerUniversalMachO::Dump (Stream *s) const
{
s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
s->Indent();
const size_t num_archs = GetNumArchitectures();
const size_t num_objects = GetNumObjects();
s->Printf("ObjectContainerUniversalMachO, num_archs = %u, num_objects = %u", num_archs, num_objects);
uint32_t i;
ArchSpec arch;
s->IndentMore();
for (i=0; i<num_archs; i++)
{
s->Indent();
GetArchitectureAtIndex(i, arch);
s->Printf("arch[%u] = %s\n", arch.GetArchitectureName());
}
for (i=0; i<num_objects; i++)
{
s->Indent();
s->Printf("object[%u] = %s\n", GetObjectNameAtIndex (i));
}
s->IndentLess();
s->EOL();
}
示例2: FindPlugin
ObjectFile *
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:
if (!m_module->GetArchitecture().IsValid())
{
arch = Target::GetDefaultArchitecture ();
if (!arch.IsValid())
arch.SetTriple (LLDB_ARCH_DEFAULT);
}
else
arch = m_module->GetArchitecture();
ArchSpec curr_arch;
for (arch_idx = 0; arch_idx < m_header.nfat_arch; ++arch_idx)
{
if (GetArchitectureAtIndex (arch_idx, curr_arch))
{
if (arch == curr_arch)
{
return ObjectFile::FindPlugin (m_module, file, m_offset + m_fat_archs[arch_idx].offset, m_fat_archs[arch_idx].size);
}
}
}
return NULL;
}
示例3: switch
unsigned
POSIXThread::GetRegisterIndexFromOffset(unsigned offset)
{
unsigned reg = LLDB_INVALID_REGNUM;
ArchSpec arch = Host::GetArchitecture();
switch (arch.GetCore())
{
default:
llvm_unreachable("CPU type not supported!");
break;
case ArchSpec::eCore_mips64:
case ArchSpec::eCore_x86_32_i386:
case ArchSpec::eCore_x86_32_i486:
case ArchSpec::eCore_x86_32_i486sx:
case ArchSpec::eCore_x86_64_x86_64:
{
POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
reg = reg_ctx->GetRegisterIndexFromOffset(offset);
}
break;
}
return reg;
}
示例4: if
lldb::TypeSystemSP
GoASTContext::CreateInstance (lldb::LanguageType language, Module *module, Target *target, const char *compiler_options)
{
if (language == eLanguageTypeGo)
{
ArchSpec arch;
std::shared_ptr<GoASTContext> go_ast_sp;
if (module)
{
arch = module->GetArchitecture();
go_ast_sp = std::shared_ptr<GoASTContext>(new GoASTContext);
}
else if (target)
{
arch = target->GetArchitecture();
go_ast_sp = std::shared_ptr<GoASTContextForExpr>(new GoASTContextForExpr(target->shared_from_this()));
}
if (arch.IsValid())
{
go_ast_sp->SetAddressByteSize(arch.GetAddressByteSize());
return go_ast_sp;
}
}
return lldb::TypeSystemSP();
}
示例5: data
lldb::DisassemblerSP
Disassembler::DisassembleBytes
(
const ArchSpec &arch,
const char *plugin_name,
const Address &start,
const void *bytes,
size_t length,
uint32_t num_instructions
)
{
lldb::DisassemblerSP disasm_sp;
if (bytes)
{
disasm_sp.reset(Disassembler::FindPlugin(arch, plugin_name));
if (disasm_sp)
{
DataExtractor data(bytes, length, arch.GetByteOrder(), arch.GetAddressByteSize());
(void)disasm_sp->DecodeInstructions (start,
data,
0,
num_instructions,
false);
}
}
return disasm_sp;
}
示例6: switch
unsigned
POSIXThread::GetRegisterIndexFromOffset(unsigned offset)
{
unsigned reg = LLDB_INVALID_REGNUM;
ArchSpec arch = Host::GetArchitecture();
switch (arch.GetCore())
{
default:
llvm_unreachable("CPU type not supported!");
break;
case ArchSpec::eCore_x86_32_i386:
case ArchSpec::eCore_x86_32_i486:
case ArchSpec::eCore_x86_32_i486sx:
case ArchSpec::eCore_x86_64_x86_64:
{
RegisterContextSP base = GetRegisterContext();
if (base) {
RegisterContextPOSIX &context = static_cast<RegisterContextPOSIX &>(*base);
reg = context.GetRegisterIndexFromOffset(offset);
}
}
break;
}
return reg;
}
示例7: module_sp
void
ObjectFileJIT::Dump (Stream *s)
{
ModuleSP module_sp(GetModule());
if (module_sp)
{
lldb_private::Mutex::Locker locker(module_sp->GetMutex());
s->Printf("%p: ", static_cast<void*>(this));
s->Indent();
s->PutCString("ObjectFileJIT");
ArchSpec arch;
if (GetArchitecture(arch))
*s << ", arch = " << arch.GetArchitectureName();
s->EOL();
SectionList *sections = GetSectionList();
if (sections)
sections->Dump(s, NULL, true, UINT32_MAX);
if (m_symtab_ap.get())
m_symtab_ap->Dump(s, NULL, eSortOrderNone);
}
}
示例8: switch
size_t
PlatformFreeBSD::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site)
{
ArchSpec arch = target.GetArchitecture();
const uint8_t *trap_opcode = NULL;
size_t trap_opcode_size = 0;
switch (arch.GetMachine())
{
default:
llvm_unreachable("Unhandled architecture in PlatformFreeBSD::GetSoftwareBreakpointTrapOpcode()");
break;
case llvm::Triple::x86:
case llvm::Triple::x86_64:
{
static const uint8_t g_i386_opcode[] = { 0xCC };
trap_opcode = g_i386_opcode;
trap_opcode_size = sizeof(g_i386_opcode);
}
break;
}
if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
return trap_opcode_size;
return 0;
}
示例9: switch
RegisterContextSP
TargetThreadWindowsLive::CreateRegisterContextForFrameIndex(uint32_t idx) {
if (!m_reg_context_sp) {
ArchSpec arch = HostInfo::GetArchitecture();
switch (arch.GetMachine()) {
case llvm::Triple::x86:
#if defined(_WIN64)
// FIXME: This is a Wow64 process, create a RegisterContextWindows_Wow64
#else
m_reg_context_sp.reset(new RegisterContextWindowsLive_x86(*this, idx));
#endif
break;
case llvm::Triple::x86_64:
#if defined(_WIN64)
m_reg_context_sp.reset(new RegisterContextWindowsLive_x64(*this, idx));
#else
// LLDB is 32-bit, but the target process is 64-bit. We probably can't debug
// this.
#endif
default:
break;
}
}
return m_reg_context_sp;
}
示例10: switch
uint64_t Type::GetByteSize() {
if (m_byte_size == 0) {
switch (m_encoding_uid_type) {
case eEncodingInvalid:
case eEncodingIsSyntheticUID:
break;
case eEncodingIsUID:
case eEncodingIsConstUID:
case eEncodingIsRestrictUID:
case eEncodingIsVolatileUID:
case eEncodingIsTypedefUID: {
Type *encoding_type = GetEncodingType();
if (encoding_type)
m_byte_size = encoding_type->GetByteSize();
if (m_byte_size == 0)
m_byte_size = GetLayoutCompilerType().GetByteSize(nullptr);
} break;
// If we are a pointer or reference, then this is just a pointer size;
case eEncodingIsPointerUID:
case eEncodingIsLValueReferenceUID:
case eEncodingIsRValueReferenceUID: {
ArchSpec arch;
if (m_symbol_file->GetObjectFile()->GetArchitecture(arch))
m_byte_size = arch.GetAddressByteSize();
} break;
}
}
return m_byte_size;
}
示例11: data
lldb::DisassemblerSP
Disassembler::DisassembleBytes (const ArchSpec &arch,
const char *plugin_name,
const char *flavor,
const Address &start,
const void *src,
size_t src_len,
uint32_t num_instructions,
bool data_from_file)
{
lldb::DisassemblerSP disasm_sp;
if (src)
{
disasm_sp = Disassembler::FindPlugin(arch, flavor, plugin_name);
if (disasm_sp)
{
DataExtractor data(src, src_len, arch.GetByteOrder(), arch.GetAddressByteSize());
(void)disasm_sp->DecodeInstructions (start,
data,
0,
num_instructions,
false,
data_from_file);
}
}
return disasm_sp;
}
示例12: ParseFreeBSDPrStatus
// Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details.
static void
ParseFreeBSDPrStatus(ThreadData &thread_data, DataExtractor &data,
ArchSpec &arch)
{
lldb::offset_t offset = 0;
bool lp64 = (arch.GetMachine() == llvm::Triple::aarch64 ||
arch.GetMachine() == llvm::Triple::mips64 ||
arch.GetMachine() == llvm::Triple::ppc64 ||
arch.GetMachine() == llvm::Triple::x86_64);
int pr_version = data.GetU32(&offset);
Log *log (GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
if (log)
{
if (pr_version > 1)
log->Printf("FreeBSD PRSTATUS unexpected version %d", pr_version);
}
// Skip padding, pr_statussz, pr_gregsetsz, pr_fpregsetsz, pr_osreldate
if (lp64)
offset += 32;
else
offset += 16;
thread_data.signo = data.GetU32(&offset); // pr_cursig
thread_data.tid = data.GetU32(&offset); // pr_pid
if (lp64)
offset += 4;
size_t len = data.GetByteSize() - offset;
thread_data.gpregset = DataExtractor(data, offset, len);
}
示例13: Disassembler
DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch) :
Disassembler(arch),
m_exe_ctx (NULL),
m_inst (NULL),
m_disasm_context (NULL),
m_alternate_disasm_context (NULL)
{
m_disasm_context = ::LLVMCreateDisasm(arch.GetTriple().getTriple().c_str(),
(void*)this,
/*TagType=*/1,
NULL,
DisassemblerLLVMC::SymbolLookupCallback);
if (arch.GetTriple().getArch() == llvm::Triple::arm)
{
ArchSpec thumb_arch(arch);
thumb_arch.GetTriple().setArchName(llvm::StringRef("thumbv7"));
std::string thumb_triple(thumb_arch.GetTriple().getTriple());
m_alternate_disasm_context = ::LLVMCreateDisasm(thumb_triple.c_str(),
(void*)this,
/*TagType=*/1,
NULL,
DisassemblerLLVMC::SymbolLookupCallback);
}
}
示例14: m_arch
//----------------------------------------------------------------------
// Disassembler copy constructor
//----------------------------------------------------------------------
Disassembler::Disassembler(const ArchSpec& arch, const char *flavor) :
m_arch (arch),
m_instruction_list(),
m_base_addr(LLDB_INVALID_ADDRESS),
m_flavor ()
{
if (flavor == NULL)
m_flavor.assign("default");
else
m_flavor.assign(flavor);
// If this is an arm variant that can only include thumb (T16, T32)
// instructions, force the arch triple to be "thumbv.." instead of
// "armv..."
if (arch.GetTriple().getArch() == llvm::Triple::arm
&& (arch.GetCore() == ArchSpec::Core::eCore_arm_armv7m
|| arch.GetCore() == ArchSpec::Core::eCore_arm_armv7em
|| arch.GetCore() == ArchSpec::Core::eCore_arm_armv6m))
{
std::string thumb_arch_name (arch.GetTriple().getArchName().str());
// Replace "arm" with "thumb" so we get all thumb variants correct
if (thumb_arch_name.size() > 3)
{
thumb_arch_name.erase(0, 3);
thumb_arch_name.insert(0, "thumb");
}
m_arch.SetTriple (thumb_arch_name.c_str());
}
}
示例15: GetLogIfAnyCategoriesSet
bool
PlatformRemoteGDBServer::GetModuleSpec (const FileSpec& module_file_spec,
const ArchSpec& arch,
ModuleSpec &module_spec)
{
Log *log = GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PLATFORM);
const auto module_path = module_file_spec.GetPath (false);
if (!m_gdb_client.GetModuleInfo (module_file_spec, arch, module_spec))
{
if (log)
log->Printf ("PlatformRemoteGDBServer::%s - failed to get module info for %s:%s",
__FUNCTION__, module_path.c_str (), arch.GetTriple ().getTriple ().c_str ());
return false;
}
if (log)
{
StreamString stream;
module_spec.Dump (stream);
log->Printf ("PlatformRemoteGDBServer::%s - got module info for (%s:%s) : %s",
__FUNCTION__, module_path.c_str (), arch.GetTriple ().getTriple ().c_str (), stream.GetString ().c_str ());
}
return true;
}