4

我的主要 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.hunified.cpp

gdb: b 56
gdb: r
gdb: s

程序跳转到第 12 行。例如,如果定义了 ctor,如何转到unified.cpp并跳转到Ctor基类。UnifiedQueryunified.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,隐式声明为内联函数,因为它位于头文件中。

4

2 回答 2

6

你也可以

break UnifiedDirListQuery::UnifiedDirListQuery

另请注意,gdb 具有制表符完成功能,因此您不必键入所有内容。

于 2013-07-30T08:09:51.853 回答
0

break unified.cpp:25应该做到这一点,例如在第 25 行中断特别是如果您有多个文件,则必须提供要中断的文件的名称。请参阅此处了解更多信息

于 2013-07-30T08:07:41.003 回答