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
|
|