[Lldb-commits] [lldb] [LLDB][Minidump] Add breakpoint stop reasons to the minidump. (PR #108448)
Jacob Lalonde via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 12 13:32:13 PDT 2024
https://github.com/Jlalond created https://github.com/llvm/llvm-project/pull/108448
Recently my coworker @jeffreytan81 pointed out that Minidumps don't show breakpoints when collected. This was prior blocked because Minidumps could only contain 1 exception, now that we support N signals/sections we can save all the threads stopped on breakpoints.
>From adcc5e8065d2a1b7edf877bd74de9cebd2f84cc9 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Thu, 12 Sep 2024 13:10:58 -0700
Subject: [PATCH 1/2] Create set for the stop reasons we collect, and add
breakpoint to it.
---
.../ObjectFile/Minidump/MinidumpFileBuilder.cpp | 13 +++----------
.../ObjectFile/Minidump/MinidumpFileBuilder.h | 4 +++-
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index edc568a6b47e00..38e71e0e485d55 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -75,8 +75,7 @@ Status MinidumpFileBuilder::AddHeaderAndCalculateDirectories() {
StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
if (stop_info_sp) {
const StopReason &stop_reason = stop_info_sp->GetStopReason();
- if (stop_reason == StopReason::eStopReasonException ||
- stop_reason == StopReason::eStopReasonSignal)
+ if (m_thread_stop_reasons.count(stop_reason) > 0)
m_expected_directories++;
}
}
@@ -686,16 +685,10 @@ Status MinidumpFileBuilder::AddExceptions() {
for (const ThreadSP &thread_sp : thread_list) {
StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
bool add_exception = false;
- if (stop_info_sp) {
- switch (stop_info_sp->GetStopReason()) {
- case eStopReasonSignal:
- case eStopReasonException:
+ if (stop_info_sp && m_thread_stop_reasons.count(stop_info_sp->GetStopReason()) > 0) {
add_exception = true;
- break;
- default:
- break;
- }
}
+
if (add_exception) {
constexpr size_t minidump_exception_size =
sizeof(llvm::minidump::ExceptionStream);
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
index 71001e26c00e91..569ba7fb07d871 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
@@ -168,7 +168,9 @@ class MinidumpFileBuilder {
m_tid_to_reg_ctx;
std::unordered_set<lldb::addr_t> m_saved_stack_ranges;
lldb::FileUP m_core_file;
- lldb_private::SaveCoreOptions m_save_core_options;
+ lldb_private::SaveCoreOptions m_save_core_options;
+ const std::unordered_set<lldb::StopReason> m_thread_stop_reasons = {lldb::StopReason::eStopReasonException, lldb::StopReason::eStopReasonSignal,
+ lldb::StopReason::eStopReasonBreakpoint };
};
#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_MINIDUMP_MINIDUMPFILEBUILDER_H
>From 030b74c9e763c86d217da39487478e7cf2dff074 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Thu, 12 Sep 2024 13:30:04 -0700
Subject: [PATCH 2/2] Make const set with the stop reasons
---
.../ObjectFile/Minidump/MinidumpFileBuilder.cpp | 11 +++++++++--
.../Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h | 4 +---
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 38e71e0e485d55..0b69f1b8205610 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -54,6 +54,13 @@ using namespace lldb;
using namespace lldb_private;
using namespace llvm::minidump;
+// Set of all the stop reasons minidumps will collect.
+const std::unordered_set<lldb::StopReason> MinidumpFileBuilder::thread_stop_reasons {
+ lldb::StopReason::eStopReasonException,
+ lldb::StopReason::eStopReasonSignal,
+ lldb::StopReason::eStopReasonBreakpoint,
+};
+
Status MinidumpFileBuilder::AddHeaderAndCalculateDirectories() {
// First set the offset on the file, and on the bytes saved
m_saved_data_size = HEADER_SIZE;
@@ -75,7 +82,7 @@ Status MinidumpFileBuilder::AddHeaderAndCalculateDirectories() {
StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
if (stop_info_sp) {
const StopReason &stop_reason = stop_info_sp->GetStopReason();
- if (m_thread_stop_reasons.count(stop_reason) > 0)
+ if (thread_stop_reasons.count(stop_reason) > 0)
m_expected_directories++;
}
}
@@ -685,7 +692,7 @@ Status MinidumpFileBuilder::AddExceptions() {
for (const ThreadSP &thread_sp : thread_list) {
StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
bool add_exception = false;
- if (stop_info_sp && m_thread_stop_reasons.count(stop_info_sp->GetStopReason()) > 0) {
+ if (stop_info_sp && thread_stop_reasons.count(stop_info_sp->GetStopReason()) > 0) {
add_exception = true;
}
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
index 569ba7fb07d871..488eec7b9282bc 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
@@ -169,8 +169,6 @@ class MinidumpFileBuilder {
std::unordered_set<lldb::addr_t> m_saved_stack_ranges;
lldb::FileUP m_core_file;
lldb_private::SaveCoreOptions m_save_core_options;
- const std::unordered_set<lldb::StopReason> m_thread_stop_reasons = {lldb::StopReason::eStopReasonException, lldb::StopReason::eStopReasonSignal,
- lldb::StopReason::eStopReasonBreakpoint };
+ static const std::unordered_set<lldb::StopReason> thread_stop_reasons;
};
-
#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_MINIDUMP_MINIDUMPFILEBUILDER_H
More information about the lldb-commits
mailing list