32 bit Mixed mode applications can be debugged using both Gdb and Visual studio debugger. (Since there is no 64 bit gcc suite available for SUA, 64 bit mixed mode apps cant be debugged using gdb - VS debugger is the only option.)
There is caveat that you need to be aware of when using gdb to debug mixed-mode applications - code in the windows dll that the mixed-mode application links to can’t be debugged. On the other hand, Visual studio debugger can be used to debug both the posix part of the code and the windows part of the code. Gdb, being a SUA utility, doesn’t have the capability to debug windows part of the code.
So how is then Visual studio able to debug both the posix part and windows part of the code? It’s because all Mixed-mode processes are essentially windows processes. The binary image of a mixed-mode process is stamped as Windows CUI. So on pure technical grounds, a mixed-mode process is a windows process that can make calls in to the SUA subsystem.
After I had written this post, my colleague Sanjay pointed out that file utility shows this difference as well.
output of file utility for a pure SUA binary
Windows NT PE format (EXE), executable not stripped Intel Posix-CUI DOS executable (EXE)
output of file utility for a mixed-mode binary
mixed.out: Windows NT PE format (EXE), executable not stripped Intel Windows-CUI DOS executable (EXE)
This has a lot of significance with respect to the kind of tool that can be used with mixed-mode processes. Windows subsystem sees a mixed-mode process as if it were a normal win32 process. So you can use all of the windows world tools with mixed-mode processes as well. Some such tools are
- Task manager lists mixed-mode processes
- You can add mixed-mode processes windows fire wall
- You can use profiling tools on mixed-mode processes.
- Application verifier can be used on mixed-mode processes to detect heap corruptions among many other things.
For those that are familiar with mixed-mode, the above fact that mixed-mode processes are windows processes might appear counter intuitive. You needn’t worry much about it. It still makes lot of sense to think of a mixed more process as if it were a SUA/posix process that has the capability to call into windows dlls. This mental model will help you when thinking of how effectively you can leverage mixed-mode in your existing applications.