[Lldb-commits] [lldb] r252950 - Implement RegisterContext for Mini Dumps.

Adrian McCarthy via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 12 13:16:15 PST 2015


Author: amccarth
Date: Thu Nov 12 15:16:15 2015
New Revision: 252950

URL: http://llvm.org/viewvc/llvm-project?rev=252950&view=rev
Log:
Implement RegisterContext for Mini Dumps.

Differential Revision: http://reviews.llvm.org/D14591

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

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py?rev=252950&r1=252949&r2=252950&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py Thu Nov 12 15:16:15 2015
@@ -32,6 +32,20 @@ class MiniDumpTestCase(TestBase):
         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("pc")
+        self.assertTrue(eip.IsValid())
+        self.assertEqual(pc, eip.GetValueAsUnsigned())
+
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)

Modified: lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h?rev=252950&r1=252949&r2=252950&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h Thu Nov 12 15:16:15 2015
@@ -60,8 +60,6 @@ class RegisterContextWindows : public ll
     virtual bool CacheAllRegisterValues();
 
     CONTEXT m_context;
-
-  private:
     bool m_context_stale;
 };
 }

Modified: lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp?rev=252950&r1=252949&r2=252950&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp Thu Nov 12 15:16:15 2015
@@ -121,3 +121,58 @@ RegisterContextWindows_x86::GetRegisterS
     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;
+}

Modified: lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h?rev=252950&r1=252949&r2=252950&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h Thu Nov 12 15:16:15 2015
@@ -38,6 +38,9 @@ class RegisterContextWindows_x86 : publi
     size_t GetRegisterSetCount() override;
 
     const RegisterSet *GetRegisterSet(size_t reg_set) override;
+
+    bool ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value) override;
+
 };
 
 }

Modified: lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp?rev=252950&r1=252949&r2=252950&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp Thu Nov 12 15:16:15 2015
@@ -36,63 +36,6 @@ RegisterContextWindowsLive_x86::~Registe
 
 
 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

Modified: lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h?rev=252950&r1=252949&r2=252950&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h Thu Nov 12 15:16:15 2015
@@ -28,8 +28,6 @@ class RegisterContextWindowsLive_x86 : p
 
     virtual ~RegisterContextWindowsLive_x86();
 
-    bool ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value) override;
-
     bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue &reg_value) override;
 };
 

Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/CMakeLists.txt?rev=252950&r1=252949&r2=252950&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/CMakeLists.txt Thu Nov 12 15:16:15 2015
@@ -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}
+  )

Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp?rev=252950&r1=252949&r2=252950&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp Thu Nov 12 15:16:15 2015
@@ -14,7 +14,7 @@
 
 #include <assert.h>
 #include <stdlib.h>
-
+#include <memory>
 #include <mutex>
 
 #include "lldb/Core/PluginManager.h"
@@ -189,7 +189,13 @@ ProcessWinMiniDump::UpdateThreadList(Thr
     {
         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];
+            auto thread_sp = std::make_shared<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);
         }
     }

Removed: lldb/trunk/source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.cpp?rev=252949&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.cpp (removed)
@@ -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;
-}

Removed: lldb/trunk/source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.h?rev=252949&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/RegisterContextWindowsMiniDump.h (removed)
@@ -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_

Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp?rev=252950&r1=252949&r2=252950&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp Thu Nov 12 15:16:15 2015
@@ -9,12 +9,16 @@
 
 #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;
@@ -22,9 +26,15 @@ 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,7 +60,26 @@ lldb::RegisterContextSP
 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;
 }
 
@@ -59,22 +88,17 @@ 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;
 }

Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h?rev=252950&r1=252949&r2=252950&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h Thu Nov 12 15:16:15 2015
@@ -35,15 +35,13 @@ public:
     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;
 };

Added: lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp?rev=252950&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp (added)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp Thu Nov 12 15:16:15 2015
@@ -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

Added: lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h?rev=252950&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h (added)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h Thu Nov 12 15:16:15 2015
@@ -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 "Plugins/Process/Windows/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_

Added: lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp?rev=252950&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp (added)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp Thu Nov 12 15:16:15 2015
@@ -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

Added: lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h?rev=252950&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h (added)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h Thu Nov 12 15:16:15 2015
@@ -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 "Plugins/Process/Windows/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_




More information about the lldb-commits mailing list