由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 又一个GDB的问题:关于显示数据
相关主题
请高人解释一下为啥这个输出总是"HELLO-ERR"One network C question
shm_open failed关于STDERR定向到文件问题
50伪币:请教perl代码差错的问题!多谢啦!fprintf in C\C++
一个 perl 的 print 的初级问题c的文件写入问题
[合集] (c++)为什么不能把这个function的definition放到class里A question related to pipe
求救, F家onsite算法题c++ template中如何判断类型
帮忙!!! 需要比较两文件, 有包子相送 (转载)请教用Mathematica输出mesh数据 (转载)
关于fscanf格式化读取的问题.如何把系统错误信息写入日志文件(c++)
相关话题的讨论汇总
话题: dz话题: gdb话题: 打印话题: 程序话题: 数据
进入Programming版参与讨论
1 (共1页)
s********h
发帖数: 286
1
我在程序停止的时候用
print dz[j]
打印我的数据,dz是一个数组,j是index。打印出来的数据和实际不一样!
实际上,在我的程序中,也就是停止程序的前一个语句,已经让程序打印出来这个值:
fprintf(stderr, "dz[%d]=%g,",j,dz[j]);
显示的是
dz[5]=0.603372,
可是用GDB打印的结果却是
(gdb) print dz[j]
$3 = 36.7898712
我也试了打印其它格式,都不对,实在找不到问题在哪里了。
请问大家知道这是怎么回事吗?多谢先!!!
s********h
发帖数: 286
2
找到gdb manual里面的一段话,可能是这个原因吧:
Warning: Occasionally, a local variable may appear to have the wrong value
at certain points in a function--just after entry to a new scope, and just
before exit.
You may see this problem when you are stepping by machine instructions. This
is because, on most machines, it takes more than one instruction to set up
a stack frame (including local variable definitions); if you are stepping by
machine instructions, variables may appear to have the wrong values until
the s

【在 s********h 的大作中提到】
: 我在程序停止的时候用
: print dz[j]
: 打印我的数据,dz是一个数组,j是index。打印出来的数据和实际不一样!
: 实际上,在我的程序中,也就是停止程序的前一个语句,已经让程序打印出来这个值:
: fprintf(stderr, "dz[%d]=%g,",j,dz[j]);
: 显示的是
: dz[5]=0.603372,
: 可是用GDB打印的结果却是
: (gdb) print dz[j]
: $3 = 36.7898712

1 (共1页)
进入Programming版参与讨论
相关主题
如何把系统错误信息写入日志文件(c++)[合集] (c++)为什么不能把这个function的definition放到class里
[合集] Why it only write the file once?求救, F家onsite算法题
MPI I/O 问题帮忙!!! 需要比较两文件, 有包子相送 (转载)
问一个vc++ 2008的问题关于fscanf格式化读取的问题.
请高人解释一下为啥这个输出总是"HELLO-ERR"One network C question
shm_open failed关于STDERR定向到文件问题
50伪币:请教perl代码差错的问题!多谢啦!fprintf in C\C++
一个 perl 的 print 的初级问题c的文件写入问题
相关话题的讨论汇总
话题: dz话题: gdb话题: 打印话题: 程序话题: 数据