1 //===-- llvm-dwarfdump - Debug info dumping utility -------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_TOOLS_LLVM_DWARFDUMP_LLVM_DWARFDUMP_H
10 #define LLVM_TOOLS_LLVM_DWARFDUMP_LLVM_DWARFDUMP_H
11 
12 #include "llvm/ADT/MapVector.h"
13 #include "llvm/ADT/StringMap.h"
14 #include "llvm/ADT/Twine.h"
15 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
16 #include "llvm/Object/ObjectFile.h"
17 #include "llvm/Support/raw_ostream.h"
18 
19 namespace llvm {
20 namespace dwarfdump {
21 
22 /// Holds cumulative section sizes for an object file.
23 struct SectionSizes {
24   /// Map of .debug section names and their sizes across all such-named
25   /// sections.
26   MapVector<std::string, uint64_t, StringMap<uint64_t>> DebugSectionSizes;
27   /// Total number of bytes of all sections.
28   uint64_t TotalObjectSize = 0;
29   /// Total number of bytes of all debug sections.
30   uint64_t TotalDebugSectionsSize = 0;
31 };
32 
33 /// Calculate the section sizes.
34 void calculateSectionSizes(const object::ObjectFile &Obj, SectionSizes &Sizes,
35                            const Twine &Filename);
36 
37 bool collectStatsForObjectFile(object::ObjectFile &Obj, DWARFContext &DICtx,
38                                const Twine &Filename, raw_ostream &OS);
39 bool collectObjectSectionSizes(object::ObjectFile &Obj, DWARFContext &DICtx,
40                                const Twine &Filename, raw_ostream &OS);
41 
42 } // namespace dwarfdump
43 } // namespace llvm
44 
45 #endif
46