OSDN Git Service

Made changes to shared library support and added more of the support needed
[pf3gnuchains/pf3gnuchains3x.git] / gdb / ia64-aix-nat.c
1 /* Functions specific to running gdb native on IA-64 running AIX.
2    Copyright 2000, 2001 Free Software Foundation, Inc.
3
4    This file is part of GDB.
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.  */
20
21 #include "defs.h"
22 #include "inferior.h"
23 #include "target.h"
24 #include "gdbcore.h"
25 #include <sys/procfs.h>
26
27 #include "symtab.h"
28 #include "bfd.h"
29 #include "symfile.h"
30 #include "objfiles.h"
31
32 #include <sys/types.h>
33 #include <fcntl.h>
34 #include "gdb_stat.h"
35
36 void
37 supply_gregset (prgregset_t *gregsetp)
38 {
39   int regi;
40
41   for (regi = IA64_GR0_REGNUM; regi <= IA64_GR31_REGNUM; regi++)
42     {
43       supply_register (regi, 
44                        (char *) &(gregsetp->__gpr[regi - IA64_GR0_REGNUM]));
45     }
46
47   for (regi = IA64_BR0_REGNUM; regi <= IA64_BR7_REGNUM; regi++)
48     {
49       supply_register (regi, 
50                        (char *) &(gregsetp->__br[regi - IA64_BR0_REGNUM]));
51     }
52
53   supply_register (IA64_PSR_REGNUM, (char *) &(gregsetp->__psr));
54   supply_register (IA64_IP_REGNUM, (char *) &(gregsetp->__ip));
55   supply_register (IA64_CFM_REGNUM, (char *) &(gregsetp->__ifs));
56   supply_register (IA64_RSC_REGNUM, (char *) &(gregsetp->__rsc));
57   supply_register (IA64_BSP_REGNUM, (char *) &(gregsetp->__bsp));
58   supply_register (IA64_BSPSTORE_REGNUM, (char *) &(gregsetp->__bspstore));
59   supply_register (IA64_RNAT_REGNUM, (char *) &(gregsetp->__rnat));
60   supply_register (IA64_PFS_REGNUM, (char *) &(gregsetp->__pfs));
61   supply_register (IA64_UNAT_REGNUM, (char *) &(gregsetp->__unat));
62   supply_register (IA64_PR_REGNUM, (char *) &(gregsetp->__preds));
63   supply_register (IA64_CCV_REGNUM, (char *) &(gregsetp->__ccv));
64   supply_register (IA64_LC_REGNUM, (char *) &(gregsetp->__lc));
65   supply_register (IA64_EC_REGNUM, (char *) &(gregsetp->__ec));
66   /* FIXME: __nats */
67   supply_register (IA64_FPSR_REGNUM, (char *) &(gregsetp->__fpsr));
68
69   /* These (for the most part) are pseudo registers and are obtained
70      by other means.  Those that aren't are already handled by the
71      code above.  */
72   for (regi = IA64_GR32_REGNUM; regi <= IA64_GR127_REGNUM; regi++)
73     register_valid[regi] = 1;
74   for (regi = IA64_PR0_REGNUM; regi <= IA64_PR63_REGNUM; regi++)
75     register_valid[regi] = 1;
76   for (regi = IA64_VFP_REGNUM; regi <= NUM_REGS; regi++)
77     register_valid[regi] = 1;
78 }
79
80 void
81 fill_gregset (prgregset_t *gregsetp, int regno)
82 {
83   int regi;
84
85 #define COPY_REG(_fld_,_regi_) \
86   if ((regno == -1) || regno == _regi_) \
87     memcpy (&(gregsetp->_fld_), &registers[REGISTER_BYTE (_regi_)], \
88             REGISTER_RAW_SIZE (_regi_))
89
90   for (regi = IA64_GR0_REGNUM; regi <= IA64_GR31_REGNUM; regi++)
91     {
92       COPY_REG (__gpr[regi - IA64_GR0_REGNUM], regi);
93     }
94
95   for (regi = IA64_BR0_REGNUM; regi <= IA64_BR7_REGNUM; regi++)
96     {
97       COPY_REG (__br[regi - IA64_BR0_REGNUM], regi);
98     }
99   COPY_REG (__psr, IA64_PSR_REGNUM);
100   COPY_REG (__ip, IA64_IP_REGNUM);
101   COPY_REG (__ifs, IA64_CFM_REGNUM);
102   COPY_REG (__rsc, IA64_RSC_REGNUM);
103   COPY_REG (__bsp, IA64_BSP_REGNUM);
104
105   /* Bad things happen if we don't update both bsp and bspstore at the
106      same time.  */
107   if (regno == IA64_BSP_REGNUM || regno == -1)
108     {
109       memcpy (&(gregsetp->__bspstore),
110               &registers[REGISTER_BYTE (IA64_BSP_REGNUM)],
111               REGISTER_RAW_SIZE (IA64_BSP_REGNUM));
112       memcpy (&registers[REGISTER_BYTE (IA64_BSPSTORE_REGNUM)],
113               &registers[REGISTER_BYTE (IA64_BSP_REGNUM)],
114               REGISTER_RAW_SIZE (IA64_BSP_REGNUM));
115     }
116
117 #if 0
118   /* We never actually write to bspstore, or we'd have to do the same thing
119      here too.  */
120   COPY_REG (__bspstore, IA64_BSPSTORE_REGNUM);
121 #endif
122   COPY_REG (__rnat, IA64_RNAT_REGNUM);
123   COPY_REG (__pfs, IA64_PFS_REGNUM);
124   COPY_REG (__unat, IA64_UNAT_REGNUM);
125   COPY_REG (__preds, IA64_PR_REGNUM);
126   COPY_REG (__ccv, IA64_CCV_REGNUM);
127   COPY_REG (__lc, IA64_LC_REGNUM);
128   COPY_REG (__ec, IA64_EC_REGNUM);
129   /* FIXME: __nats */
130   COPY_REG (__fpsr, IA64_FPSR_REGNUM);
131 #undef COPY_REG
132 }
133
134 void
135 supply_fpregset (prfpregset_t *fpregsetp)
136 {
137   register int regi;
138
139   for (regi = IA64_FR0_REGNUM; regi <= IA64_FR127_REGNUM; regi++)
140     supply_register (regi, 
141                      (char *) &(fpregsetp->__fpr[regi - IA64_FR0_REGNUM]));
142 }
143
144 void
145 fill_fpregset (prfpregset_t *fpregsetp, int regno)
146 {
147   int regi;
148   char *to;
149   char *from;
150
151   for (regi = IA64_FR0_REGNUM; regi <= IA64_FR127_REGNUM; regi++)
152     {
153       if ((regno == -1) || (regno == regi))
154         {
155           from = (char *) &registers[REGISTER_BYTE (regi)];
156           to = (char *) &(fpregsetp->__fpr[regi - IA64_FR0_REGNUM]);
157           memcpy (to, from, REGISTER_RAW_SIZE (regi));
158         }
159     }
160 }