In Qt Creator, a build kit is composed of a compiler and a debugger,etc. Click Tools/Options, you may see quite a few kits such as Desktop Qt 5.12.1 MinGW 64-bit, Desktop Qt 5.12.1 MSVC2017 64bit, Desktop Qt 5.12.1 MSVC2017 32bit. Click each kit, you will see its compiler and the debugger are matched in architecture. For example,Mingw 64 bit compiler is bundled with GDB 64 bit debugger. MSVC 64 bit C/C++ compiler is accompanied with CDB 64 bit debugger. Visual C++ 32 bit compiler is accompanied by CDB 32 bit debugger. I’m curious about the effects of combining compiler and debugger with different CPU architecture, e.g.
- Can 32 bit CDB be used to debug a 64 bit application?
- Can 64 bit CDB be used to debug a 32 bit program?
- Can GDB be used to debug an MSVC built program?
- Can CDB be used to debug an Mingw compiled app?
My first guess is yes, as long as the debugger and the target application can be executed on your OS. If you are on a 64 bit OS, all debuggers regardless of CDB or GDB, 32bit or 64 bit can be run to debug applications, regardless of a 32bit program or a 64 bit program, regardless it being built with MSVC or Mingw. However, the reality is:
- both CDB 32bit and CDB 64 bit can debug MSVC built 32 bit applications.
- GDB 64 bit can also be used to debug MSVC built 32 bit exes, but has the following warning:The selected debugger may be inappropriate for the inferior. Examining symbols and setting breakpoints by file name and line number may fail. The inferior is in the Portable Executable format. Selecting CDB as debugger would improve the experience for this binary format.
And I also get the following messages in the Application Output tab:
`C:\Windows\SYSTEM32\ntdll.dll': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
`C:\Windows\System32\wow64.dll': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
`C:\Windows\System32\wow64win.dll': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
`C:\Windows\System32\wow64cpu.dll': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
As the warning says, although the program runs normally, it can not hit the breakpoints I set.
- CDB 32bit cannot debug MSVC generated 64 bit programs. The following are the error messages in the debugger log window:Cannot execute xxx, Win32 error 0n50
“The request is not supported.”
Debuggee initialization failed, Win32 error 0n50
The request is not supported.
eERROR: Process crashed
dNOTE: INFERIOR ILL
dCALL: SHUTDOWN INFERIOR
- GDB 64 bit can debug the 64 bit MSVC applications but also has the above warning.
- Mingw 64 bit projects can not be debugged with CDB(32/64bit). In fact, you cannot specify the CDB debugger in the Mingw build kit.
The conclusion is: although you can debug a 32 bit program with a 32 bit debugger or a 64 bit debugger, a 64 bit application can not be debugged with a 32 bit debugger. In practice, I recommend you use CDB to debug MSVC generated binaries and use GDB to debug Mingw generated executables.