1 /* HP/UX interface for HP 300's, for GDB when running under Unix.
2 Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 /* Defining this means some system include files define some extra stuff. */
28 #include <sys/param.h>
32 #include <sys/ioctl.h>
35 #include <sys/ptrace.h>
44 #define INFERIOR_AR0(u) \
46 (PT_RUAREA, inferior_pid, ((char *) &u.u_ar0 - (char *) &u), 0)) \
50 fetch_inferior_register (regno
, regaddr
)
52 register unsigned int regaddr
;
54 #ifndef HPUX_VERSION_5
55 if (regno
== PS_REGNUM
)
57 union { int i
; short s
[2]; } ps_val
;
60 ps_val
.i
= (ptrace (PT_RUAREA
, inferior_pid
, regaddr
, 0));
62 supply_register (regno
, ®val
);
65 #endif /* not HPUX_VERSION_5 */
67 char buf
[MAX_REGISTER_RAW_SIZE
];
70 for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
+= sizeof (int))
72 *(int *) &buf
[i
] = ptrace (PT_RUAREA
, inferior_pid
, regaddr
, 0);
73 regaddr
+= sizeof (int);
75 supply_register (regno
, buf
);
81 store_inferior_register_1 (regno
, regaddr
, value
)
87 ptrace (PT_WUAREA
, inferior_pid
, regaddr
, value
);
89 /* HP-UX randomly sets errno to non-zero for regno == 25.
90 However, the value is correctly written, so ignore errno. */
95 sprintf (string_buf
, "writing register number %d", regno
);
96 perror_with_name (string_buf
);
103 store_inferior_register (regno
, regaddr
)
105 register unsigned int regaddr
;
107 #ifndef HPUX_VERSION_5
108 if (regno
== PS_REGNUM
)
110 union { int i
; short s
[2]; } ps_val
;
112 ps_val
.i
= (ptrace (PT_RUAREA
, inferior_pid
, regaddr
, 0));
113 ps_val
.s
[0] = (read_register (regno
));
114 store_inferior_register_1 (regno
, regaddr
, ps_val
.i
);
117 #endif /* not HPUX_VERSION_5 */
119 char buf
[MAX_REGISTER_RAW_SIZE
];
121 extern char registers
[];
123 for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
+= sizeof (int))
125 store_inferior_register_1
127 (*(int *) ®isters
[(REGISTER_BYTE (regno
)) + i
]));
128 regaddr
+= sizeof (int);
135 fetch_inferior_registers (regno
)
140 register unsigned int ar0_offset
;
142 ar0_offset
= (INFERIOR_AR0 (u
));
145 for (regno
= 0; (regno
< FP0_REGNUM
); regno
++)
146 fetch_inferior_register (regno
, (REGISTER_ADDR (ar0_offset
, regno
)));
147 for (; (regno
< NUM_REGS
); regno
++)
148 fetch_inferior_register (regno
, (FP_REGISTER_ADDR (u
, regno
)));
151 fetch_inferior_register (regno
,
153 ? REGISTER_ADDR (ar0_offset
, regno
)
154 : FP_REGISTER_ADDR (u
, regno
)));
157 /* Store our register values back into the inferior.
158 If REGNO is -1, do this for all registers.
159 Otherwise, REGNO specifies which register (so we can save time). */
161 store_inferior_registers (regno
)
165 register unsigned int ar0_offset
;
166 extern char registers
[];
168 if (regno
>= FP0_REGNUM
)
170 store_inferior_register (regno
, (FP_REGISTER_ADDR (u
, regno
)));
174 ar0_offset
= (INFERIOR_AR0 (u
));
177 store_inferior_register (regno
, (REGISTER_ADDR (ar0_offset
, regno
)));
181 for (regno
= 0; (regno
< FP0_REGNUM
); regno
++)
182 store_inferior_register (regno
, (REGISTER_ADDR (ar0_offset
, regno
)));
183 for (; (regno
< NUM_REGS
); regno
++)
184 store_inferior_register (regno
, (FP_REGISTER_ADDR (u
, regno
)));
189 /* Take the register values out of a core file and store
190 them where `read_register' will find them. */
192 #ifdef HPUX_VERSION_5
193 #define e_PS e_regs[PS]
194 #define e_PC e_regs[PC]
195 #endif /* HPUX_VERSION_5 */
198 fetch_core_registers (core_reg_sect
, core_reg_size
, which
)
205 struct exception_stack
*pes
= (struct exception_stack
*) core_reg_sect
;
211 ((char *) &es
.e_offset
- (char *) &es
.e_regs
[R0
]))
212 error ("Not enough registers in core file");
213 for (regno
= 0; (regno
< PS_REGNUM
); regno
++)
214 supply_register (regno
, &es
.e_regs
[regno
+ R0
]);
216 supply_register (regno
++, &val
);
217 supply_register (regno
++, &es
.e_PC
);
219 } else if (which
== 2) {
221 /* FIXME: This may not work if the float regs and control regs are
223 for (regno
= FP0_REGNUM
, buf
= core_reg_sect
;
225 buf
+= REGISTER_RAW_SIZE (regno
), regno
++)
227 supply_register (regno
, buf
);