wiki:Debugging With Visual Studio

Version 4 (modified by Adam Roben, 14 years ago) (diff)


Using the Microsoft and Safari Symbol Servers

Follow the instructions for using the Microsoft and Safari symbol servers so that Visual Studio can show you backtraces that involve closed-source components.

Watch Window

You can open any of the Watch windows using the Debug > Windows > Watch submenu.

MSDN Magazine published a very useful article about Watch window pseudo-variables and format specifiers. Those of particular interest to WebKit developers are mentioned explicitly below, but the whole article is worth a read.

Adding $err,hr to the Watch Window will show you what ::GetLastError() would return at this moment, and will show you both the numerical error value and the error string associated with it.

Calling CFShow

When debugging code that uses CF types, you can invoke the CFShow function in the Immediate window (Debug > Windows > Immediate or Ctrl+Alt+I) to print a debug description of a CF object to the Output window like so:


Note that you usually won't be able to pass a variable name as the parameter to CFShow, as the Immediate window will get confused and think you're specifying a symbol in CoreFoundation.dll rather than whatever code you're debugging. It's usually easiest just to pass the address of the object directly as above.

Debugging Multi-Process Applications

You can attach a single debugger to more than one process. To do this, launch or attach to the first process, then use Tools > Attach to Process… or Ctrl+Alt+P to attach to the second process. Your breakpoints will apply to both processes.

There are two ways to see which process the debugger is currently operating on, and to switch the current process: the Processes window and the Debug Location toolbar. You can open the Processes window using Debug > Windows > Processes or Ctrl+Shift+Alt+P. You can show the Debug Location toolbar using View > Toolbars > Debug Location.

Visual Studio will always pauses all processes (i.e., you can't pause just one process). Similarly, Visual Studio will always step all processes when using the Step In/Over/Out commands.