1 //===- DWARFObject.h --------------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===-----------------------------------------------------------------------===/ 9 10 #ifndef LLVM_DEBUGINFO_DWARF_DWARFOBJECT_H 11 #define LLVM_DEBUGINFO_DWARF_DWARFOBJECT_H 12 13 #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" 14 #include "llvm/DebugInfo/DWARF/DWARFSection.h" 15 #include "llvm/Object/ObjectFile.h" 16 17 namespace llvm { 18 // This is responsible for low level access to the object file. It 19 // knows how to find the required sections and compute relocated 20 // values. 21 // The default implementations of the get<Section> methods return dummy values. 22 // This is to allow clients that only need some of those to implement just the 23 // ones they need. We can't use unreachable for as many cases because the parser 24 // implementation is eager and will call some of these methods even if the 25 // result is not used. 26 class DWARFObject { 27 DWARFSection Dummy; 28 29 public: 30 virtual ~DWARFObject() = default; getFileName()31 virtual StringRef getFileName() const { llvm_unreachable("unimplemented"); } getFile()32 virtual const object::ObjectFile *getFile() const { return nullptr; } getSectionNames()33 virtual ArrayRef<SectionName> getSectionNames() const { return {}; } 34 virtual bool isLittleEndian() const = 0; getAddressSize()35 virtual uint8_t getAddressSize() const { llvm_unreachable("unimplemented"); } 36 virtual void forEachInfoSections(function_ref<void (const DWARFSection &)> F)37 forEachInfoSections(function_ref<void(const DWARFSection &)> F) const {} 38 virtual void forEachTypesSections(function_ref<void (const DWARFSection &)> F)39 forEachTypesSections(function_ref<void(const DWARFSection &)> F) const {} getAbbrevSection()40 virtual StringRef getAbbrevSection() const { return ""; } getLocSection()41 virtual const DWARFSection &getLocSection() const { return Dummy; } getLoclistsSection()42 virtual const DWARFSection &getLoclistsSection() const { return Dummy; } getARangeSection()43 virtual StringRef getARangeSection() const { return ""; } getDebugFrameSection()44 virtual StringRef getDebugFrameSection() const { return ""; } getEHFrameSection()45 virtual StringRef getEHFrameSection() const { return ""; } getLineSection()46 virtual const DWARFSection &getLineSection() const { return Dummy; } getLineStringSection()47 virtual StringRef getLineStringSection() const { return ""; } getStringSection()48 virtual StringRef getStringSection() const { return ""; } getRangeSection()49 virtual const DWARFSection &getRangeSection() const { return Dummy; } getRnglistsSection()50 virtual const DWARFSection &getRnglistsSection() const { return Dummy; } getMacinfoSection()51 virtual StringRef getMacinfoSection() const { return ""; } getPubNamesSection()52 virtual const DWARFSection &getPubNamesSection() const { return Dummy; } getPubTypesSection()53 virtual const DWARFSection &getPubTypesSection() const { return Dummy; } getGnuPubNamesSection()54 virtual const DWARFSection &getGnuPubNamesSection() const { return Dummy; } getGnuPubTypesSection()55 virtual const DWARFSection &getGnuPubTypesSection() const { return Dummy; } getStringOffsetSection()56 virtual const DWARFSection &getStringOffsetSection() const { return Dummy; } 57 virtual void forEachInfoDWOSections(function_ref<void (const DWARFSection &)> F)58 forEachInfoDWOSections(function_ref<void(const DWARFSection &)> F) const {} 59 virtual void forEachTypesDWOSections(function_ref<void (const DWARFSection &)> F)60 forEachTypesDWOSections(function_ref<void(const DWARFSection &)> F) const {} getAbbrevDWOSection()61 virtual StringRef getAbbrevDWOSection() const { return ""; } getLineDWOSection()62 virtual const DWARFSection &getLineDWOSection() const { return Dummy; } getLocDWOSection()63 virtual const DWARFSection &getLocDWOSection() const { return Dummy; } getStringDWOSection()64 virtual StringRef getStringDWOSection() const { return ""; } getStringOffsetDWOSection()65 virtual const DWARFSection &getStringOffsetDWOSection() const { 66 return Dummy; 67 } getRangeDWOSection()68 virtual const DWARFSection &getRangeDWOSection() const { return Dummy; } getRnglistsDWOSection()69 virtual const DWARFSection &getRnglistsDWOSection() const { return Dummy; } getAddrSection()70 virtual const DWARFSection &getAddrSection() const { return Dummy; } getAppleNamesSection()71 virtual const DWARFSection &getAppleNamesSection() const { return Dummy; } getAppleTypesSection()72 virtual const DWARFSection &getAppleTypesSection() const { return Dummy; } getAppleNamespacesSection()73 virtual const DWARFSection &getAppleNamespacesSection() const { 74 return Dummy; 75 } getDebugNamesSection()76 virtual const DWARFSection &getDebugNamesSection() const { return Dummy; } getAppleObjCSection()77 virtual const DWARFSection &getAppleObjCSection() const { return Dummy; } getCUIndexSection()78 virtual StringRef getCUIndexSection() const { return ""; } getGdbIndexSection()79 virtual StringRef getGdbIndexSection() const { return ""; } getTUIndexSection()80 virtual StringRef getTUIndexSection() const { return ""; } 81 virtual Optional<RelocAddrEntry> find(const DWARFSection &Sec, 82 uint64_t Pos) const = 0; 83 }; 84 85 } // namespace llvm 86 #endif 87