本文整理汇总了C++中SymbolContext类的典型用法代码示例。如果您正苦于以下问题:C++ SymbolContext类的具体用法?C++ SymbolContext怎么用?C++ SymbolContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SymbolContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
size_t
Disassembler::Disassemble
(
Debugger &debugger,
const ArchSpec &arch,
const ExecutionContext &exe_ctx,
SymbolContextList &sc_list,
uint32_t num_mixed_context_lines,
bool show_bytes,
Stream &strm
)
{
size_t success_count = 0;
const size_t count = sc_list.GetSize();
SymbolContext sc;
AddressRange range;
for (size_t i=0; i<count; ++i)
{
if (sc_list.GetContextAtIndex(i, sc) == false)
break;
if (sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, range))
{
if (Disassemble (debugger, arch, exe_ctx, range, num_mixed_context_lines, show_bytes, strm))
{
++success_count;
strm.EOL();
}
}
}
return success_count;
}
示例2: locker
size_t
ModuleList::FindFunctionSymbols (const ConstString &name,
uint32_t name_type_mask,
SymbolContextList& sc_list)
{
const size_t old_size = sc_list.GetSize();
if (name_type_mask & eFunctionNameTypeAuto)
{
ConstString lookup_name;
uint32_t lookup_name_type_mask = 0;
bool match_name_after_lookup = false;
Module::PrepareForFunctionNameLookup (name, name_type_mask,
eLanguageTypeUnknown, // TODO: add support
lookup_name,
lookup_name_type_mask,
match_name_after_lookup);
Mutex::Locker locker(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
(*pos)->FindFunctionSymbols (lookup_name,
lookup_name_type_mask,
sc_list);
}
if (match_name_after_lookup)
{
SymbolContext sc;
size_t i = old_size;
while (i < sc_list.GetSize())
{
if (sc_list.GetContextAtIndex(i, sc))
{
const char *func_name = sc.GetFunctionName().GetCString();
if (func_name != nullptr && strstr(func_name, name.GetCString()) == nullptr)
{
// Remove the current context
sc_list.RemoveContextAtIndex(i);
// Don't increment i and continue in the loop
continue;
}
}
++i;
}
}
}
else
{
Mutex::Locker locker(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
(*pos)->FindFunctionSymbols (name, name_type_mask, sc_list);
}
}
return sc_list.GetSize() - old_size;
}
示例3: Address
bool
Variable::DumpDeclaration (Stream *s, bool show_fullpaths, bool show_module)
{
bool dumped_declaration_info = false;
if (m_owner_scope)
{
SymbolContext sc;
m_owner_scope->CalculateSymbolContext(&sc);
sc.block = nullptr;
sc.line_entry.Clear();
bool show_inlined_frames = false;
const bool show_function_arguments = true;
const bool show_function_name = true;
dumped_declaration_info = sc.DumpStopContext (s,
nullptr,
Address(),
show_fullpaths,
show_module,
show_inlined_frames,
show_function_arguments,
show_function_name);
if (sc.function)
s->PutChar(':');
}
if (m_declaration.DumpStopContext (s, false))
dumped_declaration_info = true;
return dumped_declaration_info;
}
示例4:
Searcher::CallbackReturn
CommandCompletions::SymbolCompleter::SearchCallback(SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool complete)
{
if (context.module_sp)
{
SymbolContextList sc_list;
const bool include_symbols = true;
const bool include_inlines = true;
const bool append = true;
context.module_sp->FindFunctions (m_regex, include_symbols, include_inlines, append, sc_list);
SymbolContext sc;
// Now add the functions & symbols to the list - only add if unique:
for (uint32_t i = 0; i < sc_list.GetSize(); i++)
{
if (sc_list.GetContextAtIndex(i, sc))
{
ConstString func_name = sc.GetFunctionName(Mangled::ePreferDemangled);
if (!func_name.IsEmpty())
m_match_set.insert (func_name);
}
}
}
return Searcher::eCallbackReturnContinue;
}
示例5: 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;
}
示例6: if
bool
ThreadPlanStepInRange::DefaultShouldStopHereCallback (ThreadPlan *current_plan, Flags &flags, FrameComparison operation, void *baton)
{
bool should_stop_here = true;
StackFrame *frame = current_plan->GetThread().GetStackFrameAtIndex(0).get();
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
// First see if the ThreadPlanShouldStopHere default implementation thinks we should get out of here:
should_stop_here = ThreadPlanShouldStopHere::DefaultShouldStopHereCallback (current_plan, flags, operation, baton);
if (!should_stop_here)
return should_stop_here;
if (should_stop_here && current_plan->GetKind() == eKindStepInRange && operation == eFrameCompareYounger)
{
ThreadPlanStepInRange *step_in_range_plan = static_cast<ThreadPlanStepInRange *> (current_plan);
if (step_in_range_plan->m_step_into_target)
{
SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock|eSymbolContextSymbol);
if (sc.symbol != NULL)
{
// First try an exact match, since that's cheap with ConstStrings. Then do a strstr compare.
if (step_in_range_plan->m_step_into_target == sc.GetFunctionName())
{
should_stop_here = true;
}
else
{
const char *target_name = step_in_range_plan->m_step_into_target.AsCString();
const char *function_name = sc.GetFunctionName().AsCString();
if (function_name == NULL)
should_stop_here = false;
else if (strstr (function_name, target_name) == NULL)
should_stop_here = false;
}
if (log && !should_stop_here)
log->Printf("Stepping out of frame %s which did not match step into target %s.",
sc.GetFunctionName().AsCString(),
step_in_range_plan->m_step_into_target.AsCString());
}
}
if (should_stop_here)
{
ThreadPlanStepInRange *step_in_range_plan = static_cast<ThreadPlanStepInRange *> (current_plan);
// Don't log the should_step_out here, it's easier to do it in FrameMatchesAvoidCriteria.
should_stop_here = !step_in_range_plan->FrameMatchesAvoidCriteria ();
}
}
return should_stop_here;
}
示例7: sym_ctx
bool
SystemRuntimeMacOSX::SafeToCallFunctionsOnThisThread (ThreadSP thread_sp)
{
if (thread_sp && thread_sp->GetStackFrameCount() > 0 && thread_sp->GetFrameWithConcreteFrameIndex(0))
{
const SymbolContext sym_ctx (thread_sp->GetFrameWithConcreteFrameIndex(0)->GetSymbolContext (eSymbolContextSymbol));
static ConstString g_select_symbol ("__select");
if (sym_ctx.GetFunctionName() == g_select_symbol)
{
return false;
}
}
return true;
}
示例8:
size_t
Disassembler::Disassemble
(
Debugger &debugger,
const ArchSpec &arch,
const char *plugin_name,
const char *flavor,
const ExecutionContext &exe_ctx,
SymbolContextList &sc_list,
uint32_t num_instructions,
uint32_t num_mixed_context_lines,
uint32_t options,
Stream &strm
)
{
size_t success_count = 0;
const size_t count = sc_list.GetSize();
SymbolContext sc;
AddressRange range;
const uint32_t scope = eSymbolContextBlock | eSymbolContextFunction | eSymbolContextSymbol;
const bool use_inline_block_range = true;
for (size_t i=0; i<count; ++i)
{
if (sc_list.GetContextAtIndex(i, sc) == false)
break;
for (uint32_t range_idx = 0; sc.GetAddressRange(scope, range_idx, use_inline_block_range, range); ++range_idx)
{
if (Disassemble (debugger,
arch,
plugin_name,
flavor,
exe_ctx,
range,
num_instructions,
num_mixed_context_lines,
options,
strm))
{
++success_count;
strm.EOL();
}
}
}
return success_count;
}
示例9: OutputToStream
void StackTrace::OutputToStream(std::ostream* os)
{
SymbolContext* context = SymbolContext::Get();
DWORD error = context->init_error();
if(error != ERROR_SUCCESS)
{
(*os) << "Error initializing symbols (" << error
<< "). Dumping unresolved backtrace:\n";
for(int i=0; (i<count_)&&os->good(); ++i)
{
(*os) << "\t" << trace_[i] << "\n";
}
}
else
{
(*os) << "Backtrace:\n";
context->OutputTraceToStream(trace_, count_, os);
}
}
示例10: GetThread
bool
ThreadPlanStepInRange::FrameMatchesAvoidRegexp ()
{
StackFrame *frame = GetThread().GetStackFrameAtIndex(0).get();
const RegularExpression *avoid_regexp_to_use = m_avoid_regexp_ap.get();
if (avoid_regexp_to_use == NULL)
avoid_regexp_to_use = GetThread().GetSymbolsToAvoidRegexp();
if (avoid_regexp_to_use != NULL)
{
SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock|eSymbolContextSymbol);
if (sc.symbol != NULL)
{
const char *frame_function_name = sc.GetFunctionName().GetCString();
if (frame_function_name)
return avoid_regexp_to_use->Execute(frame_function_name);
}
}
return false;
}
示例11: locker
uint32_t
Module::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc)
{
Mutex::Locker locker (m_mutex);
uint32_t resolved_flags = 0;
// Clear the result symbol context in case we don't find anything
sc.Clear();
// Get the section from the section/offset address.
const Section *section = so_addr.GetSection();
// Make sure the section matches this module before we try and match anything
if (section && section->GetModule() == this)
{
// If the section offset based address resolved itself, then this
// is the right module.
sc.module_sp = GetSP();
resolved_flags |= eSymbolContextModule;
// Resolve the compile unit, function, block, line table or line
// entry if requested.
if (resolve_scope & eSymbolContextCompUnit ||
resolve_scope & eSymbolContextFunction ||
resolve_scope & eSymbolContextBlock ||
resolve_scope & eSymbolContextLineEntry )
{
SymbolVendor *symbols = GetSymbolVendor ();
if (symbols)
resolved_flags |= symbols->ResolveSymbolContext (so_addr, resolve_scope, sc);
}
// Resolve the symbol if requested, but don't re-look it up if we've already found it.
if (resolve_scope & eSymbolContextSymbol && !(resolved_flags & eSymbolContextSymbol))
{
ObjectFile* ofile = GetObjectFile();
if (ofile)
{
Symtab *symtab = ofile->GetSymtab();
if (symtab)
{
if (so_addr.IsSectionOffset())
{
sc.symbol = symtab->FindSymbolContainingFileAddress(so_addr.GetFileAddress());
if (sc.symbol)
resolved_flags |= eSymbolContextSymbol;
}
}
}
}
}
return resolved_flags;
}
示例12: full_name
void
BreakpointResolverName::LookupInfo::Prune (SymbolContextList &sc_list, size_t start_idx) const
{
if (match_name_after_lookup && name)
{
SymbolContext sc;
size_t i = start_idx;
while (i < sc_list.GetSize())
{
if (!sc_list.GetContextAtIndex(i, sc))
break;
ConstString full_name (sc.GetFunctionName());
if (full_name && ::strstr(full_name.GetCString(), name.GetCString()) == NULL)
{
sc_list.RemoveContextAtIndex(i);
}
else
{
++i;
}
}
}
}
示例13: Initialize
FuncUnwindersSP
UnwindTable::GetUncachedFuncUnwindersContainingAddress (const Address& addr, SymbolContext &sc)
{
FuncUnwindersSP no_unwind_found;
Initialize();
AddressRange range;
if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, false, range) || !range.GetBaseAddress().IsValid())
{
// Does the eh_frame unwind info has a function bounds for this addr?
if (m_eh_frame == NULL || !m_eh_frame->GetAddressRange (addr, range))
{
return no_unwind_found;
}
}
FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, m_assembly_profiler, range));
return func_unwinder_sp;
}
示例14:
llvm::Optional<AddressRange> UnwindTable::GetAddressRange(const Address &addr,
SymbolContext &sc) {
AddressRange range;
// First check the symbol context
if (sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0,
false, range) &&
range.GetBaseAddress().IsValid())
return range;
// Does the eh_frame unwind info has a function bounds for this addr?
if (m_eh_frame_up && m_eh_frame_up->GetAddressRange(addr, range))
return range;
// Try debug_frame as well
if (m_debug_frame_up && m_debug_frame_up->GetAddressRange(addr, range))
return range;
return llvm::None;
}
示例15: Initialize
FuncUnwindersSP
UnwindTable::GetFuncUnwindersContainingAddress (const Address& addr, SymbolContext &sc)
{
FuncUnwindersSP no_unwind_found;
Initialize();
// There is an UnwindTable per object file, so we can safely use file handles
addr_t file_addr = addr.GetFileAddress();
iterator end = m_unwinds.end ();
iterator insert_pos = end;
if (!m_unwinds.empty())
{
insert_pos = m_unwinds.lower_bound (file_addr);
iterator pos = insert_pos;
if ((pos == m_unwinds.end ()) || (pos != m_unwinds.begin() && pos->second->GetFunctionStartAddress() != addr))
--pos;
if (pos->second->ContainsAddress (addr))
return pos->second;
}
AddressRange range;
if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, false, range) || !range.GetBaseAddress().IsValid())
{
// Does the eh_frame unwind info has a function bounds for this addr?
if (m_eh_frame == NULL || !m_eh_frame->GetAddressRange (addr, range))
{
return no_unwind_found;
}
}
FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, m_assembly_profiler, range));
m_unwinds.insert (insert_pos, std::make_pair(range.GetBaseAddress().GetFileAddress(), func_unwinder_sp));
// StreamFile s(stdout);
// Dump (s);
return func_unwinder_sp;
}