mojo
mojo

Reputation: 4132

How do I programmatically refer to a breakpoint in WinDbg?

Programmatic Breakpoint IDs

Breakpoint Syntax (learn.microsoft.com) claims this about setting breakpoints using an expression for the ID.

Breakpoint IDs do not have to be referred to explicitly. Instead, you can use a numerical expression that resolves to an integer that corresponds to a breakpoint ID. To indicate that the expression should be interpreted as a breakpoint, use the following syntax.

b?[Expression]

In this syntax, the square brackets are required, and Expression stands for any numerical expression that resolves to an integer that corresponds to a breakpoint ID.

This is exactly what I want to do. However, it doesn't seem to work for me. The one example they give

b?[@$t0]

produces a syntax error. I tried it a few other ways.

0:000> r $t0 = 300
0:000> ? $t0
Evaluate expression: 768 = 00000300
0:000> b?[@$t0]
        ^ Syntax error in 'b?[@$t0]'
0:000> b0
        ^ Syntax error in 'b0'
0:000> b
        ^ Syntax error in 'b'
0:000> bl?[@$t0]
        ^ Syntax error in 'bl?[@$t0]'
0:000> bl
 0 e 77c27d89     0001 (0001)  0:**** ntdll!LdrpDoDebuggerBreak+0x2b
0:000> bl0
 0 e 77c27d89     0001 (0001)  0:**** ntdll!LdrpDoDebuggerBreak+0x2b
0:000> bl300
0:000>

I don't really know if the example given is viable, since b and b0 don't work. However, I can't seem to use a similar syntax for commands that otherwise work with hardcoded values.

How can I make use of this (mythical?) feature?

(WinDbg 10.0.17134.12 X86)

Upvotes: 0

Views: 126

Answers (1)

blabb
blabb

Reputation: 8987

The what is a regex substitute either of these (p,u,a) which will denote bp1 .. bpn | ba1 ... ban | bu1 .. bun

0:000> bl
 0 e 62e5f7a0     0001 (0001)  xxx
 1 e 62e5f7a2     0001 (0001)  xxx
 2 e 62e5f7a3     0001 (0001)  xxx
 3 e 62e5f7a5     0001 (0001)  xxx

0:000> bp[8-5]
breakpoint 3 exists, redefining
breakpoint 0 redefined
0:000>

or a better usage scenerio

0:000> bp .
0:000> bl
 0 e 77ac05a6     0001 (0001)  0:**** ntdll!LdrpDoDebuggerBreak+0x2c
0:000> r $t0 =0
0:000> bp[@$t0] ntdll!LdrpCompareServiceChecksum
breakpoint 0 exists, redefining
0:000> bl
 0 e 77a4b931     0001 (0001)  0:**** ntdll!LdrpCompareServiceChecksum
0:000> bp[@$t0] kernel32!CreateWaitableTimerExA
breakpoint 0 exists, redefining
0:000> bl
 0 e 77584202     0001 (0001)  0:**** kernel32!CreateWaitableTimerExA
0:000>

Upvotes: 1

Related Questions