amccarth created this revision.
amccarth added a reviewer: zturner.
amccarth added a subscriber: lldb-commits.

The old RegisterContextWinMiniDump stub is replaced with x86 and x64 
implementations that derive from the common windows register contexts.

ProcessWindowsMiniDump grabs the WinAPI CONTEXT for each thread and stashes it 
in the thread object when building the thread list.  The threads create the 
register context, stuffing in the saved CONTEXT.

New test ensures we can see the stack and registers for the (single) frame in 
the fizzbuzz minidump.  (No variables or function names, since that inferior 
doesn't have DWARF information.)

You might also notice that I remove the thread names for MiniDump threads.  
Thread names are unavailable when port-mortem debugging Windows apps (since 
naming the thread requires having the debugger catch a special exception raised 
while the inferior is running).

http://reviews.llvm.org/D14591

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
  source/Plugins/Process/Windows/Common/RegisterContextWindows.h
  source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
  source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h
  source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp
  source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h
  source/Plugins/Process/Windows/MiniDump/CMakeLists.txt
  source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
  source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.cpp
  source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.h
  source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp
  source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h
  
source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp
  
source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h
  
source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
  
source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h

Index: source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h
===================================================================
--- /dev/null
+++ source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h
@@ -0,0 +1,36 @@
+//===-- RegisterContextWindowsMiniDump_x86.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_RegisterContextWindowsMiniDump_x86_H_
+#define liblldb_RegisterContextWindowsMiniDump_x86_H_
+
+#include "lldb/lldb-forward.h"
+#include "../../Common/x86/RegisterContextWindows_x86.h"
+
+namespace lldb_private
+{
+
+class Thread;
+
+class RegisterContextWindowsMiniDump_x86 : public RegisterContextWindows_x86
+{
+  public:
+    RegisterContextWindowsMiniDump_x86(Thread &thread, uint32_t concrete_frame_idx, const CONTEXT *context);
+
+    virtual ~RegisterContextWindowsMiniDump_x86();
+
+    bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue &reg_value) override;
+
+  protected:
+    bool CacheAllRegisterValues() override;
+};
+
+}
+
+#endif // #ifndef liblldb_RegisterContextWindowsMiniDump_x86_H_
Index: source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
===================================================================
--- /dev/null
+++ source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
@@ -0,0 +1,47 @@
+//===-- RegisterContextWindowsMiniDump_x86.cpp ------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/lldb-private-types.h"
+#include "lldb/Host/windows/windows.h"
+
+#include "RegisterContextWindowsMiniDump_x86.h"
+
+using namespace lldb;
+
+namespace lldb_private
+{
+
+RegisterContextWindowsMiniDump_x86::RegisterContextWindowsMiniDump_x86(Thread &thread, uint32_t concrete_frame_idx, const CONTEXT *context)
+    : RegisterContextWindows_x86(thread, concrete_frame_idx)
+{
+    if (context)
+    {
+        m_context = *context;
+        m_context_stale = false;
+    }
+}
+
+RegisterContextWindowsMiniDump_x86::~RegisterContextWindowsMiniDump_x86()
+{
+}
+
+bool
+RegisterContextWindowsMiniDump_x86::WriteRegister(const RegisterInfo * /* reg_info */, const RegisterValue & /* reg_value */)
+{
+    return false;
+}
+
+bool
+RegisterContextWindowsMiniDump_x86::CacheAllRegisterValues()
+{
+    // Since this is post-mortem debugging, we either have the context or we don't.
+    return !m_context_stale;
+}
+
+}  // namespace lldb_private
Index: source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h
===================================================================
--- /dev/null
+++ source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h
@@ -0,0 +1,36 @@
+//===-- RegisterContextWindowsMiniDump_x64.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_RegisterContextWindowsMiniDump_x64_H_
+#define liblldb_RegisterContextWindowsMiniDump_x64_H_
+
+#include "lldb/lldb-forward.h"
+#include "../../Common/x64/RegisterContextWindows_x64.h"
+
+namespace lldb_private
+{
+
+class Thread;
+
+class RegisterContextWindowsMiniDump_x64 : public RegisterContextWindows_x64
+{
+  public:
+    RegisterContextWindowsMiniDump_x64(Thread &thread, uint32_t concrete_frame_idx, const CONTEXT *context);
+
+    virtual ~RegisterContextWindowsMiniDump_x64();
+
+    bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue &reg_value) override;
+
+  protected:
+    bool CacheAllRegisterValues() override;
+};
+
+}
+
+#endif // #ifndef liblldb_RegisterContextWindowsMiniDump_x64_H_
Index: source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp
===================================================================
--- /dev/null
+++ source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp
@@ -0,0 +1,47 @@
+//===-- RegisterContextWindowsMiniDump_x64.cpp ------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/lldb-private-types.h"
+#include "lldb/Host/windows/windows.h"
+
+#include "RegisterContextWindowsMiniDump_x64.h"
+
+using namespace lldb;
+
+namespace lldb_private
+{
+
+RegisterContextWindowsMiniDump_x64::RegisterContextWindowsMiniDump_x64(Thread &thread, uint32_t concrete_frame_idx, const CONTEXT *context)
+    : RegisterContextWindows_x64(thread, concrete_frame_idx)
+{
+    if (context)
+    {
+        m_context = *context;
+        m_context_stale = false;
+    }
+}
+
+RegisterContextWindowsMiniDump_x64::~RegisterContextWindowsMiniDump_x64()
+{
+}
+
+bool
+RegisterContextWindowsMiniDump_x64::WriteRegister(const RegisterInfo * /* reg_info */, const RegisterValue & /* reg_value */)
+{
+    return false;
+}
+
+bool
+RegisterContextWindowsMiniDump_x64::CacheAllRegisterValues()
+{
+    // Since this is post-mortem debugging, we either have the context or we don't.
+    return !m_context_stale;
+}
+
+}  // namespace lldb_private
Index: source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h
===================================================================
--- source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h
+++ source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h
@@ -35,15 +35,13 @@
     void
     ClearStackFrames() override;
 
-    const char *
-    GetName() override;
-
     void
-    SetName(const char *name);
+    SetContext(const void *context);
 
 protected:
-    std::string m_thread_name;
     lldb::RegisterContextSP m_reg_context_sp;
+    class Data;
+    std::unique_ptr<Data> m_data;  // for WinAPI-specific data
 
     bool CalculateStopInfo() override;
 };
Index: source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp
===================================================================
--- source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp
+++ source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp
@@ -9,22 +9,32 @@
 
 #include "ThreadWinMiniDump.h"
 
-// Windows includes
+#include "lldb/Host/HostInfo.h"
 #include "lldb/Host/windows/windows.h"
 #include <DbgHelp.h>
 
 #include "ProcessWinMiniDump.h"
-#include "RegisterContextWindowsMiniDump.h"
+#if defined(_WIN64)
+#include "x64/RegisterContextWindowsMiniDump_x64.h"
+#else
+#include "x86/RegisterContextWindowsMiniDump_x86.h"
+#endif
 
 using namespace lldb;
 using namespace lldb_private;
 
 // This is a minimal implementation in order to get something running.  It will
 // be fleshed out as more mini-dump functionality is added.
 
+class ThreadWinMiniDump::Data {
+  public:
+    Data() : m_context(nullptr) {}
+    const CONTEXT *m_context;
+};
+
 ThreadWinMiniDump::ThreadWinMiniDump(lldb_private::Process &process, lldb::tid_t tid) :
     Thread(process, tid),
-    m_thread_name()
+    m_data(new Data)
 {
 }
 
@@ -50,31 +60,45 @@
 ThreadWinMiniDump::CreateRegisterContextForFrame(lldb_private::StackFrame *frame)
 {
     const uint32_t concrete_frame_idx = (frame) ? frame->GetConcreteFrameIndex() : 0;
-    RegisterContextSP reg_ctx_sp(new RegisterContextWindowsMiniDump(*this, concrete_frame_idx));
+    RegisterContextSP reg_ctx_sp;
+    ArchSpec arch = HostInfo::GetArchitecture();
+    switch (arch.GetMachine())
+    {
+        case llvm::Triple::x86:
+#if defined(_WIN64)
+            // FIXME: This is a Wow64 process, create a RegisterContextWindows_Wow64
+#else
+            reg_ctx_sp.reset(new RegisterContextWindowsMiniDump_x86(*this, concrete_frame_idx, m_data->m_context));
+#endif
+            break;
+        case llvm::Triple::x86_64:
+#if defined(_WIN64)
+            reg_ctx_sp.reset(new RegisterContextWindowsMiniDump_x64(*this, concrete_frame_idx, m_data->m_context));
+#else
+            // LLDB is 32-bit, but the target process is 64-bit.  We probably can't debug this.
+#endif
+        default:
+            break;
+    }
     return reg_ctx_sp;
 }
 
 void
 ThreadWinMiniDump::ClearStackFrames()
 {
 }
 
-const char *
-ThreadWinMiniDump::GetName()
-{
-    return m_thread_name.empty() ? nullptr : m_thread_name.c_str();
-}
-
 void
-ThreadWinMiniDump::SetName(const char *name)
+ThreadWinMiniDump::SetContext(const void *context)
 {
-    if (name && name[0])
-        m_thread_name.assign(name);
-    else
-        m_thread_name.clear();
+    if (m_data)
+    {
+        m_data->m_context = static_cast<const CONTEXT *>(context);
+    }
 }
 
-bool ThreadWinMiniDump::CalculateStopInfo()
+bool
+ThreadWinMiniDump::CalculateStopInfo()
 {
     return false;
 }
Index: source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.h
===================================================================
--- source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.h
+++ /dev/null
@@ -1,75 +0,0 @@
-//===-- RegisterContextWindowsMiniDump.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_RegisterContextWindowsMiniDump_H_
-#define liblldb_RegisterContextWindowsMiniDump_H_
-
-#include "lldb/lldb-forward.h"
-#include "lldb/Target/RegisterContext.h"
-
-#include "Plugins/Process/Windows/Common/RegisterContextWindows.h"
-
-
-namespace lldb_private
-{
-
-class Thread;
-
-class RegisterContextWindowsMiniDump : public lldb_private::RegisterContextWindows
-{
-  public:
-    RegisterContextWindowsMiniDump(Thread &thread, uint32_t concrete_frame_idx);
-
-    virtual ~RegisterContextWindowsMiniDump();
-
-    void
-    InvalidateAllRegisters() override;
-
-    size_t
-    GetRegisterCount() override;
-
-    const RegisterInfo *
-    GetRegisterInfoAtIndex(size_t reg) override;
-
-    size_t
-    GetRegisterSetCount() override;
-
-    const RegisterSet *
-    GetRegisterSet(size_t reg_set) override;
-
-    bool
-    ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value) override;
-
-    bool
-    WriteRegister(const RegisterInfo *reg_info, const RegisterValue &reg_value) override;
-
-    bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
-
-    bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
-
-    uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
-
-    uint32_t NumSupportedHardwareBreakpoints() override;
-
-    uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
-
-    bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
-
-    uint32_t NumSupportedHardwareWatchpoints() override;
-
-    uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size, bool read, bool write) override;
-
-    bool ClearHardwareWatchpoint(uint32_t hw_index) override;
-
-    bool HardwareSingleStep(bool enable) override;
-};
-
-}
-
-#endif // #ifndef liblldb_RegisterContextWindowsMiniDump_H_
Index: source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.cpp
===================================================================
--- source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-//===-- RegisterContextWindowsMiniDump.cpp ------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/lldb-private-types.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Host/windows/HostThreadWindows.h"
-#include "lldb/Host/windows/windows.h"
-
-#include "RegisterContextWindowsMiniDump.h"
-
-#include "llvm/ADT/STLExtras.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-// This is a do-nothing stub implementation for now.
-
-RegisterContextWindowsMiniDump::RegisterContextWindowsMiniDump(Thread &thread, uint32_t concrete_frame_idx)
-    : RegisterContextWindows(thread, concrete_frame_idx)
-{
-}
-
-RegisterContextWindowsMiniDump::~RegisterContextWindowsMiniDump()
-{
-}
-
-void
-RegisterContextWindowsMiniDump::InvalidateAllRegisters()
-{
-}
-
-size_t
-RegisterContextWindowsMiniDump::GetRegisterCount()
-{
-    return 0;
-}
-
-const RegisterInfo *
-RegisterContextWindowsMiniDump::GetRegisterInfoAtIndex(size_t reg)
-{
-    return nullptr;
-}
-
-size_t
-RegisterContextWindowsMiniDump::GetRegisterSetCount()
-{
-    return 0;
-}
-
-const RegisterSet *
-RegisterContextWindowsMiniDump::GetRegisterSet(size_t reg_set)
-{
-    return nullptr;
-}
-
-bool
-RegisterContextWindowsMiniDump::ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value)
-{
-    return false;
-}
-
-bool
-RegisterContextWindowsMiniDump::WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value)
-{
-    return false;
-}
-
-bool
-RegisterContextWindowsMiniDump::ReadAllRegisterValues(lldb::DataBufferSP &data_sp)
-{
-    return false;
-}
-
-bool
-RegisterContextWindowsMiniDump::WriteAllRegisterValues(const lldb::DataBufferSP &data_sp)
-{
-    return false;
-}
-
-uint32_t
-RegisterContextWindowsMiniDump::ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num)
-{
-    const uint32_t num_regs = GetRegisterCount();
-
-    assert(kind < kNumRegisterKinds);
-    for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx)
-    {
-        const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx);
-
-        if (reg_info->kinds[kind] == num)
-            return reg_idx;
-    }
-
-    return LLDB_INVALID_REGNUM;
-}
-
-uint32_t
-RegisterContextWindowsMiniDump::NumSupportedHardwareBreakpoints()
-{
-    // Support for hardware breakpoints not yet implemented.
-    return 0;
-}
-
-uint32_t
-RegisterContextWindowsMiniDump::SetHardwareBreakpoint(lldb::addr_t addr, size_t size)
-{
-    return 0;
-}
-
-bool
-RegisterContextWindowsMiniDump::ClearHardwareBreakpoint(uint32_t hw_idx)
-{
-    return false;
-}
-
-uint32_t
-RegisterContextWindowsMiniDump::NumSupportedHardwareWatchpoints()
-{
-    // Support for hardware watchpoints not yet implemented.
-    return 0;
-}
-
-uint32_t
-RegisterContextWindowsMiniDump::SetHardwareWatchpoint(lldb::addr_t addr, size_t size, bool read, bool write)
-{
-    return 0;
-}
-
-bool
-RegisterContextWindowsMiniDump::ClearHardwareWatchpoint(uint32_t hw_index)
-{
-    return false;
-}
-
-bool
-RegisterContextWindowsMiniDump::HardwareSingleStep(bool enable)
-{
-    return false;
-}
Index: source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
===================================================================
--- source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
+++ source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
@@ -189,7 +189,13 @@
     {
         const ULONG32 thread_count = thread_list_ptr->NumberOfThreads;
         for (ULONG32 i = 0; i < thread_count; ++i) {
-            std::shared_ptr<ThreadWinMiniDump> thread_sp(new ThreadWinMiniDump(*this, thread_list_ptr->Threads[i].ThreadId));
+            const auto &mini_dump_thread = thread_list_ptr->Threads[i];
+            std::shared_ptr<ThreadWinMiniDump> thread_sp(new ThreadWinMiniDump(*this, mini_dump_thread.ThreadId));
+            if (mini_dump_thread.ThreadContext.DataSize >= sizeof(CONTEXT))
+            {
+                const CONTEXT *context = reinterpret_cast<const CONTEXT *>(static_cast<const char *>(m_data_up->m_base_addr) + mini_dump_thread.ThreadContext.Rva);
+                thread_sp->SetContext(context);
+            }
             new_thread_list.AddThread(thread_sp);
         }
     }
Index: source/Plugins/Process/Windows/MiniDump/CMakeLists.txt
===================================================================
--- source/Plugins/Process/Windows/MiniDump/CMakeLists.txt
+++ source/Plugins/Process/Windows/MiniDump/CMakeLists.txt
@@ -1,8 +1,21 @@
 include_directories(../../Utility)
 include_directories(../Common)
 
-add_lldb_library(lldbPluginProcessWinMiniDump
+set(PROC_WINDOWS_MINIDUMP_SOURCES
   ProcessWinMiniDump.cpp
-  RegisterContextWindowsMiniDump.cpp
   ThreadWinMiniDump.cpp
   )
+
+if (CMAKE_SIZEOF_VOID_P EQUAL 4)
+  set(PROC_WINDOWS_MINIDUMP_SOURCES ${PROC_WINDOWS_MINIDUMP_SOURCES}
+    x86/RegisterContextWindowsMiniDump_x86.cpp
+    )
+elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
+  set(PROC_WINDOWS_MINIDUMP_SOURCES ${PROC_WINDOWS_MINIDUMP_SOURCES}
+    x64/RegisterContextWindowsMiniDump_x64.cpp
+    )
+endif()
+
+add_lldb_library(lldbPluginProcessWinMiniDump
+  ${PROC_WINDOWS_MINIDUMP_SOURCES}
+  )
Index: source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h
===================================================================
--- source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h
+++ source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h
@@ -28,8 +28,6 @@
 
     virtual ~RegisterContextWindowsLive_x86();
 
-    bool ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value) override;
-
     bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue &reg_value) override;
 };
 
Index: source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp
===================================================================
--- source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp
+++ source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp
@@ -36,63 +36,6 @@
 
 
 bool
-RegisterContextWindowsLive_x86::ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value)
-{
-    if (!CacheAllRegisterValues())
-        return false;
-
-    uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
-    switch (reg)
-    {
-        case lldb_eax_i386:
-            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EAX", m_context.Eax);
-            reg_value.SetUInt32(m_context.Eax);
-            break;
-        case lldb_ebx_i386:
-            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EBX", m_context.Ebx);
-            reg_value.SetUInt32(m_context.Ebx);
-            break;
-        case lldb_ecx_i386:
-            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from ECX", m_context.Ecx);
-            reg_value.SetUInt32(m_context.Ecx);
-            break;
-        case lldb_edx_i386:
-            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EDX", m_context.Edx);
-            reg_value.SetUInt32(m_context.Edx);
-            break;
-        case lldb_edi_i386:
-            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EDI", m_context.Edi);
-            reg_value.SetUInt32(m_context.Edi);
-            break;
-        case lldb_esi_i386:
-            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from ESI", m_context.Esi);
-            reg_value.SetUInt32(m_context.Esi);
-            break;
-        case lldb_ebp_i386:
-            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EBP", m_context.Ebp);
-            reg_value.SetUInt32(m_context.Ebp);
-            break;
-        case lldb_esp_i386:
-            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from ESP", m_context.Esp);
-            reg_value.SetUInt32(m_context.Esp);
-            break;
-        case lldb_eip_i386:
-            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EIP", m_context.Eip);
-            reg_value.SetUInt32(m_context.Eip);
-            break;
-        case lldb_eflags_i386:
-            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EFLAGS", m_context.EFlags);
-            reg_value.SetUInt32(m_context.EFlags);
-            break;
-        default:
-            WINWARN_IFALL(WINDOWS_LOG_REGISTERS, "Requested unknown register %u", reg);
-            break;
-    }
-    return true;
-}
-
-
-bool
 RegisterContextWindowsLive_x86::WriteRegister(const RegisterInfo *reg_info, const RegisterValue &reg_value)
 {
     // Since we cannot only write a single register value to the inferior, we need to make sure
Index: source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h
===================================================================
--- source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h
+++ source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h
@@ -38,6 +38,9 @@
     size_t GetRegisterSetCount() override;
 
     const RegisterSet *GetRegisterSet(size_t reg_set) override;
+
+    bool ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value) override;
+
 };
 
 }
Index: source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
===================================================================
--- source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
+++ source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
@@ -121,3 +121,58 @@
     return &g_register_sets[reg_set];
 }
 
+bool
+RegisterContextWindows_x86::ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value)
+{
+    if (!CacheAllRegisterValues())
+        return false;
+
+    uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+    switch (reg)
+    {
+        case lldb_eax_i386:
+            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EAX", m_context.Eax);
+            reg_value.SetUInt32(m_context.Eax);
+            break;
+        case lldb_ebx_i386:
+            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EBX", m_context.Ebx);
+            reg_value.SetUInt32(m_context.Ebx);
+            break;
+        case lldb_ecx_i386:
+            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from ECX", m_context.Ecx);
+            reg_value.SetUInt32(m_context.Ecx);
+            break;
+        case lldb_edx_i386:
+            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EDX", m_context.Edx);
+            reg_value.SetUInt32(m_context.Edx);
+            break;
+        case lldb_edi_i386:
+            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EDI", m_context.Edi);
+            reg_value.SetUInt32(m_context.Edi);
+            break;
+        case lldb_esi_i386:
+            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from ESI", m_context.Esi);
+            reg_value.SetUInt32(m_context.Esi);
+            break;
+        case lldb_ebp_i386:
+            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EBP", m_context.Ebp);
+            reg_value.SetUInt32(m_context.Ebp);
+            break;
+        case lldb_esp_i386:
+            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from ESP", m_context.Esp);
+            reg_value.SetUInt32(m_context.Esp);
+            break;
+        case lldb_eip_i386:
+            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EIP", m_context.Eip);
+            reg_value.SetUInt32(m_context.Eip);
+            break;
+        case lldb_eflags_i386:
+            WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from EFLAGS", m_context.EFlags);
+            reg_value.SetUInt32(m_context.EFlags);
+            break;
+        default:
+            WINWARN_IFALL(WINDOWS_LOG_REGISTERS, "Requested unknown register %u", reg);
+            break;
+    }
+    return true;
+}
Index: source/Plugins/Process/Windows/Common/RegisterContextWindows.h
===================================================================
--- source/Plugins/Process/Windows/Common/RegisterContextWindows.h
+++ source/Plugins/Process/Windows/Common/RegisterContextWindows.h
@@ -60,8 +60,6 @@
     virtual bool CacheAllRegisterValues();
 
     CONTEXT m_context;
-
-  private:
     bool m_context_stale;
 };
 }
Index: packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
+++ packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
@@ -32,6 +32,20 @@
         stop_description = thread.GetStopDescription(256);
         self.assertTrue("0xc0000005" in stop_description);
 
+    @no_debug_info_test
+    def test_stack_info_in_mini_dump(self):
+        """Test that we can see the stack."""
+        self.assertEqual(self.process.GetNumThreads(), 1)
+        thread = self.process.GetThreadAtIndex(0)
+        # The crash is in main, so there should be one frame on the stack.
+        self.assertEqual(thread.GetNumFrames(), 1)
+        frame = thread.GetFrameAtIndex(0)
+        self.assertTrue(frame.IsValid())
+        pc = frame.GetPC()
+        eip = frame.FindRegister("eip")
+        self.assertTrue(eip.IsValid())
+        self.assertEqual(pc, eip.GetValueAsUnsigned())
+
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to