38 : target_sp(), module_sp(m), comp_unit(cu), function(f), block(b),
39 line_entry(), symbol(s) {
47 : target_sp(t), module_sp(m), comp_unit(cu), function(f), block(b),
48 line_entry(), symbol(s) {
54 : target_sp(), module_sp(), line_entry() {
74 bool show_fullpaths,
bool show_module,
bool show_inlined_frames,
75 bool show_function_arguments,
bool show_function_name,
76 bool show_function_display_name,
77 std::optional<Stream::HighlightSettings> settings)
const {
78 bool dumped_something =
false;
83 *s <<
module_sp->GetFileSpec().GetFilename();
85 dumped_something =
true;
90 if (!show_function_name) {
92 dumped_something =
true;
95 if (!show_function_arguments)
97 if (!name && show_function_display_name)
107 const addr_t function_offset =
110 if (!show_function_name) {
112 dumped_something =
true;
113 s->
Printf(
"+%" PRIu64
">", function_offset);
114 }
else if (function_offset) {
115 dumped_something =
true;
116 s->
Printf(
" + %" PRIu64, function_offset);
121 dumped_something =
true;
129 const addr_t inlined_function_offset =
132 if (inlined_function_offset) {
133 s->
Printf(
" + %" PRIu64, inlined_function_offset);
148 if (show_inlined_frames) {
151 const bool show_function_name =
true;
153 s, exe_scope, inline_parent_addr, show_fullpaths, show_module,
154 show_inlined_frames, show_function_arguments, show_function_name,
155 show_function_display_name);
159 dumped_something =
true;
162 dumped_something =
true;
165 }
else if (
symbol !=
nullptr) {
166 if (!show_function_name) {
168 dumped_something =
true;
170 dumped_something =
true;
174 if (show_function_display_name)
182 const addr_t symbol_offset =
184 if (!show_function_name) {
186 dumped_something =
true;
187 s->
Printf(
"+%" PRIu64
">", symbol_offset);
188 }
else if (symbol_offset) {
189 dumped_something =
true;
190 s->
Printf(
" + %" PRIu64, symbol_offset);
195 dumped_something =
true;
197 return dumped_something;
202 std::optional<Stream::HighlightSettings> settings)
const {
204 s->
Indent(
" Module: file = \"");
207 if (
module_sp->GetArchitecture().IsValid())
208 s->
Printf(
", arch = \"%s\"",
209 module_sp->GetArchitecture().GetArchitectureName());
214 s->
Indent(
"CompileUnit: ");
232 if (
block !=
nullptr) {
233 std::vector<Block *> blocks;
234 blocks.push_back(
block);
237 while (parent_block) {
238 blocks.push_back(parent_block);
239 parent_block = parent_block->
GetParent();
241 std::vector<Block *>::reverse_iterator pos;
242 std::vector<Block *>::reverse_iterator begin = blocks.rbegin();
243 std::vector<Block *>::reverse_iterator end = blocks.rend();
244 for (pos = begin; pos != end; ++pos) {
249 (*pos)->GetDescription(s,
function, level, target);
255 s->
Indent(
" LineEntry: ");
301 uint32_t resolved_mask = 0;
303 resolved_mask |= eSymbolContextTarget;
305 resolved_mask |= eSymbolContextModule;
307 resolved_mask |= eSymbolContextCompUnit;
309 resolved_mask |= eSymbolContextFunction;
311 resolved_mask |= eSymbolContextBlock;
313 resolved_mask |= eSymbolContextLineEntry;
315 resolved_mask |= eSymbolContextSymbol;
317 resolved_mask |= eSymbolContextVariable;
318 return resolved_mask;
329 *s <<
"Module = " <<
module_sp.get() <<
' ';
351 func_type->
Dump(s,
false);
356 *s <<
"Block = " <<
block;
357 if (
block !=
nullptr)
361 *s <<
"LineEntry = ";
366 *s <<
"Symbol = " <<
symbol;
392 return !(lhs == rhs);
396 bool use_inline_block_range,
403 if ((scope & eSymbolContextBlock) && (
block !=
nullptr)) {
404 if (use_inline_block_range) {
413 if ((scope & eSymbolContextFunction) && (
function !=
nullptr)) {
414 if (range_idx == 0) {
420 if ((scope & eSymbolContextSymbol) && (
symbol !=
nullptr)) {
421 if (range_idx == 0) {
454 Address &next_frame_pc)
const {
455 next_frame_sc.
Clear(
false);
456 next_frame_pc.
Clear();
466 if (curr_inlined_block) {
489 std::make_shared<SupportFile>(
502 "warning: inlined block 0x%8.8" PRIx64
503 " doesn't have a range that contains file address 0x%" PRIx64,
506#ifdef LLDB_CONFIGURATION_DEBUG
511 objfile = symbol_file->GetObjectFile();
515 "inlined block {0:x} doesn't have a range that contains file "
516 "address {1:x} in {2}",
521 "inlined block {0:x} doesn't have a range that contains file "
543 return inlined_block;
563 lang_type = decl_ctx.GetLanguage();
569 return lang->GetInstanceVariableName();
576 bool isInlinedblock =
false;
577 if (curr_block !=
nullptr &&
579 isInlinedblock =
true;
583 while (curr_block !=
nullptr && !isInlinedblock) {
585 [curr_block, &type_list](
const lldb::TypeSP &type_sp) ->
bool {
588 type_list.
Insert(type_sp);
603 const size_t old_type_list_size = type_list.
GetSize();
607 type_list.
Insert(type_sp);
613 const size_t new_type_list_size = type_list.
GetSize();
614 if (new_type_list_size > old_type_list_size) {
615 for (
size_t i = old_type_list_size; i < new_type_list_size; ++i)
622 const size_t old_type_list_size = type_list.
GetSize();
627 type_list.
Insert(type_sp);
633 const size_t new_type_list_size = type_list.
GetSize();
634 if (new_type_list_size > old_type_list_size) {
635 for (
size_t i = old_type_list_size; i < new_type_list_size; ++i)
642 const size_t old_type_list_size = type_list.
GetSize();
646 type_list.
Insert(type_sp);
651 const size_t new_type_list_size = type_list.
GetSize();
652 if (new_type_list_size > old_type_list_size) {
653 for (
size_t i = old_type_list_size; i < new_type_list_size; ++i)
658 if (!type_map.
Empty()) {
660 type_list.
Insert(type_sp);
715 return llvm::createStringError(
"Symbol context has no line table.");
720 return llvm::createStringError(
721 "end line option %d must be after the current line: %d", end_line,
725 uint32_t line_index = 0;
743 return llvm::createStringError(
744 "Can't find the current line entry in the CompUnit - can't process "
745 "the end-line option");
751 return llvm::createStringError(
752 "could not find a line table entry corresponding "
753 "to end line number %d",
760 return llvm::createStringError(
761 "end line number %d is not contained within the current function.",
768 return llvm::Error::success();
782 auto ProcessMatches = [
this, &name, &target,
785 llvm::SmallVector<const Symbol *, 1> external_symbols;
786 llvm::SmallVector<const Symbol *, 1> internal_symbols;
788 if (sym_ctx.symbol) {
808 external_symbols.push_back(
symbol);
810 internal_symbols.push_back(
symbol);
823 if (!reexport_module_sp) {
832 module == reexport_module_sp.get())
868 if (external_symbols.size() > 1) {
870 ss.
Printf(
"Multiple external symbols found for '%s'\n", name.
AsCString());
877 }
else if (external_symbols.size()) {
878 return external_symbols[0];
879 }
else if (internal_symbols.size() > 1) {
881 ss.
Printf(
"Multiple internal symbols found for '%s'\n", name.
AsCString());
888 }
else if (internal_symbols.size()) {
889 return internal_symbols[0];
898 const Symbol *
const module_symbol = ProcessMatches(sc_list,
error);
900 if (!
error.Success()) {
902 }
else if (module_symbol) {
903 return module_symbol;
911 const Symbol *
const target_symbol = ProcessMatches(sc_list,
error);
913 if (!
error.Success()) {
915 }
else if (target_symbol) {
916 return target_symbol;
928 : m_target_sp(target_sp), m_module_spec(), m_module_sp(), m_file_spec_up(),
929 m_start_line(0), m_end_line(0), m_function_spec(), m_class_name(),
930 m_address_range_up(), m_type(eNothingSpecified) {}
936 bool return_value =
true;
950 return_value =
false;
958 bool return_value =
true;
965 FileSpec module_file_spec(spec_string);
984 if ((return_value = llvm::to_integer(spec_string,
m_start_line)))
988 if ((return_value = llvm::to_integer(spec_string,
m_end_line)))
1005 return return_value;
1051 bool was_inlined =
false;
1052 if (sc.
block !=
nullptr) {
1055 if (inline_info !=
nullptr) {
1065 if (!was_inlined && sc.
comp_unit !=
nullptr) {
1079 bool was_inlined =
false;
1082 if (sc.
block !=
nullptr) {
1085 if (inline_info !=
nullptr) {
1097 }
else if (sc.
symbol !=
nullptr) {
1111 Address match_address(addr,
nullptr);
1113 m_target_sp->GetImages().ResolveSymbolContextForAddress(
1114 match_address, eSymbolContextEverything, sc);
1125 s->
Printf(
"Nothing specified.\n");
1132 s->
Printf(
"Module: %s\n", path_str);
1140 s->
Printf(
"File: %s", path_str);
1204 bool merge_symbol_into_function) {
1205 uint32_t unique_sc_add_count = 0;
1209 ++unique_sc_add_count;
1211 return unique_sc_add_count;
1215 bool merge_symbol_into_function) {
1221 if (merge_symbol_into_function && sc.
symbol !=
nullptr &&
1227 if (pos->block && pos->block->GetContainingInlinedBlock())
1230 if (pos->function) {
1231 if (pos->function->GetAddressRange().GetBaseAddress() ==
1234 if (pos->symbol == sc.
symbol)
1236 if (pos->symbol ==
nullptr) {
1288 uint32_t match_count = 0;
1290 for (
size_t idx = 0; idx < size; ++idx) {
1300 for (
size_t idx = 0; idx < size; ++idx)
1306 const uint32_t size = lhs.
GetSize();
1312 for (uint32_t i = 0; i < size; ++i) {
1315 if (lhs_sc != rhs_sc)
1323 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.
bool Dump(Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style=Address::DumpStyleInvalid) const
Dump a description of this object to a Stream.
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.
uint32_t FindLineEntry(uint32_t start_idx, uint32_t line, const FileSpec *file_spec_ptr, bool exact, LineEntry *line_entry)
Find the line entry by line and optional inlined file spec.
void GetDescription(Stream *s, lldb::DescriptionLevel level) const
lldb::LanguageType GetLanguage()
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.
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target)
const AddressRange & GetAddressRange()
DEPRECATED: Use GetAddressRanges instead.
ConstString GetName() const
const Mangled & GetMangled() const
Type * GetType()
Get accessor for the type that describes the function return value type, and parameter types.
lldb::LanguageType GetLanguage() const
ConstString GetDisplayName() const
ConstString GetNameNoArguments() const
Block & GetBlock(bool can_create)
Get accessor for the block list.
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::LanguageType GuessLanguage() const
Try to guess the language from the mangling.
ConstString & GetMangledName()
Mangled name get accessor.
ConstString GetName(NamePreference preference=ePreferDemangled) const
Best name get accessor.
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
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.
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
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
void Dump(Stream *s, Target *target) const
Dump a description of this object to a Stream.
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.
SymbolContext()
Default constructor.
Provides public interface for all SymbolFiles.
bool ValueIsAddress() const
bool GetDemangledNameIsSynthesized() const
lldb::LanguageType GetLanguage() const
Address & GetAddressRef()
ConstString GetReExportedSymbolName() const
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
lldb::addr_t GetByteSize() const
ConstString GetName() const
lldb::SymbolType GetType() const
Address GetAddress() const
FileSpec GetReExportedSymbolSharedLibrary() const
ConstString GetDisplayName() const
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)
void Dump(Stream *s, bool show_context, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull)
ConstString GetName() const
lldb::LanguageType GetLanguage() const
lldb::ValueType GetScope() const
#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.
void Clear()
Clear the object's state.
bool Dump(Stream *s, Target *target, bool show_file, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_range) const
Dump a description of this object to a Stream.
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.
bool GetDescription(Stream *s, lldb::DescriptionLevel level, CompileUnit *cu, Target *target, bool show_address_only) const
bool DumpStopContext(Stream *s, bool show_fullpaths) const
Dumps information specific to a process that stops at this line entry to the supplied stream s.
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.