【发布时间】:2015-04-19 06:22:40
【问题描述】:
我正在尝试调试一个严重依赖继承的类。调试会话很乏味,因为它涉及一个对象调用链中另一个对象上的相同函数。我浪费了很多时间来执行不相关的代码,而这些代码本来可以更好地花在其他地方。
这很简单:我想使用通配符在类实例上设置断点,例如b Foo::*。这样,当我感兴趣的东西进入作用域(比如静态函数或成员函数)时,调试器就会捕捉到。
这是一个难点:参数化类:我想使用通配符在模板化类的成员函数上设置断点,例如b Foo<*>::bar。 (真正的问题比这更糟糕,因为模板参数本身就是模板类)。
虽然 GDB 似乎让我设置了一个,但调试器并没有停止(见下文)。它声称它在未来的负载上设置了一个断点。事实上,我使用了静态链接并且符号已经存在。不会加载任何库。
如何使用通配符设置断点?
(gdb) b CryptoPP::PK_EncryptorFilter::*
Function "CryptoPP::PK_EncryptorFilter::*" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (CryptoPP::PK_EncryptorFilter::*) pending.
(gdb) r
Starting program: /home/cryptopp-ecies/ecies-test.exe
Attack at dawn!
[Inferior 1 (process 5163) exited normally]
还有:
(gdb) rbreak CryptoPP::DL_EncryptionAlgorithm_Xor<*>::SymmetricEncrypt
(gdb) r
Starting program: /home/cryptopp-ecies/ecies-test.exe
Attack at dawn!
[Inferior 1 (process 5470) exited normally]
...
(gdb) rbreak CryptoPP::*::SymmetricEncrypt
(gdb) r
Starting program: /home/cryptopp-ecies/ecies-test.exe
Attack at dawn!
[Inferior 1 (process 5487) exited normally]
【问题讨论】:
标签: c++ debugging gdb wildcard breakpoints