use*_*402 4 c++ debugging ubuntu gdb
我对gdb有些麻烦.这是我在名为main.cpp的单个文件中的代码
#include <iostream>
void myfunc();
int main(){
char msg[] = "Hello World!";
myfunc();
std::cout << msg << std::endl;
return 0;
}
void myfunc(){
int boo = 16;
}
Run Code Online (Sandbox Code Playgroud)
我用这个命令来编译这段代码:
g++ -g -Wall main.cpp -o foo
Run Code Online (Sandbox Code Playgroud)
接下来,我使用了gdb:
$ gdb foo
(gdb) start
Temporary breakpoint 1 at 0x80487c3
Starting program: /home/laptop/workspace/foo
Temporary breakpoint 1, 0x080487c3 in main ()
(gdb) s
Single stepping until exit from function main,
which has no line number information.
Hello World!
__libc_start_main (main=0x80487c0 <main>, argc=1, ubp_av=0xbffff3a4, init=0x80488b0 <__libc_csu_init>, fini=0x8048920 <__libc_csu_fini>, rtld_fini=0xb7fed280 <_dl_fini>, stack_end=0xbffff39c) at libc-start.c:258
258 libc-start.c: No such file or directory.
Run Code Online (Sandbox Code Playgroud)
我做错了什么 ?我使用-g选项,但我仍然遇到此错误.
配置:
我用经典的sudo apt-get install安装了这些工具
提前感谢您的任何答案:-)
谢谢您的回答.我发现了什么是错的.正如jcm所说,我的gcc相对较新.我已将gdb更新为最新的当前版本GNU gdb(GDB)7.6.现在这完美无缺.
顺便说一句,使用版本g ++(Ubuntu/Linaro 4.6.4-1ubuntu1~12.04)4.6.4,gdb(Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1)7.4-2012.04完美运行.
谢谢你们所有人.
归档时间: |
|
查看次数: |
8975 次 |
最近记录: |