gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-31 00:48:29 26 4
gpt4 key购买 nike

我有一个 c++ 应用程序,其中包含以下 main.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(Apple 版本 gdb-1346)(2009 年 9 月 18 日星期五 20:40:51 UTC)),以及使用命令“-c -g”使用 gcc(gcc 版本 4.2.1(Apple Inc. build 5646)(点 1))编译应用程序。

当我在第 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!

最佳答案

您需要将 HeatMap 实例化为:

HeatMap heatMap;

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

关于c++ - GDB 不会中断在 C++ 中创建对象时设置的断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2582001/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com