* linux-thread-db.c (BUILD_THREAD): Delete.
[deliverable/binutils-gdb.git] / gdb / mipsv4-nat.c
CommitLineData
c906108c 1/* Native support for MIPS running SVR4, for GDB.
b6ba6518 2 Copyright 1994, 1995, 2000, 2001 Free Software Foundation, Inc.
c906108c 3
c5aa993b 4 This file is part of GDB.
c906108c 5
c5aa993b
JM
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.
c906108c 10
c5aa993b
JM
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.
c906108c 15
c5aa993b
JM
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. */
c906108c
SS
20
21#include "defs.h"
22#include "inferior.h"
23#include "gdbcore.h"
24#include "target.h"
4e052eda 25#include "regcache.h"
c906108c
SS
26
27#include <sys/time.h>
28#include <sys/procfs.h>
29#include <setjmp.h> /* For JB_XXX. */
30
c60c0f5f
MS
31/* Prototypes for supply_gregset etc. */
32#include "gregset.h"
33
c906108c
SS
34/* Size of elements in jmpbuf */
35
36#define JB_ELEMENT_SIZE 4
37
38/*
39 * See the comment in m68k-tdep.c regarding the utility of these functions.
40 *
41 * These definitions are from the MIPS SVR4 ABI, so they may work for
42 * any MIPS SVR4 target.
43 */
44
c5aa993b 45void
fba45db2 46supply_gregset (gregset_t *gregsetp)
c906108c 47{
52f0bd74
AC
48 int regi;
49 greg_t *regp = &(*gregsetp)[0];
123a958e
AC
50 char zerobuf[MAX_REGISTER_SIZE];
51 memset (zerobuf, 0, MAX_REGISTER_SIZE);
c906108c
SS
52
53 for (regi = 0; regi <= CXT_RA; regi++)
23a6d369 54 regcache_raw_supply (current_regcache, regi, (char *) (regp + regi));
c906108c 55
23a6d369
AC
56 regcache_raw_supply (current_regcache, mips_regnum (current_gdbarch)->pc,
57 (char *) (regp + CXT_EPC));
58 regcache_raw_supply (current_regcache, mips_regnum (current_gdbarch)->hi,
59 (char *) (regp + CXT_MDHI));
60 regcache_raw_supply (current_regcache, mips_regnum (current_gdbarch)->lo,
61 (char *) (regp + CXT_MDLO));
62 regcache_raw_supply (current_regcache, mips_regnum (current_gdbarch)->cause,
63 (char *) (regp + CXT_CAUSE));
c906108c
SS
64
65 /* Fill inaccessible registers with zero. */
24e05951 66 regcache_raw_supply (current_regcache, MIPS_PS_REGNUM, zerobuf);
23a6d369
AC
67 regcache_raw_supply (current_regcache,
68 mips_regnum (current_gdbarch)->badvaddr,
69 zerobuf);
70 regcache_raw_supply (current_regcache, DEPRECATED_FP_REGNUM, zerobuf);
613e114f 71 regcache_raw_supply (current_regcache, MIPS_UNUSED_REGNUM, zerobuf);
607fc93c 72 for (regi = MIPS_FIRST_EMBED_REGNUM; regi <= MIPS_LAST_EMBED_REGNUM; regi++)
23a6d369 73 regcache_raw_supply (current_regcache, regi, zerobuf);
c906108c
SS
74}
75
76void
fba45db2 77fill_gregset (gregset_t *gregsetp, int regno)
c906108c
SS
78{
79 int regi;
52f0bd74 80 greg_t *regp = &(*gregsetp)[0];
c906108c
SS
81
82 for (regi = 0; regi <= 32; regi++)
83 if ((regno == -1) || (regno == regi))
62700349 84 *(regp + regi) = *(greg_t *) & deprecated_registers[DEPRECATED_REGISTER_BYTE (regi)];
c906108c 85
56cea623
AC
86 if ((regno == -1) || (regno == mips_regnum (current_gdbarch)->pc))
87 *(regp + CXT_EPC) = *(greg_t *) & deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->pc)];
c906108c 88
56cea623
AC
89 if ((regno == -1) || (regno == mips_regnum (current_gdbarch)->cause))
90 *(regp + CXT_CAUSE) = *(greg_t *) & deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->cause)];
c906108c 91
56cea623
AC
92 if ((regno == -1) || (regno == mips_regnum (current_gdbarch)->hi))
93 *(regp + CXT_MDHI) = *(greg_t *) & deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->hi)];
c906108c 94
56cea623
AC
95 if ((regno == -1) || (regno == mips_regnum (current_gdbarch)->lo))
96 *(regp + CXT_MDLO) = *(greg_t *) & deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->lo)];
c906108c
SS
97}
98
99/*
100 * Now we do the same thing for floating-point registers.
56cea623 101 * We don't bother to condition on FP0 regnum since any
c906108c
SS
102 * reasonable MIPS configuration has an R3010 in it.
103 *
104 * Again, see the comments in m68k-tdep.c.
105 */
106
107void
fba45db2 108supply_fpregset (fpregset_t *fpregsetp)
c906108c 109{
52f0bd74 110 int regi;
123a958e
AC
111 char zerobuf[MAX_REGISTER_SIZE];
112 memset (zerobuf, 0, MAX_REGISTER_SIZE);
c906108c
SS
113
114 for (regi = 0; regi < 32; regi++)
23a6d369
AC
115 regcache_raw_supply (current_regcache,
116 mips_regnum (current_gdbarch)->fp0 + regi,
117 (char *) &fpregsetp->fp_r.fp_regs[regi]);
c906108c 118
23a6d369
AC
119 regcache_raw_supply (current_regcache,
120 mips_regnum (current_gdbarch)->fp_control_status,
121 (char *) &fpregsetp->fp_csr);
c906108c 122
56cea623 123 /* FIXME: how can we supply FCRIR? The ABI doesn't tell us. */
23a6d369
AC
124 regcache_raw_supply (current_regcache,
125 mips_regnum (current_gdbarch)->fp_implementation_revision,
126 zerobuf);
c906108c
SS
127}
128
129void
fba45db2 130fill_fpregset (fpregset_t *fpregsetp, int regno)
c906108c
SS
131{
132 int regi;
133 char *from, *to;
134
56cea623
AC
135 for (regi = mips_regnum (current_gdbarch)->fp0;
136 regi < mips_regnum (current_gdbarch)->fp0 + 32; regi++)
c906108c
SS
137 {
138 if ((regno == -1) || (regno == regi))
139 {
62700349 140 from = (char *) &deprecated_registers[DEPRECATED_REGISTER_BYTE (regi)];
56cea623 141 to = (char *) &(fpregsetp->fp_r.fp_regs[regi - mips_regnum (current_gdbarch)->fp0]);
3acba339 142 memcpy (to, from, register_size (current_gdbarch, regi));
c906108c
SS
143 }
144 }
145
56cea623
AC
146 if ((regno == -1)
147 || (regno == mips_regnum (current_gdbarch)->fp_control_status))
148 fpregsetp->fp_csr = *(unsigned *) &deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->fp_control_status)];
c906108c
SS
149}
150
151
152/* Figure out where the longjmp will land.
153 We expect the first arg to be a pointer to the jmp_buf structure from which
154 we extract the pc (_JB_PC) that we will land at. The pc is copied into PC.
155 This routine returns true on success. */
156
157int
fba45db2 158get_longjmp_target (CORE_ADDR *pc)
c906108c 159{
35fc8285 160 char *buf;
c906108c
SS
161 CORE_ADDR jb_addr;
162
35fc8285 163 buf = alloca (TARGET_PTR_BIT / TARGET_CHAR_BIT);
613e114f 164 jb_addr = read_register (MIPS_A0_REGNUM);
c906108c
SS
165
166 if (target_read_memory (jb_addr + _JB_PC * JB_ELEMENT_SIZE, buf,
167 TARGET_PTR_BIT / TARGET_CHAR_BIT))
168 return 0;
169
7c0b4a20 170 *pc = extract_unsigned_integer (buf, TARGET_PTR_BIT / TARGET_CHAR_BIT);
c906108c
SS
171
172 return 1;
173}
This page took 0.71086 seconds and 4 git commands to generate.