Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Grzegorz Cieslewski" <cieslewski@hcs.ufl.edu>
To: gdb@sourceware.org
Subject: Re: Setting a floating point register to raw hex value
Date: Thu, 18 Oct 2007 19:38:00 -0000	[thread overview]
Message-ID: <7aa837f80710181238o4aa3e19djffe5324df65e5928@mail.gmail.com> (raw)
In-Reply-To: <7aa837f80710120829y33db4c3cya21f6ead14ca56f3@mail.gmail.com>

I have figured out a workaround but it is really ugly.

Step 1:  Create shared object containing a union as follows
union longlong2double
{
long long int hexNum;
double floatNum;
} temp;

Step 2: Force load the library at runtime into your program using
LD_PRELOAD environmental variable

Step 3: When debugging the program store 0x1 into temp.hexNum;
(one would think that I could use the following now 'set $f0 =
temp.floatNum; but that yields incorrect result)

Step4:  Overwrite the current instruction with 'load float'

Step5: Using stepping command 'stepi 1' to write the value to the $f0

Step6: Undo all the changes required by steps 4 and 5

Does any one know of a simpler way because this workaround is crazy?


Greg Cieslewski



On 10/12/07, Grzegorz Cieslewski <cieslewski@hcs.ufl.edu> wrote:
> Does any one know of a way to set a floating point register ($f0) to a
> arbitrary raw hex value (for example 1)
>
> I tried the following.
>
> (gdb) set $f0 = 5.0000000000000000e-324
> (gdb) p $f0
> $1 = -1.5966722476277758e+293
> (gdb) set $f0 = 5.0000000000000000e-324
>
> The value of 5.0000000000000000e-324 should correspond to
> 0x0000000000000001 in raw hex
>
> Any ideas?
>
> I am using ppc7450 (G4) if that helps.
>


  reply	other threads:[~2007-10-18 19:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-12 15:29 Grzegorz Cieslewski
2007-10-18 19:38 ` Grzegorz Cieslewski [this message]
2007-10-18 20:16   ` Thiago Jung Bauermann
2007-10-18 21:44     ` Grzegorz Cieslewski
2007-10-18 21:54     ` Daniel Jacobowitz
2007-10-19 19:48       ` Thiago Jung Bauermann
2007-10-19 20:15         ` Daniel Jacobowitz
2007-10-22 16:22         ` Grzegorz Cieslewski

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=7aa837f80710181238o4aa3e19djffe5324df65e5928@mail.gmail.com \
    --to=cieslewski@hcs.ufl.edu \
    --cc=gdb@sourceware.org \
    /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