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 STRUCTUREPACKINGCHECK_H 0019 #define STRUCTUREPACKINGCHECK_H 0020 0021 #include <QSet> 0022 0023 class ElfFileSet; 0024 class DwarfInfo; 0025 class DwarfDie; 0026 0027 class QString; 0028 template<class T> class QVector; 0029 0030 class StructurePackingCheck 0031 { 0032 public: 0033 StructurePackingCheck() = default; 0034 StructurePackingCheck(const StructurePackingCheck&) = default; 0035 ~StructurePackingCheck() = default; 0036 0037 StructurePackingCheck& operator=(const StructurePackingCheck&) = default; 0038 0039 /** Set the ELF file set the checked DWARF info belongs to.*/ 0040 void setElfFileSet(ElfFileSet *fileSet); 0041 0042 void checkAll(DwarfInfo* info); 0043 QString checkOneStructure(DwarfDie *structDie) const; 0044 0045 private: 0046 void checkDie(DwarfDie* die); 0047 std::tuple<int, int> computeStructureMemoryUsage(DwarfDie* structDie, const QVector<DwarfDie*> &memberDies) const; 0048 QString printStructure(DwarfDie* structDie, const QVector< DwarfDie* >& memberDies) const; 0049 int optimalStructureSize(DwarfDie* structDie, const QVector<DwarfDie*> &memberDies) const; 0050 /** Look for a better type DIE for the given external one (@p typeDie). */ 0051 DwarfDie* findTypeDefinition(DwarfDie *typeDie) const; 0052 0053 ElfFileSet *m_fileSet = nullptr; 0054 QSet<QString> m_duplicateCheck; 0055 }; 0056 0057 #endif // STRUCTUREPACKINGCHECK_H