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";
161 m_obj_file(obj_file), m_type(sect_type), m_parent_wp(), m_name(name),
162 m_file_addr(file_addr), m_byte_size(byte_size),
163 m_file_offset(file_offset), m_file_size(file_size),
164 m_log2align(log2align), m_children(), m_fake(false), m_encrypted(false),
165 m_thread_specific(false), m_readable(false), m_writable(false),
166 m_executable(false), m_relocated(false), m_target_byte_size(target_byte_size) {
170 const ModuleSP &module_sp,
ObjectFile *obj_file,
177 m_obj_file(obj_file), m_type(sect_type), m_parent_wp(), m_name(name),
178 m_file_addr(file_addr), m_byte_size(byte_size),
179 m_file_offset(file_offset), m_file_size(file_size),
180 m_log2align(log2align), m_children(), m_fake(false), m_encrypted(false),
181 m_thread_specific(false), m_readable(false), m_writable(false),
182 m_executable(false), m_relocated(false), m_target_byte_size(target_byte_size) {
183 if (parent_section_sp)
205 return parent_sp->SetFileAddress(
m_file_addr - file_addr);
228 load_base_addr = parent_sp->GetLoadBaseAddress(target);
234 const_cast<Section *
>(
this)->shared_from_this());
236 return load_base_addr;
240 bool allow_section_end)
const {
242 for (
size_t i = 0; i < num_children; i++) {
246 if (child_offset <= offset &&
247 offset - child_offset <
248 child_section->
GetByteSize() + (allow_section_end ? 1 : 0))
250 so_addr, allow_section_end);
263 if (file_addr <= vm_addr) {
275 bool resolved =
true;
294 s << llvm::format(
"%c %c%c%c 0x%8.8" PRIx64
" 0x%8.8" PRIx64
" 0x%8.8x ",
310 parent_sp->DumpName(s);
314 const char *name =
nullptr;
321 if ((!name || !name[0]) && module_sp)
322 name = module_sp->GetFileSpec().GetFilename().AsCString();
334 return parent_sp->IsDescendant(section);
340 if (slide_amount == 0)
357 permissions |= ePermissionsReadable;
359 permissions |= ePermissionsWritable;
361 permissions |= ePermissionsExecutable;
367 m_readable = (permissions & ePermissionsReadable) != 0;
368 m_writable = (permissions & ePermissionsWritable) != 0;
369 m_executable = (permissions & ePermissionsExecutable) != 0;
461#pragma mark SectionList
473 return section_index;
476 return std::numeric_limits<size_t>::max();
492 for (sect_iter =
begin; sect_iter !=
end; ++sect_iter) {
493 if (sect_iter->get() == sect) {
495 return std::distance(
begin, sect_iter);
510 const lldb::SectionSP §_sp,
513 for (sect_iter =
m_sections.begin(); sect_iter !=
end; ++sect_iter) {
514 if ((*sect_iter)->GetID() == sect_id) {
515 *sect_iter = sect_sp;
517 }
else if (depth > 0) {
531 for (sect_iter =
m_sections.begin(); sect_iter !=
end; ++sect_iter) {
532 count += (*sect_iter)->GetChildren().GetNumSections(depth - 1);
553 sect_iter !=
end && sect_sp.get() ==
nullptr; ++sect_iter) {
554 Section *child_section = sect_iter->get();
556 if (child_section->
GetName() == section_dstr) {
557 sect_sp = *sect_iter;
574 sect_iter !=
end && sect_sp.get() ==
nullptr; ++sect_iter) {
575 if ((*sect_iter)->GetID() == sect_id) {
576 sect_sp = *sect_iter;
579 sect_sp = (*sect_iter)->GetChildren().FindSectionByID(sect_id);
588 size_t start_idx)
const {
591 for (
size_t idx = start_idx; idx < num_sections; ++idx) {
592 if (
m_sections[idx]->GetType() == sect_type) {
595 }
else if (check_children) {
596 sect_sp =
m_sections[idx]->GetChildren().FindSectionByType(
597 sect_type, check_children, 0);
611 sect_iter !=
end && sect_sp.get() ==
nullptr; ++sect_iter) {
612 Section *sect = sect_iter->get();
621 if (sect_sp.get() ==
nullptr && !sect->
IsFake())
622 sect_sp = *sect_iter;
633 bool show_header,
uint32_t depth)
const {
634 bool target_has_loaded_sections =
639 "SectID Type {0} Address "
640 " Perm File Off. File Size Flags "
642 target_has_loaded_sections ?
"Load" :
"File");
644 s <<
"---------- ---------------- "
645 "--------------------------------------- ---- ---------- "
647 "---------- ----------------------------\n";
651 section_sp->Dump(s, indent, target_has_loaded_sections ? target :
nullptr,
659 if ((*pos)->Slide(slide_amount, slide_children))
666 uint64_t debug_info_size = 0;
668 const SectionList &sub_sections = section->GetChildren();
669 if (sub_sections.
GetSize() > 0)
671 else if (section->ContainsOnlyDebugInfo())
672 debug_info_size += section->GetFileSize();
674 return debug_info_size;
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)
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::SectionSP GetParent() const
uint32_t GetPermissions() const
Get the permissions as OR'ed bits from lldb::Permissions.
bool SetFileAddress(lldb::addr_t file_addr)
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.
@ 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
@ eSectionTypeDWARFDebugCuIndex
@ eSectionTypeDWARFDebugAranges
@ eSectionTypeDWARFDebugAbbrevDwo
@ eSectionTypeDWARFGNUDebugAltLink
@ eSectionTypeDWARFDebugStrDwo
@ eSectionTypeDWARFDebugAbbrev
@ eSectionTypeDataPointers
@ eSectionTypeDWARFDebugLocListsDwo
@ eSectionTypeDWARFDebugInfoDwo
@ eSectionTypeDWARFDebugAddr
@ eSectionTypeDataCString
Inlined C string data.
@ eSectionTypeELFSymbolTable
Elf SHT_SYMTAB section.
A mix in class that contains a generic user ID.
lldb::user_id_t GetID() const
Get accessor for the user ID.