Normally, LLDB is creating a high-fidelity representation of a live process, including a list of modules and sections, with the associated memory address ranges. In order to build the module and section map LLDB tries to locate the local module image (object file) and will parse it. This does not work for postmortem debugging scenarios where the crash dump (minidump in this case) was captured on a different machine. Fortunately the minidump format encodes enough information about each module's memory range to allow us to create placeholder modules. This enables most LLDB functionality involving address-to-module translations. Also, we may want to completly disable the search for matching local object files if we load minidumps unless we can prove that the local image matches the one from the crash origin. (not part of this change, see: llvm.org/pr35193) Example: Identify the module from a stack frame PC: Before: thread #1, stop reason = Exception 0xc0000005 encountered at address 0x164d14 frame #0: 0x00164d14 frame #1: 0x00167c79 frame #2: 0x00167e6d frame #3: 0x7510336a frame #4: 0x77759882 frame #5: 0x77759855 After: thread #1, stop reason = Exception 0xc0000005 encountered at address 0x164d14 frame #0: 0x00164d14 C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe frame #1: 0x00167c79 C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe frame #2: 0x00167e6d C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe frame #3: 0x7510336a C:\Windows\SysWOW64\kernel32.dll frame #4: 0x77759882 C:\Windows\SysWOW64\ntdll.dll frame #5: 0x77759855 C:\Windows\SysWOW64\ntdll.dll Example: target modules list Before: error: the target has no associated executable images After: [ 0] C:\Windows\System32\MSVCP120D.dll [ 1] C:\Windows\SysWOW64\kernel32.dll [ 2] C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe [ 3] C:\Windows\System32\MSVCR120D.dll [ 4] C:\Windows\SysWOW64\KERNELBASE.dll [ 5] C:\Windows\SysWOW64\ntdll.dll NOTE: the minidump format also includes the debug info GUID, so we can fill-in the module UUID from it, but this part was excluded from this change to keep the changes simple (the LLDB UUID is hardcoded to be either 16 or 20 bytes, while the CodeView GUIDs are normally 24 bytes) Differential Revision: https://reviews.llvm.org/D45700 llvm-svn: 330302
116 lines
3.0 KiB
C++
116 lines
3.0 KiB
C++
//===-- ProcessMinidump.h ---------------------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef liblldb_ProcessMinidump_h_
|
|
#define liblldb_ProcessMinidump_h_
|
|
|
|
// Project includes
|
|
#include "MinidumpParser.h"
|
|
#include "MinidumpTypes.h"
|
|
|
|
// Other libraries and framework includes
|
|
#include "lldb/Target/Process.h"
|
|
#include "lldb/Target/StopInfo.h"
|
|
#include "lldb/Target/Target.h"
|
|
#include "lldb/Utility/ConstString.h"
|
|
#include "lldb/Utility/Status.h"
|
|
|
|
#include "llvm/Support/Format.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
// C Includes
|
|
// C++ Includes
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace minidump {
|
|
|
|
class ProcessMinidump : public Process {
|
|
public:
|
|
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
|
|
lldb::ListenerSP listener_sp,
|
|
const FileSpec *crash_file_path);
|
|
|
|
static void Initialize();
|
|
|
|
static void Terminate();
|
|
|
|
static ConstString GetPluginNameStatic();
|
|
|
|
static const char *GetPluginDescriptionStatic();
|
|
|
|
ProcessMinidump(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
|
|
const FileSpec &core_file, MinidumpParser minidump_parser);
|
|
|
|
~ProcessMinidump() override;
|
|
|
|
bool CanDebug(lldb::TargetSP target_sp,
|
|
bool plugin_specified_by_name) override;
|
|
|
|
Status DoLoadCore() override;
|
|
|
|
DynamicLoader *GetDynamicLoader() override;
|
|
|
|
ConstString GetPluginName() override;
|
|
|
|
uint32_t GetPluginVersion() override;
|
|
|
|
SystemRuntime *GetSystemRuntime() override { return nullptr; }
|
|
|
|
Status DoDestroy() override;
|
|
|
|
void RefreshStateAfterStop() override;
|
|
|
|
bool IsAlive() override;
|
|
|
|
bool WarnBeforeDetach() const override;
|
|
|
|
size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size,
|
|
Status &error) override;
|
|
|
|
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
|
|
Status &error) override;
|
|
|
|
ArchSpec GetArchitecture();
|
|
|
|
Status GetMemoryRegionInfo(lldb::addr_t load_addr,
|
|
MemoryRegionInfo &range_info) override;
|
|
|
|
bool GetProcessInfo(ProcessInstanceInfo &info) override;
|
|
|
|
Status WillResume() override {
|
|
Status error;
|
|
error.SetErrorStringWithFormat(
|
|
"error: %s does not support resuming processes",
|
|
GetPluginName().GetCString());
|
|
return error;
|
|
}
|
|
|
|
MinidumpParser m_minidump_parser;
|
|
|
|
protected:
|
|
void Clear();
|
|
|
|
bool UpdateThreadList(ThreadList &old_thread_list,
|
|
ThreadList &new_thread_list) override;
|
|
|
|
void ReadModuleList();
|
|
|
|
private:
|
|
FileSpec m_core_file;
|
|
llvm::ArrayRef<MinidumpThread> m_thread_list;
|
|
const MinidumpExceptionStream *m_active_exception;
|
|
bool m_is_wow64;
|
|
};
|
|
|
|
} // namespace minidump
|
|
} // namespace lldb_private
|
|
|
|
#endif // liblldb_ProcessMinidump_h_
|