https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/108448
>From d3137f697e130598b6ff7fa61b4cd098cb9e1b2a Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <jalalo...@fb.com> Date: Thu, 12 Sep 2024 13:10:58 -0700 Subject: [PATCH 1/8] 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 3f1e25f730a184..1f5c7c878904bb 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 d5eac9015ac422..cdfc704a5679d7 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h @@ -174,7 +174,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 9bf0b14cc4aa66224fe8d3840e6700d3f04513f9 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <jalalo...@fb.com> Date: Thu, 12 Sep 2024 13:30:04 -0700 Subject: [PATCH 2/8] 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 1f5c7c878904bb..34083959d33650 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 cdfc704a5679d7..86836bfc96cb8f 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h @@ -175,8 +175,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 78c214a54647c2d4b1deef017ecc2a416886fd4c Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <jalalo...@fb.com> Date: Thu, 12 Sep 2024 14:28:31 -0700 Subject: [PATCH 3/8] Remove the static set and add test --- .../Minidump/MinidumpFileBuilder.cpp | 11 +----- .../ObjectFile/Minidump/MinidumpFileBuilder.h | 9 ++++- .../TestProcessSaveCoreMinidump.py | 38 ++++++++++++++++++- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp index 34083959d33650..1f5c7c878904bb 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 86836bfc96cb8f..f270d3971b7a91 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h @@ -175,6 +175,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 03cc415924e0bb..21b23988f0c237 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, @@ -495,16 +494,27 @@ def test_save_minidump_custom_save_style_duplicated_regions(self): self.assertTrue(self.dbg.DeleteTarget(target)) @skipUnlessPlatform(["linux"]) +<<<<<<< HEAD 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") +======= + 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") +>>>>>>> 099f017208dd (Remove the static set and add test) try: target = self.dbg.CreateTarget(exe) process = target.LaunchSimple( None, None, self.get_process_working_directory() ) +<<<<<<< HEAD self.assertState(process.GetState(), lldb.eStateStopped) custom_file = self.getBuildArtifact("core.should.be.deleted.custom.dmp") @@ -565,3 +575,29 @@ def minidump_deterministic_difference(self): finally: self.assertTrue(self.dbg.DeleteTarget(target)) +======= + 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) +>>>>>>> 099f017208dd (Remove the static set and add test) >From f17f1256f2054d66ad97d572311ab2e201c6bcab Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <jalalo...@fb.com> Date: Fri, 27 Sep 2024 11:23:35 -0700 Subject: [PATCH 4/8] 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 1f5c7c878904bb..9287f0f257d240 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 f270d3971b7a91..272aa8fb0da2a7 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h @@ -175,13 +175,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 32ffba763c08e3..25eea4a71be87e 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 cf1fd1b3d3306d7b7cb400f5a164636d39ca5e15 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <jalalo...@fb.com> Date: Fri, 27 Sep 2024 11:25:19 -0700 Subject: [PATCH 5/8] Drop test in process save core minidump --- .../TestProcessSaveCoreMinidump.py | 38 +------------------ 1 file changed, 1 insertion(+), 37 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 21b23988f0c237..03cc415924e0bb 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,27 +495,16 @@ def test_save_minidump_custom_save_style_duplicated_regions(self): self.assertTrue(self.dbg.DeleteTarget(target)) @skipUnlessPlatform(["linux"]) -<<<<<<< HEAD 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") -======= - 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") ->>>>>>> 099f017208dd (Remove the static set and add test) try: target = self.dbg.CreateTarget(exe) process = target.LaunchSimple( None, None, self.get_process_working_directory() ) -<<<<<<< HEAD self.assertState(process.GetState(), lldb.eStateStopped) custom_file = self.getBuildArtifact("core.should.be.deleted.custom.dmp") @@ -575,29 +565,3 @@ def minidump_deterministic_difference(self): finally: self.assertTrue(self.dbg.DeleteTarget(target)) -======= - 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) ->>>>>>> 099f017208dd (Remove the static set and add test) >From 918ed000c7e8e645820472afed8b4846f451ef07 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <jalalo...@fb.com> Date: Mon, 30 Sep 2024 11:09:41 -0700 Subject: [PATCH 6/8] Use ASCII flag --- lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp | 1 - lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp | 2 +- llvm/include/llvm/BinaryFormat/Minidump.h | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp index 9287f0f257d240..2a8d13972f3f13 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp @@ -695,7 +695,6 @@ Status MinidumpFileBuilder::AddExceptions() { 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); diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp index 25eea4a71be87e..24d1db7b0103d6 100644 --- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp +++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp @@ -274,7 +274,7 @@ void ProcessMinidump::RefreshStateAfterStop() { return; } const char * description = nullptr; - if ((exception_stream.ExceptionRecord.ExceptionFlags & llvm::minidump::Exception::LLDB_FLAG) == llvm::minidump::Exception::LLDB_FLAG) + if (exception_stream.ExceptionRecord.ExceptionFlags == llvm::minidump::Exception::LLDB_FLAG) description = reinterpret_cast<const char *>(exception_stream.ExceptionRecord.ExceptionInformation); stop_info = StopInfo::CreateStopReasonWithSignal(*stop_thread, signo, description); diff --git a/llvm/include/llvm/BinaryFormat/Minidump.h b/llvm/include/llvm/BinaryFormat/Minidump.h index c9df330cbe89bd..addff42982352f 100644 --- a/llvm/include/llvm/BinaryFormat/Minidump.h +++ b/llvm/include/llvm/BinaryFormat/Minidump.h @@ -247,7 +247,7 @@ 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; + static const uint32_t LLDB_FLAG = 'LLDB'; support::ulittle32_t ExceptionCode; support::ulittle32_t ExceptionFlags; >From 00a0ad825b5495d66007aabf699c1486a999ea25 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <jalalo...@fb.com> Date: Mon, 30 Sep 2024 12:43:21 -0700 Subject: [PATCH 7/8] Update yaml to new flag --- .../minidump-new/linux-x86_64-exceptiondescription.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index ac121c630a0a48..bf26e05cd775ae 100644 --- 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 @@ -22,7 +22,7 @@ Streams: Thread ID: 0x31F222 Exception Record: Exception Code: 0x2 - Exception Flags: 0x80000000 + Exception Flags: 0x4C4C4442 Exception Address: 0x555555556671 Number of Parameters: 1 Parameter 0: 0x696F706B61657262 >From b8291b21b4ee38178a7bb9a6db5a3f1db32b6a4c Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <jalalo...@fb.com> Date: Tue, 1 Oct 2024 16:37:33 -0700 Subject: [PATCH 8/8] Run python formatter --- .../functionalities/postmortem/minidump-new/TestMiniDumpNew.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py index 6f6e19bcbb15d9..8776d72ecbc027 100644 --- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py +++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py @@ -544,4 +544,3 @@ def test_breakpoint_on_minidump(self): finally: if os.path.isfile(core): os.unlink(core) - \ No newline at end of file _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits