[Lldb-commits] [lldb] r348055 - [windows] Fix two minor bugs on Windows

Stella Stamenova via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 30 16:18:19 PST 2018


Author: stella.stamenova
Date: Fri Nov 30 16:18:19 2018
New Revision: 348055

URL: http://llvm.org/viewvc/llvm-project?rev=348055&view=rev
Log:
[windows] Fix two minor bugs on Windows

1. In ProcessWindows if we fail to allocate memory, we need to return LLDB_INVALID_ADDRESS rather than 0 or nullptr as that is the invalid address that LLDB looks for
2. In RegisterContextWindows in ReadAllRegisterValues, always create a new buffer. This is what the other platforms do and data_sp is always null in all tested scenarios on Windows as well

Modified:
    lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
    lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp

Modified: lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp?rev=348055&r1=348054&r2=348055&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp Fri Nov 30 16:18:19 2018
@@ -722,7 +722,7 @@ lldb::addr_t ProcessWindows::DoAllocateM
     LLDB_LOG(log, "cannot allocate, there is no active debugger connection.");
     error.SetErrorString(
         "cannot allocate, there is no active debugger connection");
-    return 0;
+    return LLDB_INVALID_ADDRESS;
   }
 
   HostProcess process = m_session_data->m_debugger->GetProcess();
@@ -732,7 +732,7 @@ lldb::addr_t ProcessWindows::DoAllocateM
   if (!result) {
     error.SetError(GetLastError(), eErrorTypeWin32);
     LLDB_LOG(log, "allocating failed with error: {0}", error);
-    return 0;
+    return LLDB_INVALID_ADDRESS;
   }
 
   return reinterpret_cast<addr_t>(result);

Modified: lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp?rev=348055&r1=348054&r2=348055&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp Fri Nov 30 16:18:19 2018
@@ -40,12 +40,13 @@ void RegisterContextWindows::InvalidateA
 
 bool RegisterContextWindows::ReadAllRegisterValues(
     lldb::DataBufferSP &data_sp) {
+
   if (!CacheAllRegisterValues())
     return false;
-  if (data_sp->GetByteSize() < sizeof(m_context)) {
-    data_sp.reset(new DataBufferHeap(sizeof(CONTEXT), 0));
-  }
+
+  data_sp.reset(new DataBufferHeap(sizeof(CONTEXT), 0));
   memcpy(data_sp->GetBytes(), &m_context, sizeof(m_context));
+
   return true;
 }
 




More information about the lldb-commits mailing list