This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Question: How does gdb read the computer's memory?


I am interested in the following situation: 
When a program stores a double at a certain location in the 
memory 
(cf. my c++ example below) gdb while debugging the program 
is able to retrieve the double in its decimal floating point 
representation 
and also in its hexadecimal (IEEE) representation. The latter is 
done most 
simply by the command 
 
x/1xg + <memory address of the double> 
 
In the example below one sees that the number 888.9864 
has the IEEE 64 bit hex representation 0x408bc7e425aee632 
 
-How does gdb perform this operation? 
 
Any hint is welcome (but I would appreciate most some lines of 
explicit 
c or c++ code). 
 
Thanks in anticipation. 
 
Regards 
Martin 
 
//*********************************** 
 
 #include<iostream> 
 
 
        using namespace std; 
 
        int main() 
        { 
 
          double mynumber = 888.9864; 
 
          cout << mynumber << endl; 
 
        } 
 
//************************************* 
 
g++ of this program yields a.out 
 
The debugging output is: 
 
$ gdb ./a.out 
GNU gdb 5.3-debian 
Copyright 2002 Free Software Foundation, Inc. 
GDB is free software, covered by the GNU General Public License, 
and you are 
welcome to change it and/or distribute copies of it under certain 
conditions. 
Type "show copying" to see the conditions. 
There is absolutely no warranty for GDB.  Type "show warranty" 
for details. 
This GDB was configured as "i386-linux"... 
(gdb) b 11 
Breakpoint 1 at 0x80485f6: file test.cc, line 11. 
(gdb) r 
Starting program: /c-programs/a.out 
 
Breakpoint 1, main () at test.cc:11 
11                cout << mynumber << endl; 
(gdb) print &mynumber 
$1 = (double *) 0xbffffbe0 
(gdb) x/1xg 0xbffffbe0 
0xbffffbe0:     0x408bc7e425aee632 
(gdb) 
 

-- 
NEU +++ DSL Komplett von GMX +++ http://www.gmx.net/de/go/dsl
GMX DSL-Netzanschluss + Tarif zum supergünstigen Komplett-Preis!


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]