75 bool show_fullpaths,
bool show_module,
bool show_inlined_frames,
76 bool show_function_arguments,
bool show_function_name,
77 bool show_function_display_name,
78 std::optional<Stream::HighlightSettings> settings)
const {
79 bool dumped_something =
false;
84 *s <<
module_sp->GetFileSpec().GetFilename();
86 dumped_something =
true;
91 if (!show_function_name) {
93 dumped_something =
true;
96 if (!show_function_arguments)
97 name =
function->GetNameNoArguments();
98 if (!name && show_function_display_name)
110 file_addr >=
function->GetAddress().GetFileAddress() ?
'+' :
'-';
111 addr_t offset = file_addr -
function->GetAddress().GetFileAddress();
114 if (!show_function_name) {
116 dumped_something =
true;
117 s->
Format(
"{0}{1}>", sign, offset);
119 dumped_something =
true;
120 s->
Format(
" {0} {1}", sign, offset);
125 dumped_something =
true;
126 Block *inlined_block =
block->GetContainingInlinedBlock();
133 const addr_t inlined_function_offset =
136 if (inlined_function_offset) {
137 s->
Printf(
" + %" PRIu64, inlined_function_offset);
149 line_entry.DumpStopContext(s, show_fullpaths);
152 if (show_inlined_frames) {
155 const bool show_function_name =
true;
157 s, exe_scope, inline_parent_addr, show_fullpaths, show_module,
158 show_inlined_frames, show_function_arguments, show_function_name,
159 show_function_display_name);
163 dumped_something =
true;
165 if (
line_entry.DumpStopContext(s, show_fullpaths))
166 dumped_something =
true;
169 }
else if (
symbol !=
nullptr) {
170 if (!show_function_name) {
172 dumped_something =
true;
173 }
else if (
symbol->GetName()) {
174 dumped_something =
true;
178 if (show_function_display_name)
179 name =
symbol->GetDisplayName();
186 const addr_t symbol_offset =
188 if (!show_function_name) {
190 dumped_something =
true;
191 s->
Printf(
"+%" PRIu64
">", symbol_offset);
192 }
else if (symbol_offset) {
193 dumped_something =
true;
194 s->
Printf(
" + %" PRIu64, symbol_offset);
199 dumped_something =
true;
201 return dumped_something;
206 std::optional<Stream::HighlightSettings> settings)
const {
208 s->
Indent(
" Module: file = \"");
211 if (
module_sp->GetArchitecture().IsValid())
212 s->
Printf(
", arch = \"%s\"",
213 module_sp->GetArchitecture().GetArchitectureName());
218 s->
Indent(
"CompileUnit: ");
225 function->GetDescription(s, level, target);
236 if (
block !=
nullptr) {
237 std::vector<Block *> blocks;
238 blocks.push_back(
block);
241 while (parent_block) {
242 blocks.push_back(parent_block);
243 parent_block = parent_block->
GetParent();
245 std::vector<Block *>::reverse_iterator pos;
246 std::vector<Block *>::reverse_iterator begin = blocks.rbegin();
247 std::vector<Block *>::reverse_iterator end = blocks.rend();
248 for (pos = begin; pos != end; ++pos) {
253 (*pos)->GetDescription(s,
function, level, target);
259 s->
Indent(
" LineEntry: ");
266 symbol->GetDescription(s, level, target, settings);
305 uint32_t resolved_mask = 0;
307 resolved_mask |= eSymbolContextTarget;
309 resolved_mask |= eSymbolContextModule;
311 resolved_mask |= eSymbolContextCompUnit;
313 resolved_mask |= eSymbolContextFunction;
315 resolved_mask |= eSymbolContextBlock;
317 resolved_mask |= eSymbolContextLineEntry;
319 resolved_mask |= eSymbolContextSymbol;
321 resolved_mask |= eSymbolContextVariable;
322 return resolved_mask;
337 return !(lhs == rhs);
341 bool use_inline_block_range,
343 if ((scope & eSymbolContextLineEntry) &&
line_entry.IsValid()) {
348 if ((scope & eSymbolContextBlock) && (
block !=
nullptr)) {
349 if (use_inline_block_range) {
350 Block *inline_block =
block->GetContainingInlinedBlock();
354 return block->GetRangeAtIndex(range_idx, range);
358 if ((scope & eSymbolContextFunction) && (
function !=
nullptr)) {
359 if (range_idx < function->GetAddressRanges().size()) {
360 range =
function->GetAddressRanges()[range_idx];
365 if ((scope & eSymbolContextSymbol) && (
symbol !=
nullptr)) {
366 if (range_idx == 0) {
367 if (
symbol->ValueIsAddress()) {
383 return symbol->GetAddress();
402 return symbol->GetMangled().GuessLanguage();
409 Address &next_frame_pc)
const {
410 next_frame_sc.
Clear(
false);
411 next_frame_pc.
Clear();
420 Block *curr_inlined_block =
block->GetContainingInlinedBlock();
421 if (curr_inlined_block) {
444 std::make_shared<SupportFile>(
457 "warning: inlined block 0x%8.8" PRIx64
458 " doesn't have a range that contains file address 0x%" PRIx64,
461#ifdef LLDB_CONFIGURATION_DEBUG
466 objfile = symbol_file->GetObjectFile();
470 "inlined block {0:x} doesn't have a range that contains file "
471 "address {1:x} in {2}",
476 "inlined block {0:x} doesn't have a range that contains file "
496 Block *inlined_block =
block->GetContainingInlinedBlock();
498 return inlined_block;
518 lang_type = decl_ctx.GetLanguage();
524 return lang->GetInstanceVariableName();
531 bool isInlinedblock =
false;
532 if (curr_block !=
nullptr &&
534 isInlinedblock =
true;
538 while (curr_block !=
nullptr && !isInlinedblock) {
540 [curr_block, &type_list](
const lldb::TypeSP &type_sp) ->
bool {
543 type_list.
Insert(type_sp);
558 const size_t old_type_list_size = type_list.
GetSize();
562 type_list.
Insert(type_sp);
568 const size_t new_type_list_size = type_list.
GetSize();
569 if (new_type_list_size > old_type_list_size) {
570 for (
size_t i = old_type_list_size; i < new_type_list_size; ++i)
577 const size_t old_type_list_size = type_list.
GetSize();
582 type_list.
Insert(type_sp);
588 const size_t new_type_list_size = type_list.
GetSize();
589 if (new_type_list_size > old_type_list_size) {
590 for (
size_t i = old_type_list_size; i < new_type_list_size; ++i)
597 const size_t old_type_list_size = type_list.
GetSize();
601 type_list.
Insert(type_sp);
606 const size_t new_type_list_size = type_list.
GetSize();
607 if (new_type_list_size > old_type_list_size) {
608 for (
size_t i = old_type_list_size; i < new_type_list_size; ++i)
613 if (!type_map.
Empty()) {
615 type_list.
Insert(type_sp);
625 Block *inlined_block =
block->GetContainingInlinedBlock();
634 return function->GetMangled().GetName(preference);
636 return symbol->GetMangled().GetName(preference);
647 Block *inlined_block =
block->GetContainingInlinedBlock();
668 return llvm::createStringError(
"Symbol context has no line table.");
673 return llvm::createStringError(
674 "end line option %d must be after the current line: %d", end_line,
678 uint32_t line_index = 0;
696 return llvm::createStringError(
697 "Can't find the current line entry in the CompUnit - can't process "
698 "the end-line option");
701 line_index =
comp_unit->FindLineEntry(line_index, end_line,
nullptr,
false,
704 return llvm::createStringError(
705 "could not find a line table entry corresponding "
706 "to end line number %d",
713 return llvm::createStringError(
714 "end line number %d is not contained within the current function.",
721 return llvm::Error::success();
735 auto ProcessMatches = [
this, &name, &target,
738 llvm::SmallVector<const Symbol *, 1> external_symbols;
739 llvm::SmallVector<const Symbol *, 1> internal_symbols;
741 if (sym_ctx.symbol) {
746 switch (
symbol->GetType()) {
753 if (
symbol->GetDemangledNameIsSynthesized()) {
757 if (
symbol->GetMangled().GetMangledName() != name)
760 if (
symbol->IsExternal()) {
761 external_symbols.push_back(
symbol);
763 internal_symbols.push_back(
symbol);
772 symbol->GetReExportedSymbolSharedLibrary();
776 if (!reexport_module_sp) {
784 if (name ==
symbol->GetReExportedSymbolName() &&
785 module == reexport_module_sp.get())
821 if (external_symbols.size() > 1) {
823 ss.
Printf(
"Multiple external symbols found for '%s'\n", name.
AsCString());
830 }
else if (external_symbols.size()) {
831 return external_symbols[0];
832 }
else if (internal_symbols.size() > 1) {
834 ss.
Printf(
"Multiple internal symbols found for '%s'\n", name.
AsCString());
841 }
else if (internal_symbols.size()) {
842 return internal_symbols[0];
850 module->FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list);
851 const Symbol *
const module_symbol = ProcessMatches(sc_list,
error);
853 if (!
error.Success()) {
855 }
else if (module_symbol) {
856 return module_symbol;
864 const Symbol *
const target_symbol = ProcessMatches(sc_list,
error);
866 if (!
error.Success()) {
868 }
else if (target_symbol) {
869 return target_symbol;
877 auto get_mangled = [
this]() {
882 return symbol->GetMangled();
888 return get_mangled();
890 const Block *inline_block =
block->GetContainingInlinedBlock();
892 return get_mangled();
897 return get_mangled();
921 bool return_value =
true;
935 return_value =
false;
943 bool return_value =
true;
950 FileSpec module_file_spec(spec_string);
969 if ((return_value = llvm::to_integer(spec_string,
m_start_line)))
973 if ((return_value = llvm::to_integer(spec_string,
m_end_line)))
1036 bool was_inlined =
false;
1037 if (sc.
block !=
nullptr) {
1040 if (inline_info !=
nullptr) {
1050 if (!was_inlined && sc.
comp_unit !=
nullptr) {
1064 bool was_inlined =
false;
1067 if (sc.
block !=
nullptr) {
1070 if (inline_info !=
nullptr) {
1082 }
else if (sc.
symbol !=
nullptr) {
1096 Address match_address(addr,
nullptr);
1098 m_target_sp->GetImages().ResolveSymbolContextForAddress(
1099 match_address, eSymbolContextEverything, sc);
1110 s->
Printf(
"Nothing specified.\n");
1117 s->
Printf(
"Module: %s\n", path_str);
1125 s->
Printf(
"File: %s", path_str);
1189 bool merge_symbol_into_function) {
1190 uint32_t unique_sc_add_count = 0;
1194 ++unique_sc_add_count;
1196 return unique_sc_add_count;
1200 bool merge_symbol_into_function) {
1206 if (merge_symbol_into_function && sc.
symbol !=
nullptr &&
1212 if (pos->block && pos->block->GetContainingInlinedBlock())
1215 if (pos->function) {
1218 if (pos->symbol == sc.
symbol)
1220 if (pos->symbol ==
nullptr) {
1272 uint32_t match_count = 0;
1274 for (
size_t idx = 0; idx < size; ++idx) {
1284 for (
size_t idx = 0; idx < size; ++idx)
1290 const uint32_t size = lhs.
GetSize();
1296 for (uint32_t i = 0; i < size; ++i) {
1299 if (lhs_sc != rhs_sc)
1307 return !(lhs == rhs);
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
A section + offset based address range class.
Address & GetBaseAddress()
Get accessor for the base address of the range.
void Clear()
Clear the object's state.
void SetByteSize(lldb::addr_t byte_size)
Set accessor for the byte size of this range.
A section + offset based address class.
void Clear()
Clear the object's state.
@ DumpStyleFileAddress
Display as the file address (if any).
@ DumpStyleModuleWithFileAddress
Display as the file address with the module name prepended (if any).
@ DumpStyleLoadAddress
Display as the load address (if resolved).
bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style=DumpStyleInvalid, uint32_t addr_byte_size=UINT32_MAX, bool all_ranges=false, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
Dump a description of this object to a Stream.
lldb::addr_t GetFileAddress() const
Get the file address.
lldb::addr_t GetOffset() const
Get the section relative offset value.
bool IsValid() const
Check if the object state is valid.
bool CalculateSymbolContextLineEntry(LineEntry &line_entry) const
A class that describes a single lexical block.
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object's symbol context into sc.
Block * GetContainingInlinedBlock()
Get the inlined block that contains this block.
bool GetRangeAtIndex(uint32_t range_idx, AddressRange &range)
const InlineFunctionInfo * GetInlinedFunctionInfo() const
Get const accessor for any inlined function information.
bool GetRangeContainingAddress(const Address &addr, AddressRange &range)
Block * GetParent() const
Get the parent block.
bool GetStartAddress(Address &addr)
uint32_t GetRangeIndexContainingAddress(const Address &addr)
A class that describes a compilation unit.
const FileSpec & GetPrimaryFile() const
Return the primary source spec associated with this compile unit.
Represents a generic declaration context in a program.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * GetCString() const
Get the string value as a C string.
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
uint32_t GetLine() const
Get accessor for the declaration line number.
uint16_t GetColumn() const
Get accessor for the declaration column number.
FileSpec & GetFile()
Get accessor for file specification.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
void ClearDirectory()
Clear the directory in this object.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Declaration & GetDeclaration()
Get accessor for the declaration information.
A class that describes a function.
const Mangled & GetMangled() const
A class that describes information for an inlined function.
Declaration & GetCallSite()
Get accessor for the call site declaration information.
ConstString GetName() const
Mangled & GetMangled()
Get accessor for the mangled name object.
static Language * FindPlugin(lldb::LanguageType language)
A class that handles mangled names.
bool NameMatches(ConstString name) const
Check if "name" matches either the mangled or demangled name.
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
Finds the first module whose file specification matches module_spec.
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
FileSpec & GetPlatformFileSpec()
A class that describes an executable image and its associated object and symbol files.
A plug-in interface definition class for object file parsers.
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
static Status FromErrorString(const char *str)
const char * GetData() const
A stream class that can stream formatted output to a file.
void Format(const char *format, Args &&... args)
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
void PutCStringColorHighlighted(llvm::StringRef text, std::optional< HighlightSettings > settings=std::nullopt)
Output a C string to the stream with color highlighting.
size_t EOL()
Output and End of Line character to the stream.
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Defines a list of symbol context objects.
collection m_symbol_contexts
The list of symbol contexts.
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
uint32_t GetSize() const
Get accessor for a symbol context list size.
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target) const
const_iterator end() const
bool RemoveContextAtIndex(size_t idx)
bool AppendIfUnique(const SymbolContext &sc, bool merge_symbol_into_function)
void Dump(Stream *s, Target *target) const
Dump a description of this object to a Stream.
uint32_t NumLineEntriesWithLine(uint32_t line) const
~SymbolContextList()
Destructor.
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
void Clear()
Clear the object's state.
SymbolContextList()
Default constructor.
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
virtual Function * CalculateSymbolContextFunction()
virtual CompileUnit * CalculateSymbolContextCompileUnit()
virtual void CalculateSymbolContext(SymbolContext *sc)=0
Reconstruct the object's symbol context into sc.
virtual Block * CalculateSymbolContextBlock()
virtual lldb::ModuleSP CalculateSymbolContextModule()
void GetDescription(Stream *s, lldb::DescriptionLevel level) const
bool AddressMatches(lldb::addr_t addr)
lldb::ModuleSP m_module_sp
std::unique_ptr< AddressRange > m_address_range_up
std::unique_ptr< FileSpec > m_file_spec_up
~SymbolContextSpecifier()
std::string m_module_spec
bool AddLineSpecification(uint32_t line_no, SpecificationType type)
@ eClassOrNamespaceSpecified
bool AddSpecification(const char *spec_string, SpecificationType type)
lldb::TargetSP m_target_sp
std::string m_function_spec
bool SymbolContextMatches(const SymbolContext &sc)
SymbolContextSpecifier(const lldb::TargetSP &target_sp)
Defines a symbol context baton that can be handed other debug core functions.
LineEntry GetFunctionStartLineEntry() const
Get the line entry that corresponds to the function.
const Symbol * FindBestGlobalDataSymbol(ConstString name, Status &error)
Find the best global data symbol visible from this context.
lldb::LanguageType GetLanguage() const
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
llvm::Error GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range)
Function * function
The Function for a given query.
Block * GetFunctionBlock()
Find a block that defines the function represented by this symbol context.
llvm::StringRef GetInstanceVariableName()
Determines the name of the instance variable for the this decl context.
bool GetParentOfInlinedScope(const Address &curr_frame_pc, SymbolContext &next_frame_sc, Address &inlined_frame_addr) const
Find the block containing the inlined block that contains this block.
ConstString GetFunctionName(Mangled::NamePreference preference=Mangled::ePreferDemangled) const
Find a name of the innermost function for the symbol context.
void SortTypeList(TypeMap &type_map, TypeList &type_list) const
Sorts the types in TypeMap according to SymbolContext to TypeList.
Block * block
The Block for a given query.
lldb::ModuleSP module_sp
The Module for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, const Address &so_addr, bool show_fullpaths, bool show_module, bool show_inlined_frames, bool show_function_arguments, bool show_function_name, bool show_function_display_name=false, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
Dump the stop context in this object to a Stream.
uint32_t GetResolvedMask() const
void Clear(bool clear_target)
Clear the object's state.
Variable * variable
The global variable matching the given query.
bool GetAddressRange(uint32_t scope, uint32_t range_idx, bool use_inline_block_range, AddressRange &range) const
Get the address range contained within a symbol context.
Symbol * symbol
The Symbol for a given query.
lldb::TargetSP target_sp
The Target for a given query.
LineEntry line_entry
The LineEntry for a given query.
Mangled GetPossiblyInlinedFunctionName() const
If available, will return the function name according to the specified mangling preference.
Address GetFunctionOrSymbolAddress() const
Get the address of the function or symbol represented by this symbol context.
SymbolContext()
Default constructor.
Provides public interface for all SymbolFiles.
bool ValueIsAddress() const
Address & GetAddressRef()
const ModuleList & GetImages() const
Get accessor for the images for this process.
void ForEach(std::function< bool(const lldb::TypeSP &type_sp)> const &callback) const
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
void Insert(const lldb::TypeSP &type)
bool Remove(const lldb::TypeSP &type_sp)
void ForEach(std::function< bool(const lldb::TypeSP &type_sp)> const &callback) const
void GetDescription(Stream *s, lldb::DescriptionLevel level, bool show_name, ExecutionContextScope *exe_scope)
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
bool operator!=(const Address &lhs, const Address &rhs)
bool operator==(const Address &lhs, const Address &rhs)
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelVerbose
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Type > TypeSP
@ eSymbolTypeVariableType
@ eSymbolTypeObjCMetaClass
@ eSymbolTypeAdditional
When symbols take more than one entry, the extra entries get this type.
@ eSymbolTypeInstrumentation
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
@ eValueTypeVariableGlobal
globals variable
@ eValueTypeVariableLocal
function local variables
@ eValueTypeVariableArgument
function argument variables
@ eValueTypeVariableStatic
static variable
@ eValueTypeVariableThreadLocal
thread local storage variable
A line table entry class.
uint16_t column
The column number of the source line, or zero if there is no column information.
lldb::SupportFileSP original_file_sp
The original source file, from debug info.
bool IsValid() const
Check if a line entry object is valid.
static int Compare(const LineEntry &lhs, const LineEntry &rhs)
Compare two LineEntry objects.
AddressRange range
The section offset address range for this line entry.
uint32_t line
The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line number information.
lldb::SupportFileSP file_sp
The source file, possibly mapped by the target.source-map setting.
lldb::user_id_t GetID() const
Get accessor for the user ID.