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

Re: Float registers on Sparc?



> 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$ 

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