2003-09-17 Andrew Cagney <cagney@redhat.com>
[platform/upstream/binutils.git] / gdb / sparc-linux-nat.c
1 /* Native-dependent code for GNU/Linux SPARC.
2
3    Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
4
5    This file is part of GDB.
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place - Suite 330,
20    Boston, MA 02111-1307, USA.  */
21
22 #include "defs.h"
23 #include "regcache.h"
24 #include "sparc-tdep.h"
25    
26 #include <sys/procfs.h>
27
28 /* Prototypes for supply_gregset etc.  */
29 #include "gregset.h"
30
31 void
32 supply_gregset (elf_gregset_t *gregsetp)
33 {
34   elf_greg_t *regp = (elf_greg_t *) gregsetp;
35   int i;
36
37   for (i = G0_REGNUM; i <= I7_REGNUM; i++)
38     supply_register (i, (char *) (regp + (i - G0_REGNUM)));
39
40   supply_register (PS_REGNUM, (char *) (regp + 32));
41
42   supply_register (PC_REGNUM, (char *) (regp + 33));
43   supply_register (DEPRECATED_NPC_REGNUM, (char *) (regp + 34));
44   supply_register (Y_REGNUM, (char *) (regp + 35));
45
46   supply_register (WIM_REGNUM, (char *) (regp + 36));
47   supply_register (TBR_REGNUM, (char *) (regp + 37));
48
49   /* Fill inaccessible registers with zero.  */
50   supply_register (CPS_REGNUM, NULL);
51 }
52
53 void
54 fill_gregset (elf_gregset_t *gregsetp, int regno)
55 {
56   elf_greg_t *regp = (elf_greg_t *) gregsetp;
57   int i;
58
59   for (i = G0_REGNUM; i <= I7_REGNUM; i++)
60     if (regno == -1 || regno == i)
61       regcache_collect (i, regp + (i - G0_REGNUM));
62
63   if (regno == -1 || regno == PS_REGNUM)
64     regcache_collect (PS_REGNUM, regp + 32);
65
66   if (regno == -1 || regno == PC_REGNUM)
67     regcache_collect (PC_REGNUM, regp + 33);
68   if (regno == -1 || regno == DEPRECATED_NPC_REGNUM)
69     regcache_collect (DEPRECATED_NPC_REGNUM, regp + 34);
70   if (regno == -1 || regno == Y_REGNUM)
71     regcache_collect (Y_REGNUM, regp + 35);
72
73   if (regno == -1 || regno == WIM_REGNUM)
74     regcache_collect (WIM_REGNUM, regp + 36);
75   if (regno == -1 || regno == TBR_REGNUM)
76     regcache_collect (TBR_REGNUM, regp + 37);
77 }
78
79 void
80 supply_fpregset (elf_fpregset_t *fpregsetp)
81 {
82   int i;
83
84   for (i = FP0_REGNUM; i < FP0_REGNUM + 32; i++)
85     supply_register (i, (char *) &fpregsetp->pr_fr.pr_regs[i - FP0_REGNUM]);
86
87   supply_register (FPS_REGNUM, (char *) &fpregsetp->pr_fsr);
88 }
89
90 void
91 fill_fpregset (elf_fpregset_t *fpregsetp, int regno)
92 {
93   int i;
94
95   for (i = FP0_REGNUM; i < FP0_REGNUM + 32; i++)
96     if (regno == -1 || regno == i)
97       regcache_collect (i, &fpregsetp->pr_fr.pr_regs[i - FP0_REGNUM]);
98
99   if (regno == -1 || regno == FPS_REGNUM)
100     regcache_collect (FPS_REGNUM, &fpregsetp->pr_fsr);
101 }