1 /* Native support for MIPS running SVR4, for GDB.
2 Copyright 1994, 1995, 2000, 2001 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., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
28 #include <sys/procfs.h>
29 #include <setjmp.h> /* For JB_XXX. */
31 /* Prototypes for supply_gregset etc. */
34 /* Size of elements in jmpbuf */
36 #define JB_ELEMENT_SIZE 4
39 * See the comment in m68k-tdep.c regarding the utility of these functions.
41 * These definitions are from the MIPS SVR4 ABI, so they may work for
42 * any MIPS SVR4 target.
46 supply_gregset (gregset_t
*gregsetp
)
49 register greg_t
*regp
= &(*gregsetp
)[0];
50 static char zerobuf
[MAX_REGISTER_RAW_SIZE
] =
53 for (regi
= 0; regi
<= CXT_RA
; regi
++)
54 supply_register (regi
, (char *) (regp
+ regi
));
56 supply_register (PC_REGNUM
, (char *) (regp
+ CXT_EPC
));
57 supply_register (HI_REGNUM
, (char *) (regp
+ CXT_MDHI
));
58 supply_register (LO_REGNUM
, (char *) (regp
+ CXT_MDLO
));
59 supply_register (CAUSE_REGNUM
, (char *) (regp
+ CXT_CAUSE
));
61 /* Fill inaccessible registers with zero. */
62 supply_register (PS_REGNUM
, zerobuf
);
63 supply_register (BADVADDR_REGNUM
, zerobuf
);
64 supply_register (FP_REGNUM
, zerobuf
);
65 supply_register (UNUSED_REGNUM
, zerobuf
);
66 for (regi
= FIRST_EMBED_REGNUM
; regi
<= LAST_EMBED_REGNUM
; regi
++)
67 supply_register (regi
, zerobuf
);
71 fill_gregset (gregset_t
*gregsetp
, int regno
)
74 register greg_t
*regp
= &(*gregsetp
)[0];
76 for (regi
= 0; regi
<= 32; regi
++)
77 if ((regno
== -1) || (regno
== regi
))
78 *(regp
+ regi
) = *(greg_t
*) & registers
[REGISTER_BYTE (regi
)];
80 if ((regno
== -1) || (regno
== PC_REGNUM
))
81 *(regp
+ CXT_EPC
) = *(greg_t
*) & registers
[REGISTER_BYTE (PC_REGNUM
)];
83 if ((regno
== -1) || (regno
== CAUSE_REGNUM
))
84 *(regp
+ CXT_CAUSE
) = *(greg_t
*) & registers
[REGISTER_BYTE (CAUSE_REGNUM
)];
86 if ((regno
== -1) || (regno
== HI_REGNUM
))
87 *(regp
+ CXT_MDHI
) = *(greg_t
*) & registers
[REGISTER_BYTE (HI_REGNUM
)];
89 if ((regno
== -1) || (regno
== LO_REGNUM
))
90 *(regp
+ CXT_MDLO
) = *(greg_t
*) & registers
[REGISTER_BYTE (LO_REGNUM
)];
94 * Now we do the same thing for floating-point registers.
95 * We don't bother to condition on FP0_REGNUM since any
96 * reasonable MIPS configuration has an R3010 in it.
98 * Again, see the comments in m68k-tdep.c.
102 supply_fpregset (fpregset_t
*fpregsetp
)
105 static char zerobuf
[MAX_REGISTER_RAW_SIZE
] =
108 for (regi
= 0; regi
< 32; regi
++)
109 supply_register (FP0_REGNUM
+ regi
,
110 (char *) &fpregsetp
->fp_r
.fp_regs
[regi
]);
112 supply_register (FCRCS_REGNUM
, (char *) &fpregsetp
->fp_csr
);
114 /* FIXME: how can we supply FCRIR_REGNUM? The ABI doesn't tell us. */
115 supply_register (FCRIR_REGNUM
, zerobuf
);
119 fill_fpregset (fpregset_t
*fpregsetp
, int regno
)
124 for (regi
= FP0_REGNUM
; regi
< FP0_REGNUM
+ 32; regi
++)
126 if ((regno
== -1) || (regno
== regi
))
128 from
= (char *) ®isters
[REGISTER_BYTE (regi
)];
129 to
= (char *) &(fpregsetp
->fp_r
.fp_regs
[regi
- FP0_REGNUM
]);
130 memcpy (to
, from
, REGISTER_RAW_SIZE (regi
));
134 if ((regno
== -1) || (regno
== FCRCS_REGNUM
))
135 fpregsetp
->fp_csr
= *(unsigned *) ®isters
[REGISTER_BYTE (FCRCS_REGNUM
)];
139 /* Figure out where the longjmp will land.
140 We expect the first arg to be a pointer to the jmp_buf structure from which
141 we extract the pc (_JB_PC) that we will land at. The pc is copied into PC.
142 This routine returns true on success. */
145 get_longjmp_target (CORE_ADDR
*pc
)
150 buf
= alloca (TARGET_PTR_BIT
/ TARGET_CHAR_BIT
);
151 jb_addr
= read_register (A0_REGNUM
);
153 if (target_read_memory (jb_addr
+ _JB_PC
* JB_ELEMENT_SIZE
, buf
,
154 TARGET_PTR_BIT
/ TARGET_CHAR_BIT
))
157 *pc
= extract_address (buf
, TARGET_PTR_BIT
/ TARGET_CHAR_BIT
);
This page took 0.03208 seconds and 4 git commands to generate.