本文整理汇总了C++中StackFrame::GetSymbolContext方法的典型用法代码示例。如果您正苦于以下问题:C++ StackFrame::GetSymbolContext方法的具体用法?C++ StackFrame::GetSymbolContext怎么用?C++ StackFrame::GetSymbolContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StackFrame
的用法示例。
在下文中一共展示了StackFrame::GetSymbolContext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new_context
bool
ThreadPlanStepRange::InRange ()
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
bool ret_value = false;
lldb::addr_t pc_load_addr = m_thread.GetRegisterContext()->GetPC();
size_t num_ranges = m_address_ranges.size();
for (size_t i = 0; i < num_ranges; i++)
{
ret_value = m_address_ranges[i].ContainsLoadAddress(pc_load_addr, m_thread.CalculateTarget().get());
if (ret_value)
break;
}
if (!ret_value && !m_given_ranges_only)
{
// See if we've just stepped to another part of the same line number...
StackFrame *frame = m_thread.GetStackFrameAtIndex(0).get();
SymbolContext new_context(frame->GetSymbolContext(eSymbolContextEverything));
if (m_addr_context.line_entry.IsValid() && new_context.line_entry.IsValid())
{
if (m_addr_context.line_entry.original_file == new_context.line_entry.original_file)
{
if (m_addr_context.line_entry.line == new_context.line_entry.line)
{
m_addr_context = new_context;
AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange());
ret_value = true;
if (log)
{
StreamString s;
m_addr_context.line_entry.Dump (&s,
m_thread.CalculateTarget().get(),
true,
Address::DumpStyleLoadAddress,
Address::DumpStyleLoadAddress,
true);
log->Printf ("Step range plan stepped to another range of same line: %s", s.GetData());
}
}
else if (new_context.line_entry.line == 0)
{
new_context.line_entry.line = m_addr_context.line_entry.line;
m_addr_context = new_context;
AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange());
ret_value = true;
if (log)
{
StreamString s;
m_addr_context.line_entry.Dump (&s,
m_thread.CalculateTarget().get(),
true,
Address::DumpStyleLoadAddress,
Address::DumpStyleLoadAddress,
true);
log->Printf ("Step range plan stepped to a range at linenumber 0 stepping through that range: %s", s.GetData());
}
}
else if (new_context.line_entry.range.GetBaseAddress().GetLoadAddress(m_thread.CalculateTarget().get())
!= pc_load_addr)
{
// Another thing that sometimes happens here is that we step out of one line into the MIDDLE of another
// line. So far I mostly see this due to bugs in the debug information.
// But we probably don't want to be in the middle of a line range, so in that case reset the stepping
// range to the line we've stepped into the middle of and continue.
m_addr_context = new_context;
m_address_ranges.clear();
AddRange(m_addr_context.line_entry.range);
ret_value = true;
if (log)
{
StreamString s;
m_addr_context.line_entry.Dump (&s,
m_thread.CalculateTarget().get(),
true,
Address::DumpStyleLoadAddress,
Address::DumpStyleLoadAddress,
true);
log->Printf ("Step range plan stepped to the middle of new line(%d): %s, continuing to clear this line.",
new_context.line_entry.line,
s.GetData());
}
}
}
}
}
if (!ret_value && log)
log->Printf ("Step range plan out of range to 0x%" PRIx64, pc_load_addr);
return ret_value;
}
示例2: exe_ctx
SBValue
SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic)
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBValue sb_value;
if (name == NULL || name[0] == '\0')
{
if (log)
log->Printf ("SBFrame::FindValue called with empty name.");
return sb_value;
}
ValueObjectSP value_sp;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
StackFrame *frame = NULL;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
{
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock()))
{
frame = exe_ctx.GetFramePtr();
if (frame)
{
switch (value_type)
{
case eValueTypeVariableGlobal: // global variable
case eValueTypeVariableStatic: // static variable
case eValueTypeVariableArgument: // function argument variables
case eValueTypeVariableLocal: // function local variables
{
VariableList *variable_list = frame->GetVariableList(true);
SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock));
const bool can_create = true;
const bool get_parent_variables = true;
const bool stop_if_block_is_inlined_function = true;
if (sc.block && sc.block->AppendVariables (can_create,
get_parent_variables,
stop_if_block_is_inlined_function,
variable_list))
{
ConstString const_name(name);
const uint32_t num_variables = variable_list->GetSize();
for (uint32_t i = 0; i < num_variables; ++i)
{
VariableSP variable_sp (variable_list->GetVariableAtIndex(i));
if (variable_sp &&
variable_sp->GetScope() == value_type &&
variable_sp->GetName() == const_name)
{
value_sp = frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues);
sb_value.SetSP (value_sp, use_dynamic);
break;
}
}
}
}
break;
case eValueTypeRegister: // stack frame register value
{
RegisterContextSP reg_ctx (frame->GetRegisterContext());
if (reg_ctx)
{
const uint32_t num_regs = reg_ctx->GetRegisterCount();
for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx)
{
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx);
if (reg_info &&
((reg_info->name && strcasecmp (reg_info->name, name) == 0) ||
(reg_info->alt_name && strcasecmp (reg_info->alt_name, name) == 0)))
{
value_sp = ValueObjectRegister::Create (frame, reg_ctx, reg_idx);
sb_value.SetSP (value_sp);
break;
}
}
}
}
break;
case eValueTypeRegisterSet: // A collection of stack frame register values
{
RegisterContextSP reg_ctx (frame->GetRegisterContext());
if (reg_ctx)
{
const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
{
const RegisterSet *reg_set = reg_ctx->GetRegisterSet (set_idx);
if (reg_set &&
((reg_set->name && strcasecmp (reg_set->name, name) == 0) ||
(reg_set->short_name && strcasecmp (reg_set->short_name, name) == 0)))
//.........这里部分代码省略.........
示例3: DoExecute
//.........这里部分代码省略.........
options |= Disassembler::eOptionShowBytes;
if (m_options.raw)
options |= Disassembler::eOptionRawOuput;
if (!m_options.func_name.empty()) {
ConstString name(m_options.func_name.c_str());
if (Disassembler::Disassemble(
m_interpreter.GetDebugger(), m_options.arch, plugin_name,
flavor_string, m_exe_ctx, name,
nullptr, // Module *
m_options.num_instructions, m_options.show_mixed,
m_options.show_mixed ? m_options.num_lines_context : 0, options,
result.GetOutputStream())) {
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
result.AppendErrorWithFormat("Unable to find symbol with name '%s'.\n",
name.GetCString());
result.SetStatus(eReturnStatusFailed);
}
} else {
std::vector<AddressRange> ranges;
AddressRange range;
StackFrame *frame = m_exe_ctx.GetFramePtr();
if (m_options.frame_line) {
if (frame == nullptr) {
result.AppendError("Cannot disassemble around the current line without "
"a selected frame.\n");
result.SetStatus(eReturnStatusFailed);
return false;
}
LineEntry pc_line_entry(
frame->GetSymbolContext(eSymbolContextLineEntry).line_entry);
if (pc_line_entry.IsValid()) {
range = pc_line_entry.range;
} else {
m_options.at_pc =
true; // No line entry, so just disassemble around the current pc
m_options.show_mixed = false;
}
} else if (m_options.current_function) {
if (frame == nullptr) {
result.AppendError("Cannot disassemble around the current function "
"without a selected frame.\n");
result.SetStatus(eReturnStatusFailed);
return false;
}
Symbol *symbol = frame->GetSymbolContext(eSymbolContextSymbol).symbol;
if (symbol) {
range.GetBaseAddress() = symbol->GetAddress();
range.SetByteSize(symbol->GetByteSize());
}
}
// Did the "m_options.frame_line" find a valid range already? If so
// skip the rest...
if (range.GetByteSize() == 0) {
if (m_options.at_pc) {
if (frame == nullptr) {
result.AppendError("Cannot disassemble around the current PC without "
"a selected frame.\n");
result.SetStatus(eReturnStatusFailed);
return false;
}
range.GetBaseAddress() = frame->GetFrameCodeAddress();
示例4: ScanContext
void ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
if (log)
log->Printf("ClangUserExpression::ScanContext()");
m_target = exe_ctx.GetTargetPtr();
if (!(m_allow_cxx || m_allow_objc)) {
if (log)
log->Printf(" [CUE::SC] Settings inhibit C++ and Objective-C");
return;
}
StackFrame *frame = exe_ctx.GetFramePtr();
if (frame == NULL) {
if (log)
log->Printf(" [CUE::SC] Null stack frame");
return;
}
SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
lldb::eSymbolContextBlock);
if (!sym_ctx.function) {
if (log)
log->Printf(" [CUE::SC] Null function");
return;
}
// Find the block that defines the function represented by "sym_ctx"
Block *function_block = sym_ctx.GetFunctionBlock();
if (!function_block) {
if (log)
log->Printf(" [CUE::SC] Null function block");
return;
}
CompilerDeclContext decl_context = function_block->GetDeclContext();
if (!decl_context) {
if (log)
log->Printf(" [CUE::SC] Null decl context");
return;
}
if (clang::CXXMethodDecl *method_decl =
ClangASTContext::DeclContextGetAsCXXMethodDecl(decl_context)) {
if (m_allow_cxx && method_decl->isInstance()) {
if (m_enforce_valid_object) {
lldb::VariableListSP variable_list_sp(
function_block->GetBlockVariableList(true));
const char *thisErrorString = "Stopped in a C++ method, but 'this' "
"isn't available; pretending we are in a "
"generic context";
if (!variable_list_sp) {
err.SetErrorString(thisErrorString);
return;
}
lldb::VariableSP this_var_sp(
variable_list_sp->FindVariable(ConstString("this")));
if (!this_var_sp || !this_var_sp->IsInScope(frame) ||
!this_var_sp->LocationIsValidForFrame(frame)) {
err.SetErrorString(thisErrorString);
return;
}
}
m_in_cplusplus_method = true;
m_needs_object_ptr = true;
}
} else if (clang::ObjCMethodDecl *method_decl =
ClangASTContext::DeclContextGetAsObjCMethodDecl(
decl_context)) {
if (m_allow_objc) {
if (m_enforce_valid_object) {
lldb::VariableListSP variable_list_sp(
function_block->GetBlockVariableList(true));
const char *selfErrorString = "Stopped in an Objective-C method, but "
"'self' isn't available; pretending we "
"are in a generic context";
if (!variable_list_sp) {
err.SetErrorString(selfErrorString);
return;
}
lldb::VariableSP self_variable_sp =
variable_list_sp->FindVariable(ConstString("self"));
if (!self_variable_sp || !self_variable_sp->IsInScope(frame) ||
!self_variable_sp->LocationIsValidForFrame(frame)) {
err.SetErrorString(selfErrorString);
return;
//.........这里部分代码省略.........