diff options
author | Dimitar Vlahovski <dvlahovski@google.com> | 2016-10-04 21:02:13 +0000 |
---|---|---|
committer | Dimitar Vlahovski <dvlahovski@google.com> | 2016-10-04 21:02:13 +0000 |
commit | 8cabfb764d6b0390038f2d0af6f29781b4b2294b (patch) | |
tree | d5f809b2ae4a5dce6cb4e632e95b8b673547f733 /lldb/source/Plugins/Process/minidump/ThreadMinidump.cpp | |
parent | 625fba88406e3ff47ceb63b7d36d5db756ec44cf (diff) | |
download | bcm5719-llvm-8cabfb764d6b0390038f2d0af6f29781b4b2294b.tar.gz bcm5719-llvm-8cabfb764d6b0390038f2d0af6f29781b4b2294b.zip |
Adding a new Minidump post-mortem debugging plugin
Summary:
This plugin resembles the already existing Windows-only Minidump plugin.
The WinMinidumpPlugin uses the Windows API for parsing Minidumps
while this plugin is cross-platform because it includes a Minidump
parser (which is already commited)
It is able to produce a backtrace, to read the general puprose regiters,
inspect local variables, show image list, do memory reads, etc.
For now the only arch that this supports is x86 64 bit
This is because I have only written a register context for that arch.
Others will come in next CLs.
I copied the WinMinidump tests and adapted them a little bit for them to
work with the new plugin (and they pass)
I will add more tests, aiming for better code coverage.
There is still functionality to be added, see TODOs in code.
Reviewers: labath, zturner
Subscribers: beanz, mgorny, amccarth, lldb-commits, modocache
Differential Revision: https://reviews.llvm.org/D25196
llvm-svn: 283259
Diffstat (limited to 'lldb/source/Plugins/Process/minidump/ThreadMinidump.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/minidump/ThreadMinidump.cpp | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/minidump/ThreadMinidump.cpp b/lldb/source/Plugins/Process/minidump/ThreadMinidump.cpp new file mode 100644 index 00000000000..22641da9e69 --- /dev/null +++ b/lldb/source/Plugins/Process/minidump/ThreadMinidump.cpp @@ -0,0 +1,102 @@ +//===-- ThreadMinidump.cpp --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Project includes +#include "ThreadMinidump.h" +#include "ProcessMinidump.h" + +#include "RegisterContextMinidump_x86_64.h" + +// Other libraries and framework includes +#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h" + +#include "Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h" + +#include "lldb/Core/DataExtractor.h" +#include "lldb/Core/Log.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/StopInfo.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Unwind.h" + +// C Includes +// C++ Includes + +using namespace lldb; +using namespace lldb_private; +using namespace minidump; + +ThreadMinidump::ThreadMinidump(Process &process, const MinidumpThread &td, + llvm::ArrayRef<uint8_t> gpregset_data) + : Thread(process, td.thread_id), m_thread_reg_ctx_sp(), + m_gpregset_data(gpregset_data) {} + +ThreadMinidump::~ThreadMinidump() {} + +void ThreadMinidump::RefreshStateAfterStop() {} + +void ThreadMinidump::ClearStackFrames() {} + +RegisterContextSP ThreadMinidump::GetRegisterContext() { + if (!m_reg_context_sp) { + m_reg_context_sp = CreateRegisterContextForFrame(nullptr); + } + return m_reg_context_sp; +} + +RegisterContextSP +ThreadMinidump::CreateRegisterContextForFrame(StackFrame *frame) { + RegisterContextSP reg_ctx_sp; + uint32_t concrete_frame_idx = 0; + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD)); + + if (frame) + concrete_frame_idx = frame->GetConcreteFrameIndex(); + + if (concrete_frame_idx == 0) { + if (m_thread_reg_ctx_sp) + return m_thread_reg_ctx_sp; + + ProcessMinidump *process = + static_cast<ProcessMinidump *>(GetProcess().get()); + ArchSpec arch = process->GetArchitecture(); + RegisterInfoInterface *reg_interface = nullptr; + + // TODO write other register contexts and add them here + switch (arch.GetMachine()) { + case llvm::Triple::x86_64: { + reg_interface = new RegisterContextLinux_x86_64(arch); + lldb::DataBufferSP buf = + ConvertMinidumpContextToRegIface(m_gpregset_data, reg_interface); + DataExtractor gpregs(buf, lldb::eByteOrderLittle, 8); + DataExtractor fpregs; + m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_x86_64( + *this, reg_interface, gpregs, fpregs)); + break; + } + default: + break; + } + + if (!reg_interface) { + if (log) + log->Printf("elf-core::%s:: Architecture(%d) not supported", + __FUNCTION__, arch.GetMachine()); + assert(false && "Architecture not supported"); + } + + reg_ctx_sp = m_thread_reg_ctx_sp; + } else if (m_unwinder_ap) { + reg_ctx_sp = m_unwinder_ap->CreateRegisterContextForFrame(frame); + } + + return reg_ctx_sp; +} + +bool ThreadMinidump::CalculateStopInfo() { return false; } |