[Lldb-commits] [lldb] r252100 - Fix x64 build on Windows, which was broken by my refactor from last week.

Adrian McCarthy via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 4 15:47:55 PST 2015


Author: amccarth
Date: Wed Nov  4 17:47:55 2015
New Revision: 252100

URL: http://llvm.org/viewvc/llvm-project?rev=252100&view=rev
Log:
Fix x64 build on Windows, which was broken by my refactor from last week.

No build bots build x64 on Windows yet, but this was spotted by another developer who emailed me directly.

Added:
    lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.cpp
    lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.h
      - copied, changed from r252058, lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h
Modified:
    lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h

Modified: lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h?rev=252100&r1=252099&r2=252100&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h Wed Nov  4 17:47:55 2015
@@ -45,4 +45,4 @@ class RegisterContextWindows_x64 : publi
 };
 }
 
-#endif // #ifndef liblldb_RegisterContextPOSIX_x64_H_
+#endif // #ifndef liblldb_RegisterContextWindows_x64_H_

Added: lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.cpp?rev=252100&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.cpp (added)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.cpp Wed Nov  4 17:47:55 2015
@@ -0,0 +1,171 @@
+//===-- RegisterContextWindowsLive_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/Core/Error.h"
+#include "lldb/Core/RegisterValue.h"
+#include "lldb/Host/windows/HostThreadWindows.h"
+#include "lldb/Host/windows/windows.h"
+
+#include "lldb-x86-register-enums.h"
+#include "RegisterContextWindowsLive_x64.h"
+#include "TargetThreadWindows.h"
+
+#include "llvm/ADT/STLExtras.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+RegisterContextWindowsLive_x64::RegisterContextWindowsLive_x64(Thread &thread, uint32_t concrete_frame_idx)
+    : RegisterContextWindows_x64(thread, concrete_frame_idx)
+{
+}
+
+RegisterContextWindowsLive_x64::~RegisterContextWindowsLive_x64()
+{
+}
+
+
+bool
+RegisterContextWindowsLive_x64::ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value)
+{
+    if (!CacheAllRegisterValues())
+        return false;
+
+    switch (reg_info->kinds[eRegisterKindLLDB])
+    {
+        case lldb_rax_x86_64:
+            reg_value.SetUInt64(m_context.Rax);
+            break;
+        case lldb_rbx_x86_64:
+            reg_value.SetUInt64(m_context.Rbx);
+            break;
+        case lldb_rcx_x86_64:
+            reg_value.SetUInt64(m_context.Rcx);
+            break;
+        case lldb_rdx_x86_64:
+            reg_value.SetUInt64(m_context.Rdx);
+            break;
+        case lldb_rdi_x86_64:
+            reg_value.SetUInt64(m_context.Rdi);
+            break;
+        case lldb_rsi_x86_64:
+            reg_value.SetUInt64(m_context.Rsi);
+            break;
+        case lldb_r8_x86_64:
+            reg_value.SetUInt64(m_context.R8);
+            break;
+        case lldb_r9_x86_64:
+            reg_value.SetUInt64(m_context.R9);
+            break;
+        case lldb_r10_x86_64:
+            reg_value.SetUInt64(m_context.R10);
+            break;
+        case lldb_r11_x86_64:
+            reg_value.SetUInt64(m_context.R11);
+            break;
+        case lldb_r12_x86_64:
+            reg_value.SetUInt64(m_context.R12);
+            break;
+        case lldb_r13_x86_64:
+            reg_value.SetUInt64(m_context.R13);
+            break;
+        case lldb_r14_x86_64:
+            reg_value.SetUInt64(m_context.R14);
+            break;
+        case lldb_r15_x86_64:
+            reg_value.SetUInt64(m_context.R15);
+            break;
+        case lldb_rbp_x86_64:
+            reg_value.SetUInt64(m_context.Rbp);
+            break;
+        case lldb_rsp_x86_64:
+            reg_value.SetUInt64(m_context.Rsp);
+            break;
+        case lldb_rip_x86_64:
+            reg_value.SetUInt64(m_context.Rip);
+            break;
+        case lldb_rflags_x86_64:
+            reg_value.SetUInt64(m_context.EFlags);
+            break;
+    }
+    return true;
+}
+
+bool
+RegisterContextWindowsLive_x64::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
+    // our cached copy of the register values are fresh.  Otherwise when writing EAX, for example,
+    // we may also overwrite some other register with a stale value.
+    if (!CacheAllRegisterValues())
+        return false;
+
+    switch (reg_info->kinds[eRegisterKindLLDB])
+    {
+        case lldb_rax_x86_64:
+            m_context.Rax = reg_value.GetAsUInt64();
+            break;
+        case lldb_rbx_x86_64:
+            m_context.Rbx = reg_value.GetAsUInt64();
+            break;
+        case lldb_rcx_x86_64:
+            m_context.Rcx = reg_value.GetAsUInt64();
+            break;
+        case lldb_rdx_x86_64:
+            m_context.Rdx = reg_value.GetAsUInt64();
+            break;
+        case lldb_rdi_x86_64:
+            m_context.Rdi = reg_value.GetAsUInt64();
+            break;
+        case lldb_rsi_x86_64:
+            m_context.Rsi = reg_value.GetAsUInt64();
+            break;
+        case lldb_r8_x86_64:
+            m_context.R8 = reg_value.GetAsUInt64();
+            break;
+        case lldb_r9_x86_64:
+            m_context.R9 = reg_value.GetAsUInt64();
+            break;
+        case lldb_r10_x86_64:
+            m_context.R10 = reg_value.GetAsUInt64();
+            break;
+        case lldb_r11_x86_64:
+            m_context.R11 = reg_value.GetAsUInt64();
+            break;
+        case lldb_r12_x86_64:
+            m_context.R12 = reg_value.GetAsUInt64();
+            break;
+        case lldb_r13_x86_64:
+            m_context.R13 = reg_value.GetAsUInt64();
+            break;
+        case lldb_r14_x86_64:
+            m_context.R14 = reg_value.GetAsUInt64();
+            break;
+        case lldb_r15_x86_64:
+            m_context.R15 = reg_value.GetAsUInt64();
+            break;
+        case lldb_rbp_x86_64:
+            m_context.Rbp = reg_value.GetAsUInt64();
+            break;
+        case lldb_rsp_x86_64:
+            m_context.Rsp = reg_value.GetAsUInt64();
+            break;
+        case lldb_rip_x86_64:
+            m_context.Rip = reg_value.GetAsUInt64();
+            break;
+        case lldb_rflags_x86_64:
+            m_context.EFlags = reg_value.GetAsUInt64();
+            break;
+    }
+
+    // Physically update the registers in the target process.
+    TargetThreadWindows &wthread = static_cast<TargetThreadWindows &>(m_thread);
+    return ::SetThreadContext(wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
+}

Copied: lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.h (from r252058, lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.h?p2=lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.h&p1=lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h&r1=252058&r2=252100&rev=252100&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.h Wed Nov  4 17:47:55 2015
@@ -1,4 +1,4 @@
-//===-- RegisterContextWindows_x64.h ----------------------------*- C++ -*-===//
+//===-- RegisterContextWindowsLive_x64.h ------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,42 +7,34 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef liblldb_RegisterContextWindows_x64_H_
-#define liblldb_RegisterContextWindows_x64_H_
+#ifndef liblldb_RegisterContextWindowsLive_x64_H_
+#define liblldb_RegisterContextWindowsLive_x64_H_
 
 #include "lldb/lldb-forward.h"
-#include "RegisterContextWindows.h"
+#include "../../Common/x64/RegisterContextWindows_x64.h"
 
 namespace lldb_private
 {
 
 class Thread;
 
-class RegisterContextWindows_x64 : public RegisterContextWindows
+class RegisterContextWindowsLive_x64 : public RegisterContextWindows_x64
 {
   public:
     //------------------------------------------------------------------
     // Constructors and Destructors
     //------------------------------------------------------------------
-    RegisterContextWindows_x64(Thread &thread, uint32_t concrete_frame_idx);
+    RegisterContextWindowsLive_x64(Thread &thread, uint32_t concrete_frame_idx);
 
-    virtual ~RegisterContextWindows_x64();
+    virtual ~RegisterContextWindowsLive_x64();
 
     //------------------------------------------------------------------
     // Subclasses must override these functions
     //------------------------------------------------------------------
-    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;
 };
 }
 
-#endif // #ifndef liblldb_RegisterContextPOSIX_x64_H_
+#endif // #ifndef liblldb_RegisterContextWindowsLive_x64_H_




More information about the lldb-commits mailing list