gdb中的下一个命令无法正常工作 [英] next command in gdb is not working correctly

查看:127
本文介绍了gdb中的下一个命令无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是简单地使用gdb逐行浏览代码,以了解它是如何工作的以及它在做什么。第一次做到这一点时它运行良好,但现在下一个命令不能正常工作。有时它往前走,有时往后退。这没有意义。每次我这样做的时候,似乎都是一样的模式。下面是一个例子。任何人都知道什么是错的?



注意:这是一个旧的Mac,旧的程序版本(我没有更新的权力)



请明确。



谢谢!

 阅读共享库的符号...完成
(gdb)b main
0x2730的断点1:文件../../../../gcc-3.4.6/libf2c/ libF77 / pow_zi.c,第14行
(gdb)r
启动程序:/ Users / kevinsanchez / epeace / ConstU / main
n读取共享库+的符号。完成
重新设置断点1时出错:
未定义函数main。
重新启用共享库断点:1

main.c中main()中的断点1,0x00002730:34
34 {
(gdb)n
$ main()at main.c:42
42 for(i = 0; i (gdb)n
34 {
(gdb) n
35 runstart = clock();
(gdb)n
39 Init = ReadInit(&CaseDim); / *从初始化文件读入初始值* /
(gdb)n
35 runstart = clock() ;
(gdb)n
39 Init = ReadInit(&CaseDim); / *从初始化文件读入初始值* /
(gdb)

解决方案


任何人都知道什么是错的?


在调试使用优化构建的程序时,您描述的症状非常普遍:编译器重新排列代码的方式使得不同的行会混合在一起。



确保您编译时没有任何 -O 标志,或者添加 -O0


这里是make文件的一部分: CC = gcc CFLAGS = -g -O2


这样做:删除 -O2 并且您的调试将变得更容易。


I am simply using gdb to step through a code line by line to learn how it is working and what it is doing. It worked fine the first time I did this, but now the next command is not working right. Sometimes it goes forward, sometimes it goes backwards. It doesn't make sense. Every time I do this it seems to be the same pattern. Below is an example. Anyone know what is wrong?

Note: This is an old Mac with old program versions (That I do not have the power to update)

Please be explicit. I am fairly new to linux and programming in general.

Thanks!

Reading symbols for shared libraries ... done
(gdb) b main
Breakpoint 1 at 0x2730: file ../../../../gcc-3.4.6/libf2c/libF77/pow_zi.c, line 14.
(gdb) r
Starting program: /Users/kevinsanchez/epeace/ConstU/main 
nReading symbols for shared libraries +. done
Error in re-setting breakpoint 1:
Function "main" not defined.
Re-enabling shared library breakpoints: 1

Breakpoint 1, 0x00002730 in main () at main.c:34
34      {
(gdb) n
main () at main.c:42
42      for (i=0;i<DpDIM;i++) {
(gdb) n
34      {
(gdb) n
35      runstart=clock();
(gdb) n
39      Init=ReadInit(&CaseDim);/*reads in initial valies from initfile*/
(gdb) n
35      runstart=clock();
(gdb) n
39      Init=ReadInit(&CaseDim);/*reads in initial valies from initfile*/
(gdb) 

解决方案

Anyone know what is wrong?

The symptoms you've described are very common when debugging programs built with optimization: the compiler re-arranges code in such a way that instructions from different lines become intermixed.

Make sure you compile without any -O flags, or add -O0 at the end of your compilation lines.

here is part of the make file: CC = gcc CFLAGS = -g -O2

That would do it: remove -O2 and your debugging would go much easier.

这篇关于gdb中的下一个命令无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆