24#include "llvm/ADT/StringSwitch.h"
38 bool external,
bool is_debug,
bool is_trampoline,
41 bool contains_linker_annotations, uint32_t flags)
52 bool external,
bool is_debug,
bool is_trampoline,
54 bool size_is_valid,
bool contains_linker_annotations,
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);
166 return (
bool)
m_addr_range.GetBaseAddress().GetSection();
178 intptr_t str_ptr =
m_addr_range.GetBaseAddress().GetOffset();
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))
417 bool dumped_module =
false;
421 dumped_module =
true;
422 module_sp->DumpSymbolContext(s);
456 module_sp->FindSymbolsWithNameAndType(reexport_name,
eSymbolTypeAny,
459 if (sc.symbol->IsExternal())
465 seen_modules.
Append(module_sp);
468 module_sp->GetObjectFile()->GetReExportedLibraries();
469 size_t num_reexported_libraries = reexported_libraries.
GetSize();
470 for (
size_t idx = 0; idx < num_reexported_libraries; idx++) {
475 target, reexport_name, reexported_module_spec, seen_modules);
477 return result_symbol;
491 module_spec, seen_modules);
526 if (reexported_symbol) {
527 func_so_addr = reexported_symbol->
GetAddress();
528 is_indirect = reexported_symbol->
IsIndirect();
554 bool prefer_file_cache) {
558 module_sp->GetArchitecture(),
nullptr, flavor,
nullptr,
nullptr,
565 bool prefer_file_cache,
Stream &strm) {
568 if (disassembler_sp) {
569 const bool show_address =
true;
570 const bool show_bytes =
false;
571 const bool show_control_flow_kind =
false;
572 disassembler_sp->GetInstructionList().Dump(
573 &strm, show_address, show_bytes, show_control_flow_kind, &exe_ctx);
603 llvm::SmallString<256> name;
604 llvm::raw_svector_ostream os(name);
606 << llvm::format_hex_no_prefix(
619 const uint16_t bitfields = data.
GetU16(offset_ptr);
630 m_type = bitfields & 0x003f;
631 if (!
m_mangled.Decode(data, offset_ptr, strtab))
635 const bool is_addr = data.
GetU8(offset_ptr) != 0;
636 const uint64_t value = data.
GetU64(offset_ptr);
638 m_addr_range.GetBaseAddress().ResolveAddressUsingFileSections(value,
668 uint16_t bitfields =
m_type;
670 bitfields |= 1u << 15;
672 bitfields |= 1u << 14;
674 bitfields |= 1u << 13;
676 bitfields |= 1u << 12;
678 bitfields |= 1u << 11;
680 bitfields |= 1u << 10;
682 bitfields |= 1u << 9;
684 bitfields |= 1u << 8;
686 bitfields |= 1u << 7;
688 bitfields |= 1u << 6;
695 bool is_addr =
m_addr_range.GetBaseAddress().GetSection().get() !=
nullptr;
740#define ENUM_TO_CSTRING(x) \
741 case eSymbolType##x: \
745 switch (symbol_type) {
776 return "<unknown SymbolType>";
780 std::string str_lower = llvm::StringRef(str).lower();
781 return llvm::StringSwitch<lldb::SymbolType>(str_lower)
817 llvm::json::Path path) {
818 llvm::json::ObjectMapper o(value, path);
819 const bool mapped = o && o.map(
"value", symbol.
value) &&
820 o.map(
"address", symbol.
address) &&
821 o.map(
"size", symbol.
size) && o.map(
"id", symbol.
id) &&
822 o.map(
"type", symbol.
type) && o.map(
"name", symbol.
name);
828 path.report(
"symbol must have either a value or an address");
833 path.report(
"symbol cannot have both a value and an address");
841 llvm::json::Path path) {
842 if (
auto str = value.getAsString()) {
843 llvm::StringRef str_ref = str.value_or(
"");
847 path.report(
"invalid symbol type");
853 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.
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, 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 GetDemangledName() const
Demangled name get accessor.
ConstString & GetMangledName()
Mangled 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.
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
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
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.