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

5

14

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*'
Timisoara answered 2/10, 2008 at 10:14 Comment(0)
B
7

Try:

bu 0xff3c6100

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

Bradbradan answered 2/10, 2008 at 10:20 Comment(0)
G
5

Have you tried "bm myexe!displayerror*" ?

Grotesquery answered 23/12, 2008 at 12:8 Comment(0)
A
3
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.

Arbour answered 14/11, 2010 at 6:40 Comment(0)
W
3

bp @@( MyClass::MyMethod ) break on methods (useful if the same method is overloaded and thus present on several addresses)

Wedlock answered 25/1, 2011 at 17:59 Comment(0)
R
1

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.

Rajkot answered 10/3, 2012 at 11:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.