【发布时间】:2013-07-30 16:49:08
【问题描述】:
我的主cpp文件如下:
class UnifiedDirListQuery : public UnifiedQuery{
public:
UnifiedDirListQuery(){
//do something-------------line 12
}
}
//other code
int main( void ){
UnifiedQuery *query = new UnifiedDirListQuery();//-----line 56
//do something
delete query;
}
UnifiedQuery 分别在unified.h 和unified.cpp 中声明和定义。当我在 gdb 中调试这个程序时:
gdb: b 56
gdb: r
gdb: s
程序跳转到第 12 行。例如,如果在 unified.cpp : line 25 中定义了ctor,如何转到unified.cpp 并跳转到基类UnifiedQuery 的Ctor。
更新
对于break UnifiedDirListQuery::UnifiedDirListQuery 的答案,gdb 抱怨说:
(gdb) b UnifiedDirListQuery::UnifiedDirListQuery
[0] cancel
[1] all
?HERE
?HERE
> 1
Note: breakpoint -1 (disabled) also set at pc 0x0.
Breakpoint 1 at 0x0
Note: breakpoints -1 (disabled) and 1 also set at pc 0x0.
Breakpoint 2 at 0x0
warning: Multiple breakpoints were set.
Use the "delete" command to delete unwanted breakpoints.
(gdb) r
Starting program: /...(the path)/src/base/unified_album_list.cgi
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x0: Input/output error.
对于b file:line的答案,gdb 直接无视,不停地跑过程序。顺便说一句:实际上 ctor 的定义在一个名为 unified.h 的文件中,隐式声明为内联函数,因为它在头文件中。
【问题讨论】:
标签: c++ gdb breakpoints