Search code examples
windbgbreakpoints

Windbg: Printing the breakpoint number which triggered


When I run Windbg and it hits a breakpoint, then it prints the number of the breakpoint which triggered it. When I use a conditional breakpoint, I would want to print this as well. Is there some variable that holds the breakpoint number which triggered?

Because when I some ".printf" in the breakpoint condition, then only the stuff that I specify is printed (which is fine), but I would want to know which one it was as well.


Solution

  • When you define your breakpoints you can specify the ID value, you can then .echo this as a command string:

    bp 42 myDLL!myClass::foo ".echo 'breakpoint 42 hit!!!';gc"
    

    You will then know for sure which of your breakpoints was hit.

    Alternatively you can list the current breakpoints using bl and this will list the breakpoints and display the ordinal number (actually the ID that is assigned if you didn't specify it when defining the breakpoint).

    You can use this ordinal number and redefine you breakpoint and .echo the ordinal number the sam way as above.