Use the minidump exception record if present

If the minidump contains a saved exception record use it automatically.

Differential Revision: https://reviews.llvm.org/D56293

llvm-svn: 350546
This commit is contained in:
Leonard Mosescu 2019-01-07 17:55:42 +00:00
parent 488545ef15
commit 0d05790030
8 changed files with 82 additions and 16 deletions

View File

@ -0,0 +1,40 @@
// nodefaultlib build: cl -Zi sigsegv.cpp /link /nodefaultlib
#ifdef USE_CRT
#include <stdio.h>
#else
int main();
extern "C"
{
int _fltused;
void mainCRTStartup() { main(); }
void printf(const char*, ...) {}
}
#endif
void crash(bool crash_self)
{
printf("Before...\n");
if(crash_self)
{
printf("Crashing in 3, 2, 1 ...\n");
*(volatile int*)nullptr = 0;
}
printf("After...\n");
}
int foo(int x, float y, const char* msg)
{
bool flag = x > y;
if(flag)
printf("x = %d, y = %f, msg = %s\n", x, y, msg);
crash(flag);
return x << 1;
}
int main()
{
foo(10, 3.14, "testing");
}

Binary file not shown.

View File

@ -0,0 +1,2 @@
bt all
dis

Binary file not shown.

View File

@ -0,0 +1,13 @@
// RUN: cd %p/Inputs
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 \
// RUN: %lldb -c sigsegv.dmp -s sigsegv.lldbinit | FileCheck %s
CHECK: * thread #1, stop reason = Exception 0xc0000005 encountered at address 0x7ff7a13110d9
CHECK: * frame #0: 0x00007ff7a13110d9 sigsegv.exe
CHECK: -> 0x7ff7a13110d9: movl $0x0, 0x0
CHECK: 0x7ff7a13110e4: leaq 0x1f45(%rip), %rcx
CHECK: 0x7ff7a13110eb: callq 0x7ff7a1311019
CHECK: 0x7ff7a13110f0: addq $0x28, %rsp
CHECK: 0x7ff7a13110f4: retq
CHECK: 0x7ff7a13110f5: int3

View File

@ -107,11 +107,15 @@ llvm::ArrayRef<MinidumpThread> MinidumpParser::GetThreads() {
}
llvm::ArrayRef<uint8_t>
MinidumpParser::GetThreadContext(const MinidumpThread &td) {
if (td.thread_context.rva + td.thread_context.data_size > GetData().size())
MinidumpParser::GetThreadContext(const MinidumpLocationDescriptor &location) {
if (location.rva + location.data_size > GetData().size())
return {};
return GetData().slice(location.rva, location.data_size);
}
return GetData().slice(td.thread_context.rva, td.thread_context.data_size);
llvm::ArrayRef<uint8_t>
MinidumpParser::GetThreadContext(const MinidumpThread &td) {
return GetThreadContext(td.thread_context);
}
llvm::ArrayRef<uint8_t>

View File

@ -58,6 +58,9 @@ public:
llvm::ArrayRef<MinidumpThread> GetThreads();
llvm::ArrayRef<uint8_t>
GetThreadContext(const MinidumpLocationDescriptor &location);
llvm::ArrayRef<uint8_t> GetThreadContext(const MinidumpThread &td);
llvm::ArrayRef<uint8_t> GetThreadContextWow64(const MinidumpThread &td);

View File

@ -34,6 +34,7 @@
#include "llvm/Support/Threading.h"
#include "Plugins/Process/Utility/StopInfoMachException.h"
// C includes
// C++ includes
@ -80,7 +81,7 @@ public:
section_sp, module->base_of_image);
}
ObjectFile *GetObjectFile() override { return nullptr; }
ObjectFile *GetObjectFile() override { return nullptr; }
SectionList *GetSectionList() override {
return Module::GetUnifiedSectionList();
@ -305,19 +306,22 @@ void ProcessMinidump::Clear() { Process::m_thread_list.Clear(); }
bool ProcessMinidump::UpdateThreadList(ThreadList &old_thread_list,
ThreadList &new_thread_list) {
uint32_t num_threads = 0;
if (m_thread_list.size() > 0)
num_threads = m_thread_list.size();
for (const MinidumpThread& thread : m_thread_list) {
MinidumpLocationDescriptor context_location = thread.thread_context;
// If the minidump contains an exception context, use it
if (m_active_exception != nullptr &&
m_active_exception->thread_id == thread.thread_id) {
context_location = m_active_exception->thread_context;
}
for (lldb::tid_t tid = 0; tid < num_threads; ++tid) {
llvm::ArrayRef<uint8_t> context;
if (!m_is_wow64)
context = m_minidump_parser.GetThreadContext(m_thread_list[tid]);
context = m_minidump_parser.GetThreadContext(context_location);
else
context = m_minidump_parser.GetThreadContextWow64(m_thread_list[tid]);
context = m_minidump_parser.GetThreadContextWow64(thread);
lldb::ThreadSP thread_sp(
new ThreadMinidump(*this, m_thread_list[tid], context));
lldb::ThreadSP thread_sp(new ThreadMinidump(*this, thread, context));
new_thread_list.AddThread(thread_sp);
}
return new_thread_list.GetSize(false) > 0;
@ -549,9 +553,9 @@ public:
APPEND_OPT(m_dump_linux_all);
m_option_group.Finalize();
}
~CommandObjectProcessMinidumpDump() {}
Options *GetOptions() override { return &m_option_group; }
bool DoExecute(Args &command, CommandReturnObject &result) override {
@ -563,7 +567,7 @@ public:
return false;
}
SetDefaultOptionsIfNoneAreSet();
ProcessMinidump *process = static_cast<ProcessMinidump *>(
m_interpreter.GetExecutionContext().GetProcessPtr());
result.SetStatus(eReturnStatusSuccessFinishResult);
@ -635,7 +639,7 @@ public:
LoadSubCommand("dump",
CommandObjectSP(new CommandObjectProcessMinidumpDump(interpreter)));
}
~CommandObjectMultiwordProcessMinidump() {}
};