Tuesday, December 7, 2010

Setting data breakpoints for mixed projects in VS2008

In VS2008, data breakpoints are disabled in GUI for mixed projects, which is actually a powerful debugging mechanism for trouble-shooting. Although it could still be set in windbg, still painful.

Fortunately, data breakpoints can be set programmatically. We can found one sample from below link:
http://www.morearty.com/code/breakpoint/

Then, in your projects, try below code:

 
   1: DWORD x = 1;
   2: CBreakpoint bp;
   3: bp.Set(&x, sizeof(x), CBreakpoint::Write);
   4: ...
   5: x = 100;
   6:  
Generally, I would like to create an foo debugging thread, keep looping/sleeping, if needed, explicitly set the watch target dynamically in the debugger, then it works well.

No comments:

Post a Comment