blob: cf7da56c91f895ffd7c0a74e3e5002cc7673b5cb [file] [log] [blame]
Fangrui Songdd214542020-04-09 18:23:39 -07001//===-- 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
Fangrui Song5b280f52021-02-25 20:05:05 -080012#include "llvm/ADT/MapVector.h"
13#include "llvm/ADT/StringMap.h"
Fangrui Songdd214542020-04-09 18:23:39 -070014#include "llvm/ADT/Twine.h"
15#include "llvm/DebugInfo/DWARF/DWARFContext.h"
16#include "llvm/Object/ObjectFile.h"
Fangrui Songdd214542020-04-09 18:23:39 -070017#include "llvm/Support/raw_ostream.h"
18
19namespace llvm {
20namespace dwarfdump {
21
22/// Holds cumulative section sizes for an object file.
23struct SectionSizes {
24 /// Map of .debug section names and their sizes across all such-named
25 /// sections.
Fangrui Song5b280f52021-02-25 20:05:05 -080026 MapVector<std::string, uint64_t, StringMap<uint64_t>> DebugSectionSizes;
Fangrui Songdd214542020-04-09 18:23:39 -070027 /// 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.
34void calculateSectionSizes(const object::ObjectFile &Obj, SectionSizes &Sizes,
35 const Twine &Filename);
36
37bool collectStatsForObjectFile(object::ObjectFile &Obj, DWARFContext &DICtx,
38 const Twine &Filename, raw_ostream &OS);
39bool collectObjectSectionSizes(object::ObjectFile &Obj, DWARFContext &DICtx,
40 const Twine &Filename, raw_ostream &OS);
41
42} // namespace dwarfdump
43} // namespace llvm
44
45#endif