1 /* Native support for the SGI Iris running IRIX version 4, for GDB.
2 Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1995
3 Free Software Foundation, Inc.
4 Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU
5 and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
6 Implemented for Irix 4.x by Garrett A. Wollman.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
28 #include <sys/procfs.h>
29 #include <setjmp.h> /* For JB_XXX. */
31 /* Size of elements in jmpbuf */
33 #define JB_ELEMENT_SIZE 4
35 typedef unsigned int greg_t
; /* why isn't this defined? */
38 * See the comment in m68k-tdep.c regarding the utility of these functions.
42 supply_gregset (gregsetp
)
46 register greg_t
*regp
= (greg_t
*)(gregsetp
->gp_regs
);
47 static char zerobuf
[MAX_REGISTER_RAW_SIZE
] = {0};
49 /* FIXME: somewhere, there should be a #define for the meaning
50 of this magic number 32; we should use that. */
51 for(regi
= 0; regi
< 32; regi
++)
52 supply_register (regi
, (char *)(regp
+ regi
));
54 supply_register (PC_REGNUM
, (char *)&(gregsetp
->gp_pc
));
55 supply_register (HI_REGNUM
, (char *)&(gregsetp
->gp_mdhi
));
56 supply_register (LO_REGNUM
, (char *)&(gregsetp
->gp_mdlo
));
57 supply_register (CAUSE_REGNUM
, (char *)&(gregsetp
->gp_cause
));
59 /* Fill inaccessible registers with zero. */
60 supply_register (BADVADDR_REGNUM
, zerobuf
);
64 fill_gregset (gregsetp
, regno
)
69 register greg_t
*regp
= (greg_t
*)(gregsetp
->gp_regs
);
71 /* same FIXME as above wrt 32*/
72 for (regi
= 0; regi
< 32; regi
++)
73 if ((regno
== -1) || (regno
== regi
))
74 *(regp
+ regi
) = *(greg_t
*) ®isters
[REGISTER_BYTE (regi
)];
76 if ((regno
== -1) || (regno
== PC_REGNUM
))
77 gregsetp
->gp_pc
= *(greg_t
*) ®isters
[REGISTER_BYTE (PC_REGNUM
)];
79 if ((regno
== -1) || (regno
== CAUSE_REGNUM
))
80 gregsetp
->gp_cause
= *(greg_t
*) ®isters
[REGISTER_BYTE (CAUSE_REGNUM
)];
82 if ((regno
== -1) || (regno
== HI_REGNUM
))
83 gregsetp
->gp_mdhi
= *(greg_t
*) ®isters
[REGISTER_BYTE (HI_REGNUM
)];
85 if ((regno
== -1) || (regno
== LO_REGNUM
))
86 gregsetp
->gp_mdlo
= *(greg_t
*) ®isters
[REGISTER_BYTE (LO_REGNUM
)];
90 * Now we do the same thing for floating-point registers.
91 * We don't bother to condition on FP0_REGNUM since any
92 * reasonable MIPS configuration has an R3010 in it.
94 * Again, see the comments in m68k-tdep.c.
98 supply_fpregset (fpregsetp
)
99 fpregset_t
*fpregsetp
;
102 static char zerobuf
[MAX_REGISTER_RAW_SIZE
] = {0};
104 for (regi
= 0; regi
< 32; regi
++)
105 supply_register (FP0_REGNUM
+ regi
,
106 (char *)&fpregsetp
->fp_r
.fp_regs
[regi
]);
108 supply_register (FCRCS_REGNUM
, (char *)&fpregsetp
->fp_csr
);
110 /* FIXME: how can we supply FCRIR_REGNUM? SGI doesn't tell us. */
111 supply_register (FCRIR_REGNUM
, zerobuf
);
115 fill_fpregset (fpregsetp
, regno
)
116 fpregset_t
*fpregsetp
;
122 for (regi
= FP0_REGNUM
; regi
< FP0_REGNUM
+ 32; regi
++)
124 if ((regno
== -1) || (regno
== regi
))
126 from
= (char *) ®isters
[REGISTER_BYTE (regi
)];
127 to
= (char *) &(fpregsetp
->fp_r
.fp_regs
[regi
- FP0_REGNUM
]);
128 memcpy(to
, from
, REGISTER_RAW_SIZE (regi
));
132 if ((regno
== -1) || (regno
== FCRCS_REGNUM
))
133 fpregsetp
->fp_csr
= *(unsigned *) ®isters
[REGISTER_BYTE(FCRCS_REGNUM
)];
137 /* Figure out where the longjmp will land.
138 We expect the first arg to be a pointer to the jmp_buf structure from which
139 we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
140 This routine returns true on success. */
143 get_longjmp_target (pc
)
146 char buf
[TARGET_PTR_BIT
/ TARGET_CHAR_BIT
];
149 jb_addr
= read_register (A0_REGNUM
);
151 if (target_read_memory (jb_addr
+ JB_PC
* JB_ELEMENT_SIZE
, buf
,
152 TARGET_PTR_BIT
/ TARGET_CHAR_BIT
))
155 *pc
= extract_address (buf
, TARGET_PTR_BIT
/ TARGET_CHAR_BIT
);
161 fetch_core_registers (core_reg_sect
, core_reg_size
, which
, reg_addr
)
163 unsigned core_reg_size
;
164 int which
; /* Unused */
165 unsigned int reg_addr
; /* Unused */
167 if (core_reg_size
!= REGISTER_BYTES
)
169 warning ("wrong size gregset struct in core file");
173 memcpy ((char *)registers
, core_reg_sect
, core_reg_size
);
This page took 0.033795 seconds and 4 git commands to generate.