Original article: http://blogs.msdn.com/greggm/archive/2007/01/17/setting-conditional-breakpoints-using-object-ids.aspx
In local code, it is very useful to set an interruption condition that is the breakpoint of an instance of a specified object, so that the program can only be interrupted on a specified object instance. To achieve this effect, you can directly determine through the object address:
This = (CMyObject *) 0x10fc10
In managed code, the garbage collector (GC) moves object instances. Even if you use a language that strongly supports pointers, setting such a conditional breakpoint is futile. The alternative is to use object ids ).
Step 1: Create an object ID. To identify an object, you need to find the object instance you want to identify and put it in the monitoring window (watch window), right-click the object instance, run Make Object ID on the pop-up menu. In this way, '{1 #}' is available in the invigilator #}':
+ This {cswin. Form1, Text: Form1}{1 #}Cswin. Form1
Here, '1 # 'indicates that this object is the first identified object, and the ID of the next identified object will increase progressively (2 #, 3 #, etc ). there are articles on object identification in MSDN.
Step 2: set the condition breakpoint. In the breakpoint window, right-click the "condition breakpoint" menu and set the condition, for example:
This = 1 #
Happy debugging.
Published Wednesday, January 17,200 7 PM by greggm
Translated by Winking Zhang.