本文整理汇总了C++中Thread::GetProcess方法的典型用法代码示例。如果您正苦于以下问题:C++ Thread::GetProcess方法的具体用法?C++ Thread::GetProcess怎么用?C++ Thread::GetProcess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thread
的用法示例。
在下文中一共展示了Thread::GetProcess方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ThreadPlanTracer
ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer (Thread &thread, lldb::StreamSP &stream_sp) :
ThreadPlanTracer (thread, stream_sp),
m_process(thread.GetProcess()),
m_target(thread.GetProcess().GetTarget())
{
InitializeTracer ();
}
示例2: compiler_type
bool
ABIMacOSX_i386::GetArgumentValues (Thread &thread,
ValueList &values) const
{
unsigned int num_values = values.GetSize();
unsigned int value_index;
// Get the pointer to the first stack argument so we have a place to start
// when reading data
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return false;
addr_t sp = reg_ctx->GetSP(0);
if (!sp)
return false;
addr_t current_stack_argument = sp + 4; // jump over return address
for (value_index = 0;
value_index < num_values;
++value_index)
{
Value *value = values.GetValueAtIndex(value_index);
if (!value)
return false;
// We currently only support extracting values with Clang QualTypes.
// Do we care about others?
CompilerType compiler_type (value->GetCompilerType());
if (compiler_type)
{
bool is_signed;
if (compiler_type.IsIntegerType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
compiler_type.GetBitSize(&thread),
is_signed,
thread.GetProcess().get(),
current_stack_argument);
}
else if (compiler_type.IsPointerType())
{
ReadIntegerArgument(value->GetScalar(),
compiler_type.GetBitSize(&thread),
false,
thread.GetProcess().get(),
current_stack_argument);
}
}
}
return true;
}
示例3: executableModuleSP
ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
Address &function,
ValueList &args,
bool stop_other_threads,
bool discard_on_error) :
ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
m_valid (false),
m_stop_other_threads (stop_other_threads),
m_arg_addr (0),
m_args (&args),
m_process (thread.GetProcess()),
m_thread (thread)
{
SetOkayToDiscard (discard_on_error);
Process& process = thread.GetProcess();
Target& target = process.GetTarget();
const ABI *abi = process.GetABI();
if(!abi)
return;
lldb::addr_t spBelowRedZone = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize();
SymbolContextList contexts;
SymbolContext context;
ModuleSP executableModuleSP (target.GetExecutableModule());
if (!executableModuleSP ||
!executableModuleSP->FindSymbolsWithNameAndType(ConstString ("start"), eSymbolTypeCode, contexts))
return;
contexts.GetContextAtIndex(0, context);
m_start_addr = context.symbol->GetValue();
lldb::addr_t StartLoadAddr = m_start_addr.GetLoadAddress(&process);
if(!thread.SaveFrameZeroState(m_register_backup))
return;
m_function_addr = function;
lldb::addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&process);
if (!abi->PrepareNormalCall(thread,
spBelowRedZone,
FunctionLoadAddr,
StartLoadAddr,
*m_args))
return;
m_valid = true;
}
示例4: clang_type
bool
ABISysV_i386::GetArgumentValues (Thread &thread,
ValueList &values) const
{
unsigned int num_values = values.GetSize();
unsigned int value_index;
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return false;
// Get pointer to the first stack argument
addr_t sp = reg_ctx->GetSP(0);
if (!sp)
return false;
addr_t current_stack_argument = sp + 4; // jump over return address
for (value_index = 0;
value_index < num_values;
++value_index)
{
Value *value = values.GetValueAtIndex(value_index);
if (!value)
return false;
// Currently: Support for extracting values with Clang QualTypes only.
CompilerType clang_type (value->GetCompilerType());
if (clang_type)
{
bool is_signed;
if (clang_type.IsIntegerType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
clang_type.GetBitSize(&thread),
is_signed,
thread.GetProcess().get(),
current_stack_argument);
}
else if (clang_type.IsPointerType())
{
ReadIntegerArgument(value->GetScalar(),
clang_type.GetBitSize(&thread),
false,
thread.GetProcess().get(),
current_stack_argument);
}
}
}
return true;
}
示例5: ReadIntegerArgument
static bool ReadIntegerArgument(Scalar &scalar, unsigned int bit_width,
bool is_signed, Thread &thread,
uint32_t *argument_register_ids,
unsigned int ¤t_argument_register,
addr_t ¤t_stack_argument) {
if (bit_width > 64)
return false; // Scalar can't hold large integer arguments
if (current_argument_register < 6) {
scalar = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
argument_register_ids[current_argument_register], 0);
current_argument_register++;
if (is_signed)
scalar.SignExtend(bit_width);
} else {
uint32_t byte_size = (bit_width + (8 - 1)) / 8;
Status error;
if (thread.GetProcess()->ReadScalarIntegerFromMemory(
current_stack_argument, byte_size, is_signed, scalar, error)) {
current_stack_argument += byte_size;
return true;
}
return false;
}
return true;
}
示例6: log
ThreadPlanSP
DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan(Thread &thread, bool stop)
{
LogSP log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
ThreadPlanSP thread_plan_sp;
StackFrame *frame = thread.GetStackFrameAtIndex(0).get();
const SymbolContext &context = frame->GetSymbolContext(eSymbolContextSymbol);
Symbol *sym = context.symbol;
if (sym == NULL || !sym->IsTrampoline())
return thread_plan_sp;
const ConstString &sym_name = sym->GetMangled().GetName(Mangled::ePreferMangled);
if (!sym_name)
return thread_plan_sp;
SymbolContextList target_symbols;
Target &target = thread.GetProcess().GetTarget();
ModuleList &images = target.GetImages();
images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, target_symbols);
size_t num_targets = target_symbols.GetSize();
if (!num_targets)
return thread_plan_sp;
typedef std::vector<lldb::addr_t> AddressVector;
AddressVector addrs;
for (size_t i = 0; i < num_targets; ++i)
{
SymbolContext context;
AddressRange range;
if (target_symbols.GetContextAtIndex(i, context))
{
context.GetAddressRange(eSymbolContextEverything, 0, false, range);
lldb::addr_t addr = range.GetBaseAddress().GetLoadAddress(&target);
if (addr != LLDB_INVALID_ADDRESS)
addrs.push_back(addr);
}
}
if (addrs.size() > 0)
{
AddressVector::iterator start = addrs.begin();
AddressVector::iterator end = addrs.end();
std::sort(start, end);
addrs.erase(std::unique(start, end), end);
thread_plan_sp.reset(new ThreadPlanRunToAddress(thread, addrs, stop));
}
return thread_plan_sp;
}
示例7: ThreadPlan
ThreadPlanRunToAddress::ThreadPlanRunToAddress(
Thread &thread, const std::vector<lldb::addr_t> &addresses,
bool stop_others)
: ThreadPlan(ThreadPlan::eKindRunToAddress, "Run to address plan", thread,
eVoteNoOpinion, eVoteNoOpinion),
m_stop_others(stop_others), m_addresses(addresses), m_break_ids() {
// Convert all addresses into opcode addresses to make sure we set
// breakpoints at the correct address.
Target &target = thread.GetProcess()->GetTarget();
std::vector<lldb::addr_t>::iterator pos, end = m_addresses.end();
for (pos = m_addresses.begin(); pos != end; ++pos)
*pos = target.GetOpcodeLoadAddress(*pos);
SetInitialBreakpoints();
}
示例8: GetNonCallSiteUnwindPlanFromAssembly
bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
AddressRange &range, Thread &thread, UnwindPlan &unwind_plan) {
std::vector<uint8_t> function_text(range.GetByteSize());
ProcessSP process_sp(thread.GetProcess());
if (process_sp) {
Error error;
const bool prefer_file_cache = true;
if (process_sp->GetTarget().ReadMemory(
range.GetBaseAddress(), prefer_file_cache, function_text.data(),
range.GetByteSize(), error) != range.GetByteSize()) {
return false;
}
}
return GetNonCallSiteUnwindPlanFromAssembly(
range, function_text.data(), function_text.size(), unwind_plan);
}
示例9: buffer
static bool
GetReturnValuePassedInMemory(Thread &thread, RegisterContext* reg_ctx, size_t byte_size, Value& value)
{
Error error;
DataBufferHeap buffer(byte_size, 0);
const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1);
uint32_t address = reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX;
thread.GetProcess()->ReadMemory(address, buffer.GetBytes(), buffer.GetByteSize(), error);
if (error.Fail())
return false;
value.SetBytes(buffer.GetBytes(), buffer.GetByteSize());
return true;
}
示例10: process_sp
UnwindLLDB::UnwindLLDB (Thread &thread) :
Unwind (thread),
m_frames(),
m_unwind_complete(false),
m_user_supplied_trap_handler_functions()
{
ProcessSP process_sp(thread.GetProcess());
if (process_sp)
{
Args args;
process_sp->GetTarget().GetUserSpecifiedTrapHandlerNames (args);
size_t count = args.GetArgumentCount();
for (size_t i = 0; i < count; i++)
{
const char *func_name = args.GetArgumentAtIndex(i);
m_user_supplied_trap_handler_functions.push_back (ConstString (func_name));
}
}
}
示例11: process_sp
bool UnwindAssembly_x86::GetNonCallSiteUnwindPlanFromAssembly(
AddressRange &func, Thread &thread, UnwindPlan &unwind_plan) {
if (!func.GetBaseAddress().IsValid() || func.GetByteSize() == 0)
return false;
if (m_assembly_inspection_engine == nullptr)
return false;
ProcessSP process_sp(thread.GetProcess());
if (process_sp.get() == nullptr)
return false;
const bool prefer_file_cache = true;
std::vector<uint8_t> function_text(func.GetByteSize());
Status error;
if (process_sp->GetTarget().ReadMemory(
func.GetBaseAddress(), prefer_file_cache, function_text.data(),
func.GetByteSize(), error) == func.GetByteSize()) {
RegisterContextSP reg_ctx(thread.GetRegisterContext());
m_assembly_inspection_engine->Initialize(reg_ctx);
return m_assembly_inspection_engine->GetNonCallSiteUnwindPlanFromAssembly(
function_text.data(), func.GetByteSize(), func, unwind_plan);
}
return false;
}
示例12: memcmp
bool UnwindAssembly_x86::GetFastUnwindPlan(AddressRange &func, Thread &thread,
UnwindPlan &unwind_plan) {
// if prologue is
// 55 pushl %ebp
// 89 e5 movl %esp, %ebp
// or
// 55 pushq %rbp
// 48 89 e5 movq %rsp, %rbp
// We should pull in the ABI architecture default unwind plan and return that
llvm::SmallVector<uint8_t, 4> opcode_data;
ProcessSP process_sp = thread.GetProcess();
if (process_sp) {
Target &target(process_sp->GetTarget());
const bool prefer_file_cache = true;
Status error;
if (target.ReadMemory(func.GetBaseAddress(), prefer_file_cache,
opcode_data.data(), 4, error) == 4) {
uint8_t i386_push_mov[] = {0x55, 0x89, 0xe5};
uint8_t x86_64_push_mov[] = {0x55, 0x48, 0x89, 0xe5};
if (memcmp(opcode_data.data(), i386_push_mov, sizeof(i386_push_mov)) ==
0 ||
memcmp(opcode_data.data(), x86_64_push_mov,
sizeof(x86_64_push_mov)) == 0) {
ABISP abi_sp = process_sp->GetABI();
if (abi_sp) {
return abi_sp->CreateDefaultUnwindPlan(unwind_plan);
}
}
}
}
return false;
}
示例13: printf
bool
ABISysV_hexagon::PrepareTrivialCall ( Thread &thread,
lldb::addr_t sp ,
lldb::addr_t pc ,
lldb::addr_t ra ,
llvm::Type &prototype,
llvm::ArrayRef<ABI::CallArgument> args) const
{
// default number of register passed arguments for varg functions
const int nVArgRegParams = 1;
Error error;
// grab the process so we have access to the memory for spilling
lldb::ProcessSP proc = thread.GetProcess( );
// push host data onto target
for ( size_t i = 0; i < args.size( ); i++ )
{
const ABI::CallArgument &arg = args[i];
// skip over target values
if ( arg.type == ABI::CallArgument::TargetValue )
continue;
// round up to 8 byte multiple
size_t argSize = ( arg.size | 0x7 ) + 1;
// create space on the stack for this data
sp -= argSize;
// write this argument onto the stack of the host process
proc.get( )->WriteMemory( sp, arg.data, arg.size, error );
if ( error.Fail( ) )
return false;
// update the argument with the target pointer
//XXX: This is a gross hack for getting around the const
*((size_t*)(&arg.value)) = sp;
}
#if HEX_ABI_DEBUG
// print the original stack pointer
printf( "sp : %04lx \n", sp );
#endif
// make sure number of parameters matches prototype
assert( prototype.getFunctionNumParams( ) == args.size( ) );
// check if this is a variable argument function
bool isVArg = prototype.isFunctionVarArg();
// get the register context for modifying all of the registers
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return false;
// number of arguments passed by register
int nRegArgs = nVArgRegParams;
if (! isVArg )
{
// number of arguments is limited by [R0 : R5] space
nRegArgs = args.size( );
if ( nRegArgs > 6 )
nRegArgs = 6;
}
// pass arguments that are passed via registers
for ( int i = 0; i < nRegArgs; i++ )
{
// get the parameter as a u32
uint32_t param = (uint32_t)args[i].value;
// write argument into register
if (!reg_ctx->WriteRegisterFromUnsigned( i, param ))
return false;
}
// number of arguments to spill onto stack
int nSpillArgs = args.size( ) - nRegArgs;
// make space on the stack for arguments
sp -= 4 * nSpillArgs;
// align stack on an 8 byte boundary
if ( sp & 7 )
sp -= 4;
// arguments that are passed on the stack
for ( size_t i = nRegArgs, offs=0; i < args.size( ); i++ )
{
// get the parameter as a u32
uint32_t param = (uint32_t)args[i].value;
// write argument to stack
proc->WriteMemory( sp + offs, (void*)¶m, sizeof( param ), error );
if ( !error.Success( ) )
return false;
//
offs += 4;
}
// update registers with current function call state
reg_ctx->WriteRegisterFromUnsigned ( 41, pc );
reg_ctx->WriteRegisterFromUnsigned ( 31, ra );
reg_ctx->WriteRegisterFromUnsigned ( 29, sp );
//.........这里部分代码省略.........
示例14: disasm_sp
//.........这里部分代码省略.........
// The the instruction emulation subclass setup the unwind plan for the
// first instruction.
m_inst_emulator_ap->CreateFunctionEntryUnwind (unwind_plan);
// CreateFunctionEntryUnwind should have created the first row. If it
// doesn't, then we are done.
if (unwind_plan.GetRowCount() == 0)
return false;
ExecutionContext exe_ctx;
thread.CalculateExecutionContext(exe_ctx);
DisassemblerSP disasm_sp (Disassembler::DisassembleRange (m_arch,
NULL,
exe_ctx,
range));
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
if (disasm_sp)
{
m_range_ptr = ⦥
m_thread_ptr = &thread;
m_unwind_plan_ptr = &unwind_plan;
const uint32_t addr_byte_size = m_arch.GetAddressByteSize();
const bool show_address = true;
const bool show_bytes = true;
const bool raw = false;
// Initialize the CFA with a known value. In the 32 bit case
// it will be 0x80000000, and in the 64 bit case 0x8000000000000000.
// We use the address byte size to be safe for any future addresss sizes
m_inst_emulator_ap->GetRegisterInfo (unwind_plan.GetRegisterKind(),
unwind_plan.GetInitialCFARegister(),
m_cfa_reg_info);
m_fp_is_cfa = false;
m_register_values.clear();
m_pushed_regs.clear();
m_initial_sp = (1ull << ((addr_byte_size * 8) - 1));
RegisterValue cfa_reg_value;
cfa_reg_value.SetUInt (m_initial_sp, m_cfa_reg_info.byte_size);
SetRegisterValue (m_cfa_reg_info, cfa_reg_value);
const InstructionList &inst_list = disasm_sp->GetInstructionList ();
const size_t num_instructions = inst_list.GetSize();
if (num_instructions > 0)
{
Instruction *inst = inst_list.GetInstructionAtIndex (0).get();
const addr_t base_addr = inst->GetAddress().GetFileAddress();
// Initialize the current row with the one row that was created
// from the CreateFunctionEntryUnwind call above...
m_curr_row = unwind_plan.GetLastRow();
for (size_t idx=0; idx<num_instructions; ++idx)
{
inst = inst_list.GetInstructionAtIndex (idx).get();
if (inst)
{
if (log && log->GetVerbose ())
{
StreamString strm;
inst->Dump(&strm, inst_list.GetMaxOpcocdeByteSize (), show_address, show_bytes, &exe_ctx, raw);
log->PutCString (strm.GetData());
}
m_inst_emulator_ap->SetInstruction (inst->GetOpcode(),
inst->GetAddress(),
exe_ctx.GetTargetPtr());
m_inst_emulator_ap->EvaluateInstruction (eEmulateInstructionOptionIgnoreConditions);
if (unwind_plan.GetLastRow() != m_curr_row)
{
// Be sure to not edit the offset unless our row has changed
// so that the "!=" call above doesn't trigger every time
m_curr_row.SetOffset (inst->GetAddress().GetFileAddress() + inst->GetOpcode().GetByteSize() - base_addr);
// Append the new row
unwind_plan.AppendRow (m_curr_row);
}
}
}
}
}
if (log && log->GetVerbose ())
{
StreamString strm;
lldb::addr_t base_addr = range.GetBaseAddress().GetLoadAddress(&thread.GetProcess().GetTarget());
strm.Printf ("Resulting unwind rows for [0x%llx - 0x%llx):", base_addr, base_addr + range.GetByteSize());
unwind_plan.Dump(strm, &thread, base_addr);
log->PutCString (strm.GetData());
}
return unwind_plan.GetRowCount() > 0;
}
return false;
}
示例15: if
//.........这里部分代码省略.........
lldb::addr_t storage_addr = (uint32_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff);
return_valobj_sp = ValueObjectMemory::Create (&thread,
"",
Address (storage_addr, nullptr),
return_clang_type);
}
}
else // Neither 'Integral' nor 'Floating Point'
{
// If flow reaches here then check type_flags
// This type_flags is unhandled
}
}
else if (type_flags & eTypeIsComplex) // 'Complex Floating Point'
{
// ToDo: Yet to be implemented
}
else if (type_flags & eTypeIsVector) // 'Packed'
{
const size_t byte_size = return_clang_type.GetByteSize(nullptr);
if (byte_size > 0)
{
const RegisterInfo *vec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0);
if (vec_reg == nullptr)
vec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0);
if (vec_reg)
{
if (byte_size <= vec_reg->byte_size)
{
ProcessSP process_sp (thread.GetProcess());
if (process_sp)
{
std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0));
const ByteOrder byte_order = process_sp->GetByteOrder();
RegisterValue reg_value;
if (reg_ctx->ReadRegister(vec_reg, reg_value))
{
Error error;
if (reg_value.GetAsMemoryData (vec_reg,
heap_data_ap->GetBytes(),
heap_data_ap->GetByteSize(),
byte_order,
error))
{
DataExtractor data (DataBufferSP (heap_data_ap.release()),
byte_order,
process_sp->GetTarget().GetArchitecture().GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create (&thread,
return_clang_type,
ConstString(""),
data);
}
}
}
}
else if (byte_size <= vec_reg->byte_size*2)
{
const RegisterInfo *vec_reg2 = reg_ctx->GetRegisterInfoByName("xmm1", 0);
if (vec_reg2)
{
ProcessSP process_sp (thread.GetProcess());
if (process_sp)