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)
106 const addr_t function_offset =
109 if (!show_function_name) {
111 dumped_something =
true;
112 s->
Printf(
"+%" PRIu64
">", function_offset);
113 }
else if (function_offset) {
114 dumped_something =
true;
115 s->
Printf(
" + %" PRIu64, function_offset);
120 dumped_something =
true;
128 const addr_t inlined_function_offset =
130 if (inlined_function_offset) {
131 s->
Printf(
" + %" PRIu64, inlined_function_offset);
146 if (show_inlined_frames) {
149 const bool show_function_name =
true;
151 s, exe_scope, inline_parent_addr, show_fullpaths, show_module,
152 show_inlined_frames, show_function_arguments, show_function_name,
153 show_function_display_name);
157 dumped_something =
true;
160 dumped_something =
true;
163 }
else if (
symbol !=
nullptr) {
164 if (!show_function_name) {
166 dumped_something =
true;
168 dumped_something =
true;
172 if (show_function_display_name)
180 const addr_t symbol_offset =
182 if (!show_function_name) {
184 dumped_something =
true;
185 s->
Printf(
"+%" PRIu64
">", symbol_offset);
186 }
else if (symbol_offset) {
187 dumped_something =
true;
188 s->
Printf(
" + %" PRIu64, symbol_offset);
193 dumped_something =
true;
195 return dumped_something;
200 std::optional<Stream::HighlightSettings> settings)
const {
202 s->
Indent(
" Module: file = \"");
205 if (
module_sp->GetArchitecture().IsValid())
206 s->
Printf(
", arch = \"%s\"",
207 module_sp->GetArchitecture().GetArchitectureName());
212 s->
Indent(
"CompileUnit: ");
230 if (
block !=
nullptr) {
231 std::vector<Block *> blocks;
232 blocks.push_back(
block);
235 while (parent_block) {
236 blocks.push_back(parent_block);
237 parent_block = parent_block->
GetParent();
239 std::vector<Block *>::reverse_iterator pos;
240 std::vector<Block *>::reverse_iterator begin = blocks.rbegin();
241 std::vector<Block *>::reverse_iterator end = blocks.rend();
242 for (pos = begin; pos != end; ++pos) {
247 (*pos)->GetDescription(s,
function, level, target);
253 s->
Indent(
" LineEntry: ");
299 uint32_t resolved_mask = 0;
301 resolved_mask |= eSymbolContextTarget;
303 resolved_mask |= eSymbolContextModule;
305 resolved_mask |= eSymbolContextCompUnit;
307 resolved_mask |= eSymbolContextFunction;
309 resolved_mask |= eSymbolContextBlock;
311 resolved_mask |= eSymbolContextLineEntry;
313 resolved_mask |= eSymbolContextSymbol;
315 resolved_mask |= eSymbolContextVariable;
316 return resolved_mask;
327 *s <<
"Module = " <<
module_sp.get() <<
' ';
349 func_type->
Dump(s,
false);
354 *s <<
"Block = " <<
block;
355 if (
block !=
nullptr)
359 *s <<
"LineEntry = ";
364 *s <<
"Symbol = " <<
symbol;
390 return !(lhs == rhs);
394 bool use_inline_block_range,
401 if ((scope & eSymbolContextBlock) && (
block !=
nullptr)) {
402 if (use_inline_block_range) {
411 if ((scope & eSymbolContextFunction) && (
function !=
nullptr)) {
412 if (range_idx == 0) {
418 if ((scope & eSymbolContextSymbol) && (
symbol !=
nullptr)) {
419 if (range_idx == 0) {
452 Address &next_frame_pc)
const {
453 next_frame_sc.
Clear(
false);
454 next_frame_pc.
Clear();
464 if (curr_inlined_block) {
487 std::make_shared<SupportFile>(
500 "warning: inlined block 0x%8.8" PRIx64
501 " doesn't have a range that contains file address 0x%" PRIx64,
504#ifdef LLDB_CONFIGURATION_DEBUG
509 objfile = symbol_file->GetObjectFile();
513 "inlined block {0:x} doesn't have a range that contains file "
514 "address {1:x} in {2}",
519 "inlined block {0:x} doesn't have a range that contains file "
541 return inlined_block;
561 lang_type = decl_ctx.GetLanguage();
567 return lang->GetInstanceVariableName();
574 bool isInlinedblock =
false;
575 if (curr_block !=
nullptr &&
577 isInlinedblock =
true;
581 while (curr_block !=
nullptr && !isInlinedblock) {
583 [curr_block, &type_list](
const lldb::TypeSP &type_sp) ->
bool {
586 type_list.
Insert(type_sp);
601 const size_t old_type_list_size = type_list.
GetSize();
605 type_list.
Insert(type_sp);
611 const size_t new_type_list_size = type_list.
GetSize();
612 if (new_type_list_size > old_type_list_size) {
613 for (
size_t i = old_type_list_size; i < new_type_list_size; ++i)
620 const size_t old_type_list_size = type_list.
GetSize();
625 type_list.
Insert(type_sp);
631 const size_t new_type_list_size = type_list.
GetSize();
632 if (new_type_list_size > old_type_list_size) {
633 for (
size_t i = old_type_list_size; i < new_type_list_size; ++i)
640 const size_t old_type_list_size = type_list.
GetSize();
644 type_list.
Insert(type_sp);
649 const size_t new_type_list_size = type_list.
GetSize();
650 if (new_type_list_size > old_type_list_size) {
651 for (
size_t i = old_type_list_size; i < new_type_list_size; ++i)
656 if (!type_map.
Empty()) {
658 type_list.
Insert(type_sp);
713 error.SetErrorString(
"Symbol context has no line table.");
719 error.SetErrorStringWithFormat(
720 "end line option %d must be after the current line: %d", end_line,
725 uint32_t line_index = 0;
743 error.SetErrorString(
744 "Can't find the current line entry in the CompUnit - can't process "
745 "the end-line option");
752 error.SetErrorStringWithFormat(
753 "could not find a line table entry corresponding "
754 "to end line number %d",
762 error.SetErrorStringWithFormat(
763 "end line number %d is not contained within the current function.",
785 auto ProcessMatches = [
this, &name, &target,
788 llvm::SmallVector<const Symbol *, 1> external_symbols;
789 llvm::SmallVector<const Symbol *, 1> internal_symbols;
791 if (sym_ctx.symbol) {
811 external_symbols.push_back(
symbol);
813 internal_symbols.push_back(
symbol);
826 if (!reexport_module_sp) {
835 module == reexport_module_sp.get())
871 if (external_symbols.size() > 1) {
873 ss.
Printf(
"Multiple external symbols found for '%s'\n", name.
AsCString());
880 }
else if (external_symbols.size()) {
881 return external_symbols[0];
882 }
else if (internal_symbols.size() > 1) {
884 ss.
Printf(
"Multiple internal symbols found for '%s'\n", name.
AsCString());
891 }
else if (internal_symbols.size()) {
892 return internal_symbols[0];
901 const Symbol *
const module_symbol = ProcessMatches(sc_list,
error);
903 if (!
error.Success()) {
905 }
else if (module_symbol) {
906 return module_symbol;
914 const Symbol *
const target_symbol = ProcessMatches(sc_list,
error);
916 if (!
error.Success()) {
918 }
else if (target_symbol) {
919 return target_symbol;
931 : m_target_sp(target_sp), m_module_spec(), m_module_sp(), m_file_spec_up(),
932 m_start_line(0), m_end_line(0), m_function_spec(), m_class_name(),
933 m_address_range_up(), m_type(eNothingSpecified) {}
939 bool return_value =
true;
953 return_value =
false;
961 bool return_value =
true;
968 FileSpec module_file_spec(spec_string);
987 if ((return_value = llvm::to_integer(spec_string,
m_start_line)))
991 if ((return_value = llvm::to_integer(spec_string,
m_end_line)))
1008 return return_value;
1054 bool was_inlined =
false;
1055 if (sc.
block !=
nullptr) {
1058 if (inline_info !=
nullptr) {
1068 if (!was_inlined && sc.
comp_unit !=
nullptr) {
1082 bool was_inlined =
false;
1085 if (sc.
block !=
nullptr) {
1088 if (inline_info !=
nullptr) {
1100 }
else if (sc.
symbol !=
nullptr) {
1114 Address match_address(addr,
nullptr);
1116 m_target_sp->GetImages().ResolveSymbolContextForAddress(
1117 match_address, eSymbolContextEverything, sc);
1128 s->
Printf(
"Nothing specified.\n");
1135 s->
Printf(
"Module: %s\n", path_str);
1143 s->
Printf(
"File: %s", path_str);
1207 bool merge_symbol_into_function) {
1208 uint32_t unique_sc_add_count = 0;
1212 ++unique_sc_add_count;
1214 return unique_sc_add_count;
1218 bool merge_symbol_into_function) {
1224 if (merge_symbol_into_function && sc.
symbol !=
nullptr &&
1230 if (pos->block && pos->block->GetContainingInlinedBlock())
1233 if (pos->function) {
1234 if (pos->function->GetAddressRange().GetBaseAddress() ==
1237 if (pos->symbol == sc.
symbol)
1239 if (pos->symbol ==
nullptr) {
1291 uint32_t match_count = 0;
1293 for (
size_t idx = 0; idx < size; ++idx) {
1303 for (
size_t idx = 0; idx < size; ++idx)
1309 const uint32_t size = lhs.
GetSize();
1315 for (uint32_t i = 0; i < size; ++i) {
1318 if (lhs_sc != rhs_sc)
1326 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()
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.
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.
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.
bool GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range, Status &error)
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
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.