我认为应该是p/x
,但结果却很奇怪。这是错误还是我做错了什么?
(gdb) ptype row.DBL_NPIO2.m_value
type = double
(gdb) p row.DBL_NPIO2.m_value
$6 = -1.5707963267948966
(gdb) p/x row.DBL_NPIO2.m_value
$7 = 0xffffffffffffffff
(gdb) print (double)0xffffffffffffffff
$8 = 1.844674407370955e+19
这是在CentOS5 x86机器上,我正在调试使用gcc 4.4(未优化,带有-g)构建的C ++代码
mattheww@SEN-CentOS5: ~$ uname -a
Linux SEN-CentOS5 2.6.18-238.9.1.el5 #1 SMP Tue Apr 12 18:10:13 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
mattheww@SEN-CentOS5: ~$ gdb --version
GNU gdb (GDB) CentOS (7.0.1-45.el5.centos)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
答案 0 :(得分:1)
在x86_64中,double和unsigned long具有相同的大小,您可以先将double转换为unsigned long,然后再打印。
p /x *(unsigned long*)&row.DBL_NPIO2.m_value
或者您可以
x/8x &row.DBL_NPIO2.m_value
哪个将从低地址到高地址打印字节。