Avoid longjmp()-catching compilation errors in cross-ports.
[deliverable/binutils-gdb.git] / gdb / irix4-nat.c
1 /* Native support for the SGI Iris running IRIX version 4, for GDB.
2 Copyright 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3 Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU
4 and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
5 Implemented for Irix 4.x by Garrett A. Wollman.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
22
23 #include "defs.h"
24
25 #include <sys/time.h>
26 #include <sys/procfs.h>
27 #include <setjmp.h> /* For JB_XXX. */
28
29 /* Size of elements in jmpbuf */
30
31 #define JB_ELEMENT_SIZE 4
32
33 typedef unsigned int greg_t; /* why isn't this defined? */
34
35 /*
36 * See the comment in m68k-tdep.c regarding the utility of these functions.
37 */
38
39 void
40 supply_gregset (gregsetp)
41 gregset_t *gregsetp;
42 {
43 register int regi;
44 register greg_t *regp = (greg_t *)(gregsetp->gp_regs);
45
46 /* FIXME: somewhere, there should be a #define for the meaning
47 of this magic number 32; we should use that. */
48 for(regi = 0; regi < 32; regi++)
49 supply_register (regi, (char *)(regp + regi));
50
51 supply_register (PC_REGNUM, (char *)&(gregsetp->gp_pc));
52 supply_register (HI_REGNUM, (char *)&(gregsetp->gp_mdhi));
53 supply_register (LO_REGNUM, (char *)&(gregsetp->gp_mdlo));
54 supply_register (PS_REGNUM, (char *)&(gregsetp->gp_cause));
55 }
56
57 void
58 fill_gregset (gregsetp, regno)
59 gregset_t *gregsetp;
60 int regno;
61 {
62 int regi;
63 register greg_t *regp = (greg_t *)(gregsetp->gp_regs);
64 extern char registers[];
65
66 /* same FIXME as above wrt 32*/
67 for (regi = 0; regi < 32; regi++)
68 if ((regno == -1) || (regno == regi))
69 *(regp + regi) = *(greg_t *) &registers[REGISTER_BYTE (regi)];
70
71 if ((regno == -1) || (regno == PC_REGNUM))
72 gregsetp->gp_pc = *(greg_t *) &registers[REGISTER_BYTE (PC_REGNUM)];
73
74 if ((regno == -1) || (regno == PS_REGNUM))
75 gregsetp->gp_cause = *(greg_t *) &registers[REGISTER_BYTE (PS_REGNUM)];
76
77 if ((regno == -1) || (regno == HI_REGNUM))
78 gregsetp->gp_mdhi = *(greg_t *) &registers[REGISTER_BYTE (HI_REGNUM)];
79
80 if ((regno == -1) || (regno == LO_REGNUM))
81 gregsetp->gp_mdlo = *(greg_t *) &registers[REGISTER_BYTE (LO_REGNUM)];
82 }
83
84 /*
85 * Now we do the same thing for floating-point registers.
86 * We don't bother to condition on FP0_REGNUM since any
87 * reasonable MIPS configuration has an R3010 in it.
88 *
89 * Again, see the comments in m68k-tdep.c.
90 */
91
92 void
93 supply_fpregset (fpregsetp)
94 fpregset_t *fpregsetp;
95 {
96 register int regi;
97
98 for (regi = 0; regi < 32; regi++)
99 supply_register (FP0_REGNUM + regi,
100 (char *)&fpregsetp->fp_r.fp_regs[regi]);
101
102 supply_register (FCRCS_REGNUM, (char *)&fpregsetp->fp_csr);
103
104 /* FIXME: how can we supply FCRIR_REGNUM? SGI doesn't tell us. */
105 }
106
107 void
108 fill_fpregset (fpregsetp, regno)
109 fpregset_t *fpregsetp;
110 int regno;
111 {
112 int regi;
113 char *from, *to;
114 extern char registers[];
115
116 for (regi = FP0_REGNUM; regi < FP0_REGNUM + 32; regi++)
117 {
118 if ((regno == -1) || (regno == regi))
119 {
120 from = (char *) &registers[REGISTER_BYTE (regi)];
121 to = (char *) &(fpregsetp->fp_r.fp_regs[regi]);
122 bcopy(from, to, REGISTER_RAW_SIZE (regi));
123 }
124 }
125
126 if ((regno == -1) || (regno == FCRCS_REGNUM))
127 fpregsetp->fp_csr = *(unsigned *) &registers[REGISTER_BYTE(FCRCS_REGNUM)];
128 }
129
130
131 /* Figure out where the longjmp will land.
132 We expect the first arg to be a pointer to the jmp_buf structure from which
133 we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
134 This routine returns true on success. */
135
136 int
137 get_longjmp_target(pc)
138 CORE_ADDR *pc;
139 {
140 CORE_ADDR jb_addr;
141
142 jb_addr = read_register(A0_REGNUM);
143
144 if (target_read_memory(jb_addr + JB_PC * JB_ELEMENT_SIZE, pc,
145 sizeof(CORE_ADDR)))
146 return 0;
147
148 SWAP_TARGET_AND_HOST(pc, sizeof(CORE_ADDR));
149
150 return 1;
151 }
This page took 0.033882 seconds and 5 git commands to generate.