[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Add breakpoint stop reasons to the minidump. (PR #108448)
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Mon Oct 7 14:10:28 PDT 2024
================
@@ -685,50 +684,43 @@ 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) {
- switch (stop_info_sp->GetStopReason()) {
- case eStopReasonSignal:
- case eStopReasonException:
- add_exception = true;
- break;
- default:
- break;
- }
- }
- 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;
+ if (!stop_info_sp)
+ continue;
- 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);
+ constexpr size_t minidump_exception_size =
+ sizeof(llvm::minidump::ExceptionStream);
+ error = AddDirectory(StreamType::Exception, minidump_exception_size);
+ if (error.Fail())
+ return error;
+
+ 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>(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));
----------------
clayborg wrote:
The string might not be NULL terminated. Will that cause problems when decoding if the exception string it too long? Struct looks like:
```
struct MINIDUMP_EXCEPTION {
ULONG32 ExceptionCode;
ULONG32 ExceptionFlags;
ULONG64 ExceptionRecord;
ULONG64 ExceptionAddress;
ULONG32 NumberParameters;
ULONG32 __unusedAlignment;
ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
} ;
```
https://github.com/llvm/llvm-project/pull/108448
More information about the lldb-commits
mailing list