GDB:警告:在重载方法上设置了多个断点
anisha@linux-dopx:~> g++ -Wall -pedantic breakpoints.cpp -g
anisha@linux-dopx:~> gdb a.out
(gdb) b X::X
Breakpoint 1 at 0x400ac1: file breakpoints.cpp, line 14.
Breakpoint 2 at 0x400aa0: file breakpoints.cpp, line 9.
warning: Multiple breakpoints were set.
Use the "delete" command to delete unwanted breakpoints.
(gdb)
设置断点的方法是什么 在默认构造函数上,这样 GDB 不会创建不必要的断点 其超载的对应物?
或者是GDB所期望的问题 用户删除它的烂摊子? 还是我遗漏了一点?
编辑1.
对于以下代码:
class X
{
public:
X ()
{
std :: cout << "\nIn the default constructor";
}
X (int)
{
std :: cout << "\nIn the parameterized constructor";
}
~X () {}
};
我尝试过:
(gdb) b X:: X (11)
the class X does not have any method named X (11)
Hint: try 'X:: X (11)<TAB> or 'X:: X (11)<ESC-?>
(Note leading single quote.)
Make breakpoint pending on future shared library load? (y or [n])
没有帮助!
编辑2.
感谢osgx,以下工作有效:
(gdb) b X::X(int)
Breakpoint 5 at 0x400ac1: file breakpoints.cpp, line 14.
(gdb) b X::X()
Breakpoint 6 at 0x400aa0: file breakpoints.cpp, line 9.
(gdb)
anisha@linux-dopx:~> g++ -Wall -pedantic breakpoints.cpp -g
anisha@linux-dopx:~> gdb a.out
(gdb) b X::X
Breakpoint 1 at 0x400ac1: file breakpoints.cpp, line 14.
Breakpoint 2 at 0x400aa0: file breakpoints.cpp, line 9.
warning: Multiple breakpoints were set.
Use the "delete" command to delete unwanted breakpoints.
(gdb)
What is the way to set the breakpoint
on the default constructor, such that
GDB doesn't create unnecessary breakpoints
on the its overloaded counterparts?
Or is it a problem with GDB that it expects
the users to delete its mess?
Or am I missing a point?
EDIT 1.
For the following code:
class X
{
public:
X ()
{
std :: cout << "\nIn the default constructor";
}
X (int)
{
std :: cout << "\nIn the parameterized constructor";
}
~X () {}
};
I tried:
(gdb) b X:: X (11)
the class X does not have any method named X (11)
Hint: try 'X:: X (11)<TAB> or 'X:: X (11)<ESC-?>
(Note leading single quote.)
Make breakpoint pending on future shared library load? (y or [n])
Didn't help!
EDIT 2.
Thanks to osgx, the following works:
(gdb) b X::X(int)
Breakpoint 5 at 0x400ac1: file breakpoints.cpp, line 14.
(gdb) b X::X()
Breakpoint 6 at 0x400aa0: file breakpoints.cpp, line 9.
(gdb)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想,这种情况很正常。某些 ABI 将为一个类生成两个构造函数。当您询问
b X::X
时,gdb 将检测两个构造函数并设置两个断点。 (抱歉,这不是你的情况)“设置了多个断点”。对于重载方法也可能会发出警告(这是您的情况): http:// www.delorie.com/gnu/docs/gdb/gdb_36.html
对于此类方法,您可以通过键入其类型来选择一种方法:
更新:根据同一文档,gdb 应该要求用户选择一些重载方法:
UPDATE1: http:// /sourceware.org/gdb/onlinedocs/gdb/Ambigously-Expressions.html#Ambigously-Expressions 说这个菜单可以打开和关闭(默认是关闭的):
I think, this case is normal. Some ABI will generate two constructors for an Class. When you ask
b X::X
gdb will detect both constructors and set two breakpoints. (Sorry, this is not your case)The "Multiple breakpoints were set." warning may be also given for overloaded methods (this is your case): http://www.delorie.com/gnu/docs/gdb/gdb_36.html
For such methods you can select one method by typing its types:
Update: According to the same document, gdb should ask user to select some of overloaded methods:
UPDATE1: http://sourceware.org/gdb/onlinedocs/gdb/Ambiguous-Expressions.html#Ambiguous-Expressions says that this menu can be switched on and off (default is off):