ScreenHunter_06 Aug. 29 15.51

A little tip with Visual Studio 2010 debugger

0

Today I have upgrated my website with a newer version of this fantastic mystique template. So I resume a draft hidden post to celebrate the update :) .

Sometime, if you develop under VS2010, you would stop the debugger when a variable has a certain value. This happen mostly inside loops. For (a stupid) instance watch at the code in the following:

for (int i = 0; i < 100; i++)
{

pippo = getPippo(i);

}

getPippo(i) returns a const char * at every loop step.

You would see when getPippo(i) returns a certain value. This could happen inside the cycle at every loop step. A manual way to solve our problem (or something similar) is to put an if statement inside the loop like

for (int i = 0; i < 100; i++)
{

pippo = getPippo(i);

#ifdef _DEBUG

if (strcmp(pippo, “FIBXU1″) == 0)

{

Sleep(1); //Put here the breakpoint and set the next step to pippo = getPippo(i);

}

#endif
}

This means that you must compile your program again and remember that you would delete the debug code after you have made the necessary fix (in case you put #ifdef _DEBUG it is not really necessary). Worst if your code is inside a library used by another component. A this point you must re-compile first the library and then the program. You waste your time doing so.

With Visual Studio 2010 you can configure conditions inside breakpoints. Moreover the VS2010 debugger cames with the possibility to put string functions inside breakpoint conditions.

You must select a breakpoint inside your code and go to the breakpoint properties (mouse over breakpoint and right click) and select condition. Put there your condition and run the program again, the debugger will stop just if the condition is satisfied (in the case of image below my debugger will stop just if the variabile m_pcStart will have the value FIBXU1).

 

breakpoints

You can find further information HERE.

Back to the origins with Funto…

0

Back to the origins with Funtoo http://t.co/BbnTphfr

My website is up again at http…

0

My website is up again at http://t.co/FM04fchv. Some issues with ie7 with a wp plugin for flickr gallery. I will fix that soon.

Consultazione Pubblica Online …

0

Consultazione Pubblica Online – Miur http://t.co/mlpumFZf #valoretitolo

#saratommasi tu rappresenti il…

0

#saratommasi tu rappresenti il fallimento di questo paese. Ma il cervello che cosa ti dice? http://t.co/mXceFHoj

http://t.co/uTe9v0bm Per veder…

0

http://t.co/uTe9v0bm Per vedere come votano i nostri politici alla camera e senato (o chi per loro….).

The cyberclimber: http://t.co/…

0

The cyberclimber: http://t.co/NeEmnjFP... a nice climbing browser game.

Developers tool-kit analysis h…

0

Developers tool-kit analysis http://t.co/NFVRUSui

Go to Top