使用-g选项编译,但是“单步执行直到退出功能主,没有行号信息” [英] Compile with -g option but "Single stepping until exit from function main, which has no line number information"
问题描述
这是一个名为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;
}
我用这个命令来编译这段代码:
g ++ -g -Wall main.cpp -o foo
接下来,我使用gdb:
$ gdb foo
(gdb)start
临时断点1在0x80487c3
启动程序:/ home / laptop / workspace / foo
临时断点1,0x080487c3在main()
(gdb)s
单步执行直到退出函数main,
,没有行号信息。
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)在libc-start.c:258
258 libc-start.c:没有这样的文件或目录。
我做错了什么?
我使用-g选项,但我仍然收到此错误。
配置:
- GDB:GNU gdb(Ubuntu / Linaro 7.4-2012.04-0ubuntu2.1)7.4-2012.04
- GCC:g ++(Ubuntu 4.8.1-2ubuntu1〜12.04)4.8我已经安装了这些工具: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完美的工作。
谢谢大家。
I have some trouble with gdb. This is my code in a single file named 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; }
I used this command to compile this code :
g++ -g -Wall main.cpp -o foo
Next, I used 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.
What did I do wrong ? I use the -g option but I still got this error.
Configuration :
- GDB : GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
- GCC : g++ (Ubuntu 4.8.1-2ubuntu1~12.04) 4.8.1
I installed these tools with a classic : sudo apt-get install
Thank you by advance for any answer :-)
解决方案Thank you for your answers. I found what is wrong. As jcm says my gcc is relatively new. I have update gdb to the last current version which is GNU gdb (GDB) 7.6. Now this works perfectly.
By the way, with the version 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 works perfectly.
Thank you for all of you.
这篇关于使用-g选项编译,但是“单步执行直到退出功能主,没有行号信息”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!