Index: llvm/tools/llvm-dwarfdump/SectionsSizes.cpp =================================================================== --- llvm/tools/llvm-dwarfdump/SectionsSizes.cpp +++ llvm/tools/llvm-dwarfdump/SectionsSizes.cpp @@ -9,6 +9,7 @@ #include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/Object/ObjectFile.h" +#include "llvm/Support/Format.h" #include "llvm/Support/WithColor.h" #define DEBUG_TYPE "dwarfdump" @@ -41,21 +42,40 @@ raw_ostream &OS) { OS << "----------------------------------------------------" << "\n"; - OS << " SECTION \t\t" - << " SIZE" - << "\n"; - OS << "------------ \t\t ------------\n"; - - OS << " .debug_info \t\t " << Sizes.TotalDebugInfo << "\n"; - OS << " .debug_str \t\t " << Sizes.TotalDebugStr << "\n"; - OS << " .debug_abbrev \t\t " << Sizes.TotalDebugAbbrev << "\n"; - OS << " .debug_line \t\t " << Sizes.TotalDebugLine << "\n"; - OS << " .debug_ranges \t\t " << Sizes.TotalDebugRanges << "\n"; - OS << " .debug_loc \t\t " << Sizes.TotalDebugLoc << "\n\n"; - OS << " .debug_*: \t\t " << Sizes.TotalDebugSectionsSize << "\n"; + OS << " SECTION \t\t\t SIZE\n"; + OS << "------------ \t\t -----------------------\n"; + + OS << " .debug_info \t\t " << Sizes.TotalDebugInfo << " (" + << format("%0.2f", + Sizes.TotalDebugInfo / (double)Sizes.TotalObjectSize * 100) + << "%)\n"; + OS << " .debug_str \t\t " << Sizes.TotalDebugStr << " (" + << format("%0.2f", + Sizes.TotalDebugStr / (double)Sizes.TotalObjectSize * 100) + << "%)\n"; + OS << " .debug_abbrev \t\t " << Sizes.TotalDebugAbbrev << " (" + << format("%0.2f", + Sizes.TotalDebugAbbrev / (double)Sizes.TotalObjectSize * 100) + << "%)\n"; + OS << " .debug_line \t\t " << Sizes.TotalDebugLine << " (" + << format("%0.2f", + Sizes.TotalDebugLine / (double)Sizes.TotalObjectSize * 100) + << "%)\n"; + OS << " .debug_ranges \t\t " << Sizes.TotalDebugRanges << " (" + << format("%0.2f", + Sizes.TotalDebugRanges / (double)Sizes.TotalObjectSize * 100) + << "%)\n"; + OS << " .debug_loc \t\t " << Sizes.TotalDebugLoc << " (" + << format("%0.2f", + Sizes.TotalDebugLoc / (double)Sizes.TotalObjectSize * 100) + << "%)\n\n"; + OS << " .debug_*: \t\t " << Sizes.TotalDebugSectionsSize << " (" + << format("%0.2f", Sizes.TotalDebugSectionsSize / + (double)Sizes.TotalObjectSize * 100) + << "%)\n"; OS << "----------------------------------------------------" << "\n"; - OS << " TOTAL: " << Sizes.TotalObjectSize << "\n"; + OS << " TOTAL FILE SIZE: " << Sizes.TotalObjectSize << "\n"; OS << "----------------------------------------------------" << "\n"; }