File indexing completed on 2024-05-12 05:43:26

0001 /*
0002     Copyright (C) 2015 Volker Krause <vkrause@kde.org>
0003 
0004     This program is free software; you can redistribute it and/or modify it
0005     under the terms of the GNU Library General Public License as published by
0006     the Free Software Foundation; either version 2 of the License, or (at your
0007     option) any later version.
0008 
0009     This program is distributed in the hope that it will be useful, but WITHOUT
0010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
0012     License for more details.
0013 
0014     You should have received a copy of the GNU General Public License
0015     along with this program.  If not, see <https://www.gnu.org/licenses/>.
0016 */
0017 
0018 #ifndef DWARFADDRESSRANGES_H
0019 #define DWARFADDRESSRANGES_H
0020 
0021 #include <libdwarf.h>
0022 
0023 #include <cstdint>
0024 
0025 class DwarfInfo;
0026 class DwarfCuDie;
0027 class DwarfDie;
0028 
0029 /** Representation of the .debug_aranges section. */
0030 class DwarfAddressRanges
0031 {
0032 public:
0033     explicit DwarfAddressRanges(DwarfInfo *info);
0034     DwarfAddressRanges(const DwarfAddressRanges&) = delete;
0035     ~DwarfAddressRanges();
0036 
0037     DwarfAddressRanges& operator=(const DwarfAddressRanges&) = delete;
0038 
0039     /** Returns @c true if the .debug_aranges section is present. */
0040     bool isValid() const;
0041 
0042     /** Looks up the CU DIE for the given address. */
0043     DwarfCuDie* compilationUnitForAddress(uint64_t addr) const;
0044     /** Looks up the DIE for the given address. */
0045     DwarfDie* dieForAddress(uint64_t addr) const;
0046 
0047 private:
0048     Dwarf_Arange *m_aranges;
0049     DwarfInfo *m_info;
0050     Dwarf_Signed m_arangesSize;
0051 };
0052 
0053 #endif // DWARFADDRESSRANGES_H