代码之家  ›  专栏  ›  技术社区  ›  Drew

GDB不中断在C++中创建对象时设置的断点

  •  2
  • Drew  · 技术社区  · 16 年前

    我有一个C++应用程序,有以下主要内容:CPP:

    1:  #include <stdio.h>
    2:  #include "HeatMap.h"
    3:  #include <iostream>
    4:
    5:  int main (int argc, char * const argv[])
    6:  {
    7:    HeatMap heatMap();
    8:    printf("message");
    9:    return 0;
    10: }
    

    所有的编译都没有错误,我正在使用gdb( GNU GDB 6.3.50-20050815(苹果版GDB-1346)(星期五9月18日20:40:51 UTC 2009) ,并用gcc编译了应用程序。( GCC 4.2.1版(苹果公司5646版)(DOT 1) )使用命令“-c-g”。

    当我将断点添加到第7、8和9行,并运行gdb时,我得到以下内容…

    (gdb) break main.cpp:7
    Breakpoint 1 at 0x10000177f: file src/main.cpp, line 8.
    (gdb) break main.cpp:8
    Note: breakpoint 1 also set at pc 0x10000177f.
    Breakpoint 2 at 0x10000177f: file src/main.cpp, line 8.
    (gdb) break main.cpp:9
    Breakpoint 3 at 0x100001790: file src/main.cpp, line 9.
    (gdb) run
    Starting program: /DevProjects/DataManager/build/DataManager 
    Reading symbols for shared libraries ++. done
    
    Breakpoint 1, main (argc=1, argv=0x7fff5fbff960) at src/main.cpp:8
    8       printf("message");
    (gdb) 
    

    那么,为什么,有人知道,为什么我的应用程序没有在对象创建的断点上中断,而是在printf行中断?

    Drew J. Sonne。

    编辑 答: GDB skips over my code!

    1 回复  |  直到 16 年前
        1
  •  5
  •   GManNickG    16 年前

    您需要将heatmap实例化为:

    HeatMap heatMap;
    

    HeatMap heatMap(); 声明返回heatmap的函数。

    推荐文章