简体   繁体   中英

Windbg: How to set breakpoint on one of the overloads of a C++ function?

I have two overloads of a c++ function and I would like to set a breakpoint on one of them:

0:000> bu myexe!displayerror
Matched: 00000000`ff3c6100 myexe!displayError (int, HRESULT, wchar_t *)
Matched: 00000000`ff3c60d0 myexe!displayError (int, HRESULT)
Ambiguous symbol error at 'myexe!displayerror'

Heck I would be fine with setting breakpoints on all overloads, but can't seem to figure out how:

0:000> bu myexe!displayerror*
Matched: 00000000`ff3c6100 myexe!displayError (int, HRESULT, wchar_t *)
Matched: 00000000`ff3c60d0 myexe!displayError (int, HRESULT)
Ambiguous symbol error at 'myexe!displayerror*'

Try:

bu 0xff3c6100

If I remember right, WinDbg allows setting breakpoints by address too.

你试过“bm myexe!displayerror *”吗?

bp @@(MyClass :: MyMethod)打破方法(如果相同的方法被重载并因此出现在多个地址上,则非常有用)

bm myexe!displayerror

This will set breakpoints all all overloads, than you use bc to clear the ones you don't want

bc 1-3

Or just disable them

bd 1-3

The problem with bm is that the breakpoints it produces will sometimes fail to be evaluate and trigger a break. Annoying sometimes.

Search your dll for all entry point matching your symbol

x myexe!displayerror

this will output all symbols matching the search string and their entry points, then set the breakpoint on the address

bp ff3c6100 // for myexe!displayError (int, HRESULT, wchar_t *)

This will set a specific breakpoint when that address is hit, or you set bp against the other address. You can set the breakpoint to just hit once, clear the breakpoint and exit

bp /1 ff3c6100

and you can also execute commands such as dump the call stack, variables and continue:

bp ff3c6100 "kb;dv;g"

You may also just open your source code when WinDbg is attached, navigate to the line of code you want to set the breakpoint on and hit F9 (same as you would do using Visual Studio), it will pause for a while before setting a breakpoint at that line, this assumes you have access to the source code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM