我的主要 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
中声明和定义。当我在 gdb 中调试这个程序时:unified.h
unified.cpp
gdb: b 56
gdb: r
gdb: s
程序跳转到第 12 行。例如,如果定义了 ctor,如何转到unified.cpp
并跳转到Ctor
基类。UnifiedQuery
unified.cpp : line 25
更新
对于答案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
,隐式声明为内联函数,因为它位于头文件中。