[Lldb-commits] [lldb] [LLDB][Minidump] Add a progress bar to minidump (PR #108309)
Jacob Lalonde via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 12 09:38:17 PDT 2024
https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/108309
>From e7054832dc6e54d4b9f3ce86a8babd1f62cac81a Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Wed, 11 Sep 2024 13:33:44 -0700
Subject: [PATCH 1/3] Add Progress bar to minidump memory emission
---
.../Minidump/MinidumpFileBuilder.cpp | 18 ++++++++++++------
.../ObjectFile/Minidump/MinidumpFileBuilder.h | 7 ++++---
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index edc568a6b47e00..1765cc24721837 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -837,14 +837,16 @@ Status MinidumpFileBuilder::AddMemoryList() {
error = m_process_sp->CalculateCoreFileSaveRanges(m_save_core_options,
all_core_memory_ranges);
+ if (error.Fail())
+ return error;
+
+ lldb_private::Progress progress_tracker("Saving Minidump File", "", all_core_memory_ranges.GetSize());
std::vector<CoreFileMemoryRange> all_core_memory_vec;
// Extract all the data into just a vector of data. So we can mutate this in
// place.
for (const auto &core_range : all_core_memory_ranges)
all_core_memory_vec.push_back(core_range.data);
- if (error.Fail())
- return error;
// Start by saving all of the stacks and ensuring they fit under the 32b
// limit.
@@ -892,13 +894,13 @@ Status MinidumpFileBuilder::AddMemoryList() {
}
}
- error = AddMemoryList_32(ranges_32);
+ error = AddMemoryList_32(ranges_32, progress_tracker);
if (error.Fail())
return error;
// Add the remaining memory as a 64b range.
if (!ranges_64.empty()) {
- error = AddMemoryList_64(ranges_64);
+ error = AddMemoryList_64(ranges_64, progress_tracker);
if (error.Fail())
return error;
}
@@ -973,7 +975,7 @@ GetLargestRangeSize(const std::vector<CoreFileMemoryRange> &ranges) {
}
Status MinidumpFileBuilder::AddMemoryList_32(
- std::vector<CoreFileMemoryRange> &ranges) {
+ std::vector<CoreFileMemoryRange> &ranges, Progress &progressTracker) {
std::vector<MemoryDescriptor> descriptors;
Status error;
if (ranges.size() == 0)
@@ -1024,6 +1026,8 @@ Status MinidumpFileBuilder::AddMemoryList_32(
error = AddData(data_up->GetBytes(), bytes_read);
if (error.Fail())
return error;
+
+ progressTracker.Increment();
}
// Add a directory that references this list
@@ -1050,7 +1054,7 @@ Status MinidumpFileBuilder::AddMemoryList_32(
}
Status MinidumpFileBuilder::AddMemoryList_64(
- std::vector<CoreFileMemoryRange> &ranges) {
+ std::vector<CoreFileMemoryRange> &ranges, Progress &progressTracker) {
Status error;
if (ranges.empty())
return error;
@@ -1132,6 +1136,8 @@ Status MinidumpFileBuilder::AddMemoryList_64(
error = AddData(data_up->GetBytes(), bytes_read);
if (error.Fail())
return error;
+
+ progressTracker.Increment();
}
// Early return if there is no cleanup needed.
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
index 71001e26c00e91..77c5dba6cdf991 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
@@ -30,6 +30,7 @@
#include "lldb/Utility/Status.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-types.h"
+#include "lldb/Core/Progress.h"
#include "llvm/BinaryFormat/Minidump.h"
#include "llvm/Object/Minidump.h"
@@ -79,7 +80,7 @@ class MinidumpFileBuilder {
const lldb::ProcessSP &process_sp,
lldb_private::SaveCoreOptions &save_core_options)
: m_process_sp(process_sp), m_core_file(std::move(core_file)),
- m_save_core_options(save_core_options){}
+ m_save_core_options(save_core_options) {}
MinidumpFileBuilder(const MinidumpFileBuilder &) = delete;
MinidumpFileBuilder &operator=(const MinidumpFileBuilder &) = delete;
@@ -121,9 +122,9 @@ class MinidumpFileBuilder {
lldb_private::Status AddData(const void *data, uint64_t size);
// Add MemoryList stream, containing dumps of important memory segments
lldb_private::Status
- AddMemoryList_64(std::vector<lldb_private::CoreFileMemoryRange> &ranges);
+ AddMemoryList_64(std::vector<lldb_private::CoreFileMemoryRange> &ranges, lldb_private::Progress &progressTracker);
lldb_private::Status
- AddMemoryList_32(std::vector<lldb_private::CoreFileMemoryRange> &ranges);
+ AddMemoryList_32(std::vector<lldb_private::CoreFileMemoryRange> &ranges, lldb_private::Progress &progressTracker);
// Update the thread list on disk with the newly emitted stack RVAs.
lldb_private::Status FixThreadStacks();
lldb_private::Status FlushBufferToDisk();
>From 7d62709164be7ce39685e2c99bfda8998c9c6d39 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Wed, 11 Sep 2024 17:11:28 -0700
Subject: [PATCH 2/3] run GCF
---
.../ObjectFile/Minidump/MinidumpFileBuilder.cpp | 14 ++++++++------
.../ObjectFile/Minidump/MinidumpFileBuilder.h | 8 +++++---
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 1765cc24721837..a2100ea6268a34 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -840,14 +840,14 @@ Status MinidumpFileBuilder::AddMemoryList() {
if (error.Fail())
return error;
- lldb_private::Progress progress_tracker("Saving Minidump File", "", all_core_memory_ranges.GetSize());
+ lldb_private::Progress progress_tracker("Saving Minidump File", "",
+ all_core_memory_ranges.GetSize());
std::vector<CoreFileMemoryRange> all_core_memory_vec;
// Extract all the data into just a vector of data. So we can mutate this in
// place.
for (const auto &core_range : all_core_memory_ranges)
all_core_memory_vec.push_back(core_range.data);
-
// Start by saving all of the stacks and ensuring they fit under the 32b
// limit.
uint64_t total_size = GetCurrentDataEndOffset();
@@ -974,8 +974,9 @@ GetLargestRangeSize(const std::vector<CoreFileMemoryRange> &ranges) {
return max_size;
}
-Status MinidumpFileBuilder::AddMemoryList_32(
- std::vector<CoreFileMemoryRange> &ranges, Progress &progressTracker) {
+Status
+MinidumpFileBuilder::AddMemoryList_32(std::vector<CoreFileMemoryRange> &ranges,
+ Progress &progressTracker) {
std::vector<MemoryDescriptor> descriptors;
Status error;
if (ranges.size() == 0)
@@ -1053,8 +1054,9 @@ Status MinidumpFileBuilder::AddMemoryList_32(
return error;
}
-Status MinidumpFileBuilder::AddMemoryList_64(
- std::vector<CoreFileMemoryRange> &ranges, Progress &progressTracker) {
+Status
+MinidumpFileBuilder::AddMemoryList_64(std::vector<CoreFileMemoryRange> &ranges,
+ Progress &progressTracker) {
Status error;
if (ranges.empty())
return error;
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
index 77c5dba6cdf991..93ae96634747fd 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
@@ -23,6 +23,7 @@
#include <utility>
#include <variant>
+#include "lldb/Core/Progress.h"
#include "lldb/Symbol/SaveCoreOptions.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
@@ -30,7 +31,6 @@
#include "lldb/Utility/Status.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-types.h"
-#include "lldb/Core/Progress.h"
#include "llvm/BinaryFormat/Minidump.h"
#include "llvm/Object/Minidump.h"
@@ -122,9 +122,11 @@ class MinidumpFileBuilder {
lldb_private::Status AddData(const void *data, uint64_t size);
// Add MemoryList stream, containing dumps of important memory segments
lldb_private::Status
- AddMemoryList_64(std::vector<lldb_private::CoreFileMemoryRange> &ranges, lldb_private::Progress &progressTracker);
+ AddMemoryList_64(std::vector<lldb_private::CoreFileMemoryRange> &ranges,
+ lldb_private::Progress &progressTracker);
lldb_private::Status
- AddMemoryList_32(std::vector<lldb_private::CoreFileMemoryRange> &ranges, lldb_private::Progress &progressTracker);
+ AddMemoryList_32(std::vector<lldb_private::CoreFileMemoryRange> &ranges,
+ lldb_private::Progress &progressTracker);
// Update the thread list on disk with the newly emitted stack RVAs.
lldb_private::Status FixThreadStacks();
lldb_private::Status FlushBufferToDisk();
>From 815457ce1ff6e16b759c3b2b26f561c16b2d9d39 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Thu, 12 Sep 2024 09:30:39 -0700
Subject: [PATCH 3/3] Variable rename
---
.../ObjectFile/Minidump/MinidumpFileBuilder.cpp | 16 ++++++++--------
.../ObjectFile/Minidump/MinidumpFileBuilder.h | 4 ++--
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index a2100ea6268a34..62331d6a620357 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -840,8 +840,8 @@ Status MinidumpFileBuilder::AddMemoryList() {
if (error.Fail())
return error;
- lldb_private::Progress progress_tracker("Saving Minidump File", "",
- all_core_memory_ranges.GetSize());
+ lldb_private::Progress progress("Saving Minidump File", "",
+ all_core_memory_ranges.GetSize());
std::vector<CoreFileMemoryRange> all_core_memory_vec;
// Extract all the data into just a vector of data. So we can mutate this in
// place.
@@ -894,13 +894,13 @@ Status MinidumpFileBuilder::AddMemoryList() {
}
}
- error = AddMemoryList_32(ranges_32, progress_tracker);
+ error = AddMemoryList_32(ranges_32, progress);
if (error.Fail())
return error;
// Add the remaining memory as a 64b range.
if (!ranges_64.empty()) {
- error = AddMemoryList_64(ranges_64, progress_tracker);
+ error = AddMemoryList_64(ranges_64, progress);
if (error.Fail())
return error;
}
@@ -976,7 +976,7 @@ GetLargestRangeSize(const std::vector<CoreFileMemoryRange> &ranges) {
Status
MinidumpFileBuilder::AddMemoryList_32(std::vector<CoreFileMemoryRange> &ranges,
- Progress &progressTracker) {
+ Progress &progress) {
std::vector<MemoryDescriptor> descriptors;
Status error;
if (ranges.size() == 0)
@@ -1028,7 +1028,7 @@ MinidumpFileBuilder::AddMemoryList_32(std::vector<CoreFileMemoryRange> &ranges,
if (error.Fail())
return error;
- progressTracker.Increment();
+ progress.Increment();
}
// Add a directory that references this list
@@ -1056,7 +1056,7 @@ MinidumpFileBuilder::AddMemoryList_32(std::vector<CoreFileMemoryRange> &ranges,
Status
MinidumpFileBuilder::AddMemoryList_64(std::vector<CoreFileMemoryRange> &ranges,
- Progress &progressTracker) {
+ Progress &progress) {
Status error;
if (ranges.empty())
return error;
@@ -1139,7 +1139,7 @@ MinidumpFileBuilder::AddMemoryList_64(std::vector<CoreFileMemoryRange> &ranges,
if (error.Fail())
return error;
- progressTracker.Increment();
+ progress.Increment();
}
// Early return if there is no cleanup needed.
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
index 93ae96634747fd..a81baf742a35d0 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
@@ -123,10 +123,10 @@ class MinidumpFileBuilder {
// Add MemoryList stream, containing dumps of important memory segments
lldb_private::Status
AddMemoryList_64(std::vector<lldb_private::CoreFileMemoryRange> &ranges,
- lldb_private::Progress &progressTracker);
+ lldb_private::Progress &progress);
lldb_private::Status
AddMemoryList_32(std::vector<lldb_private::CoreFileMemoryRange> &ranges,
- lldb_private::Progress &progressTracker);
+ lldb_private::Progress &progress);
// Update the thread list on disk with the newly emitted stack RVAs.
lldb_private::Status FixThreadStacks();
lldb_private::Status FlushBufferToDisk();
More information about the lldb-commits
mailing list