I'm interested in tips and tricks regarding debugging a C/C++ project in Visual Studio's debugger. I recently found out that if you have a pointer to a certain data type, let's say char* ptr, then you can see it as an array in the watch window using a syntax such as:
ptr,10
This will display the first 10 elements from the ptr address, in the same way as it would be displayed if the definition would be:
char ptr[10];
What other tips and tricks do you know about Visual Studio debugger?
PS: I hope this subject wasn't already discussed. Should you find a similar post, please let me know.
To bring up the Run and Debug view, select the Run and Debug icon in the Activity Bar on the side of VS Code. You can also use the keyboard shortcut Ctrl+Shift+D. The Run and Debug view displays all information related to running and debugging and has a top bar with debugging commands and configuration settings.
I really like the possibility to tweak the Debugger display of types and structures through AutoExp.dat. The file is located at
..\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\autoexp.dat
and allows to define own templates for the display of data during debugging:
While debugging, Data Tips and items in the Watch and Variable windows are automatically expanded to show their most important elements. The expansion follows the format given by the rules in this file. You can add rules for your types or change the predefined rules.
The file is full of good examples and you can easily adapt certain templates to your own needs or add new ones for your own classes.
You can set the names of your threads using a somewhat awkward piece of code. See this article at MSDN.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With