本文整理汇总了C++中Thread::GetStackFrameAtIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Thread::GetStackFrameAtIndex方法的具体用法?C++ Thread::GetStackFrameAtIndex怎么用?C++ Thread::GetStackFrameAtIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thread
的用法示例。
在下文中一共展示了Thread::GetStackFrameAtIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StepOver
void SBThread::StepOver(lldb::RunMode stop_other_threads) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (log)
log->Printf("SBThread(%p)::StepOver (stop_other_threads='%s')",
static_cast<void *>(exe_ctx.GetThreadPtr()),
Thread::RunModeAsCString(stop_other_threads));
if (exe_ctx.HasThreadScope()) {
Thread *thread = exe_ctx.GetThreadPtr();
bool abort_other_plans = false;
StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
ThreadPlanSP new_plan_sp;
if (frame_sp) {
if (frame_sp->HasDebugInformation()) {
const LazyBool avoid_no_debug = eLazyBoolCalculate;
SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
new_plan_sp = thread->QueueThreadPlanForStepOverRange(
abort_other_plans, sc.line_entry, sc, stop_other_threads,
avoid_no_debug);
} else {
new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
true, abort_other_plans, stop_other_threads);
}
}
// This returns an error, we should use it!
ResumeNewPlan(exe_ctx, new_plan_sp.get());
}
}
示例2: SetSelectedFrame
lldb::SBFrame SBThread::SetSelectedFrame(uint32_t idx) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
SBFrame sb_frame;
StackFrameSP frame_sp;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (exe_ctx.HasThreadScope()) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
Thread *thread = exe_ctx.GetThreadPtr();
frame_sp = thread->GetStackFrameAtIndex(idx);
if (frame_sp) {
thread->SetSelectedFrame(frame_sp.get());
sb_frame.SetFrameSP(frame_sp);
}
} else {
if (log)
log->Printf(
"SBThread(%p)::SetSelectedFrame() => error: process is running",
static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
if (log) {
SBStream frame_desc_strm;
sb_frame.GetDescription(frame_desc_strm);
log->Printf("SBThread(%p)::SetSelectedFrame (idx=%u) => SBFrame(%p): %s",
static_cast<void *>(exe_ctx.GetThreadPtr()), idx,
static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData());
}
return sb_frame;
}
示例3: DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override {
StringList commands;
commands.AppendString("thread backtrace");
Thread *thread = m_exe_ctx.GetThreadPtr();
if (thread) {
char command_buffer[256];
uint32_t frame_count = thread->GetStackFrameCount();
for (uint32_t i = 0; i < frame_count; ++i) {
StackFrameSP frame = thread->GetStackFrameAtIndex(i);
lldb::addr_t pc = frame->GetStackID().GetPC();
snprintf(command_buffer, sizeof(command_buffer),
"disassemble --bytes --address 0x%" PRIx64, pc);
commands.AppendString(command_buffer);
snprintf(command_buffer, sizeof(command_buffer),
"image show-unwind --address 0x%" PRIx64, pc);
commands.AppendString(command_buffer);
}
}
const FileSpec &outfile_spec =
m_outfile_options.GetFile().GetCurrentValue();
if (outfile_spec) {
char path[PATH_MAX];
outfile_spec.GetPath(path, sizeof(path));
uint32_t open_options =
File::eOpenOptionWrite | File::eOpenOptionCanCreate |
File::eOpenOptionAppend | File::eOpenOptionCloseOnExec;
const bool append = m_outfile_options.GetAppend().GetCurrentValue();
if (!append)
open_options |= File::eOpenOptionTruncate;
StreamFileSP outfile_stream = std::make_shared<StreamFile>();
Status error = outfile_stream->GetFile().Open(path, open_options);
if (error.Fail()) {
result.AppendErrorWithFormat("Failed to open file '%s' for %s: %s\n",
path, append ? "append" : "write",
error.AsCString());
result.SetStatus(eReturnStatusFailed);
return false;
}
result.SetImmediateOutputStream(outfile_stream);
}
CommandInterpreterRunOptions options;
options.SetStopOnError(false);
options.SetEchoCommands(true);
options.SetPrintResults(true);
options.SetAddToHistory(false);
m_interpreter.HandleCommands(commands, &m_exe_ctx, options, result);
return result.Succeeded();
}
示例4: 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;
}
示例5: StepInto
void SBThread::StepInto(const char *target_name, uint32_t end_line,
SBError &error, lldb::RunMode stop_other_threads) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (log)
log->Printf(
"SBThread(%p)::StepInto (target_name='%s', stop_other_threads='%s')",
static_cast<void *>(exe_ctx.GetThreadPtr()),
target_name ? target_name : "<NULL>",
Thread::RunModeAsCString(stop_other_threads));
if (exe_ctx.HasThreadScope()) {
bool abort_other_plans = false;
Thread *thread = exe_ctx.GetThreadPtr();
StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
ThreadPlanSP new_plan_sp;
if (frame_sp && frame_sp->HasDebugInformation()) {
SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
AddressRange range;
if (end_line == LLDB_INVALID_LINE_NUMBER)
range = sc.line_entry.range;
else {
if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref()))
return;
}
const LazyBool step_out_avoids_code_without_debug_info =
eLazyBoolCalculate;
const LazyBool step_in_avoids_code_without_debug_info =
eLazyBoolCalculate;
new_plan_sp = thread->QueueThreadPlanForStepInRange(
abort_other_plans, range, sc, target_name, stop_other_threads,
step_in_avoids_code_without_debug_info,
step_out_avoids_code_without_debug_info);
} else {
new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
false, abort_other_plans, stop_other_threads);
}
error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
}
}
示例6: exe_ctx
void
SBThread::StepInto (const char *target_name, lldb::RunMode stop_other_threads)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
if (log)
log->Printf ("SBThread(%p)::StepInto (target_name='%s', stop_other_threads='%s')",
exe_ctx.GetThreadPtr(),
target_name? target_name: "<NULL>",
Thread::RunModeAsCString (stop_other_threads));
if (exe_ctx.HasThreadScope())
{
bool abort_other_plans = false;
Thread *thread = exe_ctx.GetThreadPtr();
StackFrameSP frame_sp(thread->GetStackFrameAtIndex (0));
ThreadPlanSP new_plan_sp;
if (frame_sp && frame_sp->HasDebugInformation ())
{
bool avoid_code_without_debug_info = true;
SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
new_plan_sp = thread->QueueThreadPlanForStepInRange (abort_other_plans,
sc.line_entry.range,
sc,
target_name,
stop_other_threads,
avoid_code_without_debug_info);
}
else
{
new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction (false,
abort_other_plans,
stop_other_threads);
}
// This returns an error, we should use it!
ResumeNewPlan (exe_ctx, new_plan_sp.get());
}
}
示例7: ValueObjectSP
ValueObjectSP
ABI::GetReturnValueObject (Thread &thread,
ClangASTType &ast_type) const
{
if (!ast_type.IsValid())
return ValueObjectSP();
Value ret_value;
ret_value.SetContext(Value::eContextTypeClangType,
ast_type.GetOpaqueQualType());
if (GetReturnValue (thread, ret_value))
{
return ValueObjectConstResult::Create(
thread.GetStackFrameAtIndex(0).get(),
ast_type.GetASTContext(),
ret_value,
ConstString("FunctionReturn"));
}
else
return ValueObjectSP();
}
示例8: if
ValueObjectSP
ABIMacOSX_i386::GetReturnValueObjectImpl (Thread &thread,
CompilerType &compiler_type) const
{
Value value;
ValueObjectSP return_valobj_sp;
if (!compiler_type)
return return_valobj_sp;
//value.SetContext (Value::eContextTypeClangType, compiler_type.GetOpaqueQualType());
value.SetCompilerType (compiler_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return return_valobj_sp;
bool is_signed;
if (compiler_type.IsIntegerType (is_signed))
{
size_t bit_width = compiler_type.GetBitSize(&thread);
unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB];
unsigned edx_id = reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB];
switch (bit_width)
{
default:
case 128:
// Scalar can't hold 128-bit literals, so we don't handle this
return return_valobj_sp;
case 64:
uint64_t raw_value;
raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff;
raw_value |= (thread.GetRegisterContext()->ReadRegisterAsUnsigned(edx_id, 0) & 0xffffffff) << 32;
if (is_signed)
value.GetScalar() = (int64_t)raw_value;
else
value.GetScalar() = (uint64_t)raw_value;
break;
case 32:
if (is_signed)
value.GetScalar() = (int32_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff);
else
value.GetScalar() = (uint32_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff);
break;
case 16:
if (is_signed)
value.GetScalar() = (int16_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffff);
else
value.GetScalar() = (uint16_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffff);
break;
case 8:
if (is_signed)
value.GetScalar() = (int8_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xff);
else
value.GetScalar() = (uint8_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xff);
break;
}
}
else if (compiler_type.IsPointerType ())
{
unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB];
uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff;
value.GetScalar() = ptr;
}
else
{
// not handled yet
return return_valobj_sp;
}
// If we get here, we have a valid Value, so make our ValueObject out of it:
return_valobj_sp = ValueObjectConstResult::Create(thread.GetStackFrameAtIndex(0).get(),
value,
ConstString(""));
return return_valobj_sp;
}
示例9: if
ValueObjectSP
ABISysV_i386::GetReturnValueObjectSimple (Thread &thread,
CompilerType &return_clang_type) const
{
ValueObjectSP return_valobj_sp;
Value value;
if (!return_clang_type)
return return_valobj_sp;
value.SetCompilerType (return_clang_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return return_valobj_sp;
const uint32_t type_flags = return_clang_type.GetTypeInfo ();
unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB];
unsigned edx_id = reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB];
// Following "IF ELSE" block categorizes various 'Fundamental Data Types'.
// The terminology 'Fundamental Data Types' used here is adopted from
// Table 2.1 of the reference document (specified on top of this file)
if (type_flags & eTypeIsPointer) // 'Pointer'
{
uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff ;
value.SetValueType(Value::eValueTypeScalar);
value.GetScalar() = ptr;
return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(),
value,
ConstString(""));
}
else if ((type_flags & eTypeIsScalar) || (type_flags & eTypeIsEnumeration)) //'Integral' + 'Floating Point'
{
value.SetValueType(Value::eValueTypeScalar);
const size_t byte_size = return_clang_type.GetByteSize(nullptr);
bool success = false;
if (type_flags & eTypeIsInteger) // 'Integral' except enum
{
const bool is_signed = ((type_flags & eTypeIsSigned) != 0);
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff ;
raw_value |= (thread.GetRegisterContext()->ReadRegisterAsUnsigned(edx_id, 0) & 0xffffffff) << 32;
switch (byte_size)
{
default:
break;
case 16:
// For clang::BuiltinType::UInt128 & Int128
// ToDo: Need to decide how to handle it
break ;
case 8:
if (is_signed)
value.GetScalar() = (int64_t)(raw_value);
else
value.GetScalar() = (uint64_t)(raw_value);
success = true;
break;
case 4:
if (is_signed)
value.GetScalar() = (int32_t)(raw_value & UINT32_MAX);
else
value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX);
success = true;
break;
case 2:
if (is_signed)
value.GetScalar() = (int16_t)(raw_value & UINT16_MAX);
else
value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX);
success = true;
break;
case 1:
if (is_signed)
value.GetScalar() = (int8_t)(raw_value & UINT8_MAX);
else
value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX);
success = true;
break;
}
if (success)
return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(),
value,
ConstString(""));
}
else if (type_flags & eTypeIsEnumeration) // handles enum
{
uint32_t enm = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff ;
//.........这里部分代码省略.........
示例10: isa_value
ThreadPlanSP
ObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool stop_others)
{
ThreadPlanSP ret_plan_sp;
lldb::addr_t curr_pc = thread.GetRegisterContext()->GetPC();
MsgsendMap::iterator pos;
pos = m_msgSend_map.find (curr_pc);
if (pos != m_msgSend_map.end())
{
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
const DispatchFunction *this_dispatch = &g_dispatch_functions[(*pos).second];
lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0);
Process *process = thread.CalculateProcess();
const ABI *abi = process->GetABI();
if (abi == NULL)
return ret_plan_sp;
Target *target = thread.CalculateTarget();
// FIXME: Since neither the value nor the Clang QualType know their ASTContext,
// we have to make sure the type we put in our value list comes from the same ASTContext
// the ABI will use to get the argument values. THis is the bottom-most frame's module.
ClangASTContext *clang_ast_context = target->GetScratchClangASTContext();
ValueList argument_values;
Value input_value;
void *clang_void_ptr_type = clang_ast_context->GetVoidPtrType(false);
input_value.SetValueType (Value::eValueTypeScalar);
input_value.SetContext (Value::eContextTypeOpaqueClangQualType, clang_void_ptr_type);
int obj_index;
int sel_index;
// If this is a struct return dispatch, then the first argument is the
// return struct pointer, and the object is the second, and the selector is the third.
// Otherwise the object is the first and the selector the second.
if (this_dispatch->stret_return)
{
obj_index = 1;
sel_index = 2;
argument_values.PushValue(input_value);
argument_values.PushValue(input_value);
argument_values.PushValue(input_value);
}
else
{
obj_index = 0;
sel_index = 1;
argument_values.PushValue(input_value);
argument_values.PushValue(input_value);
}
bool success = abi->GetArgumentValues (thread, argument_values);
if (!success)
return ret_plan_sp;
// Okay, the first value here is the object, we actually want the class of that object.
// For now we're just going with the ISA.
// FIXME: This should really be the return value of [object class] to properly handle KVO interposition.
Value isa_value(*(argument_values.GetValueAtIndex(obj_index)));
// This is a little cheesy, but since object->isa is the first field,
// making the object value a load address value and resolving it will get
// the pointer sized data pointed to by that value...
ExecutionContext exec_ctx;
thread.Calculate (exec_ctx);
isa_value.SetValueType(Value::eValueTypeLoadAddress);
isa_value.ResolveValue(&exec_ctx, clang_ast_context->getASTContext());
if (this_dispatch->fixedup == DispatchFunction::eFixUpFixed)
{
// For the FixedUp method the Selector is actually a pointer to a
// structure, the second field of which is the selector number.
Value *sel_value = argument_values.GetValueAtIndex(sel_index);
sel_value->GetScalar() += process->GetAddressByteSize();
sel_value->SetValueType(Value::eValueTypeLoadAddress);
sel_value->ResolveValue(&exec_ctx, clang_ast_context->getASTContext());
}
else if (this_dispatch->fixedup == DispatchFunction::eFixUpToFix)
{
// FIXME: If the method dispatch is not "fixed up" then the selector is actually a
// pointer to the string name of the selector. We need to look that up...
// For now I'm going to punt on that and just return no plan.
if (log)
log->Printf ("Punting on stepping into un-fixed-up method dispatch.");
return ret_plan_sp;
}
// FIXME: If this is a dispatch to the super-class, we need to get the super-class from
// the class, and disaptch to that instead.
// But for now I just punt and return no plan.
if (this_dispatch->is_super)
{
//.........这里部分代码省略.........
示例11: call_plan_sp
bool
lldb_private::InferiorCallMmap (Process *process,
addr_t &allocated_addr,
addr_t addr,
addr_t length,
unsigned prot,
unsigned flags,
addr_t fd,
addr_t offset)
{
Thread *thread = process->GetThreadList().GetSelectedThread().get();
if (thread == NULL)
return false;
const bool append = true;
const bool include_symbols = true;
const bool include_inlines = false;
SymbolContextList sc_list;
const uint32_t count
= process->GetTarget().GetImages().FindFunctions (ConstString ("mmap"),
eFunctionNameTypeFull,
include_symbols,
include_inlines,
append,
sc_list);
if (count > 0)
{
SymbolContext sc;
if (sc_list.GetContextAtIndex(0, sc))
{
const uint32_t range_scope = eSymbolContextFunction | eSymbolContextSymbol;
const bool use_inline_block_range = false;
EvaluateExpressionOptions options;
options.SetStopOthers(true);
options.SetUnwindOnError(true);
options.SetIgnoreBreakpoints(true);
options.SetTryAllThreads(true);
options.SetDebug (false);
options.SetTimeoutUsec(500000);
addr_t prot_arg, flags_arg = 0;
if (prot == eMmapProtNone)
prot_arg = PROT_NONE;
else {
prot_arg = 0;
if (prot & eMmapProtExec)
prot_arg |= PROT_EXEC;
if (prot & eMmapProtRead)
prot_arg |= PROT_READ;
if (prot & eMmapProtWrite)
prot_arg |= PROT_WRITE;
}
const ArchSpec arch = process->GetTarget().GetArchitecture();
flags_arg = process->GetTarget().GetPlatform()->ConvertMmapFlagsToPlatform(arch,flags);
AddressRange mmap_range;
if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, mmap_range))
{
ClangASTContext *clang_ast_context = process->GetTarget().GetScratchClangASTContext();
CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
lldb::addr_t args[] = { addr, length, prot_arg, flags_arg, fd, offset };
lldb::ThreadPlanSP call_plan_sp (new ThreadPlanCallFunction (*thread,
mmap_range.GetBaseAddress(),
clang_void_ptr_type,
args,
options));
if (call_plan_sp)
{
StreamFile error_strm;
// This plan is a utility plan, so set it to discard itself when done.
call_plan_sp->SetIsMasterPlan (true);
call_plan_sp->SetOkayToDiscard(true);
StackFrame *frame = thread->GetStackFrameAtIndex (0).get();
if (frame)
{
ExecutionContext exe_ctx;
frame->CalculateExecutionContext (exe_ctx);
ExpressionResults result = process->RunThreadPlan (exe_ctx,
call_plan_sp,
options,
error_strm);
if (result == eExpressionCompleted)
{
allocated_addr = call_plan_sp->GetReturnValueObject()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
if (process->GetAddressByteSize() == 4)
{
if (allocated_addr == UINT32_MAX)
return false;
}
else if (process->GetAddressByteSize() == 8)
{
if (allocated_addr == UINT64_MAX)
return false;
}
return true;
}
}
//.........这里部分代码省略.........
示例12: sizeof
ValueObjectSP ABISysV_ppc64::GetReturnValueObjectSimple(
Thread &thread, CompilerType &return_compiler_type) const {
ValueObjectSP return_valobj_sp;
Value value;
if (!return_compiler_type)
return return_valobj_sp;
// value.SetContext (Value::eContextTypeClangType, return_value_type);
value.SetCompilerType(return_compiler_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return return_valobj_sp;
const uint32_t type_flags = return_compiler_type.GetTypeInfo();
if (type_flags & eTypeIsScalar) {
value.SetValueType(Value::eValueTypeScalar);
bool success = false;
if (type_flags & eTypeIsInteger) {
// Extract the register context so we can read arguments from registers
const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
reg_ctx->GetRegisterInfoByName("r3", 0), 0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
switch (byte_size) {
default:
break;
case sizeof(uint64_t):
if (is_signed)
value.GetScalar() = (int64_t)(raw_value);
else
value.GetScalar() = (uint64_t)(raw_value);
success = true;
break;
case sizeof(uint32_t):
if (is_signed)
value.GetScalar() = (int32_t)(raw_value & UINT32_MAX);
else
value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX);
success = true;
break;
case sizeof(uint16_t):
if (is_signed)
value.GetScalar() = (int16_t)(raw_value & UINT16_MAX);
else
value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX);
success = true;
break;
case sizeof(uint8_t):
if (is_signed)
value.GetScalar() = (int8_t)(raw_value & UINT8_MAX);
else
value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX);
success = true;
break;
}
} else if (type_flags & eTypeIsFloat) {
if (type_flags & eTypeIsComplex) {
// Don't handle complex yet.
} else {
const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
if (byte_size <= sizeof(long double)) {
const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
RegisterValue f1_value;
if (reg_ctx->ReadRegister(f1_info, f1_value)) {
DataExtractor data;
if (f1_value.GetData(data)) {
lldb::offset_t offset = 0;
if (byte_size == sizeof(float)) {
value.GetScalar() = (float)data.GetFloat(&offset);
success = true;
} else if (byte_size == sizeof(double)) {
value.GetScalar() = (double)data.GetDouble(&offset);
success = true;
}
}
}
}
}
}
if (success)
return_valobj_sp = ValueObjectConstResult::Create(
thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
} else if (type_flags & eTypeIsPointer) {
unsigned r3_id =
reg_ctx->GetRegisterInfoByName("r3", 0)->kinds[eRegisterKindLLDB];
value.GetScalar() =
(uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r3_id, 0);
value.SetValueType(Value::eValueTypeScalar);
return_valobj_sp = ValueObjectConstResult::Create(
thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
} else if (type_flags & eTypeIsVector) {
//.........这里部分代码省略.........
示例13: InferiorCallMunmap
bool lldb_private::InferiorCallMunmap(Process *process, addr_t addr,
addr_t length) {
Thread *thread = process->GetThreadList().GetSelectedThread().get();
if (thread == NULL)
return false;
const bool append = true;
const bool include_symbols = true;
const bool include_inlines = false;
SymbolContextList sc_list;
const uint32_t count
= process->GetTarget().GetImages().FindFunctions (ConstString ("munmap"),
eFunctionNameTypeFull,
include_symbols,
include_inlines,
append,
sc_list);
if (count > 0)
{
SymbolContext sc;
if (sc_list.GetContextAtIndex(0, sc))
{
const uint32_t range_scope = eSymbolContextFunction | eSymbolContextSymbol;
const bool use_inline_block_range = false;
const bool stop_other_threads = true;
const bool unwind_on_error = true;
const bool ignore_breakpoints = true;
const bool try_all_threads = true;
const uint32_t timeout_usec = 500000;
AddressRange munmap_range;
if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, munmap_range))
{
lldb::ThreadPlanSP call_plan_sp (new ThreadPlanCallFunction (*thread,
munmap_range.GetBaseAddress(),
ClangASTType(),
stop_other_threads,
unwind_on_error,
ignore_breakpoints,
&addr,
&length));
if (call_plan_sp)
{
StreamFile error_strm;
// This plan is a utility plan, so set it to discard itself when done.
call_plan_sp->SetIsMasterPlan (true);
call_plan_sp->SetOkayToDiscard(true);
Frame *frame = thread->GetStackFrameAtIndex (0).get();
if (frame)
{
ExecutionContext exe_ctx;
frame->CalculateExecutionContext (exe_ctx);
ExecutionResults result = process->RunThreadPlan (exe_ctx,
call_plan_sp,
stop_other_threads,
try_all_threads,
unwind_on_error,
ignore_breakpoints,
timeout_usec,
error_strm);
if (result == eExecutionCompleted)
{
return true;
}
}
}
}
}
}
return false;
}
示例14: exe_ctx
ValueObjectSP
ABISysV_mips64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clang_type) const
{
ValueObjectSP return_valobj_sp;
Value value;
ExecutionContext exe_ctx (thread.shared_from_this());
if (exe_ctx.GetTargetPtr() == NULL || exe_ctx.GetProcessPtr() == NULL)
return return_valobj_sp;
value.SetClangType(return_clang_type);
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return return_valobj_sp;
const size_t byte_size = return_clang_type.GetByteSize(nullptr);
const uint32_t type_flags = return_clang_type.GetTypeInfo (NULL);
if (type_flags & eTypeIsScalar)
{
value.SetValueType(Value::eValueTypeScalar);
bool success = false;
if (type_flags & eTypeIsInteger)
{
// Extract the register context so we can read arguments from registers
// In MIPS register "r2" (v0) holds the integer function return values
uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r2", 0), 0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
switch (byte_size)
{
default:
break;
case sizeof(uint64_t):
if (is_signed)
value.GetScalar() = (int64_t)(raw_value);
else
value.GetScalar() = (uint64_t)(raw_value);
success = true;
break;
case sizeof(uint32_t):
if (is_signed)
value.GetScalar() = (int32_t)(raw_value & UINT32_MAX);
else
value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX);
success = true;
break;
case sizeof(uint16_t):
if (is_signed)
value.GetScalar() = (int16_t)(raw_value & UINT16_MAX);
else
value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX);
success = true;
break;
case sizeof(uint8_t):
if (is_signed)
value.GetScalar() = (int8_t)(raw_value & UINT8_MAX);
else
value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX);
success = true;
break;
}
}
if (success)
return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(),
value,
ConstString(""));
}
else if (type_flags & eTypeIsPointer)
{
value.SetValueType(Value::eValueTypeScalar);
uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r2", 0), 0);
value.GetScalar() = (uint64_t)(raw_value);
return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(),
value,
ConstString(""));
}
else if (type_flags & eTypeIsVector)
{
// TODO: Handle vector types
}
return return_valobj_sp;
}
示例15: exe_ctx
//.........这里部分代码省略.........
switch (bit_width)
{
default:
return return_valobj_sp;
case 64:
{
const RegisterInfo *r3_reg_info = reg_ctx->GetRegisterInfoByName("r3", 0);
uint64_t raw_value;
raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT32_MAX;
raw_value |= ((uint64_t)(reg_ctx->ReadRegisterAsUnsigned(r3_reg_info, 0) & UINT32_MAX)) << 32;
if (is_signed)
value.GetScalar() = (int64_t)raw_value;
else
value.GetScalar() = (uint64_t)raw_value;
}
break;
case 32:
if (is_signed)
value.GetScalar() = (int32_t)(reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT32_MAX);
else
value.GetScalar() = (uint32_t)(reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT32_MAX);
break;
case 16:
if (is_signed)
value.GetScalar() = (int16_t)(reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT16_MAX);
else
value.GetScalar() = (uint16_t)(reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT16_MAX);
break;
case 8:
if (is_signed)
value.GetScalar() = (int8_t)(reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT8_MAX);
else
value.GetScalar() = (uint8_t)(reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT8_MAX);
break;
}
}
else if (return_clang_type.IsPointerType ())
{
uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT32_MAX;
value.GetScalar() = ptr;
}
else if (return_clang_type.IsAggregateType ())
{
// Structure/Vector is always passed in memory and pointer to that memory is passed in r2.
uint64_t mem_address = reg_ctx->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r2", 0), 0);
// We have got the address. Create a memory object out of it
return_valobj_sp = ValueObjectMemory::Create (&thread,
"",
Address (mem_address, NULL),
return_clang_type);
return return_valobj_sp;
}
else if (return_clang_type.IsFloatingPointType (count, is_complex))
{
const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0);
const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
if (count == 1 && !is_complex)
{
switch (bit_width)
{
default:
return return_valobj_sp;
case 64:
{
static_assert(sizeof(double) == sizeof(uint64_t), "");
uint64_t raw_value;
raw_value = reg_ctx->ReadRegisterAsUnsigned(f0_info, 0) & UINT32_MAX;
raw_value |= ((uint64_t)(reg_ctx->ReadRegisterAsUnsigned(f1_info, 0) & UINT32_MAX)) << 32;
value.GetScalar() = *reinterpret_cast<double*>(&raw_value);
break;
}
case 32:
{
static_assert(sizeof(float) == sizeof(uint32_t), "");
uint32_t raw_value = reg_ctx->ReadRegisterAsUnsigned(f0_info, 0) & UINT32_MAX;
value.GetScalar() = *reinterpret_cast<float*>(&raw_value);
break;
}
}
}
else
{
// not handled yet
return return_valobj_sp;
}
}
else
{
// not handled yet
return return_valobj_sp;
}
// If we get here, we have a valid Value, so make our ValueObject out of it:
return_valobj_sp = ValueObjectConstResult::Create(thread.GetStackFrameAtIndex(0).get(),
value,
ConstString(""));
return return_valobj_sp;
}