views:

842

answers:

5

If an application† crashes:

alt text

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

alt text

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

alt text

  • 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 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. i.e. there is no source code or debug into. Visual Studio should still be able to show me an assembly dump.

+2  A: 

Assuming this is your application that you wrote in VS, just press F5 to run the program and either use a breakpoint, or manually break the program to start debugging.

Geoffrey Chetwood
How do i load an executable into Visual Studio?
Ian Boyd
If it is your program, you would be developing it in VS. Just press F5. If it is anything besides this, you will need to supply a lot more details in the question.
Geoffrey Chetwood
He's not writing the application, it's when programs he's the end user of crash (unhandled exceptions) that he is getting this.Thus, he has no source code.
Jeff
Not every Win32 executable written today is created with Visual Studio.
Ian Boyd
+1  A: 

The problem in the last screen shot is that VS 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 screen shot you were actually attached to the program .. the output windows show it loaded stripped symbols for ole and the crt.

Steve Steiner
+1  A: 

You can debug a program with VS if yo 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 VS debugger and look for the problem.

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

John Smithers
+1  A: 

Debug -> Windows -> Disassembly (I think the keyboard shortcut is ALT+8, but I am configured for VC6.0 bindings, cause that's how I roll, and it may have changed).

You can get public symbols for the operating system from http://msdl.microsoft.com/download/symbols. Add it to the list in Tools -> Options -> Debugging -> Symbols -> Symbol file locations.

Also, make sure you are running in the same integrity level as the app. Or always run VS as Administrator.

jeffamaphone
+1  A: 

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 4 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 cant 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 wont 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 doesnt - it may be more suited to the sort of debugging you need to do.

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

Kragen