aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
diff options
context:
space:
mode:
authorDjordje Todorovic <djordje.todorovic@syrmia.com>2020-04-02 10:58:27 +0200
committerDjordje Todorovic <djordje.todorovic@syrmia.com>2020-04-02 13:14:30 +0200
commit5e508b9bac05cef8c1f77a154f943183f97cd131 (patch)
treeb78ac52de4b0f9a961a5a497053bc149506f5a78 /llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
parentb02c7a81523f3a9d14f418e5453bd222127e780a (diff)
downloadllvm-5e508b9bac05cef8c1f77a154f943183f97cd131.zip
llvm-5e508b9bac05cef8c1f77a154f943183f97cd131.tar.gz
llvm-5e508b9bac05cef8c1f77a154f943183f97cd131.tar.bz2
[llvm-dwarfdump] Add the --show-sections-sizes option
Add an option to llvm-dwarfdump to calculate the bytes within the debug sections. Dump this numbers when using --statistics option as well. This is an initial patch (e.g. we should support other units, since we only support 'bytes' now). Differential Revision: https://reviews.llvm.org/D74205
Diffstat (limited to 'llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp')
-rw-r--r--llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index 28ede2e..e559de1 100644
--- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -208,6 +208,11 @@ static cl::opt<bool>
Statistics("statistics",
cl::desc("Emit JSON-formatted debug info quality metrics."),
cat(DwarfDumpCategory));
+static cl::opt<bool>
+ ShowSectionSizes("show-section-sizes",
+ cl::desc("Show the sizes of all debug sections, "
+ "expressed in bytes."),
+ cat(DwarfDumpCategory));
static opt<bool> Verify("verify", desc("Verify the DWARF debug info."),
cat(DwarfDumpCategory));
static opt<bool> Quiet("quiet", desc("Use with -verify to not emit to STDOUT."),
@@ -413,6 +418,9 @@ static bool lookup(ObjectFile &Obj, DWARFContext &DICtx, uint64_t Address,
bool collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
const Twine &Filename, raw_ostream &OS);
+bool collectObjectSectionSizes(ObjectFile &Obj, DWARFContext & /*DICtx*/,
+ const Twine &Filename, raw_ostream &OS);
+
static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
const Twine &Filename, raw_ostream &OS) {
logAllUnhandledErrors(DICtx.loadRegisterInfo(Obj), errs(),
@@ -635,12 +643,16 @@ int main(int argc, char **argv) {
return handleFile(Object, verifyObjectFile, OutputFile.os());
}))
return 1;
- } else if (Statistics)
+ } else if (Statistics) {
for (auto Object : Objects)
handleFile(Object, collectStatsForObjectFile, OutputFile.os());
- else
+ } else if (ShowSectionSizes) {
+ for (auto Object : Objects)
+ handleFile(Object, collectObjectSectionSizes, OutputFile.os());
+ } else {
for (auto Object : Objects)
handleFile(Object, dumpObjectFile, OutputFile.os());
+ }
return EXIT_SUCCESS;
}