25#include "llvm/ADT/StringSwitch.h"
39 bool external,
bool is_debug,
bool is_trampoline,
42 bool contains_linker_annotations, uint32_t flags)
59 bool external,
bool is_debug,
bool is_trampoline,
61 bool size_is_valid,
bool contains_linker_annotations,
99 SymbolContextScope::operator=(rhs);
130 return llvm::createStringError(
"no section list provided");
133 return llvm::createStringError(
134 "symbol must contain either a value or an address");
137 return llvm::createStringError(
138 "symbol cannot contain both a value and an address");
140 const uint64_t size = symbol.
size.value_or(0);
141 const bool is_artificial =
false;
142 const bool is_trampoline =
false;
143 const bool is_debug =
false;
144 const bool external =
false;
145 const bool size_is_valid = symbol.
size.has_value();
146 const bool contains_linker_annotations =
false;
147 const uint32_t flags = 0;
152 const uint64_t offset = *symbol.
address - section_sp->GetFileAddress();
155 is_trampoline, is_artificial,
157 contains_linker_annotations, flags);
159 return llvm::createStringError(
160 llvm::formatv(
"no section found for address: {0:x}", *symbol.
address));
167 is_trampoline, is_artificial,
169 contains_linker_annotations, flags);
237 std::make_unique<FileSpec>(fspec);
253 std::optional<Stream::HighlightSettings> settings)
const {
271 s->
Printf(
", value = 0x%16.16" PRIx64,
277 s->
Printf(
", sibling = %5" PRIu64,
282 s->
Printf(
", value = 0x%16.16" PRIx64,
321 :
" 0x%16.16" PRIx64
" 0x%8.8x %s\n";
338 " Sibling -> [%5llu] 0x%8.8x %s\n"
339 :
"0x%16.16" PRIx64
" 0x%16.16" PRIx64
365 uint32_t resolved_flags = module_sp->ResolveSymbolContextForAddress(
366 base_address, eSymbolContextLineEntry, sc);
367 if (resolved_flags & eSymbolContextLineEntry) {
379 for (
int idx = 0; idx < 6; ++idx) {
381 resolved_flags = module_sp->ResolveSymbolContextForAddress(
382 addr, eSymbolContextLineEntry, sc_temp);
384 if (!(resolved_flags & eSymbolContextLineEntry))
455 bool dumped_module =
false;
459 dumped_module =
true;
460 module_sp->DumpSymbolContext(s);
499 module_sp->FindSymbolsWithNameAndType(reexport_name,
eSymbolTypeAny,
502 if (sc.symbol->IsExternal())
508 seen_modules.
Append(module_sp);
511 module_sp->GetObjectFile()->GetReExportedLibraries();
512 size_t num_reexported_libraries = reexported_libraries.
GetSize();
513 for (
size_t idx = 0; idx < num_reexported_libraries; idx++) {
518 target, reexport_name, reexported_module_spec, seen_modules);
520 return result_symbol;
534 module_spec, seen_modules);
569 if (reexported_symbol) {
570 func_so_addr = reexported_symbol->
GetAddress();
571 is_indirect = reexported_symbol->
IsIndirect();
597 bool prefer_file_cache) {
602 module_sp->GetArchitecture(),
nullptr, flavor,
nullptr,
nullptr,
610 bool prefer_file_cache,
Stream &strm) {
613 if (disassembler_sp) {
614 const bool show_address =
true;
615 const bool show_bytes =
false;
616 const bool show_control_flow_kind =
false;
617 disassembler_sp->GetInstructionList().Dump(
618 &strm, show_address, show_bytes, show_control_flow_kind, &exe_ctx);
649 llvm::SmallString<256> name;
650 llvm::raw_svector_ostream os(name);
667 const uint16_t bitfields = data.
GetU16(offset_ptr);
678 m_type = bitfields & 0x003f;
679 if (!
m_mangled.Decode(data, offset_ptr, strtab))
684 const bool is_addr = data.
GetU8(offset_ptr) != 0;
685 const uint64_t value = data.
GetU64(offset_ptr);
689 .ResolveAddressUsingFileSections(value, section_list);
714#if __SIZEOF_POINTER__ == 8
716 "Symbol size has changed, Symbol::Encode and Decode likely need "
739 uint16_t bitfields =
m_type;
741 bitfields |= 1u << 15;
743 bitfields |= 1u << 14;
745 bitfields |= 1u << 13;
747 bitfields |= 1u << 12;
749 bitfields |= 1u << 11;
751 bitfields |= 1u << 10;
753 bitfields |= 1u << 9;
755 bitfields |= 1u << 8;
757 bitfields |= 1u << 7;
759 bitfields |= 1u << 6;
826#define ENUM_TO_CSTRING(x) \
827 case eSymbolType##x: \
831 switch (symbol_type) {
862 return "<unknown SymbolType>";
866 std::string str_lower = llvm::StringRef(str).lower();
867 return llvm::StringSwitch<lldb::SymbolType>(str_lower)
944 llvm::json::Path path) {
945 llvm::json::ObjectMapper o(value, path);
946 const bool mapped = o && o.map(
"value", symbol.
value) &&
947 o.map(
"address", symbol.
address) &&
948 o.map(
"size", symbol.
size) && o.map(
"id", symbol.
id) &&
949 o.map(
"type", symbol.
type) && o.map(
"name", symbol.
name);
955 path.report(
"symbol must have either a value or an address");
960 path.report(
"symbol cannot have both a value and an address");
968 llvm::json::Path path) {
969 if (
auto str = value.getAsString()) {
970 llvm::StringRef str_ref = str.value_or(
"");
974 path.report(
"invalid symbol type");
980 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.
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.
lldb::addr_t GetCallableLoadAddress(Target *target, bool is_indirect=false) const
Get the load address as a callable code load address.
Function * CalculateSymbolContextFunction() const
@ DumpStyleFileAddress
Display as the file address (if any).
@ DumpStyleLoadAddress
Display as the load address (if resolved).
bool Slide(int64_t offset)
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
lldb::addr_t GetFileAddress() const
Get the file address.
bool IsValid() const
Check if the object state is valid.
A class that describes a single lexical block.
Many cache files require string tables to store data efficiently.
uint32_t Add(ConstString s)
Add a string into the string table.
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * AsCString(const char *value_if_empty) 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, const char *cpu, const char *features, Target &target, llvm::ArrayRef< AddressRange > disasm_ranges, 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.
@ ePreferDemangledWithoutArguments
ConstString GetMangledName() const
Mangled name get accessor.
ConstString GetDemangledName() const
Demangled name get accessor.
ConstString GetName(NamePreference preference=ePreferDemangled) const
Best name get accessor.
ConstString GetDisplayDemangledName() const
Display demangled name get accessor.
A collection class for Module objects.
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
Finds the first module whose file specification matches module_spec.
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.
llvm::StringRef Get(uint32_t offset) const
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
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
static lldb::SymbolType GetTypeFromString(const char *str)
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
struct lldb_private::Symbol::AddrRangeOrReExport m_addr_or_reexport
Address GetAddress() const
ConstString GetNameNoArguments() const
uint16_t m_size_is_sibling
Symbol * ResolveReExportedSymbol(Target &target) const
FileSpec GetReExportedSymbolSharedLibrary() const
Symbol * ResolveReExportedSymbolInModuleSpec(Target &target, ConstString reexport_name, lldb_private::ModuleSpec &module_spec, lldb_private::ModuleList &seen_modules) 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, SymbolValue &data, 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.
void SetReExportInfo(Symbol &sym, const ReExportInfo reexport_info)
ReExportInfo m_reexport_info
void SetAddressRange(Symbol &sym, const AddressRange addr_range)
ReExportInfo & GetReExportInfo(Symbol &sym)
AddressRange & GetAddressRange(Symbol &sym)
AddressRange m_addr_range
std::unique_ptr< FileSpec > library_up