From 08a77271364725fb9e83f937f59eb723baaa70b5 Mon Sep 17 00:00:00 2001 From: brandonvu12 Date: Wed, 29 Jun 2022 20:24:13 +0000 Subject: [PATCH 01/10] Preserving size information, including the old and new binaries in diff mode --- src/bloaty.cc | 103 ++++++++++++++++++++++++++------------ src/bloaty.h | 21 ++++++-- tests/bloaty_misc_test.cc | 6 +-- tests/bloaty_test.cc | 60 +++++++++++----------- tests/test.h | 22 ++++---- 5 files changed, 133 insertions(+), 79 deletions(-) diff --git a/src/bloaty.cc b/src/bloaty.cc index 3dbc924b..f0b2f1ff 100644 --- a/src/bloaty.cc +++ b/src/bloaty.cc @@ -274,10 +274,10 @@ class Rollup { void CreateDiffModeRollupOutput(Rollup* base, const Options& options, RollupOutput* output) const { RollupRow* row = &output->toplevel_row_; - row->vmsize = vm_total_; - row->filesize = file_total_; - row->filtered_vmsize = filtered_vm_total_; - row->filtered_filesize = filtered_file_total_; + row->size.vm = vm_total_; + row->size.file = file_total_; + row->filtered_size.vm = filtered_vm_total_; + row->filtered_size.file = filtered_file_total_; row->vmpercent = 100; row->filepercent = 100; output->diff_mode_ = true; @@ -413,11 +413,41 @@ void Rollup::CreateRows(RollupRow* row, const Rollup* base, } for (const auto& value : children_) { - if (value.second->vm_total_ != 0 || value.second->file_total_ != 0) { + int64_t vm_total = value.second->vm_total_; + int64_t file_total = value.second->file_total_; + Rollup* base_child = nullptr; + + if (base) { + // Reassign sizes to base during a diff to compare to target sizes. + auto it = base->children_.find(value.first); + if (it != base->children_.end()) { + base_child = it->second.get(); + vm_total -= base_child->vm_total_; + file_total -= base_child->file_total_; + } + } + + if (vm_total != 0 || file_total != 0) { row->sorted_children.emplace_back(value.first); RollupRow& child_row = row->sorted_children.back(); - child_row.vmsize = value.second->vm_total_; - child_row.filesize = value.second->file_total_; + child_row.size.vm = vm_total; + child_row.size.file = file_total; + + // Preserve the old and new sizes for this label in the RollupRow output. + // If there is a diff base, the old sizes come from the size of the label + // in that base. Otherwise, the old size is the same as the new (current) + // size. + if (base_child) { + child_row.old_size.vm = base_child->vm_total_; + child_row.old_size.file = base_child->file_total_; + child_row.new_size.vm = value.second->vm_total_; + child_row.new_size.file = value.second->file_total_; + } else { + child_row.old_size.vm = child_row.size.vm; + child_row.old_size.file = child_row.size.file; + child_row.new_size.vm = child_row.size.vm; + child_row.new_size.file = child_row.size.file; + } } } @@ -452,14 +482,14 @@ void Rollup::SortAndAggregateRows(RollupRow* row, const Rollup* base, for (auto& child : child_rows) { switch (options.sort_by()) { case Options::SORTBY_VMSIZE: - child.sortkey = std::abs(child.vmsize); + child.sortkey = std::abs(child.size.vm); break; case Options::SORTBY_FILESIZE: - child.sortkey = std::abs(child.filesize); + child.sortkey = std::abs(child.size.file); break; case Options::SORTBY_BOTH: child.sortkey = - std::max(std::abs(child.vmsize), std::abs(child.filesize)); + std::max(std::abs(child.size.vm), std::abs(child.size.file)); break; default: BLOATY_UNREACHABLE(); @@ -478,8 +508,8 @@ void Rollup::SortAndAggregateRows(RollupRow* row, const Rollup* base, // out to "others_row". size_t i = child_rows.size() - 1; while (i >= options.max_rows_per_level()) { - CheckedAdd(&others_row.vmsize, child_rows[i].vmsize); - CheckedAdd(&others_row.filesize, child_rows[i].filesize); + CheckedAdd(&others_row.size.vm, child_rows[i].size.vm); + CheckedAdd(&others_row.size.file, child_rows[i].size.file); if (base) { auto it = base->children_.find(child_rows[i].name); if (it != base->children_.end()) { @@ -492,26 +522,26 @@ void Rollup::SortAndAggregateRows(RollupRow* row, const Rollup* base, i--; } - if (std::abs(others_row.vmsize) > 0 || std::abs(others_row.filesize) > 0) { + if (std::abs(others_row.size.vm) > 0 || std::abs(others_row.size.file) > 0) { child_rows.push_back(others_row); - CheckedAdd(&others_rollup.vm_total_, others_row.vmsize); - CheckedAdd(&others_rollup.file_total_, others_row.filesize); + CheckedAdd(&others_rollup.vm_total_, others_row.size.vm); + CheckedAdd(&others_rollup.file_total_, others_row.size.file); } // Now sort by actual value (positive or negative). for (auto& child : child_rows) { switch (options.sort_by()) { case Options::SORTBY_VMSIZE: - child.sortkey = child.vmsize; + child.sortkey = child.size.vm; break; case Options::SORTBY_FILESIZE: - child.sortkey = child.filesize; + child.sortkey = child.size.file; break; case Options::SORTBY_BOTH: - if (std::abs(child.vmsize) > std::abs(child.filesize)) { - child.sortkey = child.vmsize; + if (std::abs(child.size.vm) > std::abs(child.size.file)) { + child.sortkey = child.size.vm; } else { - child.sortkey = child.filesize; + child.sortkey = child.size.file; } break; default: @@ -524,8 +554,8 @@ void Rollup::SortAndAggregateRows(RollupRow* row, const Rollup* base, // For a non-diff, the percentage is compared to the total size of the parent. if (!base) { for (auto& child_row : child_rows) { - child_row.vmpercent = Percent(child_row.vmsize, row->vmsize); - child_row.filepercent = Percent(child_row.filesize, row->filesize); + child_row.vmpercent = Percent(child_row.size.vm, row->size.vm); + child_row.filepercent = Percent(child_row.size.file, row->size.file); } } @@ -698,8 +728,8 @@ void RollupOutput::PrettyPrintRow(const RollupRow& row, size_t indent, if (&row != &toplevel_row_) { // Avoid printing this row if it is only zero. // This can happen when using --domain if the row is zero for this domain. - if ((!ShowFile(options) && row.vmsize == 0) || - (!ShowVM(options) && row.filesize == 0)) { + if ((!ShowFile(options) && row.size.vm == 0) || + (!ShowVM(options) && row.size.file == 0)) { return; } } @@ -708,12 +738,12 @@ void RollupOutput::PrettyPrintRow(const RollupRow& row, size_t indent, if (ShowFile(options)) { *out << PercentString(row.filepercent, diff_mode_) << " " - << SiPrint(row.filesize, diff_mode_) << " "; + << SiPrint(row.size.file, diff_mode_) << " "; } if (ShowVM(options)) { *out << PercentString(row.vmpercent, diff_mode_) << " " - << SiPrint(row.vmsize, diff_mode_) << " "; + << SiPrint(row.size.vm, diff_mode_) << " "; } *out << " " << row.name << "\n"; @@ -737,7 +767,7 @@ void RollupOutput::PrettyPrintTree(const RollupRow& row, size_t indent, // Rows are printed before their sub-rows. PrettyPrintRow(row, indent, options, out); - if (!row.vmsize && !row.filesize) { + if (!row.size.vm && !row.size.file) { return; } @@ -783,11 +813,12 @@ void RollupOutput::PrettyPrint(const OutputOptions& options, uint64_t file_filtered = 0; uint64_t vm_filtered = 0; + uint64_t filtered = 0; if (ShowFile(options)) { - file_filtered = toplevel_row_.filtered_filesize; + filtered += toplevel_row_.filtered_size.file; } if (ShowVM(options)) { - vm_filtered = toplevel_row_.filtered_vmsize; + filtered += toplevel_row_.filtered_size.vm; } if (vm_filtered == 0 && file_filtered == 0) { @@ -816,8 +847,12 @@ void RollupOutput::PrintRowToCSV(const RollupRow& row, parent_labels.push_back(""); } - parent_labels.push_back(std::to_string(row.vmsize)); - parent_labels.push_back(std::to_string(row.filesize)); + parent_labels.push_back(std::to_string(row.size.vm)); + parent_labels.push_back(std::to_string(row.size.file)); + parent_labels.push_back(std::to_string(row.old_size.vm)); + parent_labels.push_back(std::to_string(row.old_size.file)); + parent_labels.push_back(std::to_string(row.new_size.vm)); + parent_labels.push_back(std::to_string(row.new_size.file)); std::string sep = tabs ? "\t" : ","; *out << absl::StrJoin(parent_labels, sep) << "\n"; @@ -845,6 +880,12 @@ void RollupOutput::PrintToCSV(std::ostream* out, bool tabs) const { std::vector names(source_names_); names.push_back("vmsize"); names.push_back("filesize"); + names.push_back("vmcapacity"); + names.push_back("filecapacity"); + names.push_back("original_vmsize"); + names.push_back("original_filesize"); + names.push_back("current_vmsize"); + names.push_back("current_filesize"); std::string sep = tabs ? "\t" : ","; *out << absl::StrJoin(names, sep) << "\n"; for (const auto& child_row : toplevel_row_.sorted_children) { diff --git a/src/bloaty.h b/src/bloaty.h index 82c0c55c..14550869 100644 --- a/src/bloaty.h +++ b/src/bloaty.h @@ -337,18 +337,31 @@ void DisassembleFindReferences(const DisassemblyInfo& info, RangeSink* sink); class Rollup; +struct DomainSizes { + int64_t vm; + int64_t file; +}; + struct RollupRow { RollupRow(const std::string& name_) : name(name_) {} std::string name; - int64_t vmsize = 0; - int64_t filesize = 0; - int64_t filtered_vmsize = 0; - int64_t filtered_filesize = 0; + DomainSizes size = {0, 0}; + DomainSizes filtered_size = {0, 0}; + int64_t other_count = 0; int64_t sortkey; double vmpercent; double filepercent; + + // The size of this row in a diff base. Same as `size` for non-diff. + DomainSizes old_size = {0, 0}; + // The current size of this row (this is not the same as `size` in the case + // of a diff -- `size` is the delta). + DomainSizes new_size = {0, 0}; + + DomainSizes capacity = {0, 0}; + std::vector sorted_children; static bool Compare(const RollupRow& a, const RollupRow& b) { diff --git a/tests/bloaty_misc_test.cc b/tests/bloaty_misc_test.cc index 3a4bf41c..a1d50843 100644 --- a/tests/bloaty_misc_test.cc +++ b/tests/bloaty_misc_test.cc @@ -27,7 +27,7 @@ TEST_F(BloatyTest, InlinesOnSmallFile) { {"bloaty", "-d", "compileunits", "03-small-binary-that-crashed-inlines.bin"}); RunBloaty( {"bloaty", "-d", "inlines", "03-small-binary-that-crashed-inlines.bin"}); - EXPECT_EQ(top_row_->vmsize, 2340); + EXPECT_EQ(top_row_->size.vm, 2340); } TEST_F(BloatyTest, GoBinary) { @@ -46,7 +46,7 @@ TEST_F(BloatyTest, ImplicitConstAndLineStrp) { TEST_F(BloatyTest, MultiThreaded) { RunBloaty({"bloaty", "02-section-count-overflow.o"}); - size_t file_size = top_row_->filesize; + size_t file_size = top_row_->size.file; // Bloaty doesn't know or care that you are passing the same file multiple // times. @@ -56,5 +56,5 @@ TEST_F(BloatyTest, MultiThreaded) { args.push_back("02-section-count-overflow.o"); } RunBloaty(args); // Heavily multithreaded test. - EXPECT_EQ(top_row_->filesize, file_size * 100); + EXPECT_EQ(top_row_->size.file, file_size * 100); } diff --git a/tests/bloaty_test.cc b/tests/bloaty_test.cc index 8187aca3..68eb9df4 100644 --- a/tests/bloaty_test.cc +++ b/tests/bloaty_test.cc @@ -21,20 +21,20 @@ TEST_F(BloatyTest, EmptyObjectFile) { // Empty .c file should result in a .o file with no vmsize. RunBloaty({"bloaty", file}); - EXPECT_EQ(top_row_->vmsize, 0); - EXPECT_EQ(top_row_->filesize, size); + EXPECT_EQ(top_row_->size.vm, 0); + EXPECT_EQ(top_row_->size.file, size); EXPECT_GT(top_row_->sorted_children.size(), 1); // Same with segments (we fake segments on .o files). RunBloaty({"bloaty", "-d", "segments", file}); - EXPECT_EQ(top_row_->vmsize, 0); - EXPECT_EQ(top_row_->filesize, size); + EXPECT_EQ(top_row_->size.vm, 0); + EXPECT_EQ(top_row_->size.file, size); EXPECT_GT(top_row_->sorted_children.size(), 1); // Same with symbols. RunBloaty({"bloaty", "-d", "symbols", file}); - EXPECT_EQ(top_row_->vmsize, 0); - EXPECT_EQ(top_row_->filesize, size); + EXPECT_EQ(top_row_->size.vm, 0); + EXPECT_EQ(top_row_->size.file, size); EXPECT_GT(top_row_->sorted_children.size(), 1); // We can't run any of these targets against object files. @@ -50,16 +50,16 @@ TEST_F(BloatyTest, SimpleObjectFile) { // Test "-n 0" which should return an unlimited number of rows. RunBloaty({"bloaty", "-n", "0", file}); - EXPECT_GT(top_row_->vmsize, 64); - EXPECT_LT(top_row_->vmsize, 300); - EXPECT_EQ(top_row_->filesize, size); + EXPECT_GT(top_row_->size.vm, 64); + EXPECT_LT(top_row_->size.vm, 300); + EXPECT_EQ(top_row_->size.file, size); EXPECT_GT(top_row_->sorted_children.size(), 1); // Same with segments (we fake segments on .o files). RunBloaty({"bloaty", "-d", "segments", file}); - EXPECT_GT(top_row_->vmsize, 64); - EXPECT_LT(top_row_->vmsize, 300); - EXPECT_EQ(top_row_->filesize, size); + EXPECT_GT(top_row_->size.vm, 64); + EXPECT_LT(top_row_->size.vm, 300); + EXPECT_EQ(top_row_->size.file, size); EXPECT_GT(top_row_->sorted_children.size(), 1); // For inputfiles we should get everything attributed to the input file. @@ -111,15 +111,15 @@ TEST_F(BloatyTest, SimpleArchiveFile) { ASSERT_TRUE(GetFileSize(file, &size)); RunBloaty({"bloaty", file}); - EXPECT_GT(top_row_->vmsize, 8000); - EXPECT_LT(top_row_->vmsize, 12000); - //EXPECT_EQ(top_row_->filesize, size); + EXPECT_GT(top_row_->size.vm, 8000); + EXPECT_LT(top_row_->size.vm, 12000); + //EXPECT_EQ(top_row_->size.file, size); EXPECT_GT(top_row_->sorted_children.size(), 3); RunBloaty({"bloaty", "-d", "segments", file}); - EXPECT_GT(top_row_->vmsize, 8000); - EXPECT_LT(top_row_->vmsize, 12000); - //EXPECT_EQ(top_row_->filesize, size); + EXPECT_GT(top_row_->size.vm, 8000); + EXPECT_LT(top_row_->size.vm, 12000); + //EXPECT_EQ(top_row_->size.file, size); RunBloaty({"bloaty", "-d", "symbols", "-n", "40", "-s", "vm", file}); AssertChildren(*top_row_, { @@ -174,15 +174,15 @@ TEST_F(BloatyTest, SimpleSharedObjectFile) { ASSERT_TRUE(GetFileSize(file, &size)); RunBloaty({"bloaty", file}); - EXPECT_GT(top_row_->vmsize, 8000); - EXPECT_LT(top_row_->vmsize, 12000); - EXPECT_EQ(top_row_->filesize, size); + EXPECT_GT(top_row_->size.vm, 8000); + EXPECT_LT(top_row_->size.vm, 12000); + EXPECT_EQ(top_row_->size.file, size); EXPECT_GT(top_row_->sorted_children.size(), 3); RunBloaty({"bloaty", "-d", "segments", file}); - EXPECT_GT(top_row_->vmsize, 8000); - EXPECT_LT(top_row_->vmsize, 12000); - EXPECT_EQ(top_row_->filesize, size); + EXPECT_GT(top_row_->size.vm, 8000); + EXPECT_LT(top_row_->size.vm, 12000); + EXPECT_EQ(top_row_->size.file, size); RunBloaty({"bloaty", "-d", "symbols", "-n", "50", file}); AssertChildren(*top_row_, { @@ -199,15 +199,15 @@ TEST_F(BloatyTest, SimpleBinary) { ASSERT_TRUE(GetFileSize(file, &size)); RunBloaty({"bloaty", file}); - EXPECT_GT(top_row_->vmsize, 8000); - EXPECT_LT(top_row_->vmsize, 12000); - EXPECT_EQ(top_row_->filesize, size); + EXPECT_GT(top_row_->size.vm, 8000); + EXPECT_LT(top_row_->size.vm, 12000); + EXPECT_EQ(top_row_->size.file, size); EXPECT_GT(top_row_->sorted_children.size(), 3); RunBloaty({"bloaty", "-d", "segments", file}); - EXPECT_GT(top_row_->vmsize, 8000); - EXPECT_LT(top_row_->vmsize, 12000); - EXPECT_EQ(top_row_->filesize, size); + EXPECT_GT(top_row_->size.vm, 8000); + EXPECT_LT(top_row_->size.vm, 12000); + EXPECT_EQ(top_row_->size.file, size); RunBloaty({"bloaty", "-d", "symbols", "-n", "50", "-s", "vm", file}); AssertChildren(*top_row_, { diff --git a/tests/test.h b/tests/test.h index dc864f0a..99517d73 100644 --- a/tests/test.h +++ b/tests/test.h @@ -81,16 +81,16 @@ class BloatyTest : public ::testing::Test { uint64_t vmtotal = 0; uint64_t filetotal = 0; for (const auto& child : row.sorted_children) { - vmtotal += child.vmsize; - filetotal += child.filesize; + vmtotal += child.size.vm; + filetotal += child.size.file; CheckConsistencyForRow(child, false, diff_mode, count); ASSERT_TRUE(names.insert(child.name).second); - ASSERT_FALSE(child.vmsize == 0 && child.filesize == 0); + ASSERT_FALSE(child.size.vm == 0 && child.size.file == 0); } if (!diff_mode) { - ASSERT_EQ(vmtotal, row.vmsize); - ASSERT_EQ(filetotal, row.filesize); + ASSERT_EQ(vmtotal, row.size.vm); + ASSERT_EQ(filetotal, row.size.file); } } else { // Count leaf rows. @@ -147,7 +147,7 @@ class BloatyTest : public ::testing::Test { ASSERT_TRUE(GetFileSize(filename, &size)); total_input_size += size; } - ASSERT_EQ(top_row_->filesize, total_input_size); + ASSERT_EQ(top_row_->size.file, total_input_size); } int rows = 0; @@ -248,21 +248,21 @@ class BloatyTest : public ::testing::Test { if (expected_vm == kUnknown) { // Always pass. } else if (expected_vm > 0) { - EXPECT_GE(child.vmsize, expected_vm); + EXPECT_GE(child.size.vm, expected_vm); // Allow some overhead. - EXPECT_LE(child.vmsize, (expected_vm * 1.1) + 100); + EXPECT_LE(child.size.vm, (expected_vm * 1.1) + 100); } else { ASSERT_TRUE(false); } if (expected_file == kSameAsVM) { - expected_file = child.vmsize; + expected_file = child.size.vm; } if (expected_file != kUnknown) { - EXPECT_GE(child.filesize, expected_file); + EXPECT_GE(child.size.file, expected_file); // Allow some overhead. - EXPECT_LE(child.filesize, (expected_file * 1.2) + 180); + EXPECT_LE(child.size.file, (expected_file * 1.2) + 180); } if (++i == children.size()) { From eb6dac31bd4272c459a0f928496558fcbbea3373 Mon Sep 17 00:00:00 2001 From: brandonvu12 Date: Wed, 6 Jul 2022 23:30:21 +0000 Subject: [PATCH 02/10] Remove Subtract() and fix comments. --- src/bloaty.cc | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/bloaty.cc b/src/bloaty.cc index f0b2f1ff..d156bcd7 100644 --- a/src/bloaty.cc +++ b/src/bloaty.cc @@ -288,20 +288,6 @@ class Rollup { filter_regex_ = regex; } - // Subtract the values in "other" from this. - void Subtract(const Rollup& other) { - vm_total_ -= other.vm_total_; - file_total_ -= other.file_total_; - - for (const auto& other_child : other.children_) { - auto& child = children_[other_child.first]; - if (child.get() == NULL) { - child.reset(new Rollup()); - } - child->Subtract(*other_child.second); - } - } - // Add the values in "other" from this. void Add(const Rollup& other) { vm_total_ += other.vm_total_; From 7c5547aeac42917c0d58e19b77332cd07f122a02 Mon Sep 17 00:00:00 2001 From: brandonvu12 Date: Fri, 8 Jul 2022 22:05:15 +0000 Subject: [PATCH 03/10] Add AddEntriesFrom() to keep labels if they exist in only one binary --- src/bloaty.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/bloaty.cc b/src/bloaty.cc index d156bcd7..2b30a8a4 100644 --- a/src/bloaty.cc +++ b/src/bloaty.cc @@ -302,6 +302,18 @@ class Rollup { } } + // Create entries for all children which exist in "other" but not in this. + void AddEntriesFrom(const Rollup& other) { + for (const auto& other_child : other.children_) { + auto& child = children_[other_child.first]; + if (child.get() == NULL) { + child.reset(new Rollup()); + } + child->AddEntriesFrom(*other_child.second); + } + } + + int64_t file_total() const { return file_total_; } int64_t filtered_file_total() const { return filtered_file_total_; } @@ -1865,7 +1877,7 @@ void Bloaty::ScanAndRollup(const Options& options, RollupOutput* output) { base_filenames.push_back(file_info.filename_); } ScanAndRollupFiles(base_filenames, &build_ids, &base); - rollup.Subtract(base); + rollup.AddEntriesFrom(base); rollup.CreateDiffModeRollupOutput(&base, options, output); } else { rollup.CreateRollupOutput(options, output); From e80acc5c5d7501bd1289f25cf45e42e6deb6669b Mon Sep 17 00:00:00 2001 From: brandonvu12 Date: Fri, 8 Jul 2022 22:08:19 +0000 Subject: [PATCH 04/10] Remove capacity variables from csv. --- src/bloaty.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/bloaty.cc b/src/bloaty.cc index 2b30a8a4..f49fb6e1 100644 --- a/src/bloaty.cc +++ b/src/bloaty.cc @@ -878,8 +878,6 @@ void RollupOutput::PrintToCSV(std::ostream* out, bool tabs) const { std::vector names(source_names_); names.push_back("vmsize"); names.push_back("filesize"); - names.push_back("vmcapacity"); - names.push_back("filecapacity"); names.push_back("original_vmsize"); names.push_back("original_filesize"); names.push_back("current_vmsize"); From 9c91a5f7a45842b738b0eddbb1fb3706fc56dc0f Mon Sep 17 00:00:00 2001 From: brandonvu12 Date: Tue, 12 Jul 2022 17:17:15 +0000 Subject: [PATCH 05/10] Remove Capacity variable. --- src/bloaty.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/bloaty.h b/src/bloaty.h index 14550869..8cb98ec7 100644 --- a/src/bloaty.h +++ b/src/bloaty.h @@ -357,10 +357,8 @@ struct RollupRow { // The size of this row in a diff base. Same as `size` for non-diff. DomainSizes old_size = {0, 0}; // The current size of this row (this is not the same as `size` in the case - // of a diff -- `size` is the delta). + // of a diff -- `size` is the delta). -1 if non-diff. DomainSizes new_size = {0, 0}; - - DomainSizes capacity = {0, 0}; std::vector sorted_children; From 5a53d5ba49979395ca01b610501a503c90203fc6 Mon Sep 17 00:00:00 2001 From: brandonvu12 Date: Tue, 12 Jul 2022 17:25:43 +0000 Subject: [PATCH 06/10] Remove Comment. --- src/bloaty.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bloaty.h b/src/bloaty.h index 8cb98ec7..68abb704 100644 --- a/src/bloaty.h +++ b/src/bloaty.h @@ -357,7 +357,7 @@ struct RollupRow { // The size of this row in a diff base. Same as `size` for non-diff. DomainSizes old_size = {0, 0}; // The current size of this row (this is not the same as `size` in the case - // of a diff -- `size` is the delta). -1 if non-diff. + // of a diff -- `size` is the delta). DomainSizes new_size = {0, 0}; std::vector sorted_children; From 5ab4f4e61316e68eb0f6e6b06c5d5388691bbd7a Mon Sep 17 00:00:00 2001 From: brandonvu12 Date: Tue, 12 Jul 2022 21:58:21 +0000 Subject: [PATCH 07/10] Remove new_size variable and derive values by adding diff size to base size. --- src/bloaty.cc | 29 +++++++++++++++-------------- src/bloaty.h | 5 +---- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/bloaty.cc b/src/bloaty.cc index f49fb6e1..a9f02e5c 100644 --- a/src/bloaty.cc +++ b/src/bloaty.cc @@ -431,21 +431,13 @@ void Rollup::CreateRows(RollupRow* row, const Rollup* base, child_row.size.vm = vm_total; child_row.size.file = file_total; - // Preserve the old and new sizes for this label in the RollupRow output. + // Preserve the old size for this label in the RollupRow output. // If there is a diff base, the old sizes come from the size of the label - // in that base. Otherwise, the old size is the same as the new (current) - // size. + // in that base. Otherwise, the old size stays 0. if (base_child) { child_row.old_size.vm = base_child->vm_total_; child_row.old_size.file = base_child->file_total_; - child_row.new_size.vm = value.second->vm_total_; - child_row.new_size.file = value.second->file_total_; - } else { - child_row.old_size.vm = child_row.size.vm; - child_row.old_size.file = child_row.size.file; - child_row.new_size.vm = child_row.size.vm; - child_row.new_size.file = child_row.size.file; - } + } } } @@ -847,10 +839,19 @@ void RollupOutput::PrintRowToCSV(const RollupRow& row, parent_labels.push_back(std::to_string(row.size.vm)); parent_labels.push_back(std::to_string(row.size.file)); + + // If in diff where both old size are 0, get new size by adding diff size to old size. parent_labels.push_back(std::to_string(row.old_size.vm)); - parent_labels.push_back(std::to_string(row.old_size.file)); - parent_labels.push_back(std::to_string(row.new_size.vm)); - parent_labels.push_back(std::to_string(row.new_size.file)); + parent_labels.push_back(std::to_string(row.old_size.file)); + if (row.old_size.vm != 0 && row.old_size.file != 0){ + parent_labels.push_back(std::to_string(row.old_size.vm + (row.size.vm))); + parent_labels.push_back(std::to_string(row.old_size.file + (row.size.file))); + } else { + parent_labels.push_back(std::to_string(0)); + parent_labels.push_back(std::to_string(0)); + } + + std::string sep = tabs ? "\t" : ","; *out << absl::StrJoin(parent_labels, sep) << "\n"; diff --git a/src/bloaty.h b/src/bloaty.h index 68abb704..f3a6c336 100644 --- a/src/bloaty.h +++ b/src/bloaty.h @@ -354,11 +354,8 @@ struct RollupRow { double vmpercent; double filepercent; - // The size of this row in a diff base. Same as `size` for non-diff. + // The size of the base in a diff mode. Otherwise stay 0. DomainSizes old_size = {0, 0}; - // The current size of this row (this is not the same as `size` in the case - // of a diff -- `size` is the delta). - DomainSizes new_size = {0, 0}; std::vector sorted_children; From c033212aed3e916804420dfcff333b321b2148ee Mon Sep 17 00:00:00 2001 From: brandonvu12 Date: Tue, 19 Jul 2022 23:07:50 +0000 Subject: [PATCH 08/10] Adjust tests for new CSV output. --- tests/test.h | 11 ++++++++++- .../x64/msvc-15.0-foo-bar-main-cv.bin.seg.txt | 18 +++++++++--------- .../PE/x64/msvc-15.0-foo-bar-main-cv.bin.txt | 18 +++++++++--------- .../PE/x64/msvc-15.0-foo-bar.dll.seg.txt | 18 +++++++++--------- .../testdata/PE/x64/msvc-15.0-foo-bar.dll.txt | 18 +++++++++--------- .../x64/msvc-16.0-foo-bar-main-cv.bin.seg.txt | 18 +++++++++--------- .../PE/x64/msvc-16.0-foo-bar-main-cv.bin.txt | 18 +++++++++--------- .../PE/x64/msvc-16.0-foo-bar.dll.seg.txt | 18 +++++++++--------- .../testdata/PE/x64/msvc-16.0-foo-bar.dll.txt | 18 +++++++++--------- .../x86/msvc-15.0-foo-bar-main-cv.bin.seg.txt | 16 ++++++++-------- .../PE/x86/msvc-15.0-foo-bar-main-cv.bin.txt | 16 ++++++++-------- .../PE/x86/msvc-15.0-foo-bar.dll.seg.txt | 16 ++++++++-------- .../testdata/PE/x86/msvc-15.0-foo-bar.dll.txt | 16 ++++++++-------- .../x86/msvc-16.0-foo-bar-main-cv.bin.seg.txt | 16 ++++++++-------- .../PE/x86/msvc-16.0-foo-bar-main-cv.bin.txt | 16 ++++++++-------- .../PE/x86/msvc-16.0-foo-bar.dll.seg.txt | 16 ++++++++-------- .../testdata/PE/x86/msvc-16.0-foo-bar.dll.txt | 16 ++++++++-------- tests/testdata/make_all_msvc_test_files.bat | 0 18 files changed, 146 insertions(+), 137 deletions(-) mode change 100644 => 100755 tests/testdata/make_all_msvc_test_files.bat diff --git a/tests/test.h b/tests/test.h index 99517d73..84aaff7b 100644 --- a/tests/test.h +++ b/tests/test.h @@ -125,14 +125,23 @@ class BloatyTest : public ::testing::Test { std::vector expected_headers(output_->source_names()); expected_headers.push_back("vmsize"); expected_headers.push_back("filesize"); + expected_headers.push_back("original_vmsize"); + expected_headers.push_back("original_filesize"); + expected_headers.push_back("current_vmsize"); + expected_headers.push_back("current_filesize"); ASSERT_EQ(cols, expected_headers); first = false; } else { // Final two columns should parse as integer. int out; - ASSERT_EQ(output_->source_names().size() + 2, cols.size()); + ASSERT_EQ(output_->source_names().size() + 6, cols.size()); ASSERT_TRUE(absl::SimpleAtoi(cols[cols.size() - 1], &out)); ASSERT_TRUE(absl::SimpleAtoi(cols[cols.size() - 2], &out)); + ASSERT_TRUE(absl::SimpleAtoi(cols[cols.size() - 3], &out)); + ASSERT_TRUE(absl::SimpleAtoi(cols[cols.size() - 4], &out)); + ASSERT_TRUE(absl::SimpleAtoi(cols[cols.size() - 5], &out)); + ASSERT_TRUE(absl::SimpleAtoi(cols[cols.size() - 6], &out)); + } } } diff --git a/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.seg.txt b/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.seg.txt index 5f1154b4..6794dcca 100644 --- a/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.seg.txt +++ b/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.seg.txt @@ -1,9 +1,9 @@ -segments vmsize filesize -.rdata 7840 8192 -.data 5608 512 -.text 5000 5120 -.pdata 552 1024 -.reloc 40 512 -[PE Headers] 496 496 -[Unmapped] 0 328 -[PE Section Headers] 200 200 +segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.rdata 7840 8192 0 0 0 0 +.data 5608 512 0 0 0 0 +.text 5000 5120 0 0 0 0 +.pdata 552 1024 0 0 0 0 +.reloc 40 512 0 0 0 0 +[PE Headers] 496 496 0 0 0 0 +[Unmapped] 0 328 0 0 0 0 +[PE Section Headers] 200 200 0 0 0 0 diff --git a/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.txt b/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.txt index 1b8f6584..beb592f7 100644 --- a/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.txt +++ b/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.txt @@ -1,9 +1,9 @@ -sections vmsize filesize -.rdata 7840 8192 -.data 5608 512 -.text 5000 5120 -.pdata 552 1024 -.reloc 40 512 -[PE Headers] 496 496 -[Unmapped] 0 328 -[PE Section Headers] 200 200 +sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.rdata 7840 8192 0 0 0 0 +.data 5608 512 0 0 0 0 +.text 5000 5120 0 0 0 0 +.pdata 552 1024 0 0 0 0 +.reloc 40 512 0 0 0 0 +[PE Headers] 496 496 0 0 0 0 +[Unmapped] 0 328 0 0 0 0 +[PE Section Headers] 200 200 0 0 0 0 diff --git a/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.seg.txt b/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.seg.txt index ee173f57..8cb7e7e0 100644 --- a/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.seg.txt +++ b/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.seg.txt @@ -1,9 +1,9 @@ -segments vmsize filesize -.text 3587 4096 -.rdata 2520 2560 -.data 1592 512 -.pdata 408 512 -.reloc 24 512 -[PE Headers] 496 496 -[Unmapped] 0 328 -[PE Section Headers] 200 200 +segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.text 3587 4096 0 0 0 0 +.rdata 2520 2560 0 0 0 0 +.data 1592 512 0 0 0 0 +.pdata 408 512 0 0 0 0 +.reloc 24 512 0 0 0 0 +[PE Headers] 496 496 0 0 0 0 +[Unmapped] 0 328 0 0 0 0 +[PE Section Headers] 200 200 0 0 0 0 diff --git a/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.txt b/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.txt index 11af42e7..baa58d93 100644 --- a/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.txt +++ b/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.txt @@ -1,9 +1,9 @@ -sections vmsize filesize -.text 3587 4096 -.rdata 2520 2560 -.data 1592 512 -.pdata 408 512 -.reloc 24 512 -[PE Headers] 496 496 -[Unmapped] 0 328 -[PE Section Headers] 200 200 +sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.text 3587 4096 0 0 0 0 +.rdata 2520 2560 0 0 0 0 +.data 1592 512 0 0 0 0 +.pdata 408 512 0 0 0 0 +.reloc 24 512 0 0 0 0 +[PE Headers] 496 496 0 0 0 0 +[Unmapped] 0 328 0 0 0 0 +[PE Section Headers] 200 200 0 0 0 0 \ No newline at end of file diff --git a/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.seg.txt b/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.seg.txt index 377693de..b91c4f64 100644 --- a/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.seg.txt +++ b/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.seg.txt @@ -1,9 +1,9 @@ -segments vmsize filesize -.rdata 8236 8704 -.text 5340 5632 -.data 5624 512 -.pdata 588 1024 -.reloc 52 512 -[PE Headers] 496 496 -[Unmapped] 0 328 -[PE Section Headers] 200 200 +segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.rdata 8236 8704 0 0 0 0 +.text 5340 5632 0 0 0 0 +.data 5624 512 0 0 0 0 +.pdata 588 1024 0 0 0 0 +.reloc 52 512 0 0 0 0 +[PE Headers] 496 496 0 0 0 0 +[Unmapped] 0 328 0 0 0 0 +[PE Section Headers] 200 200 0 0 0 0 diff --git a/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.txt b/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.txt index 25daf299..d3e8c044 100644 --- a/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.txt +++ b/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.txt @@ -1,9 +1,9 @@ -sections vmsize filesize -.rdata 8236 8704 -.text 5340 5632 -.data 5624 512 -.pdata 588 1024 -.reloc 52 512 -[PE Headers] 496 496 -[Unmapped] 0 328 -[PE Section Headers] 200 200 +sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.rdata 8236 8704 0 0 0 0 +.text 5340 5632 0 0 0 0 +.data 5624 512 0 0 0 0 +.pdata 588 1024 0 0 0 0 +.reloc 52 512 0 0 0 0 +[PE Headers] 496 496 0 0 0 0 +[Unmapped] 0 328 0 0 0 0 +[PE Section Headers] 200 200 0 0 0 0 \ No newline at end of file diff --git a/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.seg.txt b/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.seg.txt index 31b77481..3b2070ab 100644 --- a/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.seg.txt +++ b/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.seg.txt @@ -1,9 +1,9 @@ -segments vmsize filesize -.text 3592 4096 -.rdata 2680 3072 -.data 1608 512 -.pdata 432 512 -.reloc 36 512 -[PE Headers] 496 496 -[Unmapped] 0 328 -[PE Section Headers] 200 200 +segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.text 3592 4096 0 0 0 0 +.rdata 2680 3072 0 0 0 0 +.data 1608 512 0 0 0 0 +.pdata 432 512 0 0 0 0 +.reloc 36 512 0 0 0 0 +[PE Headers] 496 496 0 0 0 0 +[Unmapped] 0 328 0 0 0 0 +[PE Section Headers] 200 200 0 0 0 0 diff --git a/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.txt b/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.txt index 62886687..92aa9d23 100644 --- a/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.txt +++ b/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.txt @@ -1,9 +1,9 @@ -sections vmsize filesize -.text 3592 4096 -.rdata 2680 3072 -.data 1608 512 -.pdata 432 512 -.reloc 36 512 -[PE Headers] 496 496 -[Unmapped] 0 328 -[PE Section Headers] 200 200 +sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.text 3592 4096 0 0 0 0 +.rdata 2680 3072 0 0 0 0 +.data 1608 512 0 0 0 0 +.pdata 432 512 0 0 0 0 +.reloc 36 512 0 0 0 0 +[PE Headers] 496 496 0 0 0 0 +[Unmapped] 0 328 0 0 0 0 +[PE Section Headers] 200 200 0 0 0 0 diff --git a/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.seg.txt b/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.seg.txt index 083c52df..f28f0468 100644 --- a/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.seg.txt +++ b/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.seg.txt @@ -1,8 +1,8 @@ -segments vmsize filesize -.rdata 6724 7168 -.data 4912 512 -.text 4268 4608 -.reloc 488 512 -[PE Headers] 480 480 -[Unmapped] 0 384 -[PE Section Headers] 160 160 +segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.rdata 6724 7168 0 0 0 0 +.data 4912 512 0 0 0 0 +.text 4268 4608 0 0 0 0 +.reloc 488 512 0 0 0 0 +[PE Headers] 480 480 0 0 0 0 +[Unmapped] 0 384 0 0 0 0 +[PE Section Headers] 160 160 0 0 0 0 diff --git a/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.txt b/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.txt index 901a9acb..2c4ec600 100644 --- a/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.txt +++ b/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.txt @@ -1,8 +1,8 @@ -sections vmsize filesize -.rdata 6724 7168 -.data 4912 512 -.text 4268 4608 -.reloc 488 512 -[PE Headers] 480 480 -[Unmapped] 0 384 -[PE Section Headers] 160 160 +sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.rdata 6724 7168 0 0 0 0 +.data 4912 512 0 0 0 0 +.text 4268 4608 0 0 0 0 +.reloc 488 512 0 0 0 0 +[PE Headers] 480 480 0 0 0 0 +[Unmapped] 0 384 0 0 0 0 +[PE Section Headers] 160 160 0 0 0 0 diff --git a/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.seg.txt b/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.seg.txt index c1ab74f5..ee1713c2 100644 --- a/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.seg.txt +++ b/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.seg.txt @@ -1,8 +1,8 @@ -segments vmsize filesize -.text 3172 3584 -.rdata 1772 2048 -.data 908 512 -.reloc 296 512 -[PE Headers] 496 496 -[Unmapped] 0 368 -[PE Section Headers] 160 160 +segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.text 3172 3584 0 0 0 0 +.rdata 1772 2048 0 0 0 0 +.data 908 512 0 0 0 0 +.reloc 296 512 0 0 0 0 +[PE Headers] 496 496 0 0 0 0 +[Unmapped] 0 368 0 0 0 0 +[PE Section Headers] 160 160 0 0 0 0 diff --git a/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.txt b/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.txt index 06076357..4dbcdccf 100644 --- a/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.txt +++ b/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.txt @@ -1,8 +1,8 @@ -sections vmsize filesize -.text 3172 3584 -.rdata 1772 2048 -.data 908 512 -.reloc 296 512 -[PE Headers] 496 496 -[Unmapped] 0 368 -[PE Section Headers] 160 160 +sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.text 3172 3584 0 0 0 0 +.rdata 1772 2048 0 0 0 0 +.data 908 512 0 0 0 0 +.reloc 296 512 0 0 0 0 +[PE Headers] 496 496 0 0 0 0 +[Unmapped] 0 368 0 0 0 0 +[PE Section Headers] 160 160 0 0 0 0 diff --git a/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.seg.txt b/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.seg.txt index 7906bb38..e4ba3554 100644 --- a/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.seg.txt +++ b/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.seg.txt @@ -1,8 +1,8 @@ -segments vmsize filesize -.rdata 6944 7168 -.text 4716 5120 -.data 4912 512 -.reloc 544 1024 -[PE Headers] 488 488 -[Unmapped] 0 376 -[PE Section Headers] 160 160 +segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.rdata 6944 7168 0 0 0 0 +.text 4716 5120 0 0 0 0 +.data 4912 512 0 0 0 0 +.reloc 544 1024 0 0 0 0 +[PE Headers] 488 488 0 0 0 0 +[Unmapped] 0 376 0 0 0 0 +[PE Section Headers] 160 160 0 0 0 0 diff --git a/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.txt b/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.txt index 7973262e..22a39975 100644 --- a/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.txt +++ b/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.txt @@ -1,8 +1,8 @@ -sections vmsize filesize -.rdata 6944 7168 -.text 4716 5120 -.data 4912 512 -.reloc 544 1024 -[PE Headers] 488 488 -[Unmapped] 0 376 -[PE Section Headers] 160 160 +sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.rdata 6944 7168 0 0 0 0 +.text 4716 5120 0 0 0 0 +.data 4912 512 0 0 0 0 +.reloc 544 1024 0 0 0 0 +[PE Headers] 488 488 0 0 0 0 +[Unmapped] 0 376 0 0 0 0 +[PE Section Headers] 160 160 0 0 0 0 diff --git a/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.seg.txt b/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.seg.txt index bd99c583..b899fe46 100644 --- a/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.seg.txt +++ b/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.seg.txt @@ -1,8 +1,8 @@ -segments vmsize filesize -.text 3360 3584 -.rdata 1812 2048 -.data 912 512 -.reloc 312 512 -[PE Headers] 488 488 -[Unmapped] 0 376 -[PE Section Headers] 160 160 +segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.text 3360 3584 0 0 0 0 +.rdata 1812 2048 0 0 0 0 +.data 912 512 0 0 0 0 +.reloc 312 512 0 0 0 0 +[PE Headers] 488 488 0 0 0 0 +[Unmapped] 0 376 0 0 0 0 +[PE Section Headers] 160 160 0 0 0 0 diff --git a/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.txt b/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.txt index 6c5ff2a1..7e20f991 100644 --- a/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.txt +++ b/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.txt @@ -1,8 +1,8 @@ -sections vmsize filesize -.text 3360 3584 -.rdata 1812 2048 -.data 912 512 -.reloc 312 512 -[PE Headers] 488 488 -[Unmapped] 0 376 -[PE Section Headers] 160 160 +sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize +.text 3360 3584 0 0 0 0 +.rdata 1812 2048 0 0 0 0 +.data 912 512 0 0 0 0 +.reloc 312 512 0 0 0 0 +[PE Headers] 488 488 0 0 0 0 +[Unmapped] 0 376 0 0 0 0 +[PE Section Headers] 160 160 0 0 0 0 diff --git a/tests/testdata/make_all_msvc_test_files.bat b/tests/testdata/make_all_msvc_test_files.bat old mode 100644 new mode 100755 From 0baf6f53430ea2d2c891763106254b088fe57082 Mon Sep 17 00:00:00 2001 From: brandonvu12 Date: Tue, 19 Jul 2022 23:09:57 +0000 Subject: [PATCH 09/10] Change comment for six columns. --- tests/test.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.h b/tests/test.h index 84aaff7b..84248c57 100644 --- a/tests/test.h +++ b/tests/test.h @@ -132,7 +132,7 @@ class BloatyTest : public ::testing::Test { ASSERT_EQ(cols, expected_headers); first = false; } else { - // Final two columns should parse as integer. + // Final six columns should parse as integer. int out; ASSERT_EQ(output_->source_names().size() + 6, cols.size()); ASSERT_TRUE(absl::SimpleAtoi(cols[cols.size() - 1], &out)); From fe3b1145eeb976a18bd0318905b9f8f622a9db0a Mon Sep 17 00:00:00 2001 From: brandonvu12 Date: Wed, 20 Jul 2022 17:34:14 +0000 Subject: [PATCH 10/10] Add in flag to show new/old file sizes when running diff and restore single binary testing txt files. --- src/bloaty.cc | 207 +++++++++--------- src/bloaty.h | 7 +- tests/test.h | 13 +- .../x64/msvc-15.0-foo-bar-main-cv.bin.seg.txt | 18 +- .../PE/x64/msvc-15.0-foo-bar-main-cv.bin.txt | 18 +- .../PE/x64/msvc-15.0-foo-bar.dll.seg.txt | 18 +- .../testdata/PE/x64/msvc-15.0-foo-bar.dll.txt | 18 +- .../x64/msvc-16.0-foo-bar-main-cv.bin.seg.txt | 18 +- .../PE/x64/msvc-16.0-foo-bar-main-cv.bin.txt | 18 +- .../PE/x64/msvc-16.0-foo-bar.dll.seg.txt | 18 +- .../testdata/PE/x64/msvc-16.0-foo-bar.dll.txt | 18 +- .../x86/msvc-15.0-foo-bar-main-cv.bin.seg.txt | 16 +- .../PE/x86/msvc-15.0-foo-bar-main-cv.bin.txt | 16 +- .../PE/x86/msvc-15.0-foo-bar.dll.seg.txt | 16 +- .../testdata/PE/x86/msvc-15.0-foo-bar.dll.txt | 16 +- .../x86/msvc-16.0-foo-bar-main-cv.bin.seg.txt | 16 +- .../PE/x86/msvc-16.0-foo-bar-main-cv.bin.txt | 16 +- .../PE/x86/msvc-16.0-foo-bar.dll.seg.txt | 16 +- .../testdata/PE/x86/msvc-16.0-foo-bar.dll.txt | 16 +- 19 files changed, 243 insertions(+), 256 deletions(-) diff --git a/src/bloaty.cc b/src/bloaty.cc index a9f02e5c..200c6b4f 100644 --- a/src/bloaty.cc +++ b/src/bloaty.cc @@ -18,6 +18,12 @@ // It's very hard to figure out why. For the moment this seems to fix it, // but ideally we'd have a better solution here. typedef size_t z_size_t; +#include +#include +#include +#include +#include +#include #include #include @@ -33,13 +39,6 @@ typedef size_t z_size_t; #include #include #include - -#include -#include -#include -#include -#include -#include #if !defined(_WIN32) #include #include @@ -53,14 +52,13 @@ typedef size_t z_size_t; #include "absl/debugging/internal/demangle.h" #include "absl/memory/memory.h" #include "absl/strings/numbers.h" -#include "absl/strings/string_view.h" #include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" #include "absl/strings/substitute.h" -#include "google/protobuf/io/zero_copy_stream_impl.h" -#include "google/protobuf/text_format.h" - #include "bloaty.h" #include "bloaty.pb.h" +#include "google/protobuf/io/zero_copy_stream_impl.h" +#include "google/protobuf/text_format.h" #include "re.h" #include "util.h" @@ -187,8 +185,7 @@ std::string ItaniumDemangle(string_view symbol, DataSource source) { return std::string(symbol); } } else if (source == DataSource::kFullSymbols) { - char* demangled = - __cxa_demangle(demangle_from.data(), NULL, NULL, NULL); + char* demangled = __cxa_demangle(demangle_from.data(), NULL, NULL, NULL); if (demangled) { std::string ret(demangled); free(demangled); @@ -202,10 +199,10 @@ std::string ItaniumDemangle(string_view symbol, DataSource source) { } } - // NameMunger ////////////////////////////////////////////////////////////////// -void NameMunger::AddRegex(const std::string& regex, const std::string& replacement) { +void NameMunger::AddRegex(const std::string& regex, + const std::string& replacement) { auto reg = absl::make_unique(regex); regexes_.push_back(std::make_pair(std::move(reg), replacement)); } @@ -223,7 +220,6 @@ std::string NameMunger::Munge(string_view name) const { return name_str; } - // Rollup ////////////////////////////////////////////////////////////////////// // A Rollup is a hierarchical tally of sizes. Its graphical representation is @@ -259,8 +255,8 @@ class Rollup { Rollup(Rollup&& other) = default; Rollup& operator=(Rollup&& other) = default; - void AddSizes(const std::vector& names, - uint64_t size, bool is_vmsize) { + void AddSizes(const std::vector& names, uint64_t size, + bool is_vmsize) { // We start at 1 to exclude the base map (see base_map_). AddInternal(names, 1, size, is_vmsize); } @@ -284,9 +280,7 @@ class Rollup { CreateRows(row, base, options, true); } - void SetFilterRegex(const ReImpl* regex) { - filter_regex_ = regex; - } + void SetFilterRegex(const ReImpl* regex) { filter_regex_ = regex; } // Add the values in "other" from this. void Add(const Rollup& other) { @@ -313,7 +307,6 @@ class Rollup { } } - int64_t file_total() const { return file_total_; } int64_t filtered_file_total() const { return filtered_file_total_; } @@ -437,7 +430,7 @@ void Rollup::CreateRows(RollupRow* row, const Rollup* base, if (base_child) { child_row.old_size.vm = base_child->vm_total_; child_row.old_size.file = base_child->file_total_; - } + } } } @@ -581,7 +574,6 @@ void Rollup::SortAndAggregateRows(RollupRow* row, const Rollup* base, } } - // RollupOutput //////////////////////////////////////////////////////////////// // RollupOutput represents rollup data after we have applied output massaging @@ -620,14 +612,14 @@ std::string LeftPad(const std::string& input, size_t size) { return ret; } -std::string DoubleStringPrintf(const char *fmt, double d) { +std::string DoubleStringPrintf(const char* fmt, double d) { char buf[1024]; snprintf(buf, sizeof(buf), fmt, d); return std::string(buf); } std::string SiPrint(int64_t size, bool force_sign) { - const char *prefixes[] = {"", "Ki", "Mi", "Gi", "Ti"}; + const char* prefixes[] = {"", "Ki", "Mi", "Gi", "Ti"}; size_t num_prefixes = 5; size_t n = 0; double size_d = size; @@ -697,10 +689,10 @@ void RollupOutput::Print(const OutputOptions& options, std::ostream* out) { PrettyPrint(options, out); break; case bloaty::OutputFormat::kCSV: - PrintToCSV(out, /*tabs=*/false); + PrintToCSV(out, /*tabs=*/false, options.showAllSizesCSV); break; case bloaty::OutputFormat::kTSV: - PrintToCSV(out, /*tabs=*/true); + PrintToCSV(out, /*tabs=*/true, options.showAllSizesCSV); break; default: BLOATY_UNREACHABLE(); @@ -826,12 +818,12 @@ void RollupOutput::PrettyPrint(const OutputOptions& options, *out << SiPrint(vm_filtered, /*force_sign=*/false); } - *out << " of entries\n"; + *out << " of entries\n"; } void RollupOutput::PrintRowToCSV(const RollupRow& row, std::vector parent_labels, - std::ostream* out, bool tabs) const { + std::ostream* out, bool tabs, bool csvDiff) const { while (parent_labels.size() < source_names_.size()) { // If this label had no data at this level, append an empty string. parent_labels.push_back(""); @@ -840,18 +832,14 @@ void RollupOutput::PrintRowToCSV(const RollupRow& row, parent_labels.push_back(std::to_string(row.size.vm)); parent_labels.push_back(std::to_string(row.size.file)); - // If in diff where both old size are 0, get new size by adding diff size to old size. - parent_labels.push_back(std::to_string(row.old_size.vm)); - parent_labels.push_back(std::to_string(row.old_size.file)); - if (row.old_size.vm != 0 && row.old_size.file != 0){ - parent_labels.push_back(std::to_string(row.old_size.vm + (row.size.vm))); - parent_labels.push_back(std::to_string(row.old_size.file + (row.size.file))); - } else { - parent_labels.push_back(std::to_string(0)); - parent_labels.push_back(std::to_string(0)); - } - - + // If in diff where both old size are 0, get new size by adding diff size to + // old size. + if (csvDiff) { + parent_labels.push_back(std::to_string(row.old_size.vm)); + parent_labels.push_back(std::to_string(row.old_size.file)); + parent_labels.push_back(std::to_string(row.old_size.vm + (row.size.vm))); + parent_labels.push_back( + std::to_string(row.old_size.file + (row.size.file)));} std::string sep = tabs ? "\t" : ","; *out << absl::StrJoin(parent_labels, sep) << "\n"; @@ -859,7 +847,7 @@ void RollupOutput::PrintRowToCSV(const RollupRow& row, void RollupOutput::PrintTreeToCSV(const RollupRow& row, std::vector parent_labels, - std::ostream* out, bool tabs) const { + std::ostream* out, bool tabs, bool csvDiff) const { if (tabs) { parent_labels.push_back(row.name); } else { @@ -868,25 +856,28 @@ void RollupOutput::PrintTreeToCSV(const RollupRow& row, if (row.sorted_children.size() > 0) { for (const auto& child_row : row.sorted_children) { - PrintTreeToCSV(child_row, parent_labels, out, tabs); + PrintTreeToCSV(child_row, parent_labels, out, tabs, csvDiff); } } else { - PrintRowToCSV(row, parent_labels, out, tabs); + PrintRowToCSV(row, parent_labels, out, tabs, csvDiff); } } -void RollupOutput::PrintToCSV(std::ostream* out, bool tabs) const { +void RollupOutput::PrintToCSV(std::ostream* out, bool tabs, + bool csvDiff) const { std::vector names(source_names_); names.push_back("vmsize"); names.push_back("filesize"); - names.push_back("original_vmsize"); - names.push_back("original_filesize"); - names.push_back("current_vmsize"); - names.push_back("current_filesize"); + if (csvDiff) { + names.push_back("original_vmsize"); + names.push_back("original_filesize"); + names.push_back("current_vmsize"); + names.push_back("current_filesize"); + } std::string sep = tabs ? "\t" : ","; *out << absl::StrJoin(names, sep) << "\n"; for (const auto& child_row : toplevel_row_.sorted_children) { - PrintTreeToCSV(child_row, std::vector(), out, tabs); + PrintTreeToCSV(child_row, std::vector(), out, tabs, csvDiff); } } @@ -894,7 +885,6 @@ void RollupOutput::PrintToCSV(std::ostream* out, bool tabs) const { constexpr uint64_t RangeSink::kUnknownSize; - // MmapInputFile /////////////////////////////////////////////////////////////// #if !defined(_WIN32) @@ -913,7 +903,6 @@ class MmapInputFile : public InputFile { std::unique_ptr& file); }; - class FileDescriptor { public: FileDescriptor(int fd) : fd_(fd) {} @@ -935,7 +924,7 @@ bool MmapInputFile::DoTryOpen(absl::string_view filename, std::string str(filename); FileDescriptor fd(open(str.c_str(), O_RDONLY)); struct stat buf; - const char *map; + const char* map; if (fd.fd() < 0) { std::cerr << absl::Substitute("couldn't open file '$0': $1\n", filename, @@ -983,7 +972,7 @@ std::unique_ptr MmapInputFileFactory::OpenFile( return ret; } -#else // !_WIN32 +#else // !_WIN32 // MmapInputFile /////////////////////////////////////////////////////////////// @@ -1027,9 +1016,9 @@ Win32MMapInputFile::Win32MMapInputFile(string_view filename, string_view data) bool Win32MMapInputFile::DoTryOpen(absl::string_view filename, std::unique_ptr& file) { std::string str(filename); - Win32Handle fd(::CreateFileA(str.c_str(), FILE_GENERIC_READ, - FILE_SHARE_READ, NULL, OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, NULL)); + Win32Handle fd(::CreateFileA(str.c_str(), FILE_GENERIC_READ, FILE_SHARE_READ, + NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, + NULL)); LARGE_INTEGER li = {}; const char* map; @@ -1084,11 +1073,14 @@ std::unique_ptr MmapInputFileFactory::OpenFile( // RangeSink /////////////////////////////////////////////////////////////////// -RangeSink::RangeSink(const InputFile *file, const Options &options, - DataSource data_source, const DualMap *translator, - google::protobuf::Arena *arena) - : file_(file), options_(options), data_source_(data_source), - translator_(translator), arena_(arena) {} +RangeSink::RangeSink(const InputFile* file, const Options& options, + DataSource data_source, const DualMap* translator, + google::protobuf::Arena* arena) + : file_(file), + options_(options), + data_source_(data_source), + translator_(translator), + arena_(arena) {} RangeSink::~RangeSink() {} @@ -1384,21 +1376,23 @@ absl::string_view RangeSink::ZlibDecompress(absl::string_view data, } uint64_t mb = 1 << 20; // Limit for uncompressed size is 30x the compressed size + 128MB. - if (uncompressed_size > static_cast(data.size()) * 30 + (128 * mb)) { + if (uncompressed_size > + static_cast(data.size()) * 30 + (128 * mb)) { fprintf(stderr, "warning: ignoring compressed debug data, implausible uncompressed " "size (compressed: %zu, uncompressed: %" PRIu64 ")\n", data.size(), uncompressed_size); return absl::string_view(); } - unsigned char *dbuf = + unsigned char* dbuf = arena_->google::protobuf::Arena::CreateArray( arena_, uncompressed_size); uLongf zliblen = uncompressed_size; - if (uncompress(dbuf, &zliblen, (unsigned char*)(data.data()), data.size()) != Z_OK) { + if (uncompress(dbuf, &zliblen, (unsigned char*)(data.data()), data.size()) != + Z_OK) { THROW("Error decompressing debug info"); } - string_view sv(reinterpret_cast(dbuf), zliblen); + string_view sv(reinterpret_cast(dbuf), zliblen); return sv; } @@ -1441,7 +1435,6 @@ class ThreadSafeIterIndex { const int max_; }; - // Bloaty ////////////////////////////////////////////////////////////////////// // Represents a program execution and associated state. @@ -1539,8 +1532,9 @@ class Bloaty { std::unique_ptr arena_; }; -Bloaty::Bloaty(const InputFileFactory &factory, const Options &options) - : file_factory_(factory), options_(options), +Bloaty::Bloaty(const InputFileFactory& factory, const Options& options) + : file_factory_(factory), + options_(options), arena_(std::make_unique()) { AddBuiltInSources(data_sources, options); } @@ -1601,8 +1595,10 @@ void Bloaty::DefineCustomDataSource(const CustomDataSource& source) { auto iter = all_known_sources_.find(source.base_data_source()); if (iter == all_known_sources_.end()) { - THROWF("custom data source '$0': no such base source '$1'.\nTry --list-sources to see valid sources.", source.name(), - source.base_data_source()); + THROWF( + "custom data source '$0': no such base source '$1'.\nTry " + "--list-sources to see valid sources.", + source.name(), source.base_data_source()); } else if (!iter->second->munger->IsEmpty()) { THROWF("custom data source '$0' tries to depend on custom data source '$1'", source.name(), source.base_data_source()); @@ -1620,7 +1616,8 @@ void Bloaty::AddDataSource(const std::string& name) { source_names_.emplace_back(name); auto it = all_known_sources_.find(name); if (it == all_known_sources_.end()) { - THROWF("no such data source: $0.\nTry --list-sources to see valid sources.", name); + THROWF("no such data source: $0.\nTry --list-sources to see valid sources.", + name); } sources_.emplace_back(it->second.get()); @@ -1687,7 +1684,8 @@ struct DualMaps { return ret; } - void PrintMapRow(string_view str, uint64_t start, uint64_t end, int hex_digits) { + void PrintMapRow(string_view str, uint64_t start, uint64_t end, + int hex_digits) { printf("%.*" PRIx64 "-%.*" PRIx64 "\t %s\t\t%.*s\n", hex_digits, start, hex_digits, end, LeftPad(std::to_string(end - start), 10).c_str(), (int)str.size(), str.data()); @@ -1715,7 +1713,7 @@ struct DualMaps { std::vector> maps_; }; -void Bloaty::ScanAndRollupFile(const std::string &filename, Rollup* rollup, +void Bloaty::ScanAndRollupFile(const std::string& filename, Rollup* rollup, std::vector* out_build_ids) const { auto file = GetObjectFile(filename); @@ -1732,9 +1730,9 @@ void Bloaty::ScanAndRollupFile(const std::string &filename, Rollup* rollup, sink_ptrs.push_back(sinks.back().get()); for (auto source : sources_) { - sinks.push_back(absl::make_unique(&file->file_data(), options_, - source->effective_source, - maps.base_map(), arena_.get())); + sinks.push_back(absl::make_unique( + &file->file_data(), options_, source->effective_source, maps.base_map(), + arena_.get())); sinks.back()->AddOutput(maps.AppendMap(), source->munger.get()); // We handle the kInputFiles data source internally, without handing it off // to the file format implementation. This seems slightly simpler, since @@ -1757,8 +1755,8 @@ void Bloaty::ScanAndRollupFile(const std::string &filename, Rollup* rollup, } } - int64_t filesize_before = rollup->file_total() + - rollup->filtered_file_total(); + int64_t filesize_before = + rollup->file_total() + rollup->filtered_file_total(); file->ProcessFile(sink_ptrs); // kInputFile source: Copy the base map to the filename sink(s). @@ -1778,8 +1776,8 @@ void Bloaty::ScanAndRollupFile(const std::string &filename, Rollup* rollup, maps.ComputeRollup(rollup); // The ObjectFile implementation must guarantee this. - int64_t filesize = rollup->file_total() + - rollup->filtered_file_total() - filesize_before; + int64_t filesize = + rollup->file_total() + rollup->filtered_file_total() - filesize_before; (void)filesize; assert(filesize == file->file_data().data().size()); @@ -1796,10 +1794,9 @@ void Bloaty::ScanAndRollupFile(const std::string &filename, Rollup* rollup, } } -void Bloaty::ScanAndRollupFiles( - const std::vector& filenames, - std::vector* build_ids, - Rollup * rollup) const { +void Bloaty::ScanAndRollupFiles(const std::vector& filenames, + std::vector* build_ids, + Rollup* rollup) const { int num_cpus = std::thread::hardware_concurrency(); int num_threads = std::min(num_cpus, static_cast(filenames.size())); @@ -1820,16 +1817,18 @@ void Bloaty::ScanAndRollupFiles( for (int i = 0; i < num_threads; i++) { thread_data[i].rollup.SetFilterRegex(regex.get()); - threads[i] = std::thread([this, &index, &filenames](PerThreadData* data) { - try { - int j; - while (index.TryGetNext(&j)) { - ScanAndRollupFile(filenames[j], &data->rollup, &data->build_ids); - } - } catch (const bloaty::Error& e) { - index.Abort(e.what()); - } - }, &thread_data[i]); + threads[i] = std::thread( + [this, &index, &filenames](PerThreadData* data) { + try { + int j; + while (index.TryGetNext(&j)) { + ScanAndRollupFile(filenames[j], &data->rollup, &data->build_ids); + } + } catch (const bloaty::Error& e) { + index.Abort(e.what()); + } + }, + &thread_data[i]); } for (int i = 0; i < num_threads; i++) { @@ -1841,8 +1840,7 @@ void Bloaty::ScanAndRollupFiles( rollup->Add(data->rollup); } - build_ids->insert(build_ids->end(), - data->build_ids.begin(), + build_ids->insert(build_ids->end(), data->build_ids.begin(), data->build_ids.end()); } @@ -1892,8 +1890,7 @@ void Bloaty::ScanAndRollup(const Options& options, RollupOutput* output) { std::string unused_debug; for (const auto& pair : debug_files_) { unused_debug += absl::Substitute( - "$0 $1\n", - absl::BytesToHexString(pair.first).c_str(), + "$0 $1\n", absl::BytesToHexString(pair.first).c_str(), pair.second.c_str()); } @@ -1907,9 +1904,8 @@ void Bloaty::ScanAndRollup(const Options& options, RollupOutput* output) { "$0 $1\n", absl::BytesToHexString(file_info.build_id_).c_str(), file_info.filename_.c_str()); } - THROWF( - "Debug file(s) did not match any input file:\n$0\nInput Files:\n$1", - unused_debug.c_str(), input_files.c_str()); + THROWF("Debug file(s) did not match any input file:\n$0\nInput Files:\n$1", + unused_debug.c_str(), input_files.c_str()); } } @@ -1999,9 +1995,7 @@ class ArgParser { return ret; } - void ConsumeAndSaveArg() { - (*out_argv_)[(*out_argc_)++] = argv_[index_++]; - } + void ConsumeAndSaveArg() { (*out_argv_)[(*out_argc_)++] = argv_[index_++]; } // Singular flag like --csv or -v. bool TryParseFlag(string_view flag) { @@ -2192,6 +2186,7 @@ bool DoParseOptions(bool skip_unknown, int* argc, char** argv[], } } else { if (saw_separator) { + output_options->showAllSizesCSV = true; options->add_base_filename(std::string(args.ConsumeArg())); } else { options->add_filename(std::string(args.ConsumeArg())); diff --git a/src/bloaty.h b/src/bloaty.h index f3a6c336..5f8d4700 100644 --- a/src/bloaty.h +++ b/src/bloaty.h @@ -385,6 +385,7 @@ struct OutputOptions { OutputFormat output_format = OutputFormat::kPrettyPrint; size_t max_label_len = 80; ShowDomain show = ShowDomain::kShowBoth; + bool showAllSizesCSV = false; }; struct RollupOutput { @@ -421,17 +422,17 @@ struct RollupOutput { static bool IsSame(const std::string& a, const std::string& b); void PrettyPrint(const OutputOptions& options, std::ostream* out) const; - void PrintToCSV(std::ostream* out, bool tabs) const; + void PrintToCSV(std::ostream* out, bool tabs, bool csvDiff) const; void PrettyPrintRow(const RollupRow& row, size_t indent, const OutputOptions& options, std::ostream* out) const; void PrettyPrintTree(const RollupRow& row, size_t indent, const OutputOptions& options, std::ostream* out) const; void PrintRowToCSV(const RollupRow& row, std::vector parent_labels, - std::ostream* out, bool tabs) const; + std::ostream* out, bool tabs, bool csvDiff) const; void PrintTreeToCSV(const RollupRow& row, std::vector parent_labels, - std::ostream* out, bool tabs) const; + std::ostream* out, bool tabs, bool csvDiff) const; }; bool ParseOptions(bool skip_unknown, int* argc, char** argv[], Options* options, diff --git a/tests/test.h b/tests/test.h index 84248c57..99517d73 100644 --- a/tests/test.h +++ b/tests/test.h @@ -125,23 +125,14 @@ class BloatyTest : public ::testing::Test { std::vector expected_headers(output_->source_names()); expected_headers.push_back("vmsize"); expected_headers.push_back("filesize"); - expected_headers.push_back("original_vmsize"); - expected_headers.push_back("original_filesize"); - expected_headers.push_back("current_vmsize"); - expected_headers.push_back("current_filesize"); ASSERT_EQ(cols, expected_headers); first = false; } else { - // Final six columns should parse as integer. + // Final two columns should parse as integer. int out; - ASSERT_EQ(output_->source_names().size() + 6, cols.size()); + ASSERT_EQ(output_->source_names().size() + 2, cols.size()); ASSERT_TRUE(absl::SimpleAtoi(cols[cols.size() - 1], &out)); ASSERT_TRUE(absl::SimpleAtoi(cols[cols.size() - 2], &out)); - ASSERT_TRUE(absl::SimpleAtoi(cols[cols.size() - 3], &out)); - ASSERT_TRUE(absl::SimpleAtoi(cols[cols.size() - 4], &out)); - ASSERT_TRUE(absl::SimpleAtoi(cols[cols.size() - 5], &out)); - ASSERT_TRUE(absl::SimpleAtoi(cols[cols.size() - 6], &out)); - } } } diff --git a/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.seg.txt b/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.seg.txt index 6794dcca..5f1154b4 100644 --- a/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.seg.txt +++ b/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.seg.txt @@ -1,9 +1,9 @@ -segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.rdata 7840 8192 0 0 0 0 -.data 5608 512 0 0 0 0 -.text 5000 5120 0 0 0 0 -.pdata 552 1024 0 0 0 0 -.reloc 40 512 0 0 0 0 -[PE Headers] 496 496 0 0 0 0 -[Unmapped] 0 328 0 0 0 0 -[PE Section Headers] 200 200 0 0 0 0 +segments vmsize filesize +.rdata 7840 8192 +.data 5608 512 +.text 5000 5120 +.pdata 552 1024 +.reloc 40 512 +[PE Headers] 496 496 +[Unmapped] 0 328 +[PE Section Headers] 200 200 diff --git a/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.txt b/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.txt index beb592f7..1b8f6584 100644 --- a/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.txt +++ b/tests/testdata/PE/x64/msvc-15.0-foo-bar-main-cv.bin.txt @@ -1,9 +1,9 @@ -sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.rdata 7840 8192 0 0 0 0 -.data 5608 512 0 0 0 0 -.text 5000 5120 0 0 0 0 -.pdata 552 1024 0 0 0 0 -.reloc 40 512 0 0 0 0 -[PE Headers] 496 496 0 0 0 0 -[Unmapped] 0 328 0 0 0 0 -[PE Section Headers] 200 200 0 0 0 0 +sections vmsize filesize +.rdata 7840 8192 +.data 5608 512 +.text 5000 5120 +.pdata 552 1024 +.reloc 40 512 +[PE Headers] 496 496 +[Unmapped] 0 328 +[PE Section Headers] 200 200 diff --git a/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.seg.txt b/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.seg.txt index 8cb7e7e0..ee173f57 100644 --- a/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.seg.txt +++ b/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.seg.txt @@ -1,9 +1,9 @@ -segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.text 3587 4096 0 0 0 0 -.rdata 2520 2560 0 0 0 0 -.data 1592 512 0 0 0 0 -.pdata 408 512 0 0 0 0 -.reloc 24 512 0 0 0 0 -[PE Headers] 496 496 0 0 0 0 -[Unmapped] 0 328 0 0 0 0 -[PE Section Headers] 200 200 0 0 0 0 +segments vmsize filesize +.text 3587 4096 +.rdata 2520 2560 +.data 1592 512 +.pdata 408 512 +.reloc 24 512 +[PE Headers] 496 496 +[Unmapped] 0 328 +[PE Section Headers] 200 200 diff --git a/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.txt b/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.txt index baa58d93..11af42e7 100644 --- a/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.txt +++ b/tests/testdata/PE/x64/msvc-15.0-foo-bar.dll.txt @@ -1,9 +1,9 @@ -sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.text 3587 4096 0 0 0 0 -.rdata 2520 2560 0 0 0 0 -.data 1592 512 0 0 0 0 -.pdata 408 512 0 0 0 0 -.reloc 24 512 0 0 0 0 -[PE Headers] 496 496 0 0 0 0 -[Unmapped] 0 328 0 0 0 0 -[PE Section Headers] 200 200 0 0 0 0 \ No newline at end of file +sections vmsize filesize +.text 3587 4096 +.rdata 2520 2560 +.data 1592 512 +.pdata 408 512 +.reloc 24 512 +[PE Headers] 496 496 +[Unmapped] 0 328 +[PE Section Headers] 200 200 diff --git a/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.seg.txt b/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.seg.txt index b91c4f64..377693de 100644 --- a/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.seg.txt +++ b/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.seg.txt @@ -1,9 +1,9 @@ -segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.rdata 8236 8704 0 0 0 0 -.text 5340 5632 0 0 0 0 -.data 5624 512 0 0 0 0 -.pdata 588 1024 0 0 0 0 -.reloc 52 512 0 0 0 0 -[PE Headers] 496 496 0 0 0 0 -[Unmapped] 0 328 0 0 0 0 -[PE Section Headers] 200 200 0 0 0 0 +segments vmsize filesize +.rdata 8236 8704 +.text 5340 5632 +.data 5624 512 +.pdata 588 1024 +.reloc 52 512 +[PE Headers] 496 496 +[Unmapped] 0 328 +[PE Section Headers] 200 200 diff --git a/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.txt b/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.txt index d3e8c044..25daf299 100644 --- a/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.txt +++ b/tests/testdata/PE/x64/msvc-16.0-foo-bar-main-cv.bin.txt @@ -1,9 +1,9 @@ -sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.rdata 8236 8704 0 0 0 0 -.text 5340 5632 0 0 0 0 -.data 5624 512 0 0 0 0 -.pdata 588 1024 0 0 0 0 -.reloc 52 512 0 0 0 0 -[PE Headers] 496 496 0 0 0 0 -[Unmapped] 0 328 0 0 0 0 -[PE Section Headers] 200 200 0 0 0 0 \ No newline at end of file +sections vmsize filesize +.rdata 8236 8704 +.text 5340 5632 +.data 5624 512 +.pdata 588 1024 +.reloc 52 512 +[PE Headers] 496 496 +[Unmapped] 0 328 +[PE Section Headers] 200 200 diff --git a/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.seg.txt b/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.seg.txt index 3b2070ab..31b77481 100644 --- a/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.seg.txt +++ b/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.seg.txt @@ -1,9 +1,9 @@ -segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.text 3592 4096 0 0 0 0 -.rdata 2680 3072 0 0 0 0 -.data 1608 512 0 0 0 0 -.pdata 432 512 0 0 0 0 -.reloc 36 512 0 0 0 0 -[PE Headers] 496 496 0 0 0 0 -[Unmapped] 0 328 0 0 0 0 -[PE Section Headers] 200 200 0 0 0 0 +segments vmsize filesize +.text 3592 4096 +.rdata 2680 3072 +.data 1608 512 +.pdata 432 512 +.reloc 36 512 +[PE Headers] 496 496 +[Unmapped] 0 328 +[PE Section Headers] 200 200 diff --git a/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.txt b/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.txt index 92aa9d23..62886687 100644 --- a/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.txt +++ b/tests/testdata/PE/x64/msvc-16.0-foo-bar.dll.txt @@ -1,9 +1,9 @@ -sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.text 3592 4096 0 0 0 0 -.rdata 2680 3072 0 0 0 0 -.data 1608 512 0 0 0 0 -.pdata 432 512 0 0 0 0 -.reloc 36 512 0 0 0 0 -[PE Headers] 496 496 0 0 0 0 -[Unmapped] 0 328 0 0 0 0 -[PE Section Headers] 200 200 0 0 0 0 +sections vmsize filesize +.text 3592 4096 +.rdata 2680 3072 +.data 1608 512 +.pdata 432 512 +.reloc 36 512 +[PE Headers] 496 496 +[Unmapped] 0 328 +[PE Section Headers] 200 200 diff --git a/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.seg.txt b/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.seg.txt index f28f0468..083c52df 100644 --- a/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.seg.txt +++ b/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.seg.txt @@ -1,8 +1,8 @@ -segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.rdata 6724 7168 0 0 0 0 -.data 4912 512 0 0 0 0 -.text 4268 4608 0 0 0 0 -.reloc 488 512 0 0 0 0 -[PE Headers] 480 480 0 0 0 0 -[Unmapped] 0 384 0 0 0 0 -[PE Section Headers] 160 160 0 0 0 0 +segments vmsize filesize +.rdata 6724 7168 +.data 4912 512 +.text 4268 4608 +.reloc 488 512 +[PE Headers] 480 480 +[Unmapped] 0 384 +[PE Section Headers] 160 160 diff --git a/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.txt b/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.txt index 2c4ec600..901a9acb 100644 --- a/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.txt +++ b/tests/testdata/PE/x86/msvc-15.0-foo-bar-main-cv.bin.txt @@ -1,8 +1,8 @@ -sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.rdata 6724 7168 0 0 0 0 -.data 4912 512 0 0 0 0 -.text 4268 4608 0 0 0 0 -.reloc 488 512 0 0 0 0 -[PE Headers] 480 480 0 0 0 0 -[Unmapped] 0 384 0 0 0 0 -[PE Section Headers] 160 160 0 0 0 0 +sections vmsize filesize +.rdata 6724 7168 +.data 4912 512 +.text 4268 4608 +.reloc 488 512 +[PE Headers] 480 480 +[Unmapped] 0 384 +[PE Section Headers] 160 160 diff --git a/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.seg.txt b/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.seg.txt index ee1713c2..c1ab74f5 100644 --- a/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.seg.txt +++ b/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.seg.txt @@ -1,8 +1,8 @@ -segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.text 3172 3584 0 0 0 0 -.rdata 1772 2048 0 0 0 0 -.data 908 512 0 0 0 0 -.reloc 296 512 0 0 0 0 -[PE Headers] 496 496 0 0 0 0 -[Unmapped] 0 368 0 0 0 0 -[PE Section Headers] 160 160 0 0 0 0 +segments vmsize filesize +.text 3172 3584 +.rdata 1772 2048 +.data 908 512 +.reloc 296 512 +[PE Headers] 496 496 +[Unmapped] 0 368 +[PE Section Headers] 160 160 diff --git a/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.txt b/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.txt index 4dbcdccf..06076357 100644 --- a/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.txt +++ b/tests/testdata/PE/x86/msvc-15.0-foo-bar.dll.txt @@ -1,8 +1,8 @@ -sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.text 3172 3584 0 0 0 0 -.rdata 1772 2048 0 0 0 0 -.data 908 512 0 0 0 0 -.reloc 296 512 0 0 0 0 -[PE Headers] 496 496 0 0 0 0 -[Unmapped] 0 368 0 0 0 0 -[PE Section Headers] 160 160 0 0 0 0 +sections vmsize filesize +.text 3172 3584 +.rdata 1772 2048 +.data 908 512 +.reloc 296 512 +[PE Headers] 496 496 +[Unmapped] 0 368 +[PE Section Headers] 160 160 diff --git a/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.seg.txt b/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.seg.txt index e4ba3554..7906bb38 100644 --- a/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.seg.txt +++ b/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.seg.txt @@ -1,8 +1,8 @@ -segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.rdata 6944 7168 0 0 0 0 -.text 4716 5120 0 0 0 0 -.data 4912 512 0 0 0 0 -.reloc 544 1024 0 0 0 0 -[PE Headers] 488 488 0 0 0 0 -[Unmapped] 0 376 0 0 0 0 -[PE Section Headers] 160 160 0 0 0 0 +segments vmsize filesize +.rdata 6944 7168 +.text 4716 5120 +.data 4912 512 +.reloc 544 1024 +[PE Headers] 488 488 +[Unmapped] 0 376 +[PE Section Headers] 160 160 diff --git a/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.txt b/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.txt index 22a39975..7973262e 100644 --- a/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.txt +++ b/tests/testdata/PE/x86/msvc-16.0-foo-bar-main-cv.bin.txt @@ -1,8 +1,8 @@ -sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.rdata 6944 7168 0 0 0 0 -.text 4716 5120 0 0 0 0 -.data 4912 512 0 0 0 0 -.reloc 544 1024 0 0 0 0 -[PE Headers] 488 488 0 0 0 0 -[Unmapped] 0 376 0 0 0 0 -[PE Section Headers] 160 160 0 0 0 0 +sections vmsize filesize +.rdata 6944 7168 +.text 4716 5120 +.data 4912 512 +.reloc 544 1024 +[PE Headers] 488 488 +[Unmapped] 0 376 +[PE Section Headers] 160 160 diff --git a/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.seg.txt b/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.seg.txt index b899fe46..bd99c583 100644 --- a/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.seg.txt +++ b/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.seg.txt @@ -1,8 +1,8 @@ -segments vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.text 3360 3584 0 0 0 0 -.rdata 1812 2048 0 0 0 0 -.data 912 512 0 0 0 0 -.reloc 312 512 0 0 0 0 -[PE Headers] 488 488 0 0 0 0 -[Unmapped] 0 376 0 0 0 0 -[PE Section Headers] 160 160 0 0 0 0 +segments vmsize filesize +.text 3360 3584 +.rdata 1812 2048 +.data 912 512 +.reloc 312 512 +[PE Headers] 488 488 +[Unmapped] 0 376 +[PE Section Headers] 160 160 diff --git a/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.txt b/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.txt index 7e20f991..6c5ff2a1 100644 --- a/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.txt +++ b/tests/testdata/PE/x86/msvc-16.0-foo-bar.dll.txt @@ -1,8 +1,8 @@ -sections vmsize filesize original_vmsize original_filesize current_vmsize current_filesize -.text 3360 3584 0 0 0 0 -.rdata 1812 2048 0 0 0 0 -.data 912 512 0 0 0 0 -.reloc 312 512 0 0 0 0 -[PE Headers] 488 488 0 0 0 0 -[Unmapped] 0 376 0 0 0 0 -[PE Section Headers] 160 160 0 0 0 0 +sections vmsize filesize +.text 3360 3584 +.rdata 1812 2048 +.data 912 512 +.reloc 312 512 +[PE Headers] 488 488 +[Unmapped] 0 376 +[PE Section Headers] 160 160