1 /* Native-dependent code for GNU/Linux SPARC.
3 Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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. */
24 #include "sparc-tdep.h"
26 #include <sys/procfs.h>
28 /* Prototypes for supply_gregset etc. */
32 supply_gregset (elf_gregset_t *gregsetp)
34 elf_greg_t *regp = (elf_greg_t *) gregsetp;
37 for (i = G0_REGNUM; i <= I7_REGNUM; i++)
38 supply_register (i, (char *) (regp + (i - G0_REGNUM)));
40 supply_register (PS_REGNUM, (char *) (regp + 32));
42 supply_register (PC_REGNUM, (char *) (regp + 33));
43 supply_register (NPC_REGNUM, (char *) (regp + 34));
44 supply_register (Y_REGNUM, (char *) (regp + 35));
46 supply_register (WIM_REGNUM, (char *) (regp + 36));
47 supply_register (TBR_REGNUM, (char *) (regp + 37));
49 /* Fill inaccessible registers with zero. */
50 supply_register (CPS_REGNUM, NULL);
54 fill_gregset (elf_gregset_t *gregsetp, int regno)
56 elf_greg_t *regp = (elf_greg_t *) gregsetp;
59 for (i = G0_REGNUM; i <= I7_REGNUM; i++)
60 if (regno == -1 || regno == i)
61 regcache_collect (i, regp + (i - G0_REGNUM));
63 if (regno == -1 || regno == PS_REGNUM)
64 regcache_collect (PS_REGNUM, regp + 32);
66 if (regno == -1 || regno == PC_REGNUM)
67 regcache_collect (PC_REGNUM, regp + 33);
68 if (regno == -1 || regno == NPC_REGNUM)
69 regcache_collect (NPC_REGNUM, regp + 34);
70 if (regno == -1 || regno == Y_REGNUM)
71 regcache_collect (Y_REGNUM, regp + 35);
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);
80 supply_fpregset (elf_fpregset_t *fpregsetp)
84 for (i = FP0_REGNUM; i < FP0_REGNUM + 32; i++)
85 supply_register (i, (char *) &fpregsetp->pr_fr.pr_regs[i - FP0_REGNUM]);
87 supply_register (FPS_REGNUM, (char *) &fpregsetp->pr_fsr);
91 fill_fpregset (elf_fpregset_t *fpregsetp, int regno)
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]);
99 if (regno == -1 || regno == FPS_REGNUM)
100 regcache_collect (FPS_REGNUM, &fpregsetp->pr_fsr);