I hit "Debug" and Visual Studio is my currently registered Just-In-Time (JIT) debugger:

Visual Studio appears, but there's no way to debug anything:

I do not see any disassembly

I do not see any registers (assuming it runs on a CPU with registers)

The call stack is empty (assuming the CPU has a stack pointer)

I do not see any symbols (assuming it had any)

I do not see reconstructed source code from reflection (assuming it was managed)

Other JIT debugger products are able to show disassembly, but they are either command-line based (Debugging Tools for Windows), or do not support symbols (OllyDbg, Delphi). Additionally, my question is about debugging using Visual Studio, since I already have it installed, and it is already my registered JIT.

How do you debug a program using Visual Studio?

Alternatively: has anyone written a graphical debugger that supports the Microsoft symbol server?

† Not, necessarily, written in Visual Studio.

Edit: Changes title to process rather than application, since the latter somehow implies "my application."

Edit: Assume the original application was written in assembly language by Steve Gibson. That is, there is no source code or debug information. Visual Studio should still be able to show me an assembly dump.

I don't get it. Is this your program? Or someone else's?
–
GEOCHETDec 11 '08 at 21:11

Yes. The same question applies for both. If it is my own application, then i want to debug the executable. If it is someone elses then i want tot debug the executable.
–
Ian BoydDec 11 '08 at 21:28

If it is yours, you would be in VS, and you would perform the steps in my answer. If it is not yours, you will likely be very limited if the debugging symbols are not included.
–
GEOCHETDec 11 '08 at 21:29

6 Answers
6

Looking at the screenshot it appears that Visual Studio is currently debugging in Run mode - you need to break execution of the process before it makes sense to look at things like the call stack, etc...

To break execution of the process you either need to hit a breakpoint, or you can break execution of the process at any time by using the Pause / Break all toolbar item (Control + Alt + Break).

Then you should be able to access the following windows under the Debug -> Windows menu:

The disassembly window

The registers window

The call stack window

The modules window shows a list of loaded modules along with where their corresponding symbols are loaded from (if loaded)

Some other useful windows:

The processes window is useful if you are debugging more than one process at a time

The Threads window

The Memory window (there are four of them)

The Locals window

Some of these might not be visible by default depending on which window configuration you selected when you first started Visual Studio - if you can't find them then right click on the toolbar and goto customise to add them.

Visual studio doesn't reconstruct soucre code from disassembly - you really need to have the original source code available to you, otherwise the symbols almost certainly won't match the source code you are debugging.

If you are debugging unmanaged modules without source code then I recommend you at least try WinDbg - its user interface is a bit clunky at times, and it does have a steep learning curve, however it is a very powerful debugger supporting many features that Visual Studio doesn't - it may be more suited to the sort of debugging you need to do.

(Visual Studio is a fantastic debugger, however it's primarily used to debug modules where the source code is available and so it lacks certain features in favour of a better user experience).

The problem in the last screenshot is that Visual Studio did not enter break mode automatically. That seems like a bug. If you hit the 'pause' button on the toolbar, it would enter break mode, giving you disassembly, and a callstack.

According to that last screenshot you were actually attached to the program ... the output windows shows it loaded stripped symbols for OLE and the crt.

You can debug a program with Visual Studio if you have the debug information available for this program. It's the difference between compiling a Release version (normally without debug information) and compiling a Debug version.

This dialog to debug a program is handy if you are testing the debug version of your self-written program. You can attach it "on-the-fly" to your Visual Studio debugger and look for the problem.

If it is not your program or it is your program, but does not provide debugging information which Visual Studio can understand, then you are out of luck.