[Lldb-commits] [PATCH] D70742: [LLDB] [Windows] Avoid using InitializeContext for allocating a CONTEXT. NFC.
Martin Storsjö via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Nov 26 13:02:45 PST 2019
mstorsjo created this revision.
mstorsjo added reviewers: labath, amccarth, asmith, aleksandr.urakov.
Herald added a project: LLDB.
InitializeContext is useful for allocating a CONTEXT struct in an unaligned byte buffer. In this case, we already have a CONTEXT we want to initialize, and we only used this as a very roundabout way of zero initializing it.
Instead just memset the CONTEXT we have, and set the ContextFlags field manually.
This matches how it is done in NativeRegisterContextWindows_*.cpp.
This also makes LLDB run successfully in Wine (for a trivial tested case at least), as Wine haven't implemented the InitializeContext function.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D70742
Files:
lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
Index: lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
===================================================================
--- lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
@@ -154,15 +154,8 @@
return true;
TargetThreadWindows &wthread = static_cast<TargetThreadWindows &>(m_thread);
- uint8_t buffer[2048];
- memset(buffer, 0, sizeof(buffer));
- PCONTEXT tmpContext = NULL;
- DWORD contextLength = (DWORD)sizeof(buffer);
- if (!::InitializeContext(buffer, kWinContextFlags, &tmpContext,
- &contextLength)) {
- return false;
- }
- memcpy(&m_context, tmpContext, sizeof(m_context));
+ memset(&m_context, 0, sizeof(m_context));
+ m_context.ContextFlags = kWinContextFlags;
if (::SuspendThread(
wthread.GetHostThread().GetNativeThread().GetSystemHandle()) ==
(DWORD)-1) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70742.231128.patch
Type: text/x-patch
Size: 958 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191126/3ea00cf9/attachment.bin>
More information about the lldb-commits
mailing list