本文整理汇总了C++中SymbolContext::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolContext::Clear方法的具体用法?C++ SymbolContext::Clear怎么用?C++ SymbolContext::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolContext
的用法示例。
在下文中一共展示了SymbolContext::Clear方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2:
bool
SymbolContext::GetParentOfInlinedScope (const Address &curr_frame_pc,
SymbolContext &next_frame_sc,
Address &next_frame_pc) const
{
next_frame_sc.Clear(false);
next_frame_pc.Clear();
if (block)
{
//const addr_t curr_frame_file_addr = curr_frame_pc.GetFileAddress();
// In order to get the parent of an inlined function we first need to
// see if we are in an inlined block as "this->block" could be an
// inlined block, or a parent of "block" could be. So lets check if
// this block or one of this blocks parents is an inlined function.
Block *curr_inlined_block = block->GetContainingInlinedBlock();
if (curr_inlined_block)
{
// "this->block" is contained in an inline function block, so to
// get the scope above the inlined block, we get the parent of the
// inlined block itself
Block *next_frame_block = curr_inlined_block->GetParent();
// Now calculate the symbol context of the containing block
next_frame_block->CalculateSymbolContext (&next_frame_sc);
// If we get here we weren't able to find the return line entry using the nesting of the blocks and
// the line table. So just use the call site info from our inlined block.
AddressRange range;
if (curr_inlined_block->GetRangeContainingAddress (curr_frame_pc, range))
{
// To see there this new frame block it, we need to look at the
// call site information from
const InlineFunctionInfo* curr_inlined_block_inlined_info = curr_inlined_block->GetInlinedFunctionInfo();
next_frame_pc = range.GetBaseAddress();
next_frame_sc.line_entry.range.GetBaseAddress() = next_frame_pc;
next_frame_sc.line_entry.file = curr_inlined_block_inlined_info->GetCallSite().GetFile();
next_frame_sc.line_entry.line = curr_inlined_block_inlined_info->GetCallSite().GetLine();
next_frame_sc.line_entry.column = curr_inlined_block_inlined_info->GetCallSite().GetColumn();
return true;
}
else
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYMBOLS));
if (log)
{
log->Printf ("warning: inlined block 0x%8.8" PRIx64 " doesn't have a range that contains file address 0x%" PRIx64,
curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress());
}
#ifdef LLDB_CONFIGURATION_DEBUG
else
{
ObjectFile *objfile = NULL;
if (module_sp)
{
SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor();
if (symbol_vendor)
{
SymbolFile *symbol_file = symbol_vendor->GetSymbolFile();
if (symbol_file)
objfile = symbol_file->GetObjectFile();
}
}
if (objfile)
{
Host::SystemLog (Host::eSystemLogWarning,
"warning: inlined block 0x%8.8" PRIx64 " doesn't have a range that contains file address 0x%" PRIx64 " in %s\n",
curr_inlined_block->GetID(),
curr_frame_pc.GetFileAddress(),
objfile->GetFileSpec().GetPath().c_str());
}
else
{
Host::SystemLog (Host::eSystemLogWarning,
"warning: inlined block 0x%8.8" PRIx64 " doesn't have a range that contains file address 0x%" PRIx64 "\n",
curr_inlined_block->GetID(),
curr_frame_pc.GetFileAddress());
}
}
#endif
}
}
}
return false;
}
示例3: exe_ctx
bool
DoExecute (Args& command, CommandReturnObject &result)
{
const int argc = command.GetArgumentCount();
if (argc != 0)
{
result.AppendErrorWithFormat("'%s' takes no arguments, only flags.\n", GetCommandName());
result.SetStatus (eReturnStatusFailed);
return false;
}
ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
Target *target = exe_ctx.GetTargetPtr();
if (target == NULL)
target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target == NULL)
{
result.AppendError ("invalid target, create a debug target using the 'target create' command");
result.SetStatus (eReturnStatusFailed);
return false;
}
SymbolContextList sc_list;
if (!m_options.symbol_name.empty())
{
// Displaying the source for a symbol:
ConstString name(m_options.symbol_name.c_str());
bool include_symbols = false;
bool include_inlines = true;
bool append = true;
size_t num_matches = 0;
if (m_options.modules.size() > 0)
{
ModuleList matching_modules;
for (unsigned i = 0, e = m_options.modules.size(); i != e; i++)
{
FileSpec module_file_spec(m_options.modules[i].c_str(), false);
if (module_file_spec)
{
ModuleSpec module_spec (module_file_spec);
matching_modules.Clear();
target->GetImages().FindModules (module_spec, matching_modules);
num_matches += matching_modules.FindFunctions (name, eFunctionNameTypeAuto, include_symbols, include_inlines, append, sc_list);
}
}
}
else
{
num_matches = target->GetImages().FindFunctions (name, eFunctionNameTypeAuto, include_symbols, include_inlines, append, sc_list);
}
SymbolContext sc;
if (num_matches == 0)
{
result.AppendErrorWithFormat("Could not find function named: \"%s\".\n", m_options.symbol_name.c_str());
result.SetStatus (eReturnStatusFailed);
return false;
}
sc_list.GetContextAtIndex (0, sc);
FileSpec start_file;
uint32_t start_line;
uint32_t end_line;
FileSpec end_file;
if (sc.function != NULL)
{
sc.function->GetStartLineSourceInfo (start_file, start_line);
if (start_line == 0)
{
result.AppendErrorWithFormat("Could not find line information for start of function: \"%s\".\n", m_options.symbol_name.c_str());
result.SetStatus (eReturnStatusFailed);
return false;
}
sc.function->GetEndLineSourceInfo (end_file, end_line);
}
else
{
result.AppendErrorWithFormat("Could not find function info for: \"%s\".\n", m_options.symbol_name.c_str());
result.SetStatus (eReturnStatusFailed);
return false;
}
if (num_matches > 1)
{
// This could either be because there are multiple functions of this name, in which case
// we'll have to specify this further... Or it could be because there are multiple inlined instances
// of one function. So run through the matches and if they all have the same file & line then we can just
// list one.
bool found_multiple = false;
for (size_t i = 1; i < num_matches; i++)
{
SymbolContext scratch_sc;
sc_list.GetContextAtIndex (i, scratch_sc);
//.........这里部分代码省略.........
示例4: target_sp
bool
Disassembler::PrintInstructions
(
Disassembler *disasm_ptr,
Debugger &debugger,
const ArchSpec &arch,
const ExecutionContext &exe_ctx,
uint32_t num_instructions,
uint32_t num_mixed_context_lines,
uint32_t options,
Stream &strm
)
{
// We got some things disassembled...
size_t num_instructions_found = disasm_ptr->GetInstructionList().GetSize();
if (num_instructions > 0 && num_instructions < num_instructions_found)
num_instructions_found = num_instructions;
const uint32_t max_opcode_byte_size = disasm_ptr->GetInstructionList().GetMaxOpcocdeByteSize ();
uint32_t offset = 0;
SymbolContext sc;
SymbolContext prev_sc;
AddressRange sc_range;
const Address *pc_addr_ptr = NULL;
StackFrame *frame = exe_ctx.GetFramePtr();
TargetSP target_sp (exe_ctx.GetTargetSP());
SourceManager &source_manager = target_sp ? target_sp->GetSourceManager() : debugger.GetSourceManager();
if (frame)
{
pc_addr_ptr = &frame->GetFrameCodeAddress();
}
const uint32_t scope = eSymbolContextLineEntry | eSymbolContextFunction | eSymbolContextSymbol;
const bool use_inline_block_range = false;
const FormatEntity::Entry *disassembly_format = NULL;
FormatEntity::Entry format;
if (exe_ctx.HasTargetScope())
{
disassembly_format = exe_ctx.GetTargetRef().GetDebugger().GetDisassemblyFormat ();
}
else
{
FormatEntity::Parse("${addr}: ", format);
disassembly_format = &format;
}
// First pass: step through the list of instructions,
// find how long the initial addresses strings are, insert padding
// in the second pass so the opcodes all line up nicely.
size_t address_text_size = 0;
for (size_t i = 0; i < num_instructions_found; ++i)
{
Instruction *inst = disasm_ptr->GetInstructionList().GetInstructionAtIndex (i).get();
if (inst)
{
const Address &addr = inst->GetAddress();
ModuleSP module_sp (addr.GetModule());
if (module_sp)
{
const uint32_t resolve_mask = eSymbolContextFunction | eSymbolContextSymbol;
uint32_t resolved_mask = module_sp->ResolveSymbolContextForAddress(addr, resolve_mask, sc);
if (resolved_mask)
{
StreamString strmstr;
Debugger::FormatDisassemblerAddress (disassembly_format, &sc, NULL, &exe_ctx, &addr, strmstr);
size_t cur_line = strmstr.GetSizeOfLastLine();
if (cur_line > address_text_size)
address_text_size = cur_line;
}
sc.Clear(false);
}
}
}
for (size_t i = 0; i < num_instructions_found; ++i)
{
Instruction *inst = disasm_ptr->GetInstructionList().GetInstructionAtIndex (i).get();
if (inst)
{
const Address &addr = inst->GetAddress();
const bool inst_is_at_pc = pc_addr_ptr && addr == *pc_addr_ptr;
prev_sc = sc;
ModuleSP module_sp (addr.GetModule());
if (module_sp)
{
uint32_t resolved_mask = module_sp->ResolveSymbolContextForAddress(addr, eSymbolContextEverything, sc);
if (resolved_mask)
{
if (num_mixed_context_lines)
{
if (!sc_range.ContainsFileAddress (addr))
{
sc.GetAddressRange (scope, 0, use_inline_block_range, sc_range);
if (sc != prev_sc)
//.........这里部分代码省略.........
示例5: target_sp
bool
Disassembler::PrintInstructions
(
Disassembler *disasm_ptr,
Debugger &debugger,
const ArchSpec &arch,
const ExecutionContext &exe_ctx,
uint32_t num_instructions,
uint32_t num_mixed_context_lines,
uint32_t options,
Stream &strm
)
{
// We got some things disassembled...
size_t num_instructions_found = disasm_ptr->GetInstructionList().GetSize();
if (num_instructions > 0 && num_instructions < num_instructions_found)
num_instructions_found = num_instructions;
const uint32_t max_opcode_byte_size = disasm_ptr->GetInstructionList().GetMaxOpcocdeByteSize ();
uint32_t offset = 0;
SymbolContext sc;
SymbolContext prev_sc;
AddressRange sc_range;
const Address *pc_addr_ptr = NULL;
ExecutionContextScope *exe_scope = exe_ctx.GetBestExecutionContextScope();
Frame *frame = exe_ctx.GetFramePtr();
TargetSP target_sp (exe_ctx.GetTargetSP());
SourceManager &source_manager = target_sp ? target_sp->GetSourceManager() : debugger.GetSourceManager();
if (frame)
pc_addr_ptr = &frame->GetFrameCodeAddress();
const uint32_t scope = eSymbolContextLineEntry | eSymbolContextFunction | eSymbolContextSymbol;
const bool use_inline_block_range = false;
for (size_t i=0; i<num_instructions_found; ++i)
{
Instruction *inst = disasm_ptr->GetInstructionList().GetInstructionAtIndex (i).get();
if (inst)
{
const Address &addr = inst->GetAddress();
const bool inst_is_at_pc = pc_addr_ptr && addr == *pc_addr_ptr;
prev_sc = sc;
ModuleSP module_sp (addr.GetModule());
if (module_sp)
{
uint32_t resolved_mask = module_sp->ResolveSymbolContextForAddress(addr, eSymbolContextEverything, sc);
if (resolved_mask)
{
if (num_mixed_context_lines)
{
if (!sc_range.ContainsFileAddress (addr))
{
sc.GetAddressRange (scope, 0, use_inline_block_range, sc_range);
if (sc != prev_sc)
{
if (offset != 0)
strm.EOL();
sc.DumpStopContext(&strm, exe_ctx.GetProcessPtr(), addr, false, true, false);
strm.EOL();
if (sc.comp_unit && sc.line_entry.IsValid())
{
source_manager.DisplaySourceLinesWithLineNumbers (sc.line_entry.file,
sc.line_entry.line,
num_mixed_context_lines,
num_mixed_context_lines,
((inst_is_at_pc && (options & eOptionMarkPCSourceLine)) ? "->" : ""),
&strm);
}
}
}
}
else if ((sc.function || sc.symbol) && (sc.function != prev_sc.function || sc.symbol != prev_sc.symbol))
{
if (prev_sc.function || prev_sc.symbol)
strm.EOL();
bool show_fullpaths = false;
bool show_module = true;
bool show_inlined_frames = true;
sc.DumpStopContext (&strm,
exe_scope,
addr,
show_fullpaths,
show_module,
show_inlined_frames);
strm << ":\n";
}
}
else
{
sc.Clear(true);
}
}
//.........这里部分代码省略.........
示例6: range
//.........这里部分代码省略.........
Address addr(range.GetBaseAddress());
// We extract the section to make sure we don't transition out
// of the current section when disassembling
const Section *addr_section = addr.GetSection();
Module *range_module = range.GetBaseAddress().GetModule();
for (size_t i=0; i<num_instructions; ++i)
{
Disassembler::Instruction *inst = disassembler->GetInstructionList().GetInstructionAtIndex (i);
if (inst)
{
addr_t file_addr = addr.GetFileAddress();
if (addr_section == NULL || addr_section->ContainsFileAddress (file_addr) == false)
{
if (range_module)
range_module->ResolveFileAddress (file_addr, addr);
else if (exe_ctx.target)
exe_ctx.target->GetImages().ResolveFileAddress (file_addr, addr);
addr_section = addr.GetSection();
}
prev_sc = sc;
if (addr_section)
{
Module *module = addr_section->GetModule();
uint32_t resolved_mask = module->ResolveSymbolContextForAddress(addr, eSymbolContextEverything, sc);
if (resolved_mask)
{
if (prev_sc.function != sc.function || prev_sc.symbol != sc.symbol)
{
if (prev_sc.function || prev_sc.symbol)
strm.EOL();
strm << sc.module_sp->GetFileSpec().GetFilename();
if (sc.function)
strm << '`' << sc.function->GetMangled().GetName();
else if (sc.symbol)
strm << '`' << sc.symbol->GetMangled().GetName();
strm << ":\n";
}
if (num_mixed_context_lines && !sc_range.ContainsFileAddress (addr))
{
sc.GetAddressRange (eSymbolContextEverything, sc_range);
if (sc != prev_sc)
{
if (offset != 0)
strm.EOL();
sc.DumpStopContext(&strm, process, addr);
if (sc.comp_unit && sc.line_entry.IsValid())
{
debugger.GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.line_entry.file,
sc.line_entry.line,
num_mixed_context_lines,
num_mixed_context_lines,
num_mixed_context_lines ? "->" : "",
&strm);
}
}
}
}
else
{
sc.Clear();
}
}
if (num_mixed_context_lines)
strm.IndentMore ();
strm.Indent();
size_t inst_byte_size = inst->GetByteSize();
inst->Dump(&strm, &addr, show_bytes ? &data : NULL, offset, exe_ctx, show_bytes);
strm.EOL();
offset += inst_byte_size;
addr.SetOffset (addr.GetOffset() + inst_byte_size);
if (num_mixed_context_lines)
strm.IndentLess ();
}
else
{
break;
}
}
if (num_mixed_context_lines)
strm.IndentLess ();
}
}
return true;
}
return false;
}
示例7: name
//.........这里部分代码省略.........
SymbolContext sc;
sc_list.GetContextAtIndex (0, sc);
SourceInfo source_info;
if (DisplayFunctionSource (sc, source_info, result))
{
result.SetStatus (eReturnStatusSuccessFinishResult);
}
else
{
result.SetStatus (eReturnStatusFailed);
}
}
return result.Succeeded();
}
else if (m_options.address != LLDB_INVALID_ADDRESS)
{
Address so_addr;
StreamString error_strm;
SymbolContextList sc_list;
if (target->GetSectionLoadList().IsEmpty())
{
// The target isn't loaded yet, we need to lookup the file address
// in all modules
const ModuleList &module_list = target->GetImages();
const size_t num_modules = module_list.GetSize();
for (size_t i=0; i<num_modules; ++i)
{
ModuleSP module_sp (module_list.GetModuleAtIndex(i));
if (module_sp && module_sp->ResolveFileAddress(m_options.address, so_addr))
{
SymbolContext sc;
sc.Clear(true);
if (module_sp->ResolveSymbolContextForAddress (so_addr, eSymbolContextEverything, sc) & eSymbolContextLineEntry)
sc_list.Append(sc);
}
}
if (sc_list.GetSize() == 0)
{
result.AppendErrorWithFormat("no modules have source information for file address 0x%" PRIx64 ".\n",
m_options.address);
result.SetStatus (eReturnStatusFailed);
return false;
}
}
else
{
// The target has some things loaded, resolve this address to a
// compile unit + file + line and display
if (target->GetSectionLoadList().ResolveLoadAddress (m_options.address, so_addr))
{
ModuleSP module_sp (so_addr.GetModule());
if (module_sp)
{
SymbolContext sc;
sc.Clear(true);
if (module_sp->ResolveSymbolContextForAddress (so_addr, eSymbolContextEverything, sc) & eSymbolContextLineEntry)
{
sc_list.Append(sc);
}
else
{
so_addr.Dump(&error_strm, NULL, Address::DumpStyleModuleWithFileAddress);
result.AppendErrorWithFormat("address resolves to %s, but there is no line table information available for this address.\n",