41 return "data-cstr-ptr";
43 return "data-symbol-addr";
49 return "data-16-byte";
57 return "objc-message-refs";
59 return "objc-cfstrings";
61 return "dwarf-abbrev";
63 return "dwarf-abbrev-dwo";
67 return "dwarf-aranges";
69 return "dwarf-cu-index";
71 return "dwarf-tu-index";
77 return "dwarf-info-dwo";
81 return "dwarf-line-str";
85 return "dwarf-loc-dwo";
87 return "dwarf-loclists";
89 return "dwarf-loclists-dwo";
91 return "dwarf-macinfo";
95 return "dwarf-pubnames";
97 return "dwarf-pubtypes";
99 return "dwarf-ranges";
101 return "dwarf-rnglists";
103 return "dwarf-rnglists-dwo";
107 return "dwarf-str-dwo";
109 return "dwarf-str-offsets";
111 return "dwarf-str-offsets-dwo";
113 return "dwarf-types";
115 return "dwarf-types-dwo";
117 return "dwarf-names";
119 return "elf-symbol-table";
121 return "elf-dynamic-symbols";
123 return "elf-relocation-entries";
125 return "elf-dynamic-link-info";
127 return "apple-names";
129 return "apple-types";
131 return "apple-namespaces";
141 return "compact-unwind";
147 return "dwarf-gnu-debugaltlink";
153 return "swift-modules";
162 uint32_t log2align, uint32_t flags,
163 uint32_t target_byte_size )
165 m_obj_file(obj_file), m_type(sect_type), m_parent_wp(), m_name(name),
166 m_file_addr(file_addr), m_byte_size(byte_size),
167 m_file_offset(file_offset), m_file_size(file_size),
168 m_log2align(log2align), m_children(), m_fake(false), m_encrypted(false),
169 m_thread_specific(false), m_readable(false), m_writable(false),
170 m_executable(false), m_relocated(false), m_target_byte_size(target_byte_size) {
178 uint32_t log2align, uint32_t flags,
179 uint32_t target_byte_size )
181 m_obj_file(obj_file), m_type(sect_type), m_parent_wp(), m_name(name),
182 m_file_addr(file_addr), m_byte_size(byte_size),
183 m_file_offset(file_offset), m_file_size(file_size),
184 m_log2align(log2align), m_children(), m_fake(false), m_encrypted(false),
185 m_thread_specific(false), m_readable(false), m_writable(false),
186 m_executable(false), m_relocated(false), m_target_byte_size(target_byte_size) {
187 if (parent_section_sp)
209 return parent_sp->SetFileAddress(
m_file_addr - file_addr);
232 load_base_addr = parent_sp->GetLoadBaseAddress(target);
238 const_cast<Section *
>(
this)->shared_from_this());
240 return load_base_addr;
244 bool allow_section_end)
const {
246 for (
size_t i = 0; i < num_children; i++) {
250 if (child_offset <= offset &&
251 offset - child_offset <
252 child_section->
GetByteSize() + (allow_section_end ? 1 : 0))
254 so_addr, allow_section_end);
267 if (file_addr <= vm_addr) {
276 uint32_t depth)
const {
279 bool resolved =
true;
298 s << llvm::format(
"%c %c%c%c 0x%8.8" PRIx64
" 0x%8.8" PRIx64
" 0x%8.8x ",
314 parent_sp->DumpName(s);
318 const char *name =
nullptr;
325 if ((!name || !name[0]) && module_sp)
326 name = module_sp->GetFileSpec().GetFilename().AsCString();
338 return parent_sp->IsDescendant(section);
344 if (slide_amount == 0)
359 uint32_t permissions = 0;
361 permissions |= ePermissionsReadable;
363 permissions |= ePermissionsWritable;
365 permissions |= ePermissionsExecutable;
371 m_readable = (permissions & ePermissionsReadable) != 0;
372 m_writable = (permissions & ePermissionsWritable) != 0;
373 m_executable = (permissions & ePermissionsExecutable) != 0;
467#pragma mark SectionList
479 return section_index;
482 return std::numeric_limits<size_t>::max();
498 for (sect_iter =
begin; sect_iter !=
end; ++sect_iter) {
499 if (sect_iter->get() == sect) {
501 return std::distance(
begin, sect_iter);
519 for (sect_iter =
m_sections.begin(); sect_iter !=
end; ++sect_iter) {
520 if ((*sect_iter)->GetID() == sect_id) {
521 *sect_iter = sect_sp;
523 }
else if (depth > 0) {
537 for (sect_iter =
m_sections.begin(); sect_iter !=
end; ++sect_iter) {
538 count += (*sect_iter)->GetChildren().GetNumSections(depth - 1);
559 sect_iter !=
end && sect_sp.get() ==
nullptr; ++sect_iter) {
560 Section *child_section = sect_iter->get();
562 if (child_section->
GetName() == section_dstr) {
563 sect_sp = *sect_iter;
580 sect_iter !=
end && sect_sp.get() ==
nullptr; ++sect_iter) {
581 if ((*sect_iter)->GetID() == sect_id) {
582 sect_sp = *sect_iter;
585 sect_sp = (*sect_iter)->GetChildren().FindSectionByID(sect_id);
594 size_t start_idx)
const {
597 for (
size_t idx = start_idx; idx < num_sections; ++idx) {
598 if (
m_sections[idx]->GetType() == sect_type) {
601 }
else if (check_children) {
602 sect_sp =
m_sections[idx]->GetChildren().FindSectionByType(
603 sect_type, check_children, 0);
612 uint32_t depth)
const {
617 sect_iter !=
end && sect_sp.get() ==
nullptr; ++sect_iter) {
618 Section *sect = sect_iter->get();
627 if (sect_sp.get() ==
nullptr && !sect->
IsFake())
628 sect_sp = *sect_iter;
639 bool show_header, uint32_t depth)
const {
640 bool target_has_loaded_sections =
645 "SectID Type {0} Address "
646 " Perm File Off. File Size Flags Section Name\n",
647 target_has_loaded_sections ?
"Load" :
"File");
649 s <<
"------------------ ---------------------- "
650 "--------------------------------------- ---- ---------- ---------- "
651 "---------- ----------------------------\n";
655 section_sp->Dump(s, indent, target_has_loaded_sections ? target :
nullptr,
663 if ((*pos)->Slide(slide_amount, slide_children))
670 uint64_t debug_info_size = 0;
672 const SectionList &sub_sections = section->GetChildren();
673 if (sub_sections.
GetSize() > 0)
675 else if (section->ContainsOnlyDebugInfo())
676 debug_info_size += section->GetFileSize();
678 return debug_info_size;
686 llvm::json::ObjectMapper o(value, path);
687 return o && o.map(
"name", section.
name) && o.map(
"type", section.
type) &&
688 o.map(
"size", section.
address) && o.map(
"size", section.
size);
692 llvm::json::Path path) {
693 if (
auto str = value.getAsString()) {
694 type = llvm::StringSwitch<lldb::SectionType>(*str)
702 path.report(
"invalid section type");
708 path.report(
"expected string");
A section + offset based address class.
void SetSection(const lldb::SectionSP §ion_sp)
Set accessor for the section.
bool SetOffset(lldb::addr_t offset)
Set accessor for the offset.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
const ConstString & GetFilename() const
Filename string const get accessor.
ValueType Get() const
Get accessor for all flags.
A mix in class that contains a pointer back to the module that owns the object which inherits from it...
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
A plug-in interface definition class for object file parsers.
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
virtual size_t ReadSectionData(Section *section, lldb::offset_t section_offset, void *dst, size_t dst_len)
const_iterator begin() const
bool ContainsSection(lldb::user_id_t sect_id) const
const_iterator end() const
lldb::SectionSP FindSectionByName(ConstString section_dstr) const
collection::iterator iterator
size_t GetNumSections(uint32_t depth) const
lldb::SectionSP FindSectionByID(lldb::user_id_t sect_id) const
size_t Slide(lldb::addr_t slide_amount, bool slide_children)
lldb::SectionSP FindSectionContainingFileAddress(lldb::addr_t addr, uint32_t depth=UINT32_MAX) const
uint64_t GetDebugInfoSize() const
Get the debug information size from all sections that contain debug information.
bool DeleteSection(size_t idx)
size_t AddSection(const lldb::SectionSP §ion_sp)
bool ReplaceSection(lldb::user_id_t sect_id, const lldb::SectionSP §ion_sp, uint32_t depth=UINT32_MAX)
SectionList & operator=(const SectionList &rhs)
size_t FindSectionIndex(const Section *sect)
lldb::SectionSP FindSectionByType(lldb::SectionType sect_type, bool check_children, size_t start_idx=0) const
size_t AddUniqueSection(const lldb::SectionSP §ion_sp)
void Dump(llvm::raw_ostream &s, unsigned indent, Target *target, bool show_header, uint32_t depth) const
lldb::SectionSP GetSectionAtIndex(size_t idx) const
collection::const_iterator const_iterator
lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP §ion_sp) const
bool IsThreadSpecific() const
bool ContainsFileAddress(lldb::addr_t vm_addr) const
lldb::addr_t GetOffset() const
void SetPermissions(uint32_t permissions)
Set the permissions using bits OR'ed from lldb::Permissions.
ConstString GetName() const
void DumpName(llvm::raw_ostream &s) const
lldb::offset_t GetSectionData(void *dst, lldb::offset_t dst_len, lldb::offset_t offset=0)
Read the section data from the object file that the section resides in.
bool IsDescendant(const Section *section)
lldb::SectionSP GetParent() const
uint32_t GetPermissions() const
Get the permissions as OR'ed bits from lldb::Permissions.
bool SetFileAddress(lldb::addr_t file_addr)
Section(const lldb::ModuleSP &module_sp, ObjectFile *obj_file, lldb::user_id_t sect_id, ConstString name, lldb::SectionType sect_type, lldb::addr_t file_vm_addr, lldb::addr_t vm_size, lldb::offset_t file_offset, lldb::offset_t file_size, uint32_t log2align, uint32_t flags, uint32_t target_byte_size=1)
lldb::SectionWP m_parent_wp
lldb::addr_t GetFileAddress() const
SectionList & GetChildren()
bool ContainsOnlyDebugInfo() const
Returns true if this section contains debug information.
void Dump(llvm::raw_ostream &s, unsigned indent, Target *target, uint32_t depth) const
const char * GetTypeAsCString() const
lldb::addr_t GetLoadBaseAddress(Target *target) const
bool Slide(lldb::addr_t slide_amount, bool slide_children)
bool ResolveContainedAddress(lldb::addr_t offset, Address &so_addr, bool allow_section_end=false) const
lldb::offset_t m_file_offset
lldb::offset_t m_file_size
lldb::addr_t GetByteSize() const
uint32_t m_target_byte_size
SectionLoadList & GetSectionLoadList()
void Dump(llvm::raw_ostream &s, lldb::addr_t base_addr=0, uint32_t addr_width=8) const
#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)
std::shared_ptr< lldb_private::Section > SectionSP
@ eSectionTypeDWARFDebugStrOffsets
@ eSectionTypeELFDynamicSymbols
Elf SHT_DYNSYM section.
@ eSectionTypeDWARFDebugPubNames
@ eSectionTypeDataObjCCFStrings
Objective-C const CFString/NSString objects.
@ eSectionTypeDWARFDebugLocDwo
@ eSectionTypeDWARFDebugFrame
@ eSectionTypeContainer
The section contains child sections.
@ eSectionTypeDWARFDebugLocLists
DWARF v5 .debug_loclists.
@ eSectionTypeDWARFDebugTypes
DWARF .debug_types section.
@ eSectionTypeDataSymbolAddress
Address of a symbol in the symbol table.
@ eSectionTypeELFDynamicLinkInfo
Elf SHT_DYNAMIC section.
@ eSectionTypeDWARFDebugMacInfo
@ eSectionTypeAbsoluteAddress
Dummy section for symbols with absolute address.
@ eSectionTypeCompactUnwind
compact unwind section in Mach-O, __TEXT,__unwind_info
@ eSectionTypeELFRelocationEntries
Elf SHT_REL or SHT_REL section.
@ eSectionTypeDWARFAppleNamespaces
@ eSectionTypeDWARFDebugNames
DWARF v5 .debug_names.
@ eSectionTypeDWARFDebugRngLists
DWARF v5 .debug_rnglists.
@ eSectionTypeDWARFDebugStrOffsetsDwo
@ eSectionTypeDWARFDebugMacro
@ eSectionTypeDWARFAppleTypes
@ eSectionTypeDWARFDebugInfo
@ eSectionTypeDWARFDebugTypesDwo
@ eSectionTypeDWARFDebugRanges
@ eSectionTypeDWARFDebugRngListsDwo
@ eSectionTypeDWARFDebugLine
@ eSectionTypeDWARFDebugPubTypes
@ eSectionTypeDataObjCMessageRefs
Pointer to function pointer + selector.
@ eSectionTypeDWARFDebugTuIndex
@ eSectionTypeDWARFDebugStr
@ eSectionTypeDWARFDebugLineStr
DWARF v5 .debug_line_str.
@ eSectionTypeDWARFDebugLoc
@ eSectionTypeDWARFAppleNames
@ eSectionTypeDataCStringPointers
Pointers to C string data.
@ eSectionTypeDWARFAppleObjC
@ eSectionTypeSwiftModules
@ eSectionTypeDWARFDebugCuIndex
@ eSectionTypeDWARFDebugAranges
@ eSectionTypeDWARFDebugAbbrevDwo
@ eSectionTypeDWARFGNUDebugAltLink
@ eSectionTypeDWARFDebugStrDwo
@ eSectionTypeDWARFDebugAbbrev
@ eSectionTypeDataPointers
@ eSectionTypeDWARFDebugLocListsDwo
@ eSectionTypeDWARFDebugInfoDwo
@ eSectionTypeDWARFDebugAddr
@ eSectionTypeDataCString
Inlined C string data.
@ eSectionTypeELFSymbolTable
Elf SHT_SYMTAB section.
std::shared_ptr< lldb_private::Module > ModuleSP
std::optional< uint64_t > size
std::optional< lldb::SectionType > type
std::optional< uint64_t > address
A mix in class that contains a generic user ID.
lldb::user_id_t GetID() const
Get accessor for the user ID.