[lldb] [llvm] [LLDB][Minidump] Add breakpoint stop reasons to the minidump. (PR #108448)
Jacob Lalonde via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 27 11:30:41 PDT 2024
https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/108448
>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/5] 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/5] 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
>From 099f017208ddadc07b3743ea7b04612f0f79617f Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Thu, 12 Sep 2024 14:28:31 -0700
Subject: [PATCH 3/5] Remove the static set and add test
---
.../Minidump/MinidumpFileBuilder.cpp | 11 +-----
.../ObjectFile/Minidump/MinidumpFileBuilder.h | 9 ++++-
.../TestProcessSaveCoreMinidump.py | 39 ++++++++++++++++++-
3 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 0b69f1b8205610..38e71e0e485d55 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -54,13 +54,6 @@ 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;
@@ -82,7 +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 (thread_stop_reasons.count(stop_reason) > 0)
+ if (m_thread_stop_reasons.count(stop_reason) > 0)
m_expected_directories++;
}
}
@@ -692,7 +685,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 && thread_stop_reasons.count(stop_info_sp->GetStopReason()) > 0) {
+ if (stop_info_sp && m_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 488eec7b9282bc..851d62d16920c1 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
@@ -169,6 +169,13 @@ class MinidumpFileBuilder {
std::unordered_set<lldb::addr_t> m_saved_stack_ranges;
lldb::FileUP m_core_file;
lldb_private::SaveCoreOptions m_save_core_options;
- static const std::unordered_set<lldb::StopReason> thread_stop_reasons;
+ // Non const so we don't introduce an issue with the default copy assignment
+ // operator, in the future we also want to be able to define these in the
+ // save core options.
+ 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
diff --git a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
index 2cbe20ee10b1af..50a23eeb6496e2 100644
--- a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
+++ b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
@@ -8,7 +8,6 @@
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
-
class ProcessSaveCoreMinidumpTestCase(TestBase):
def verify_core_file(
self,
@@ -493,3 +492,41 @@ def test_save_minidump_custom_save_style_duplicated_regions(self):
finally:
self.assertTrue(self.dbg.DeleteTarget(target))
+
+ @skipUnlessPlatform(["linux"])
+ def test_save_minidump_breakpoint(self):
+ """Test that verifies a custom and unspecified save style fails for
+ containing no data to save"""
+
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ custom_file = self.getBuildArtifact("core.custom.dmp")
+ try:
+ target = self.dbg.CreateTarget(exe)
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory()
+ )
+ breakpoint = target.BreakpointCreateByName("main")
+ self.assertState(process.GetState(), lldb.eStateStopped)
+
+ options = lldb.SBSaveCoreOptions()
+ options.SetOutputFile(lldb.SBFileSpec(custom_file))
+ options.SetPluginName("minidump")
+ options.SetStyle(lldb.eSaveCoreStackOnly)
+
+ error = process.SaveCore(options)
+ self.assertTrue(error.Success())
+ foundSigInt = False
+ for thread_idx in range(process.GetNumThreads()):
+ thread = process.GetThreadAtIndex(thread_idx)
+ stop = thread.stop_reason
+ if stop == 1:
+ foundSigInt = True
+ break
+
+ self.assertTrue(foundSigInt, "Breakpoint not included in minidump.")
+
+ finally:
+ self.assertTrue(self.dbg.DeleteTarget(target))
+ if os.path.isfile(custom_file):
+ os.unlink(custom_file)
>From 357d4f25aad3c4f8c08f6f55171d56d95f15be80 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Fri, 27 Sep 2024 11:23:35 -0700
Subject: [PATCH 4/5] Add description to stream and add yaml test
---
.../Minidump/MinidumpFileBuilder.cpp | 70 +++++++++----------
.../ObjectFile/Minidump/MinidumpFileBuilder.h | 8 ---
.../Process/minidump/ProcessMinidump.cpp | 5 +-
.../minidump-new/TestMiniDumpNew.py | 21 ++++++
.../linux-x86_64-exceptiondescription.yaml | 37 ++++++++++
llvm/include/llvm/BinaryFormat/Minidump.h | 2 +
6 files changed, 98 insertions(+), 45 deletions(-)
create mode 100644 lldb/test/API/functionalities/postmortem/minidump-new/linux-x86_64-exceptiondescription.yaml
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 38e71e0e485d55..7c765b2c2a0b01 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -75,7 +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 (m_thread_stop_reasons.count(stop_reason) > 0)
+ if (stop_reason)
m_expected_directories++;
}
}
@@ -684,44 +684,42 @@ Status MinidumpFileBuilder::AddExceptions() {
Status error;
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) {
- add_exception = true;
- }
+ if (!stop_info_sp)
+ continue;
- if (add_exception) {
- constexpr size_t minidump_exception_size =
- sizeof(llvm::minidump::ExceptionStream);
- error = AddDirectory(StreamType::Exception, minidump_exception_size);
- if (error.Fail())
- return error;
+ constexpr size_t minidump_exception_size =
+ sizeof(llvm::minidump::ExceptionStream);
+ error = AddDirectory(StreamType::Exception, minidump_exception_size);
+ if (error.Fail())
+ return error;
- StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
- RegisterContextSP reg_ctx_sp(thread_sp->GetRegisterContext());
- Exception exp_record = {};
- exp_record.ExceptionCode =
- static_cast<llvm::support::ulittle32_t>(stop_info_sp->GetValue());
- exp_record.ExceptionFlags = static_cast<llvm::support::ulittle32_t>(0);
- exp_record.ExceptionRecord = static_cast<llvm::support::ulittle64_t>(0);
- exp_record.ExceptionAddress = reg_ctx_sp->GetPC();
- exp_record.NumberParameters = static_cast<llvm::support::ulittle32_t>(0);
- exp_record.UnusedAlignment = static_cast<llvm::support::ulittle32_t>(0);
- // exp_record.ExceptionInformation;
-
- ExceptionStream exp_stream;
- exp_stream.ThreadId =
- static_cast<llvm::support::ulittle32_t>(thread_sp->GetID());
- exp_stream.UnusedAlignment = static_cast<llvm::support::ulittle32_t>(0);
- exp_stream.ExceptionRecord = exp_record;
- auto Iter = m_tid_to_reg_ctx.find(thread_sp->GetID());
- if (Iter != m_tid_to_reg_ctx.end()) {
- exp_stream.ThreadContext = Iter->second;
- } else {
- exp_stream.ThreadContext.DataSize = 0;
- exp_stream.ThreadContext.RVA = 0;
- }
- m_data.AppendData(&exp_stream, minidump_exception_size);
+ RegisterContextSP reg_ctx_sp(thread_sp->GetRegisterContext());
+ Exception exp_record = {};
+ exp_record.ExceptionCode = static_cast<llvm::support::ulittle32_t>(stop_info_sp->GetValue());
+ exp_record.ExceptionCode =
+ static_cast<llvm::support::ulittle32_t>(stop_info_sp->GetValue());
+ exp_record.ExceptionFlags = static_cast<llvm::support::ulittle32_t>(Exception::LLDB_FLAG);
+ exp_record.ExceptionRecord = static_cast<llvm::support::ulittle64_t>(0);
+ exp_record.ExceptionAddress = reg_ctx_sp->GetPC();
+ exp_record.NumberParameters = static_cast<llvm::support::ulittle32_t>(1);
+ std::string description = stop_info_sp->GetDescription();
+ // We have 120 bytes to work with and it's unlikely description will
+ // overflow, but we gotta check.
+ memcpy(&exp_record.ExceptionInformation, description.c_str(), std::max(description.size(), Exception::MaxParameterBytes));
+ exp_record.UnusedAlignment = static_cast<llvm::support::ulittle32_t>(0);
+ ExceptionStream exp_stream;
+ exp_stream.ThreadId =
+ static_cast<llvm::support::ulittle32_t>(thread_sp->GetID());
+ exp_stream.UnusedAlignment = static_cast<llvm::support::ulittle32_t>(0);
+ exp_stream.ExceptionRecord = exp_record;
+ auto Iter = m_tid_to_reg_ctx.find(thread_sp->GetID());
+ if (Iter != m_tid_to_reg_ctx.end()) {
+ exp_stream.ThreadContext = Iter->second;
+ } else {
+ exp_stream.ThreadContext.DataSize = 0;
+ exp_stream.ThreadContext.RVA = 0;
}
+ m_data.AppendData(&exp_stream, minidump_exception_size);
}
return error;
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
index 851d62d16920c1..3ddbd47e2abe06 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
@@ -169,13 +169,5 @@ class MinidumpFileBuilder {
std::unordered_set<lldb::addr_t> m_saved_stack_ranges;
lldb::FileUP m_core_file;
lldb_private::SaveCoreOptions m_save_core_options;
- // Non const so we don't introduce an issue with the default copy assignment
- // operator, in the future we also want to be able to define these in the
- // save core options.
- 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
diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
index 42cc9f02518b32..85ab1dfe743b1f 100644
--- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -273,8 +273,11 @@ void ProcessMinidump::RefreshStateAfterStop() {
// No stop.
return;
}
+ const char * description = nullptr;
+ if ((exception_stream.ExceptionRecord.ExceptionFlags & llvm::minidump::Exception::LLDB_FLAG) == llvm::minidump::Exception::LLDB_FLAG)
+ description = reinterpret_cast<const char *>(exception_stream.ExceptionRecord.ExceptionInformation);
- stop_info = StopInfo::CreateStopReasonWithSignal(*stop_thread, signo);
+ stop_info = StopInfo::CreateStopReasonWithSignal(*stop_thread, signo, description);
} else if (arch.GetTriple().getVendor() == llvm::Triple::Apple) {
stop_info = StopInfoMachException::CreateStopReasonWithMachException(
*stop_thread, exception_stream.ExceptionRecord.ExceptionCode, 2,
diff --git a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
index 5a0b6e790a424c..6f6e19bcbb15d9 100644
--- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -524,3 +524,24 @@ def test_multiple_exceptions_or_signals(self):
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonSignal)
stop_description = thread.GetStopDescription(256)
self.assertIn("SIGSEGV", stop_description)
+
+ def test_breakpoint_on_minidump(self):
+ """
+ Test that LLDB breakpoints are recorded in Minidumps
+ """
+ yaml = "linux-x86_64-exceptiondescription.yaml"
+ core = self.getBuildArtifact("breakpoint.core.dmp")
+ self.yaml2obj(yaml, core)
+ try:
+ # Create a target with the object file we just created from YAML
+ target = self.dbg.CreateTarget(None)
+ self.assertTrue(target, VALID_TARGET)
+ process = target.LoadCore(core)
+ self.assertTrue(process, VALID_PROCESS)
+ thread = process.GetThreadAtIndex(0)
+ stop_reason = thread.GetStopDescription(256)
+ self.assertIn("breakpoint 1.1", stop_reason)
+ finally:
+ if os.path.isfile(core):
+ os.unlink(core)
+
\ No newline at end of file
diff --git a/lldb/test/API/functionalities/postmortem/minidump-new/linux-x86_64-exceptiondescription.yaml b/lldb/test/API/functionalities/postmortem/minidump-new/linux-x86_64-exceptiondescription.yaml
new file mode 100644
index 00000000000000..ac121c630a0a48
--- /dev/null
+++ b/lldb/test/API/functionalities/postmortem/minidump-new/linux-x86_64-exceptiondescription.yaml
@@ -0,0 +1,37 @@
+--- !minidump
+Streams:
+ - Type: SystemInfo
+ Processor Arch: AMD64
+ Processor Level: 6
+ Processor Revision: 15876
+ Number of Processors: 40
+ Platform ID: Linux
+ CSD Version: 'Linux 3.13.0-91-generic'
+ CPU:
+ Vendor ID: GenuineIntel
+ Version Info: 0x00000000
+ Feature Info: 0x00000000
+ - Type: ThreadList
+ Threads:
+ - Thread Id: 0x31F222
+ Context: 00000000000000
+ Stack:
+ Start of Memory Range: 0x7FFFFFFFD660
+ Content: ''
+ - Type: Exception
+ Thread ID: 0x31F222
+ Exception Record:
+ Exception Code: 0x2
+ Exception Flags: 0x80000000
+ Exception Address: 0x555555556671
+ Number of Parameters: 1
+ Parameter 0: 0x696F706B61657262
+ Parameter 1: 0x312E3120746E
+ Parameter 2: 0x1
+ Parameter 3: 0x8000000000000000
+ Parameter 4: 0x200000002
+ Parameter 5: 0x8000000000000002
+ Parameter 7: 0x555555556671
+ Parameter 8: 0x1
+ Thread Context: ''
+...
diff --git a/llvm/include/llvm/BinaryFormat/Minidump.h b/llvm/include/llvm/BinaryFormat/Minidump.h
index 8054e81322a92a..c9df330cbe89bd 100644
--- a/llvm/include/llvm/BinaryFormat/Minidump.h
+++ b/llvm/include/llvm/BinaryFormat/Minidump.h
@@ -246,6 +246,8 @@ static_assert(sizeof(Thread) == 48);
struct Exception {
static constexpr size_t MaxParameters = 15;
+ static constexpr size_t MaxParameterBytes = MaxParameters * sizeof(uint64_t);
+ static const uint32_t LLDB_FLAG = 0x80000000;
support::ulittle32_t ExceptionCode;
support::ulittle32_t ExceptionFlags;
>From 8115d37311c5675733bfece62c925cfbfdac512e Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Fri, 27 Sep 2024 11:25:19 -0700
Subject: [PATCH 5/5] Drop test in process save core minidump
---
.../TestProcessSaveCoreMinidump.py | 30 +++++++------------
1 file changed, 11 insertions(+), 19 deletions(-)
diff --git a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
index 50a23eeb6496e2..ccdb6653cf16f8 100644
--- a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
+++ b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
@@ -8,6 +8,7 @@
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class ProcessSaveCoreMinidumpTestCase(TestBase):
def verify_core_file(
self,
@@ -494,39 +495,30 @@ def test_save_minidump_custom_save_style_duplicated_regions(self):
self.assertTrue(self.dbg.DeleteTarget(target))
@skipUnlessPlatform(["linux"])
- def test_save_minidump_breakpoint(self):
- """Test that verifies a custom and unspecified save style fails for
- containing no data to save"""
+ def minidump_deleted_on_save_failure(self):
+ """Test that verifies the minidump file is deleted after an error"""
self.build()
exe = self.getBuildArtifact("a.out")
- custom_file = self.getBuildArtifact("core.custom.dmp")
try:
target = self.dbg.CreateTarget(exe)
process = target.LaunchSimple(
None, None, self.get_process_working_directory()
)
- breakpoint = target.BreakpointCreateByName("main")
self.assertState(process.GetState(), lldb.eStateStopped)
+ custom_file = self.getBuildArtifact("core.should.be.deleted.custom.dmp")
options = lldb.SBSaveCoreOptions()
options.SetOutputFile(lldb.SBFileSpec(custom_file))
options.SetPluginName("minidump")
- options.SetStyle(lldb.eSaveCoreStackOnly)
-
+ options.SetStyle(lldb.eSaveCoreCustomOnly)
+ # We set custom only and have no thread list and have no memory.
error = process.SaveCore(options)
- self.assertTrue(error.Success())
- foundSigInt = False
- for thread_idx in range(process.GetNumThreads()):
- thread = process.GetThreadAtIndex(thread_idx)
- stop = thread.stop_reason
- if stop == 1:
- foundSigInt = True
- break
-
- self.assertTrue(foundSigInt, "Breakpoint not included in minidump.")
+ self.assertTrue(error.Fail())
+ self.assertIn(
+ "no valid address ranges found for core style", error.GetCString()
+ )
+ self.assertTrue(not os.path.isfile(custom_file))
finally:
self.assertTrue(self.dbg.DeleteTarget(target))
- if os.path.isfile(custom_file):
- os.unlink(custom_file)
More information about the llvm-commits
mailing list