【问题标题】:Windbg: How to set breakpoint on one of the overloads of a C++ function?Windbg:如何在 C++ 函数的重载之一上设置断点?
【发布时间】:2008-10-02 10:14:44
【问题描述】:

我有两个 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*'

【问题讨论】:

    标签: c++ debugging windbg


    【解决方案1】:

    试试:

    bu 0xff3c6100
    

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:
        bm myexe!displayerror
        

        这将为所有重载设置断点,而不是使用bc 清除不需要的重载

        bc 1-3
        

        或者只是禁用它们

        bd 1-3
        

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

        【讨论】:

          【解决方案4】:

          bp @@( MyClass::MyMethod ) 中断方法(如果同一个方法被重载并因此出现在多个地址上时很有用)

          【讨论】:

            【解决方案5】:

            在您的 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 的操作相同),它会暂停一段时间在该行设置断点,这假定您可以访问源代码。

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2019-08-04
              • 1970-01-01
              相关资源
              最近更新 更多