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";
151 return "lldb-type-summaries";
153 return "lldb-formatters";
155 return "swift-modules";
168 uint32_t target_byte_size )
183 uint32_t target_byte_size )
192 if (parent_section_sp)
214 return parent_sp->SetFileAddress(
m_file_addr - file_addr);
237 load_base_addr = parent_sp->GetLoadBaseAddress(target);
243 const_cast<Section *
>(
this)->shared_from_this());
245 return load_base_addr;
249 bool allow_section_end)
const {
250 const size_t num_children =
m_children.GetSize();
251 for (
size_t i = 0; i < num_children; i++) {
255 if (child_offset <= offset &&
256 offset - child_offset <
257 child_section->
GetByteSize() + (allow_section_end ? 1 : 0))
259 so_addr, allow_section_end);
272 if (file_addr <= vm_addr) {
281 uint32_t depth)
const {
284 bool resolved =
true;
303 s << llvm::format(
"%c %c%c%c 0x%8.8" PRIx64
" 0x%8.8" PRIx64
" 0x%8.8x ",
313 m_children.Dump(s, indent, target,
false, depth - 1);
319 parent_sp->DumpName(s);
323 const char *name =
nullptr;
330 if ((!name || !name[0]) && module_sp)
331 name = module_sp->GetFileSpec().GetFilename().AsCString();
343 return parent_sp->IsDescendant(section);
349 if (slide_amount == 0)
355 m_children.Slide(slide_amount, slide_children);
364 uint32_t permissions = 0;
366 permissions |= ePermissionsReadable;
368 permissions |= ePermissionsWritable;
370 permissions |= ePermissionsExecutable;
376 m_readable = (permissions & ePermissionsReadable) != 0;
377 m_writable = (permissions & ePermissionsWritable) != 0;
378 m_executable = (permissions & ePermissionsExecutable) != 0;
384 return m_obj_file->ReadSectionData(
this, offset, dst, dst_len);
390 return m_obj_file->ReadSectionData(
this, section_data);
474#pragma mark SectionList
486 return section_index;
489 return std::numeric_limits<size_t>::max();
505 for (sect_iter =
begin; sect_iter !=
end; ++sect_iter) {
506 if (sect_iter->get() == sect) {
508 return std::distance(
begin, sect_iter);
526 for (sect_iter =
m_sections.begin(); sect_iter !=
end; ++sect_iter) {
527 if ((*sect_iter)->GetID() == sect_id) {
528 *sect_iter = sect_sp;
530 }
else if (depth > 0) {
544 for (sect_iter =
m_sections.begin(); sect_iter !=
end; ++sect_iter) {
545 count += (*sect_iter)->GetChildren().GetNumSections(depth - 1);
565 sect_iter !=
end && sect_sp.get() ==
nullptr; ++sect_iter) {
566 Section *child_section = sect_iter->get();
568 if (child_section->
GetName() == section_dstr) {
569 sect_sp = *sect_iter;
586 sect_iter !=
end && sect_sp.get() ==
nullptr; ++sect_iter) {
587 if ((*sect_iter)->GetID() == sect_id) {
588 sect_sp = *sect_iter;
591 sect_sp = (*sect_iter)->GetChildren().FindSectionByID(sect_id);
600 size_t start_idx)
const {
603 for (
size_t idx = start_idx; idx < num_sections; ++idx) {
604 if (
m_sections[idx]->GetType() == sect_type) {
607 }
else if (check_children) {
608 sect_sp =
m_sections[idx]->GetChildren().FindSectionByType(
609 sect_type, check_children, 0);
618 uint32_t depth)
const {
623 sect_iter !=
end && sect_sp.get() ==
nullptr; ++sect_iter) {
624 Section *sect = sect_iter->get();
633 if (sect_sp.get() ==
nullptr && !sect->
IsFake())
634 sect_sp = *sect_iter;
645 bool show_header, uint32_t depth)
const {
650 "SectID Type {0} Address "
651 " Perm File Off. File Size Flags Section Name\n",
652 target_has_loaded_sections ?
"Load" :
"File");
654 s <<
"------------------ ---------------------- "
655 "--------------------------------------- ---- ---------- ---------- "
656 "---------- ----------------------------\n";
660 section_sp->Dump(s, indent, target_has_loaded_sections ? target :
nullptr,
668 if ((*pos)->Slide(slide_amount, slide_children))
675 uint64_t debug_info_size = 0;
677 const SectionList &sub_sections = section->GetChildren();
678 if (sub_sections.
GetSize() > 0)
680 else if (section->ContainsOnlyDebugInfo())
681 debug_info_size += section->GetFileSize();
683 return debug_info_size;
691 llvm::json::ObjectMapper o(value, path);
692 return o && o.map(
"name", section.
name) && o.map(
"type", section.
type) &&
693 o.map(
"address", section.
address) && o.map(
"size", section.
size) &&
694 o.map(
"read", section.
read) && o.map(
"write", section.
write) &&
695 o.map(
"execute", section.
execute) &&
696 o.mapOptional(
"subsections", section.
subsections) &&
697 o.map(
"user_id", section.
user_id) &&
701 o.map(
"flags", section.
flags) && o.map(
"fake", section.
fake) &&
707 llvm::json::Path path) {
708 if (
auto str = value.getAsString()) {
709 type = llvm::StringSwitch<lldb::SectionType>(*str)
717 path.report(
"invalid section type");
723 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.
Flags(ValueType flags=0)
Construct with initial flag bit values.
ValueType Get() const
Get accessor for all flags.
ModuleChild(const lldb::ModuleSP &module_sp)
Construct with owning module.
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
A plug-in interface definition class for object file parsers.
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
SectionList()=default
Create an empty list.
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
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
lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP §ion_sp)
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
@ eSectionTypeLLDBFormatters
@ eSectionTypeDWARFDebugNames
DWARF v5 .debug_names.
@ eSectionTypeDWARFDebugRngLists
DWARF v5 .debug_rnglists.
@ eSectionTypeDWARFDebugStrOffsetsDwo
@ eSectionTypeDWARFDebugMacro
@ eSectionTypeDWARFAppleTypes
@ eSectionTypeDWARFDebugInfo
@ eSectionTypeDWARFDebugTypesDwo
@ eSectionTypeDWARFDebugRanges
@ eSectionTypeDWARFDebugRngListsDwo
@ eSectionTypeLLDBTypeSummaries
@ 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< lldb::user_id_t > user_id
std::optional< uint64_t > log2align
std::optional< uint64_t > size
std::optional< uint64_t > flags
std::optional< bool > encrypted
std::optional< bool > fake
std::optional< lldb::SectionType > type
std::optional< bool > write
std::optional< bool > execute
std::optional< uint64_t > file_offset
std::optional< uint64_t > address
std::optional< bool > thread_specific
std::optional< uint64_t > file_size
std::vector< JSONSection > subsections
std::optional< bool > read
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
lldb::user_id_t GetID() const
Get accessor for the user ID.