Welcome to MSDN Blogs Sign in | Join | Help

Debugging mixed-mode applications

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.

<edit>

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)

Thanks Sanjay.

</edit> 

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.

Published Tuesday, February 13, 2007 7:44 PM by shankul
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

Thursday, February 22, 2007 8:42 PM by shamit

# re: Debugging mixed-mode applications

Does gdb allow debugging of 64 bit apps? i think it should, so is our gdb 64 bitized?

I just was curious - we could have a table

App (x86, x64, 32 on 64 bit), Gdb (32/64) -> (debugging possible - yes/no)

Thursday, February 22, 2007 8:45 PM by shamit

# re: Debugging mixed-mode applications

correction probably  -

gdb to be used for debugging instead of gcc

Process identifiers could also be found using command line tools - ps -ef, or tlist etc

Tuesday, September 01, 2009 2:36 PM by WinGDB

# re: Debugging mixed-mode applications

We've prepared add-in which supports debugging (with use of gdb) native Linux or MinGW applications under VisualStudio. If you are interested in, then please check our site :)

Kind regards,

WinGDB team

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker