public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Float registers on Sparc?
@ 1999-12-15  7:21 Raymond Toy
  1999-12-15 10:54 ` Jim Blandy
  0 siblings, 1 reply; 6+ messages in thread
From: Raymond Toy @ 1999-12-15  7:21 UTC (permalink / raw)
  To: gdb

I'd like to add support for accessing the floating-point registers on
a Sparc, but I need a few pointers to get started.  Any one have a few
pointers?  (Does any care?)

Thanks,

Ray

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Float registers on Sparc?
  1999-12-15  7:21 Float registers on Sparc? Raymond Toy
@ 1999-12-15 10:54 ` Jim Blandy
  1999-12-15 11:23   ` Raymond Toy
  0 siblings, 1 reply; 6+ messages in thread
From: Jim Blandy @ 1999-12-15 10:54 UTC (permalink / raw)
  To: Raymond Toy; +Cc: gdb

> I'd like to add support for accessing the floating-point registers on
> a Sparc, but I need a few pointers to get started.  Any one have a few
> pointers?  (Does any care?)

It looks to me like GDB does support the floating-point registers on
the SPARC; see below.  Perhaps you should explain the problem you're
having in more detail.


zwingli:play$ cat fp.c
#include <stdio.h>
#include <math.h>
 
double
dot_product (int n, double *a, double *b)
{
  int i;
  double sum = 0;
  double prod = 1;
    
  for (i = 0; i < n; i++)
    {
      sum += a[i] * b[i];
      prod *= sum;
    }
 
  return sum + prod;
}
 
main ()
{
  static double a[] = { 1.0, 3.0, 2.0 };
  static double b[] = { 4.0, 0.0, 2.0 };
 
  printf ("dot product = %g\n", dot_product (3, a, b));
 
  return 0;
}
zwingli:play$ gcc -g -O2 fp.c -o fp
zwingli:play$ gdb fp
GNU gdb 4.17-gnupro-98r1
Copyright 1998 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.  This version of GDB is supported
for customers of Cygnus Solutions.  Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.5"...
(gdb) break dot_product
Breakpoint 1 at 0x10788: file fp.c, line 8.
(gdb) run
Starting program: /mill/home/jimb/play/fp 
 
Breakpoint 1, dot_product (n=3, a=0x215b0, b=0x215c8) at fp.c:8
8         double sum = 0;
(gdb) next
11        for (i = 0; i < n; i++)
(gdb) next
9         double prod = 1;
(gdb) p $f0
$1 = 0
(gdb) next
11        for (i = 0; i < n; i++)
(gdb) 
13            sum += a[i] * b[i];
(gdb) 
11        for (i = 0; i < n; i++)
(gdb) p $f0
$2 = 2.25
(gdb) The program is running.  Exit anyway? (y or n) y
zwingli:play$ 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Float registers on Sparc?
  1999-12-15 10:54 ` Jim Blandy
@ 1999-12-15 11:23   ` Raymond Toy
  1999-12-15 15:20     ` Jim Blandy
  0 siblings, 1 reply; 6+ messages in thread
From: Raymond Toy @ 1999-12-15 11:23 UTC (permalink / raw)
  To: Jim Blandy; +Cc: gdb

>>>>> "Jim" == Jim Blandy <jimb@cygnus.com> writes:

    >> I'd like to add support for accessing the floating-point registers on
    >> a Sparc, but I need a few pointers to get started.  Any one have a few
    >> pointers?  (Does any care?)

    Jim> It looks to me like GDB does support the floating-point registers on
    Jim> the SPARC; see below.  Perhaps you should explain the problem you're
    Jim> having in more detail.

[nice example deleted]

Ok, I just did "info float" and gdb says no floating-point info
available, and thus erroneously assumed FP registers couldn't be
read. 

How do I get access to the single-precision registers?  What about the
quad registers?  I looked through the gdb manual, but didn't find
anything obvious.

Sorry for the confusion,

Ray

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Float registers on Sparc?
  1999-12-15 11:23   ` Raymond Toy
@ 1999-12-15 15:20     ` Jim Blandy
  1999-12-15 21:09       ` Chitti Raju
  0 siblings, 1 reply; 6+ messages in thread
From: Jim Blandy @ 1999-12-15 15:20 UTC (permalink / raw)
  To: Raymond Toy; +Cc: gdb

> How do I get access to the single-precision registers?  What about the
> quad registers?  I looked through the gdb manual, but didn't find
> anything obvious.

I believe that $f0 -- $f31 are the single-precision registers.  I
don't think GDB has any way to print the double- or quad-precision
registers.  But I'm not a SPARC expert --- perhaps someone else here
knows.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Float registers on Sparc?
  1999-12-15 15:20     ` Jim Blandy
@ 1999-12-15 21:09       ` Chitti Raju
  1999-12-16  5:28         ` Raymond Toy
  0 siblings, 1 reply; 6+ messages in thread
From: Chitti Raju @ 1999-12-15 21:09 UTC (permalink / raw)
  To: Jim Blandy; +Cc: toy, gdb

> 
> > How do I get access to the single-precision registers?  What about the
> > quad registers?  I looked through the gdb manual, but didn't find
> > anything obvious.
> 
> I believe that $f0 -- $f31 are the single-precision registers.  I
> don't think GDB has any way to print the double- or quad-precision
> registers.  But I'm not a SPARC expert --- perhaps someone else here
> knows.
> 
'info all-registers' prints all the registers including the floating point
registers. 

sample output from 'info all-registers'

f4             2.8125   (raw 0x40340000)        20
f5             0        (raw 0x00000000)
f6             -NaN(0x7fffff)   (raw 0xffffffff)        -NaN(0xfffffffffffff)
f7             -NaN(0x7fffff)   (raw 0xffffffff)

The first two columns represent the single-precision value in decimal and hex,
and the third column gives double precision value of the pair <fx, fx+1>

look at the function sparc_print_register_hook() in sparc-tdep.c. 
Looks like the call to print the double-precision register is made from here. 
There is support to print the quad-precision register also, but is in comments.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Float registers on Sparc?
  1999-12-15 21:09       ` Chitti Raju
@ 1999-12-16  5:28         ` Raymond Toy
  0 siblings, 0 replies; 6+ messages in thread
From: Raymond Toy @ 1999-12-16  5:28 UTC (permalink / raw)
  To: chitti; +Cc: Jim Blandy, toy, gdb

>>>>> "Chitti" == Chitti Raju <chitti@wipinfo.soft.net> writes:

    Chitti> 'info all-registers' prints all the registers including
    Chitti> the floating point registers.

Found that just after I posted my message.  So that error message is
about floating point not supported on this architecture is really
bogus.  We should fix that.  I'll take a look into it, and fix it if I
can.

Ray

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1999-12-16  5:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-15  7:21 Float registers on Sparc? Raymond Toy
1999-12-15 10:54 ` Jim Blandy
1999-12-15 11:23   ` Raymond Toy
1999-12-15 15:20     ` Jim Blandy
1999-12-15 21:09       ` Chitti Raju
1999-12-16  5:28         ` Raymond Toy

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).