繁体   English   中英

Windbg:如何在C ++函数的一个重载上设置断点?

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

我有一个c ++函数的两个重载,我想在其中一个上设置一个断点:

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'

哎呀我可以在所有重载上设置断点,但似乎无法弄清楚如何:

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*'

尝试:

bu 0xff3c6100

如果我没记错的话,WinDbg也允许按地址设置断点。

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

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

bm myexe!displayerror

这将设置所有重载的断点,而不是使用bc来清除你不想要的那些

bc 1-3

或者只是禁用它们

bd 1-3

bm的问题在于它产生的断点有时无法评估并触发中断。 有时很烦人。

搜索您的dll以查找与您的符号匹配的所有入口点

x myexe!displayerror

这将输出与搜索字符串及其入口点匹配的所有符号,然后在地址上设置断点

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

这将在命中该地址时设置特定断点,或者将bp设置为另一个地址。 您可以将断点设置为只触发一次,清除断点并退出

bp /1 ff3c6100

您还可以执行诸如转储调用堆栈,变量和继续之类的命令:

bp ff3c6100 "kb;dv;g"

您也可以在连接WinDbg时打开源代码,导航到要设置断点的代码行并按F9(与使用Visual Studio一样),在设置断点之前会暂停一段时间在该行,这假设您可以访问源代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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