From: "Martin Jakob" <MartinJakob@gmx.ch>
To: gdb@sources.redhat.com
Subject: Question: How does gdb read the computer's memory?
Date: Sun, 07 Nov 2004 13:55:00 -0000 [thread overview]
Message-ID: <17715.1099828973@www16.gmx.net> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 1877 bytes --]
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!
reply other threads:[~2004-11-07 12:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=17715.1099828973@www16.gmx.net \
--to=martinjakob@gmx.ch \
--cc=gdb@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).