From 12bf40dbc531f238b01506a70d1832d201b3692d Mon Sep 17 00:00:00 2001
From: David Schulz <david.schulz@nokia.com>
Date: Fri, 2 Mar 2012 12:25:38 +0100
Subject: [PATCH] Debugger: DebugBreakApi is always used under 32bit Windows

Change-Id: Iacd672cf38f698912609aeb2d3e7d54101bcfe0d
Reviewed-by: hjk <qthjk@ovi.com>
---
 src/plugins/debugger/procinterrupt.cpp | 46 +++++++++++++++++---------
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/src/plugins/debugger/procinterrupt.cpp b/src/plugins/debugger/procinterrupt.cpp
index 09b725b2b9a..8c6ed93e5f3 100644
--- a/src/plugins/debugger/procinterrupt.cpp
+++ b/src/plugins/debugger/procinterrupt.cpp
@@ -37,7 +37,6 @@
 #include <QProcess> // makes kill visible on Windows.
 #include <QFile>
 #include <QDir>
-
 using namespace Debugger::Internal;
 
 static inline QString msgCannotInterrupt(int pid, const QString &why)
@@ -99,23 +98,38 @@ bool Debugger::Internal::interruptProcess(int pID, int engineType, QString *erro
         // Try DebugBreakProcess if either Qt Creator is compiled 64 bit or
         // both Qt Creator and application are 32 bit.
 #ifdef Q_OS_WIN64
-        Q_UNUSED(engineType)
-        // Qt-Creator compiled 64 bit: Always use DebugBreakProcess.
-        const bool useDebugBreakApi = true;
+        // Qt-Creator compiled 64 bit
+        // Windows must be 64 bit
+        // CDB 64 bit: use DebugBreakProcess for 32 an 64 bit processes.
+        // CDB 32 bit: untested
+        // GDB: not supported
+        const bool useDebugBreakApi= true;
+
 #else
         // Qt-Creator compiled 32 bit:
-        // CDB: If Qt-Creator is a WOW64 process (meaning a 32bit process
-        //    running in emulation), always use win64interrupt.exe for native
-        //    64 bit processes and WOW64 processes. While DebugBreakProcess()
-        //    works in theory for other WOW64 processes, the break appears
-        //    as a WOW64 breakpoint, which CDB is configured to ignore since
-        //    it also triggers on module loading.
-        // GDB: Use win64interrupt for native 64bit processes only (it fails
-        //    for WOW64 processes.
-        static const bool hostIsWow64Process = isWow64Process(GetCurrentProcess());
-        const bool useDebugBreakApi = engineType == CdbEngineType ?
-                                      !hostIsWow64Process :
-                                      !isWow64Process(inferior);
+
+        bool useDebugBreakApi;
+        if (isWow64Process(GetCurrentProcess())) {
+            // Windows is 64 bit
+            if (engineType == CdbEngineType) {
+                // CDB 64 bit: If Qt-Creator is a WOW64 process (meaning a 32bit process
+                //    running in emulation), always use win64interrupt.exe for native
+                //    64 bit processes and WOW64 processes. While DebugBreakProcess()
+                //    works in theory for other WOW64 processes, the break appears
+                //    as a WOW64 breakpoint, which CDB is configured to ignore since
+                //    it also triggers on module loading.
+                // CDB 32 bit: untested
+                useDebugBreakApi = false;
+            } else {
+                // GDB: Use win64interrupt for native 64bit processes only (it fails
+                //    for WOW64 processes.
+                useDebugBreakApi = isWow64Process(inferior);
+            }
+        } else {
+            // Windows is 32 bit
+            // All processes are 32 bit, so DebugBreakProcess can be used in all cases.
+            useDebugBreakApi = true;
+        }
 #endif
         if (useDebugBreakApi) {
             ok = DebugBreakProcess(inferior);
-- 
GitLab