24#include "llvm/ADT/StringSwitch.h"
31 m_is_debug(false), m_is_external(false), m_size_is_sibling(false),
32 m_size_is_synthesized(false), m_size_is_valid(false),
33 m_demangled_is_synthesized(false), m_contains_linker_annotations(false),
38 bool external,
bool is_debug,
bool is_trampoline,
41 bool contains_linker_annotations, uint32_t flags)
43 m_is_synthetic(is_artificial), m_is_debug(is_debug),
44 m_is_external(external), m_size_is_sibling(false),
45 m_size_is_synthesized(false), m_size_is_valid(size_is_valid || size > 0),
46 m_demangled_is_synthesized(false),
47 m_contains_linker_annotations(contains_linker_annotations),
48 m_is_weak(false), m_type(type), m_mangled(name),
49 m_addr_range(section_sp, offset, size), m_flags(flags) {}
52 bool external,
bool is_debug,
bool is_trampoline,
54 bool size_is_valid,
bool contains_linker_annotations,
57 m_is_synthetic(is_artificial), m_is_debug(is_debug),
58 m_is_external(external), m_size_is_sibling(false),
59 m_size_is_synthesized(false),
60 m_size_is_valid(size_is_valid || range.GetByteSize() > 0),
61 m_demangled_is_synthesized(false),
62 m_contains_linker_annotations(contains_linker_annotations),
63 m_is_weak(false), m_type(type), m_mangled(mangled), m_addr_range(range),
68 m_type_data_resolved(rhs.m_type_data_resolved),
69 m_is_synthetic(rhs.m_is_synthetic), m_is_debug(rhs.m_is_debug),
70 m_is_external(rhs.m_is_external),
71 m_size_is_sibling(rhs.m_size_is_sibling), m_size_is_synthesized(false),
72 m_size_is_valid(rhs.m_size_is_valid),
73 m_demangled_is_synthesized(rhs.m_demangled_is_synthesized),
74 m_contains_linker_annotations(rhs.m_contains_linker_annotations),
75 m_is_weak(rhs.m_is_weak), m_type(rhs.m_type), m_mangled(rhs.m_mangled),
76 m_addr_range(rhs.m_addr_range), m_flags(rhs.m_flags) {}
80 SymbolContextScope::operator=(rhs);
104 return llvm::createStringError(
"no section list provided");
107 return llvm::createStringError(
108 "symbol must contain either a value or an address");
111 return llvm::createStringError(
112 "symbol cannot contain both a value and an address");
114 const uint64_t size = symbol.
size.value_or(0);
115 const bool is_artificial =
false;
116 const bool is_trampoline =
false;
117 const bool is_debug =
false;
118 const bool external =
false;
119 const bool size_is_valid = symbol.
size.has_value();
120 const bool contains_linker_annotations =
false;
121 const uint32_t flags = 0;
126 const uint64_t offset = *symbol.
address - section_sp->GetFileAddress();
129 is_trampoline, is_artificial,
131 contains_linker_annotations, flags);
133 return llvm::createStringError(
134 llvm::formatv(
"no section found for address: {0:x}", *symbol.
address));
141 is_trampoline, is_artificial,
143 contains_linker_annotations, flags);
194 return FileSpec((
const char *)str_ptr);
227 std::optional<Stream::HighlightSettings> settings)
const {
244 s->
Printf(
", value = 0x%16.16" PRIx64,
248 s->
Printf(
", sibling = %5" PRIu64,
251 s->
Printf(
", value = 0x%16.16" PRIx64,
288 :
" 0x%16.16" PRIx64
" 0x%8.8x %s\n";
305 " Sibling -> [%5llu] 0x%8.8x %s\n"
306 :
"0x%16.16" PRIx64
" 0x%16.16" PRIx64
329 uint32_t resolved_flags = module_sp->ResolveSymbolContextForAddress(
330 base_address, eSymbolContextLineEntry, sc);
331 if (resolved_flags & eSymbolContextLineEntry) {
343 for (
int idx = 0; idx < 6; ++idx) {
345 resolved_flags = module_sp->ResolveSymbolContextForAddress(
346 addr, eSymbolContextLineEntry, sc_temp);
348 if (!(resolved_flags & eSymbolContextLineEntry))
395#define ENUM_TO_CSTRING(x) \
396 case eSymbolType##x: \
433 return "<unknown SymbolType>";
454 bool dumped_module =
false;
458 dumped_module =
true;
459 module_sp->DumpSymbolContext(s);
493 module_sp->FindSymbolsWithNameAndType(reexport_name,
eSymbolTypeAny,
496 if (sc.symbol->IsExternal())
502 seen_modules.
Append(module_sp);
505 module_sp->GetObjectFile()->GetReExportedLibraries();
506 size_t num_reexported_libraries = reexported_libraries.
GetSize();
507 for (
size_t idx = 0; idx < num_reexported_libraries; idx++) {
512 target, reexport_name, reexported_module_spec, seen_modules);
514 return result_symbol;
528 module_spec, seen_modules);
563 if (reexported_symbol) {
564 func_so_addr = reexported_symbol->
GetAddress();
565 is_indirect = reexported_symbol->
IsIndirect();
591 bool prefer_file_cache) {
602 bool prefer_file_cache,
Stream &strm) {
605 if (disassembler_sp) {
606 const bool show_address =
true;
607 const bool show_bytes =
false;
608 const bool show_control_flow_kind =
false;
609 disassembler_sp->GetInstructionList().Dump(
610 &strm, show_address, show_bytes, show_control_flow_kind, &exe_ctx);
640 llvm::SmallString<256> name;
641 llvm::raw_svector_ostream os(name);
654 const uint16_t bitfields = data.
GetU16(offset_ptr);
665 m_type = bitfields & 0x003f;
670 const bool is_addr = data.
GetU8(offset_ptr) != 0;
671 const uint64_t value = data.
GetU64(offset_ptr);
703 uint16_t bitfields =
m_type;
705 bitfields |= 1u << 15;
707 bitfields |= 1u << 14;
709 bitfields |= 1u << 13;
711 bitfields |= 1u << 12;
713 bitfields |= 1u << 11;
715 bitfields |= 1u << 10;
717 bitfields |= 1u << 9;
719 bitfields |= 1u << 8;
721 bitfields |= 1u << 7;
723 bitfields |= 1u << 6;
779 llvm::json::Path path) {
780 llvm::json::ObjectMapper o(value, path);
781 const bool mapped = o && o.map(
"value", symbol.
value) &&
782 o.map(
"address", symbol.
address) &&
783 o.map(
"size", symbol.
size) && o.map(
"id", symbol.
id) &&
784 o.map(
"type", symbol.
type) && o.map(
"name", symbol.
name);
790 path.report(
"symbol must have either a value or an address");
795 path.report(
"symbol cannot have both a value and an address");
803 llvm::json::Path path) {
804 if (
auto str = value.getAsString()) {
805 type = llvm::StringSwitch<lldb::SymbolType>(*str)
837 path.report(
"invalid symbol type");
843 path.report(
"expected string");
#define ENUM_TO_CSTRING(x)
A section + offset based address range class.
Address & GetBaseAddress()
Get accessor for the base address of the range.
bool ContainsFileAddress(const Address &so_addr) const
Check if a section offset address is contained in this 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.
lldb::addr_t GetByteSize() const
Get accessor for the byte size of this range.
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
bool ResolveAddressUsingFileSections(lldb::addr_t addr, const SectionList *sections)
Resolve a file virtual address using a section list.
lldb::addr_t GetCallableLoadAddress(Target *target, bool is_indirect=false) const
Get the load address as a callable code load address.
lldb::SectionSP GetSection() const
Get const accessor for the section.
void Clear()
Clear the object's state.
Function * CalculateSymbolContextFunction() const
@ DumpStyleFileAddress
Display as the file address (if any).
@ DumpStyleLoadAddress
Display as the load address (if resolved).
bool Slide(int64_t offset)
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::ModuleSP GetModule() const
Get accessor for the module for this address.
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 SetOffset(lldb::addr_t offset)
Set accessor for the offset.
A class that describes a single lexical block.
Many cache files require string tables to store data efficiently.
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.
An binary data encoding class.
void AppendU32(uint32_t value)
void AppendU8(uint8_t value)
Append a unsigned integer to the end of the owned data.
void AppendU16(uint16_t value)
void AppendU64(uint64_t value)
static lldb::DisassemblerSP DisassembleRange(const ArchSpec &arch, const char *plugin_name, const char *flavor, Target &target, const AddressRange &disasm_range, bool force_live_memory=false)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
bool HasTargetScope() const
Returns true the ExecutionContext object contains a valid target.
Target & GetTargetRef() const
Returns a reference to the target object.
const FileSpec & GetFileSpecAtIndex(size_t idx) const
Get file at index.
size_t GetSize() const
Get the number of files in the file list.
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.
A class that describes a function.
uint32_t GetPrologueByteSize()
Get the size of the prologue instructions for this function.
A class that handles mangled names.
void Encode(DataEncoder &encoder, ConstStringTable &strtab) const
Encode this object into a data encoder object.
@ ePreferDemangledWithoutArguments
void SetDemangledName(ConstString name)
ConstString GetDemangledName() const
Demangled name get accessor.
bool Decode(const DataExtractor &data, lldb::offset_t *offset_ptr, const StringTableReader &strtab)
Decode a serialized version of this object from data.
ConstString & GetMangledName()
Mangled name get accessor.
ConstString GetName(NamePreference preference=ePreferDemangled) const
Best name get accessor.
ConstString GetDisplayDemangledName() const
Display demangled name get accessor.
void Clear()
Clear the mangled and demangled values.
A collection class for Module objects.
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify=true)
Append a module to the module list, if it is not already there.
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
A plug-in interface definition class for object file parsers.
lldb::SectionSP FindSectionContainingFileAddress(lldb::addr_t addr, uint32_t depth=UINT32_MAX) const
A stream class that can stream formatted output to a file.
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.
Many cache files require string tables to store data efficiently.
Defines a list of symbol context objects.
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
Defines a symbol context baton that can be handed other debug core functions.
lldb::ModuleSP module_sp
The Module for a given query.
Symbol * symbol
The Symbol for a given query.
LineEntry line_entry
The LineEntry for a given query.
bool Decode(const DataExtractor &data, lldb::offset_t *offset_ptr, const SectionList *section_list, const StringTableReader &strtab)
Decode a serialized version of this object from data.
uint32_t GetSiblingIndex() const
lldb::addr_t GetLoadAddress(Target *target) const
bool ValueIsAddress() const
uint16_t m_type_data_resolved
void SetReExportedSymbolName(ConstString name)
void SetType(lldb::SymbolType type)
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object's symbol context into sc.
void SynthesizeNameIfNeeded() const
const char * GetTypeAsString() const
Symbol * ResolveReExportedSymbolInModuleSpec(Target &target, ConstString &reexport_name, lldb_private::ModuleSpec &module_spec, lldb_private::ModuleList &seen_modules) const
uint16_t m_demangled_is_synthesized
lldb::DisassemblerSP GetInstructions(const ExecutionContext &exe_ctx, const char *flavor, bool prefer_file_cache)
lldb::addr_t GetFileAddress() const
void DumpSymbolContext(Stream *s) override
Dump the object's symbol context to the stream s.
lldb::ModuleSP CalculateSymbolContextModule() override
bool ContainsFileAddress(lldb::addr_t file_addr) const
uint16_t m_contains_linker_annotations
bool IsTrampoline() const
Address & GetAddressRef()
const Symbol & operator=(const Symbol &rhs)
bool IsSyntheticWithAutoGeneratedName() const
void Encode(DataEncoder &encoder, ConstStringTable &strtab) const
Encode this object into a data encoder object.
ConstString GetReExportedSymbolName() const
bool Compare(ConstString name, lldb::SymbolType type) const
bool SetReExportedSymbolSharedLibrary(const FileSpec &fspec)
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
bool operator==(const Symbol &rhs) const
static llvm::StringRef GetSyntheticSymbolPrefix()
lldb::addr_t GetByteSize() const
ConstString GetName() const
lldb::SymbolType GetType() const
Address GetAddress() const
AddressRange m_addr_range
ConstString GetNameNoArguments() const
uint16_t m_size_is_sibling
Symbol * ResolveReExportedSymbol(Target &target) const
FileSpec GetReExportedSymbolSharedLibrary() const
uint32_t GetPrologueByteSize()
ConstString GetDisplayName() const
bool GetDisassembly(const ExecutionContext &exe_ctx, const char *flavor, bool prefer_file_cache, Stream &strm)
lldb::addr_t ResolveCallableAddress(Target &target) const
uint16_t m_size_is_synthesized
Symbol * CalculateSymbolContextSymbol() override
static llvm::Expected< Symbol > FromJSON(const JSONSymbol &symbol, SectionList *section_list)
void Dump(Stream *s, Target *target, uint32_t index, Mangled::NamePreference name_preference=Mangled::ePreferDemangled) const
const lldb::ProcessSP & GetProcessSP() const
const ModuleList & GetImages() const
Get accessor for the images for this process.
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
bool fromJSON(const llvm::json::Value &value, TraceSupportedResponse &info, llvm::json::Path path)
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eSymbolTypeVariableType
@ eSymbolTypeObjCMetaClass
@ eSymbolTypeAdditional
When symbols take more than one entry, the extra entries get this type.
@ eSymbolTypeInstrumentation
std::shared_ptr< lldb_private::Disassembler > DisassemblerSP
std::shared_ptr< lldb_private::Section > SectionSP
std::shared_ptr< lldb_private::Module > ModuleSP
std::optional< uint64_t > address
std::optional< uint64_t > id
std::optional< lldb::SymbolType > type
std::optional< uint64_t > value
std::optional< uint64_t > size
A line table entry class.
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.