Monday, July 11, 2011

Breakpoint setting breakpoint

Here's a little trick I used for the first time that I thought would be nice sharing.

I wanted to have a data breakpoint added automatically for an object on load (without having to find it's pointer everytime).

First thing to do, add a regular breakpoint where you would have access to the pointer you want a breakpoint for.

Create a macro that does something like the following:

Sub SetBreakpointOnTrailComponent()

Dim e As EnvDTE.Expression

e = DTE.Debugger.GetExpression("&MyVariable", True)

If e.IsValidValue Then
DTE.Debugger.Breakpoints.Add(Data:=e.Value, DataCount:=4)
End If

End Sub

Finally, on the "When hit..." condition of your breakpoint, simply set it to run your macro.

This, my friends, is power!

P.S. DTE.Debugger.ExecuteStatement("") can also be very useful.

No comments:

Post a Comment