This is the mail archive of the gdb@sourceware.org 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]

Re: Setting a floating point register to raw hex value


Hi,

Yes, that's indeed crazy. :-)

Just found out that this works:

(gdb) set (void *) $f1 = 0x1
(gdb) info reg f1
f1             4.9406564584124654e-324  (raw 0x0000000000000001)
-- 
[]'s
Thiago Jung Bauermann
Software Engineer
IBM Linux Technology Center



On Thu, 2007-10-18 at 15:38 -0400, Grzegorz Cieslewski wrote:
> 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.
> >



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