Thread specific breakpoints

Thread specific breakpoints are a feature that I wasn’t aware of for a while but have become an important part of my debugging toolbox.

As it turns out, the bp command takes a /t switch, which allows you to specify the address of the thread object that you want to set the breakpoint for. By that I mean that the breakpoint will only fire if the address specified is executed by the thread specified. This is helpful if you have a routine in your driver called from multiple threads and you’re trying to narrow down the behavior of a particular thread. Example usage would be:

bp /t 86033858  ntfs!ntfscommoncreate

This will set a breakpoint on an incredibly hot routine in the system (the open handler for NTFS) but will only break into the debugger if the breakpoint is hit by thread 0×86033858.

As an added tip, this command can be combined with the $thread pseudo register, which always evaluates to the current thread:

bp /t @$thread ntfs!ntfscommoncreate

One Response to “Thread specific breakpoints”

  1. [...] talked previously about thread specific breakpoints, which allow you to set a breakpoint that will only fire for a specific thread. Equally useful are [...]

Leave a Reply