Commit | Line | Data |
---|---|---|
75c9abc6 | 1 | /* Target-dependent code for GNU/Linux on MIPS processors. |
a094c6fb | 2 | |
4c38e0a4 | 3 | Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
76a9d10f | 4 | Free Software Foundation, Inc. |
2aa830e4 DJ |
5 | |
6 | This file is part of GDB. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 10 | the Free Software Foundation; either version 3 of the License, or |
2aa830e4 DJ |
11 | (at your option) any later version. |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
2aa830e4 DJ |
20 | |
21 | #include "defs.h" | |
22 | #include "gdbcore.h" | |
23 | #include "target.h" | |
24 | #include "solib-svr4.h" | |
19ed69dd | 25 | #include "osabi.h" |
96f026fc | 26 | #include "mips-tdep.h" |
19ed69dd | 27 | #include "gdb_string.h" |
96f026fc | 28 | #include "gdb_assert.h" |
6de918a6 | 29 | #include "frame.h" |
2fdf551c | 30 | #include "regcache.h" |
5792a79b DJ |
31 | #include "trad-frame.h" |
32 | #include "tramp-frame.h" | |
e6bb342a | 33 | #include "gdbtypes.h" |
5ea03926 | 34 | #include "solib.h" |
7d522c90 DJ |
35 | #include "solib-svr4.h" |
36 | #include "solist.h" | |
982e9687 | 37 | #include "symtab.h" |
822b6570 | 38 | #include "target-descriptions.h" |
50e8a0d5 | 39 | #include "regset.h" |
d37eb719 | 40 | #include "mips-linux-tdep.h" |
db5f024e | 41 | #include "glibc-tdep.h" |
a5ee0f0c | 42 | #include "linux-tdep.h" |
2aa830e4 | 43 | |
7d522c90 DJ |
44 | static struct target_so_ops mips_svr4_so_ops; |
45 | ||
2aa830e4 | 46 | /* Figure out where the longjmp will land. |
295093a4 MS |
47 | We expect the first arg to be a pointer to the jmp_buf structure |
48 | from which we extract the pc (MIPS_LINUX_JB_PC) that we will land | |
49 | at. The pc is copied into PC. This routine returns 1 on | |
50 | success. */ | |
2aa830e4 | 51 | |
19ed69dd KB |
52 | #define MIPS_LINUX_JB_ELEMENT_SIZE 4 |
53 | #define MIPS_LINUX_JB_PC 0 | |
54 | ||
55 | static int | |
60ade65d | 56 | mips_linux_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) |
2aa830e4 DJ |
57 | { |
58 | CORE_ADDR jb_addr; | |
2eb4d78b | 59 | struct gdbarch *gdbarch = get_frame_arch (frame); |
e17a4113 | 60 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
2eb4d78b | 61 | char buf[gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT]; |
2aa830e4 | 62 | |
60ade65d | 63 | jb_addr = get_frame_register_unsigned (frame, MIPS_A0_REGNUM); |
2aa830e4 | 64 | |
bf072999 | 65 | if (target_read_memory (jb_addr |
819844ad | 66 | + MIPS_LINUX_JB_PC * MIPS_LINUX_JB_ELEMENT_SIZE, |
2eb4d78b | 67 | buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT)) |
2aa830e4 DJ |
68 | return 0; |
69 | ||
819844ad | 70 | *pc = extract_unsigned_integer (buf, |
e17a4113 UW |
71 | gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT, |
72 | byte_order); | |
2aa830e4 DJ |
73 | |
74 | return 1; | |
75 | } | |
76 | ||
4246e332 | 77 | /* Transform the bits comprising a 32-bit register to the right size |
23a6d369 AC |
78 | for regcache_raw_supply(). This is needed when mips_isa_regsize() |
79 | is 8. */ | |
96f026fc KB |
80 | |
81 | static void | |
28f5035f | 82 | supply_32bit_reg (struct regcache *regcache, int regnum, const void *addr) |
96f026fc | 83 | { |
e17a4113 UW |
84 | struct gdbarch *gdbarch = get_regcache_arch (regcache); |
85 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | |
d37eb719 | 86 | gdb_byte buf[MAX_REGISTER_SIZE]; |
e17a4113 UW |
87 | store_signed_integer (buf, register_size (gdbarch, regnum), byte_order, |
88 | extract_signed_integer (addr, 4, byte_order)); | |
28f5035f | 89 | regcache_raw_supply (regcache, regnum, buf); |
96f026fc KB |
90 | } |
91 | ||
2aa830e4 DJ |
92 | /* Unpack an elf_gregset_t into GDB's register cache. */ |
93 | ||
d37eb719 | 94 | void |
28f5035f UW |
95 | mips_supply_gregset (struct regcache *regcache, |
96 | const mips_elf_gregset_t *gregsetp) | |
2aa830e4 DJ |
97 | { |
98 | int regi; | |
28f5035f | 99 | const mips_elf_greg_t *regp = *gregsetp; |
d9d9c31f | 100 | char zerobuf[MAX_REGISTER_SIZE]; |
2eb4d78b | 101 | struct gdbarch *gdbarch = get_regcache_arch (regcache); |
bf072999 | 102 | |
d9d9c31f | 103 | memset (zerobuf, 0, MAX_REGISTER_SIZE); |
2aa830e4 | 104 | |
822b6570 | 105 | for (regi = EF_REG0 + 1; regi <= EF_REG31; regi++) |
28f5035f | 106 | supply_32bit_reg (regcache, regi - EF_REG0, regp + regi); |
2aa830e4 | 107 | |
2eb4d78b | 108 | if (mips_linux_restart_reg_p (gdbarch)) |
822b6570 DJ |
109 | supply_32bit_reg (regcache, MIPS_RESTART_REGNUM, regp + EF_REG0); |
110 | ||
2eb4d78b UW |
111 | supply_32bit_reg (regcache, mips_regnum (gdbarch)->lo, regp + EF_LO); |
112 | supply_32bit_reg (regcache, mips_regnum (gdbarch)->hi, regp + EF_HI); | |
56cea623 | 113 | |
2eb4d78b | 114 | supply_32bit_reg (regcache, mips_regnum (gdbarch)->pc, |
28f5035f | 115 | regp + EF_CP0_EPC); |
2eb4d78b | 116 | supply_32bit_reg (regcache, mips_regnum (gdbarch)->badvaddr, |
28f5035f UW |
117 | regp + EF_CP0_BADVADDR); |
118 | supply_32bit_reg (regcache, MIPS_PS_REGNUM, regp + EF_CP0_STATUS); | |
2eb4d78b | 119 | supply_32bit_reg (regcache, mips_regnum (gdbarch)->cause, |
28f5035f | 120 | regp + EF_CP0_CAUSE); |
2aa830e4 DJ |
121 | |
122 | /* Fill inaccessible registers with zero. */ | |
822b6570 | 123 | regcache_raw_supply (regcache, MIPS_ZERO_REGNUM, zerobuf); |
28f5035f | 124 | regcache_raw_supply (regcache, MIPS_UNUSED_REGNUM, zerobuf); |
295093a4 | 125 | for (regi = MIPS_FIRST_EMBED_REGNUM; |
822b6570 | 126 | regi <= MIPS_LAST_EMBED_REGNUM; |
295093a4 | 127 | regi++) |
28f5035f | 128 | regcache_raw_supply (regcache, regi, zerobuf); |
2aa830e4 DJ |
129 | } |
130 | ||
50e8a0d5 HZ |
131 | static void |
132 | mips_supply_gregset_wrapper (const struct regset *regset, | |
133 | struct regcache *regcache, | |
134 | int regnum, const void *gregs, size_t len) | |
135 | { | |
136 | gdb_assert (len == sizeof (mips_elf_gregset_t)); | |
137 | ||
138 | mips_supply_gregset (regcache, (const mips_elf_gregset_t *)gregs); | |
139 | } | |
140 | ||
2aa830e4 DJ |
141 | /* Pack our registers (or one register) into an elf_gregset_t. */ |
142 | ||
d37eb719 | 143 | void |
28f5035f UW |
144 | mips_fill_gregset (const struct regcache *regcache, |
145 | mips_elf_gregset_t *gregsetp, int regno) | |
2aa830e4 | 146 | { |
2eb4d78b | 147 | struct gdbarch *gdbarch = get_regcache_arch (regcache); |
2aa830e4 | 148 | int regaddr, regi; |
d37eb719 | 149 | mips_elf_greg_t *regp = *gregsetp; |
96f026fc | 150 | void *dst; |
2aa830e4 DJ |
151 | |
152 | if (regno == -1) | |
153 | { | |
d37eb719 | 154 | memset (regp, 0, sizeof (mips_elf_gregset_t)); |
822b6570 | 155 | for (regi = 1; regi < 32; regi++) |
28f5035f | 156 | mips_fill_gregset (regcache, gregsetp, regi); |
2eb4d78b UW |
157 | mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->lo); |
158 | mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->hi); | |
159 | mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->pc); | |
160 | mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->badvaddr); | |
28f5035f | 161 | mips_fill_gregset (regcache, gregsetp, MIPS_PS_REGNUM); |
2eb4d78b | 162 | mips_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->cause); |
822b6570 | 163 | mips_fill_gregset (regcache, gregsetp, MIPS_RESTART_REGNUM); |
2aa830e4 DJ |
164 | return; |
165 | } | |
166 | ||
822b6570 | 167 | if (regno > 0 && regno < 32) |
2aa830e4 | 168 | { |
2aa830e4 | 169 | dst = regp + regno + EF_REG0; |
28f5035f | 170 | regcache_raw_collect (regcache, regno, dst); |
2aa830e4 DJ |
171 | return; |
172 | } | |
173 | ||
2eb4d78b UW |
174 | if (regno == mips_regnum (gdbarch)->lo) |
175 | regaddr = EF_LO; | |
176 | else if (regno == mips_regnum (gdbarch)->hi) | |
56cea623 | 177 | regaddr = EF_HI; |
2eb4d78b | 178 | else if (regno == mips_regnum (gdbarch)->pc) |
56cea623 | 179 | regaddr = EF_CP0_EPC; |
2eb4d78b | 180 | else if (regno == mips_regnum (gdbarch)->badvaddr) |
56cea623 | 181 | regaddr = EF_CP0_BADVADDR; |
24e05951 | 182 | else if (regno == MIPS_PS_REGNUM) |
56cea623 | 183 | regaddr = EF_CP0_STATUS; |
2eb4d78b | 184 | else if (regno == mips_regnum (gdbarch)->cause) |
56cea623 | 185 | regaddr = EF_CP0_CAUSE; |
2eb4d78b | 186 | else if (mips_linux_restart_reg_p (gdbarch) |
822b6570 DJ |
187 | && regno == MIPS_RESTART_REGNUM) |
188 | regaddr = EF_REG0; | |
56cea623 AC |
189 | else |
190 | regaddr = -1; | |
2aa830e4 DJ |
191 | |
192 | if (regaddr != -1) | |
193 | { | |
2aa830e4 | 194 | dst = regp + regaddr; |
28f5035f | 195 | regcache_raw_collect (regcache, regno, dst); |
2aa830e4 DJ |
196 | } |
197 | } | |
198 | ||
50e8a0d5 HZ |
199 | static void |
200 | mips_fill_gregset_wrapper (const struct regset *regset, | |
201 | const struct regcache *regcache, | |
202 | int regnum, void *gregs, size_t len) | |
203 | { | |
204 | gdb_assert (len == sizeof (mips_elf_gregset_t)); | |
205 | ||
206 | mips_fill_gregset (regcache, (mips_elf_gregset_t *)gregs, regnum); | |
207 | } | |
208 | ||
2aa830e4 DJ |
209 | /* Likewise, unpack an elf_fpregset_t. */ |
210 | ||
d37eb719 | 211 | void |
28f5035f UW |
212 | mips_supply_fpregset (struct regcache *regcache, |
213 | const mips_elf_fpregset_t *fpregsetp) | |
2aa830e4 | 214 | { |
2eb4d78b | 215 | struct gdbarch *gdbarch = get_regcache_arch (regcache); |
52f0bd74 | 216 | int regi; |
d9d9c31f | 217 | char zerobuf[MAX_REGISTER_SIZE]; |
bf072999 | 218 | |
d9d9c31f | 219 | memset (zerobuf, 0, MAX_REGISTER_SIZE); |
2aa830e4 DJ |
220 | |
221 | for (regi = 0; regi < 32; regi++) | |
3e8c568d | 222 | regcache_raw_supply (regcache, |
2eb4d78b | 223 | gdbarch_fp0_regnum (gdbarch) + regi, |
3e8c568d | 224 | *fpregsetp + regi); |
2aa830e4 | 225 | |
28f5035f | 226 | regcache_raw_supply (regcache, |
2eb4d78b | 227 | mips_regnum (gdbarch)->fp_control_status, |
28f5035f | 228 | *fpregsetp + 32); |
2aa830e4 | 229 | |
295093a4 | 230 | /* FIXME: how can we supply FCRIR? The ABI doesn't tell us. */ |
28f5035f | 231 | regcache_raw_supply (regcache, |
2eb4d78b | 232 | mips_regnum (gdbarch)->fp_implementation_revision, |
23a6d369 | 233 | zerobuf); |
2aa830e4 DJ |
234 | } |
235 | ||
50e8a0d5 HZ |
236 | static void |
237 | mips_supply_fpregset_wrapper (const struct regset *regset, | |
238 | struct regcache *regcache, | |
239 | int regnum, const void *gregs, size_t len) | |
240 | { | |
241 | gdb_assert (len == sizeof (mips_elf_fpregset_t)); | |
242 | ||
243 | mips_supply_fpregset (regcache, (const mips_elf_fpregset_t *)gregs); | |
244 | } | |
245 | ||
2aa830e4 DJ |
246 | /* Likewise, pack one or all floating point registers into an |
247 | elf_fpregset_t. */ | |
248 | ||
d37eb719 | 249 | void |
28f5035f UW |
250 | mips_fill_fpregset (const struct regcache *regcache, |
251 | mips_elf_fpregset_t *fpregsetp, int regno) | |
2aa830e4 | 252 | { |
2eb4d78b | 253 | struct gdbarch *gdbarch = get_regcache_arch (regcache); |
2aa830e4 DJ |
254 | char *from, *to; |
255 | ||
2eb4d78b UW |
256 | if ((regno >= gdbarch_fp0_regnum (gdbarch)) |
257 | && (regno < gdbarch_fp0_regnum (gdbarch) + 32)) | |
2aa830e4 | 258 | { |
2eb4d78b | 259 | to = (char *) (*fpregsetp + regno - gdbarch_fp0_regnum (gdbarch)); |
28f5035f | 260 | regcache_raw_collect (regcache, regno, to); |
2aa830e4 | 261 | } |
2eb4d78b | 262 | else if (regno == mips_regnum (gdbarch)->fp_control_status) |
2aa830e4 | 263 | { |
2aa830e4 | 264 | to = (char *) (*fpregsetp + 32); |
28f5035f | 265 | regcache_raw_collect (regcache, regno, to); |
2aa830e4 DJ |
266 | } |
267 | else if (regno == -1) | |
268 | { | |
269 | int regi; | |
270 | ||
271 | for (regi = 0; regi < 32; regi++) | |
3e8c568d | 272 | mips_fill_fpregset (regcache, fpregsetp, |
2eb4d78b | 273 | gdbarch_fp0_regnum (gdbarch) + regi); |
28f5035f | 274 | mips_fill_fpregset (regcache, fpregsetp, |
2eb4d78b | 275 | mips_regnum (gdbarch)->fp_control_status); |
2aa830e4 DJ |
276 | } |
277 | } | |
278 | ||
50e8a0d5 HZ |
279 | static void |
280 | mips_fill_fpregset_wrapper (const struct regset *regset, | |
281 | const struct regcache *regcache, | |
282 | int regnum, void *gregs, size_t len) | |
283 | { | |
284 | gdb_assert (len == sizeof (mips_elf_fpregset_t)); | |
285 | ||
286 | mips_fill_fpregset (regcache, (mips_elf_fpregset_t *)gregs, regnum); | |
287 | } | |
288 | ||
96f026fc KB |
289 | /* Support for 64-bit ABIs. */ |
290 | ||
96f026fc | 291 | /* Figure out where the longjmp will land. |
295093a4 MS |
292 | We expect the first arg to be a pointer to the jmp_buf structure |
293 | from which we extract the pc (MIPS_LINUX_JB_PC) that we will land | |
294 | at. The pc is copied into PC. This routine returns 1 on | |
295 | success. */ | |
96f026fc KB |
296 | |
297 | /* Details about jmp_buf. */ | |
298 | ||
299 | #define MIPS64_LINUX_JB_PC 0 | |
300 | ||
301 | static int | |
60ade65d | 302 | mips64_linux_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) |
96f026fc KB |
303 | { |
304 | CORE_ADDR jb_addr; | |
2eb4d78b | 305 | struct gdbarch *gdbarch = get_frame_arch (frame); |
e17a4113 | 306 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
2eb4d78b UW |
307 | void *buf = alloca (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT); |
308 | int element_size = gdbarch_ptr_bit (gdbarch) == 32 ? 4 : 8; | |
96f026fc | 309 | |
60ade65d | 310 | jb_addr = get_frame_register_unsigned (frame, MIPS_A0_REGNUM); |
96f026fc KB |
311 | |
312 | if (target_read_memory (jb_addr + MIPS64_LINUX_JB_PC * element_size, | |
819844ad | 313 | buf, |
2eb4d78b | 314 | gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT)) |
96f026fc KB |
315 | return 0; |
316 | ||
819844ad | 317 | *pc = extract_unsigned_integer (buf, |
e17a4113 UW |
318 | gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT, |
319 | byte_order); | |
96f026fc KB |
320 | |
321 | return 1; | |
322 | } | |
323 | ||
d37eb719 DJ |
324 | /* Register set support functions. These operate on standard 64-bit |
325 | regsets, but work whether the target is 32-bit or 64-bit. A 32-bit | |
326 | target will still use the 64-bit format for PTRACE_GETREGS. */ | |
327 | ||
328 | /* Supply a 64-bit register. */ | |
96f026fc | 329 | |
63807e1d | 330 | static void |
28f5035f UW |
331 | supply_64bit_reg (struct regcache *regcache, int regnum, |
332 | const gdb_byte *buf) | |
d37eb719 | 333 | { |
2eb4d78b UW |
334 | struct gdbarch *gdbarch = get_regcache_arch (regcache); |
335 | if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG | |
336 | && register_size (gdbarch, regnum) == 4) | |
28f5035f | 337 | regcache_raw_supply (regcache, regnum, buf + 4); |
d37eb719 | 338 | else |
28f5035f | 339 | regcache_raw_supply (regcache, regnum, buf); |
d37eb719 DJ |
340 | } |
341 | ||
342 | /* Unpack a 64-bit elf_gregset_t into GDB's register cache. */ | |
343 | ||
344 | void | |
28f5035f UW |
345 | mips64_supply_gregset (struct regcache *regcache, |
346 | const mips64_elf_gregset_t *gregsetp) | |
96f026fc KB |
347 | { |
348 | int regi; | |
28f5035f | 349 | const mips64_elf_greg_t *regp = *gregsetp; |
d37eb719 | 350 | gdb_byte zerobuf[MAX_REGISTER_SIZE]; |
2eb4d78b | 351 | struct gdbarch *gdbarch = get_regcache_arch (regcache); |
96f026fc | 352 | |
d9d9c31f | 353 | memset (zerobuf, 0, MAX_REGISTER_SIZE); |
96f026fc | 354 | |
822b6570 | 355 | for (regi = MIPS64_EF_REG0 + 1; regi <= MIPS64_EF_REG31; regi++) |
28f5035f UW |
356 | supply_64bit_reg (regcache, regi - MIPS64_EF_REG0, |
357 | (const gdb_byte *)(regp + regi)); | |
358 | ||
2eb4d78b | 359 | if (mips_linux_restart_reg_p (gdbarch)) |
822b6570 DJ |
360 | supply_64bit_reg (regcache, MIPS_RESTART_REGNUM, |
361 | (const gdb_byte *)(regp + MIPS64_EF_REG0)); | |
362 | ||
2eb4d78b | 363 | supply_64bit_reg (regcache, mips_regnum (gdbarch)->lo, |
28f5035f | 364 | (const gdb_byte *) (regp + MIPS64_EF_LO)); |
2eb4d78b | 365 | supply_64bit_reg (regcache, mips_regnum (gdbarch)->hi, |
28f5035f UW |
366 | (const gdb_byte *) (regp + MIPS64_EF_HI)); |
367 | ||
2eb4d78b | 368 | supply_64bit_reg (regcache, mips_regnum (gdbarch)->pc, |
28f5035f | 369 | (const gdb_byte *) (regp + MIPS64_EF_CP0_EPC)); |
2eb4d78b | 370 | supply_64bit_reg (regcache, mips_regnum (gdbarch)->badvaddr, |
28f5035f UW |
371 | (const gdb_byte *) (regp + MIPS64_EF_CP0_BADVADDR)); |
372 | supply_64bit_reg (regcache, MIPS_PS_REGNUM, | |
373 | (const gdb_byte *) (regp + MIPS64_EF_CP0_STATUS)); | |
2eb4d78b | 374 | supply_64bit_reg (regcache, mips_regnum (gdbarch)->cause, |
28f5035f | 375 | (const gdb_byte *) (regp + MIPS64_EF_CP0_CAUSE)); |
96f026fc KB |
376 | |
377 | /* Fill inaccessible registers with zero. */ | |
822b6570 | 378 | regcache_raw_supply (regcache, MIPS_ZERO_REGNUM, zerobuf); |
28f5035f | 379 | regcache_raw_supply (regcache, MIPS_UNUSED_REGNUM, zerobuf); |
295093a4 | 380 | for (regi = MIPS_FIRST_EMBED_REGNUM; |
822b6570 | 381 | regi <= MIPS_LAST_EMBED_REGNUM; |
295093a4 | 382 | regi++) |
28f5035f | 383 | regcache_raw_supply (regcache, regi, zerobuf); |
96f026fc KB |
384 | } |
385 | ||
50e8a0d5 HZ |
386 | static void |
387 | mips64_supply_gregset_wrapper (const struct regset *regset, | |
388 | struct regcache *regcache, | |
389 | int regnum, const void *gregs, size_t len) | |
390 | { | |
391 | gdb_assert (len == sizeof (mips64_elf_gregset_t)); | |
392 | ||
393 | mips64_supply_gregset (regcache, (const mips64_elf_gregset_t *)gregs); | |
394 | } | |
395 | ||
d37eb719 | 396 | /* Pack our registers (or one register) into a 64-bit elf_gregset_t. */ |
96f026fc | 397 | |
d37eb719 | 398 | void |
28f5035f UW |
399 | mips64_fill_gregset (const struct regcache *regcache, |
400 | mips64_elf_gregset_t *gregsetp, int regno) | |
96f026fc | 401 | { |
2eb4d78b | 402 | struct gdbarch *gdbarch = get_regcache_arch (regcache); |
e17a4113 | 403 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
96f026fc KB |
404 | int regaddr, regi; |
405 | mips64_elf_greg_t *regp = *gregsetp; | |
2ba93934 | 406 | void *dst; |
96f026fc KB |
407 | |
408 | if (regno == -1) | |
409 | { | |
410 | memset (regp, 0, sizeof (mips64_elf_gregset_t)); | |
822b6570 | 411 | for (regi = 1; regi < 32; regi++) |
28f5035f | 412 | mips64_fill_gregset (regcache, gregsetp, regi); |
2eb4d78b UW |
413 | mips64_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->lo); |
414 | mips64_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->hi); | |
415 | mips64_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->pc); | |
416 | mips64_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->badvaddr); | |
28f5035f | 417 | mips64_fill_gregset (regcache, gregsetp, MIPS_PS_REGNUM); |
2eb4d78b | 418 | mips64_fill_gregset (regcache, gregsetp, mips_regnum (gdbarch)->cause); |
822b6570 | 419 | mips64_fill_gregset (regcache, gregsetp, MIPS_RESTART_REGNUM); |
96f026fc KB |
420 | return; |
421 | } | |
422 | ||
822b6570 | 423 | if (regno > 0 && regno < 32) |
d37eb719 | 424 | regaddr = regno + MIPS64_EF_REG0; |
2eb4d78b | 425 | else if (regno == mips_regnum (gdbarch)->lo) |
56cea623 | 426 | regaddr = MIPS64_EF_LO; |
2eb4d78b | 427 | else if (regno == mips_regnum (gdbarch)->hi) |
56cea623 | 428 | regaddr = MIPS64_EF_HI; |
2eb4d78b | 429 | else if (regno == mips_regnum (gdbarch)->pc) |
56cea623 | 430 | regaddr = MIPS64_EF_CP0_EPC; |
2eb4d78b | 431 | else if (regno == mips_regnum (gdbarch)->badvaddr) |
56cea623 | 432 | regaddr = MIPS64_EF_CP0_BADVADDR; |
24e05951 | 433 | else if (regno == MIPS_PS_REGNUM) |
56cea623 | 434 | regaddr = MIPS64_EF_CP0_STATUS; |
2eb4d78b | 435 | else if (regno == mips_regnum (gdbarch)->cause) |
56cea623 | 436 | regaddr = MIPS64_EF_CP0_CAUSE; |
2eb4d78b | 437 | else if (mips_linux_restart_reg_p (gdbarch) |
822b6570 DJ |
438 | && regno == MIPS_RESTART_REGNUM) |
439 | regaddr = MIPS64_EF_REG0; | |
56cea623 AC |
440 | else |
441 | regaddr = -1; | |
96f026fc KB |
442 | |
443 | if (regaddr != -1) | |
444 | { | |
d37eb719 DJ |
445 | gdb_byte buf[MAX_REGISTER_SIZE]; |
446 | LONGEST val; | |
447 | ||
28f5035f | 448 | regcache_raw_collect (regcache, regno, buf); |
e17a4113 UW |
449 | val = extract_signed_integer (buf, register_size (gdbarch, regno), |
450 | byte_order); | |
96f026fc | 451 | dst = regp + regaddr; |
e17a4113 | 452 | store_signed_integer (dst, 8, byte_order, val); |
96f026fc KB |
453 | } |
454 | } | |
455 | ||
50e8a0d5 HZ |
456 | static void |
457 | mips64_fill_gregset_wrapper (const struct regset *regset, | |
458 | const struct regcache *regcache, | |
459 | int regnum, void *gregs, size_t len) | |
460 | { | |
461 | gdb_assert (len == sizeof (mips64_elf_gregset_t)); | |
462 | ||
463 | mips64_fill_gregset (regcache, (mips64_elf_gregset_t *)gregs, regnum); | |
464 | } | |
465 | ||
96f026fc KB |
466 | /* Likewise, unpack an elf_fpregset_t. */ |
467 | ||
d37eb719 | 468 | void |
28f5035f UW |
469 | mips64_supply_fpregset (struct regcache *regcache, |
470 | const mips64_elf_fpregset_t *fpregsetp) | |
96f026fc | 471 | { |
2eb4d78b | 472 | struct gdbarch *gdbarch = get_regcache_arch (regcache); |
52f0bd74 | 473 | int regi; |
96f026fc | 474 | |
d37eb719 DJ |
475 | /* See mips_linux_o32_sigframe_init for a description of the |
476 | peculiar FP register layout. */ | |
2eb4d78b | 477 | if (register_size (gdbarch, gdbarch_fp0_regnum (gdbarch)) == 4) |
d37eb719 DJ |
478 | for (regi = 0; regi < 32; regi++) |
479 | { | |
28f5035f | 480 | const gdb_byte *reg_ptr = (const gdb_byte *)(*fpregsetp + (regi & ~1)); |
2eb4d78b | 481 | if ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) != (regi & 1)) |
d37eb719 | 482 | reg_ptr += 4; |
3e8c568d | 483 | regcache_raw_supply (regcache, |
2eb4d78b | 484 | gdbarch_fp0_regnum (gdbarch) + regi, |
3e8c568d | 485 | reg_ptr); |
d37eb719 DJ |
486 | } |
487 | else | |
488 | for (regi = 0; regi < 32; regi++) | |
3e8c568d | 489 | regcache_raw_supply (regcache, |
2eb4d78b | 490 | gdbarch_fp0_regnum (gdbarch) + regi, |
28f5035f | 491 | (const char *)(*fpregsetp + regi)); |
d37eb719 | 492 | |
2eb4d78b | 493 | supply_32bit_reg (regcache, mips_regnum (gdbarch)->fp_control_status, |
28f5035f | 494 | (const gdb_byte *)(*fpregsetp + 32)); |
d37eb719 DJ |
495 | |
496 | /* The ABI doesn't tell us how to supply FCRIR, and core dumps don't | |
497 | include it - but the result of PTRACE_GETFPREGS does. The best we | |
498 | can do is to assume that its value is present. */ | |
28f5035f | 499 | supply_32bit_reg (regcache, |
2eb4d78b | 500 | mips_regnum (gdbarch)->fp_implementation_revision, |
28f5035f | 501 | (const gdb_byte *)(*fpregsetp + 32) + 4); |
96f026fc KB |
502 | } |
503 | ||
50e8a0d5 HZ |
504 | static void |
505 | mips64_supply_fpregset_wrapper (const struct regset *regset, | |
506 | struct regcache *regcache, | |
507 | int regnum, const void *gregs, size_t len) | |
508 | { | |
509 | gdb_assert (len == sizeof (mips64_elf_fpregset_t)); | |
510 | ||
511 | mips64_supply_fpregset (regcache, (const mips64_elf_fpregset_t *)gregs); | |
512 | } | |
513 | ||
96f026fc KB |
514 | /* Likewise, pack one or all floating point registers into an |
515 | elf_fpregset_t. */ | |
516 | ||
d37eb719 | 517 | void |
28f5035f UW |
518 | mips64_fill_fpregset (const struct regcache *regcache, |
519 | mips64_elf_fpregset_t *fpregsetp, int regno) | |
96f026fc | 520 | { |
2eb4d78b | 521 | struct gdbarch *gdbarch = get_regcache_arch (regcache); |
e17a4113 | 522 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
d37eb719 | 523 | gdb_byte *to; |
96f026fc | 524 | |
2eb4d78b UW |
525 | if ((regno >= gdbarch_fp0_regnum (gdbarch)) |
526 | && (regno < gdbarch_fp0_regnum (gdbarch) + 32)) | |
96f026fc | 527 | { |
d37eb719 DJ |
528 | /* See mips_linux_o32_sigframe_init for a description of the |
529 | peculiar FP register layout. */ | |
2eb4d78b | 530 | if (register_size (gdbarch, regno) == 4) |
d37eb719 | 531 | { |
2eb4d78b | 532 | int regi = regno - gdbarch_fp0_regnum (gdbarch); |
d37eb719 DJ |
533 | |
534 | to = (gdb_byte *) (*fpregsetp + (regi & ~1)); | |
2eb4d78b | 535 | if ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) != (regi & 1)) |
d37eb719 | 536 | to += 4; |
28f5035f | 537 | regcache_raw_collect (regcache, regno, to); |
d37eb719 DJ |
538 | } |
539 | else | |
540 | { | |
2eb4d78b | 541 | to = (gdb_byte *) (*fpregsetp + regno - gdbarch_fp0_regnum (gdbarch)); |
28f5035f | 542 | regcache_raw_collect (regcache, regno, to); |
d37eb719 | 543 | } |
96f026fc | 544 | } |
2eb4d78b | 545 | else if (regno == mips_regnum (gdbarch)->fp_control_status) |
96f026fc | 546 | { |
d37eb719 DJ |
547 | gdb_byte buf[MAX_REGISTER_SIZE]; |
548 | LONGEST val; | |
549 | ||
28f5035f | 550 | regcache_raw_collect (regcache, regno, buf); |
e17a4113 UW |
551 | val = extract_signed_integer (buf, register_size (gdbarch, regno), |
552 | byte_order); | |
d37eb719 | 553 | to = (gdb_byte *) (*fpregsetp + 32); |
e17a4113 | 554 | store_signed_integer (to, 4, byte_order, val); |
d37eb719 | 555 | } |
2eb4d78b | 556 | else if (regno == mips_regnum (gdbarch)->fp_implementation_revision) |
d37eb719 DJ |
557 | { |
558 | gdb_byte buf[MAX_REGISTER_SIZE]; | |
559 | LONGEST val; | |
560 | ||
28f5035f | 561 | regcache_raw_collect (regcache, regno, buf); |
e17a4113 UW |
562 | val = extract_signed_integer (buf, register_size (gdbarch, regno), |
563 | byte_order); | |
d37eb719 | 564 | to = (gdb_byte *) (*fpregsetp + 32) + 4; |
e17a4113 | 565 | store_signed_integer (to, 4, byte_order, val); |
96f026fc KB |
566 | } |
567 | else if (regno == -1) | |
568 | { | |
569 | int regi; | |
570 | ||
571 | for (regi = 0; regi < 32; regi++) | |
3e8c568d | 572 | mips64_fill_fpregset (regcache, fpregsetp, |
2eb4d78b | 573 | gdbarch_fp0_regnum (gdbarch) + regi); |
28f5035f | 574 | mips64_fill_fpregset (regcache, fpregsetp, |
2eb4d78b | 575 | mips_regnum (gdbarch)->fp_control_status); |
28f5035f | 576 | mips64_fill_fpregset (regcache, fpregsetp, |
2eb4d78b UW |
577 | (mips_regnum (gdbarch) |
578 | ->fp_implementation_revision)); | |
96f026fc KB |
579 | } |
580 | } | |
581 | ||
50e8a0d5 HZ |
582 | static void |
583 | mips64_fill_fpregset_wrapper (const struct regset *regset, | |
584 | const struct regcache *regcache, | |
585 | int regnum, void *gregs, size_t len) | |
586 | { | |
587 | gdb_assert (len == sizeof (mips64_elf_fpregset_t)); | |
96f026fc | 588 | |
50e8a0d5 HZ |
589 | mips64_fill_fpregset (regcache, (mips64_elf_fpregset_t *)gregs, regnum); |
590 | } | |
2aa830e4 | 591 | |
50e8a0d5 HZ |
592 | const struct regset * |
593 | mips_linux_regset_from_core_section (struct gdbarch *gdbarch, | |
594 | const char *sect_name, size_t sect_size) | |
2aa830e4 | 595 | { |
50e8a0d5 | 596 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
d37eb719 DJ |
597 | mips_elf_gregset_t gregset; |
598 | mips_elf_fpregset_t fpregset; | |
96f026fc KB |
599 | mips64_elf_gregset_t gregset64; |
600 | mips64_elf_fpregset_t fpregset64; | |
2aa830e4 | 601 | |
50e8a0d5 | 602 | if (strcmp (sect_name, ".reg") == 0) |
2aa830e4 | 603 | { |
50e8a0d5 | 604 | if (sect_size == sizeof (gregset)) |
2aa830e4 | 605 | { |
50e8a0d5 HZ |
606 | if (tdep->gregset == NULL) |
607 | tdep->gregset = regset_alloc (gdbarch, | |
608 | mips_supply_gregset_wrapper, | |
609 | mips_fill_gregset_wrapper); | |
610 | return tdep->gregset; | |
96f026fc | 611 | } |
50e8a0d5 | 612 | else if (sect_size == sizeof (gregset64)) |
96f026fc | 613 | { |
50e8a0d5 HZ |
614 | if (tdep->gregset64 == NULL) |
615 | tdep->gregset64 = regset_alloc (gdbarch, | |
616 | mips64_supply_gregset_wrapper, | |
617 | mips64_fill_gregset_wrapper); | |
618 | return tdep->gregset64; | |
2aa830e4 DJ |
619 | } |
620 | else | |
621 | { | |
8a3fe4f8 | 622 | warning (_("wrong size gregset struct in core file")); |
2aa830e4 DJ |
623 | } |
624 | } | |
50e8a0d5 | 625 | else if (strcmp (sect_name, ".reg2") == 0) |
2aa830e4 | 626 | { |
50e8a0d5 | 627 | if (sect_size == sizeof (fpregset)) |
2aa830e4 | 628 | { |
50e8a0d5 HZ |
629 | if (tdep->fpregset == NULL) |
630 | tdep->fpregset = regset_alloc (gdbarch, | |
631 | mips_supply_fpregset_wrapper, | |
632 | mips_fill_fpregset_wrapper); | |
633 | return tdep->fpregset; | |
96f026fc | 634 | } |
50e8a0d5 | 635 | else if (sect_size == sizeof (fpregset64)) |
96f026fc | 636 | { |
50e8a0d5 HZ |
637 | if (tdep->fpregset64 == NULL) |
638 | tdep->fpregset64 = regset_alloc (gdbarch, | |
639 | mips64_supply_fpregset_wrapper, | |
640 | mips64_fill_fpregset_wrapper); | |
641 | return tdep->fpregset64; | |
2aa830e4 DJ |
642 | } |
643 | else | |
644 | { | |
8a3fe4f8 | 645 | warning (_("wrong size fpregset struct in core file")); |
2aa830e4 DJ |
646 | } |
647 | } | |
2aa830e4 | 648 | |
50e8a0d5 HZ |
649 | return NULL; |
650 | } | |
2aa830e4 | 651 | |
4eb0ad19 DJ |
652 | static const struct target_desc * |
653 | mips_linux_core_read_description (struct gdbarch *gdbarch, | |
654 | struct target_ops *target, | |
655 | bfd *abfd) | |
656 | { | |
657 | asection *section = bfd_get_section_by_name (abfd, ".reg"); | |
658 | if (! section) | |
659 | return NULL; | |
660 | ||
661 | switch (bfd_section_size (abfd, section)) | |
662 | { | |
663 | case sizeof (mips_elf_gregset_t): | |
664 | return mips_tdesc_gp32; | |
665 | ||
666 | case sizeof (mips64_elf_gregset_t): | |
667 | return mips_tdesc_gp64; | |
668 | ||
669 | default: | |
670 | return NULL; | |
671 | } | |
672 | } | |
673 | ||
96f026fc | 674 | |
295093a4 MS |
675 | /* Check the code at PC for a dynamic linker lazy resolution stub. |
676 | Because they aren't in the .plt section, we pattern-match on the | |
677 | code generated by GNU ld. They look like this: | |
6de918a6 DJ |
678 | |
679 | lw t9,0x8010(gp) | |
680 | addu t7,ra | |
681 | jalr t9,ra | |
682 | addiu t8,zero,INDEX | |
683 | ||
295093a4 MS |
684 | (with the appropriate doubleword instructions for N64). Also |
685 | return the dynamic symbol index used in the last instruction. */ | |
6de918a6 DJ |
686 | |
687 | static int | |
688 | mips_linux_in_dynsym_stub (CORE_ADDR pc, char *name) | |
689 | { | |
690 | unsigned char buf[28], *p; | |
691 | ULONGEST insn, insn1; | |
1cf3db46 | 692 | int n64 = (mips_abi (target_gdbarch) == MIPS_ABI_N64); |
e17a4113 | 693 | enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch); |
6de918a6 DJ |
694 | |
695 | read_memory (pc - 12, buf, 28); | |
696 | ||
697 | if (n64) | |
698 | { | |
699 | /* ld t9,0x8010(gp) */ | |
700 | insn1 = 0xdf998010; | |
701 | } | |
702 | else | |
703 | { | |
704 | /* lw t9,0x8010(gp) */ | |
705 | insn1 = 0x8f998010; | |
706 | } | |
707 | ||
708 | p = buf + 12; | |
709 | while (p >= buf) | |
710 | { | |
e17a4113 | 711 | insn = extract_unsigned_integer (p, 4, byte_order); |
6de918a6 DJ |
712 | if (insn == insn1) |
713 | break; | |
714 | p -= 4; | |
715 | } | |
716 | if (p < buf) | |
717 | return 0; | |
718 | ||
e17a4113 | 719 | insn = extract_unsigned_integer (p + 4, 4, byte_order); |
6de918a6 DJ |
720 | if (n64) |
721 | { | |
722 | /* daddu t7,ra */ | |
723 | if (insn != 0x03e0782d) | |
724 | return 0; | |
725 | } | |
726 | else | |
727 | { | |
728 | /* addu t7,ra */ | |
729 | if (insn != 0x03e07821) | |
730 | return 0; | |
731 | } | |
295093a4 | 732 | |
e17a4113 | 733 | insn = extract_unsigned_integer (p + 8, 4, byte_order); |
6de918a6 DJ |
734 | /* jalr t9,ra */ |
735 | if (insn != 0x0320f809) | |
736 | return 0; | |
737 | ||
e17a4113 | 738 | insn = extract_unsigned_integer (p + 12, 4, byte_order); |
6de918a6 DJ |
739 | if (n64) |
740 | { | |
741 | /* daddiu t8,zero,0 */ | |
742 | if ((insn & 0xffff0000) != 0x64180000) | |
743 | return 0; | |
744 | } | |
745 | else | |
746 | { | |
747 | /* addiu t8,zero,0 */ | |
748 | if ((insn & 0xffff0000) != 0x24180000) | |
749 | return 0; | |
750 | } | |
751 | ||
752 | return (insn & 0xffff); | |
753 | } | |
754 | ||
295093a4 | 755 | /* Return non-zero iff PC belongs to the dynamic linker resolution |
db5f024e | 756 | code, a PLT entry, or a lazy binding stub. */ |
6de918a6 | 757 | |
7d522c90 | 758 | static int |
6de918a6 DJ |
759 | mips_linux_in_dynsym_resolve_code (CORE_ADDR pc) |
760 | { | |
295093a4 | 761 | /* Check whether PC is in the dynamic linker. This also checks |
db5f024e | 762 | whether it is in the .plt section, used by non-PIC executables. */ |
7d522c90 | 763 | if (svr4_in_dynsym_resolve_code (pc)) |
6de918a6 DJ |
764 | return 1; |
765 | ||
295093a4 MS |
766 | /* Pattern match for the stub. It would be nice if there were a |
767 | more efficient way to avoid this check. */ | |
6de918a6 DJ |
768 | if (mips_linux_in_dynsym_stub (pc, NULL)) |
769 | return 1; | |
770 | ||
771 | return 0; | |
772 | } | |
773 | ||
774 | /* See the comments for SKIP_SOLIB_RESOLVER at the top of infrun.c, | |
775 | and glibc_skip_solib_resolver in glibc-tdep.c. The normal glibc | |
776 | implementation of this triggers at "fixup" from the same objfile as | |
c4c5b7ba | 777 | "_dl_runtime_resolve"; MIPS GNU/Linux can trigger at |
db5f024e DJ |
778 | "__dl_runtime_resolve" directly. An unresolved lazy binding |
779 | stub will point to _dl_runtime_resolve, which will first call | |
c4c5b7ba AC |
780 | __dl_runtime_resolve, and then pass control to the resolved |
781 | function. */ | |
6de918a6 DJ |
782 | |
783 | static CORE_ADDR | |
784 | mips_linux_skip_resolver (struct gdbarch *gdbarch, CORE_ADDR pc) | |
785 | { | |
786 | struct minimal_symbol *resolver; | |
787 | ||
788 | resolver = lookup_minimal_symbol ("__dl_runtime_resolve", NULL, NULL); | |
789 | ||
790 | if (resolver && SYMBOL_VALUE_ADDRESS (resolver) == pc) | |
c7ce8faa | 791 | return frame_unwind_caller_pc (get_current_frame ()); |
6de918a6 | 792 | |
db5f024e | 793 | return glibc_skip_solib_resolver (gdbarch, pc); |
295093a4 | 794 | } |
6de918a6 | 795 | |
5792a79b DJ |
796 | /* Signal trampoline support. There are four supported layouts for a |
797 | signal frame: o32 sigframe, o32 rt_sigframe, n32 rt_sigframe, and | |
798 | n64 rt_sigframe. We handle them all independently; not the most | |
799 | efficient way, but simplest. First, declare all the unwinders. */ | |
800 | ||
801 | static void mips_linux_o32_sigframe_init (const struct tramp_frame *self, | |
b8a22b94 | 802 | struct frame_info *this_frame, |
5792a79b DJ |
803 | struct trad_frame_cache *this_cache, |
804 | CORE_ADDR func); | |
805 | ||
806 | static void mips_linux_n32n64_sigframe_init (const struct tramp_frame *self, | |
b8a22b94 | 807 | struct frame_info *this_frame, |
5792a79b DJ |
808 | struct trad_frame_cache *this_cache, |
809 | CORE_ADDR func); | |
810 | ||
811 | #define MIPS_NR_LINUX 4000 | |
812 | #define MIPS_NR_N64_LINUX 5000 | |
813 | #define MIPS_NR_N32_LINUX 6000 | |
814 | ||
815 | #define MIPS_NR_sigreturn MIPS_NR_LINUX + 119 | |
816 | #define MIPS_NR_rt_sigreturn MIPS_NR_LINUX + 193 | |
817 | #define MIPS_NR_N64_rt_sigreturn MIPS_NR_N64_LINUX + 211 | |
818 | #define MIPS_NR_N32_rt_sigreturn MIPS_NR_N32_LINUX + 211 | |
819 | ||
820 | #define MIPS_INST_LI_V0_SIGRETURN 0x24020000 + MIPS_NR_sigreturn | |
821 | #define MIPS_INST_LI_V0_RT_SIGRETURN 0x24020000 + MIPS_NR_rt_sigreturn | |
822 | #define MIPS_INST_LI_V0_N64_RT_SIGRETURN 0x24020000 + MIPS_NR_N64_rt_sigreturn | |
823 | #define MIPS_INST_LI_V0_N32_RT_SIGRETURN 0x24020000 + MIPS_NR_N32_rt_sigreturn | |
824 | #define MIPS_INST_SYSCALL 0x0000000c | |
825 | ||
2cd8546d AC |
826 | static const struct tramp_frame mips_linux_o32_sigframe = { |
827 | SIGTRAMP_FRAME, | |
5792a79b | 828 | 4, |
2cd8546d AC |
829 | { |
830 | { MIPS_INST_LI_V0_SIGRETURN, -1 }, | |
831 | { MIPS_INST_SYSCALL, -1 }, | |
832 | { TRAMP_SENTINEL_INSN, -1 } | |
833 | }, | |
5792a79b DJ |
834 | mips_linux_o32_sigframe_init |
835 | }; | |
836 | ||
2cd8546d AC |
837 | static const struct tramp_frame mips_linux_o32_rt_sigframe = { |
838 | SIGTRAMP_FRAME, | |
5792a79b | 839 | 4, |
2cd8546d AC |
840 | { |
841 | { MIPS_INST_LI_V0_RT_SIGRETURN, -1 }, | |
842 | { MIPS_INST_SYSCALL, -1 }, | |
843 | { TRAMP_SENTINEL_INSN, -1 } }, | |
5792a79b DJ |
844 | mips_linux_o32_sigframe_init |
845 | }; | |
846 | ||
2cd8546d AC |
847 | static const struct tramp_frame mips_linux_n32_rt_sigframe = { |
848 | SIGTRAMP_FRAME, | |
5792a79b | 849 | 4, |
2cd8546d AC |
850 | { |
851 | { MIPS_INST_LI_V0_N32_RT_SIGRETURN, -1 }, | |
852 | { MIPS_INST_SYSCALL, -1 }, | |
853 | { TRAMP_SENTINEL_INSN, -1 } | |
854 | }, | |
5792a79b DJ |
855 | mips_linux_n32n64_sigframe_init |
856 | }; | |
857 | ||
2cd8546d AC |
858 | static const struct tramp_frame mips_linux_n64_rt_sigframe = { |
859 | SIGTRAMP_FRAME, | |
5792a79b | 860 | 4, |
fcbd8a5c TS |
861 | { |
862 | { MIPS_INST_LI_V0_N64_RT_SIGRETURN, -1 }, | |
863 | { MIPS_INST_SYSCALL, -1 }, | |
864 | { TRAMP_SENTINEL_INSN, -1 } | |
865 | }, | |
5792a79b DJ |
866 | mips_linux_n32n64_sigframe_init |
867 | }; | |
868 | ||
869 | /* *INDENT-OFF* */ | |
870 | /* The unwinder for o32 signal frames. The legacy structures look | |
871 | like this: | |
872 | ||
873 | struct sigframe { | |
874 | u32 sf_ass[4]; [argument save space for o32] | |
eb195664 | 875 | u32 sf_code[2]; [signal trampoline or fill] |
5792a79b DJ |
876 | struct sigcontext sf_sc; |
877 | sigset_t sf_mask; | |
878 | }; | |
879 | ||
880 | struct sigcontext { | |
881 | unsigned int sc_regmask; [Unused] | |
882 | unsigned int sc_status; | |
883 | unsigned long long sc_pc; | |
884 | unsigned long long sc_regs[32]; | |
885 | unsigned long long sc_fpregs[32]; | |
886 | unsigned int sc_ownedfp; | |
887 | unsigned int sc_fpc_csr; | |
888 | unsigned int sc_fpc_eir; [Unused] | |
889 | unsigned int sc_used_math; | |
890 | unsigned int sc_ssflags; [Unused] | |
891 | [Alignment hole of four bytes] | |
892 | unsigned long long sc_mdhi; | |
893 | unsigned long long sc_mdlo; | |
894 | ||
895 | unsigned int sc_cause; [Unused] | |
896 | unsigned int sc_badvaddr; [Unused] | |
897 | ||
898 | unsigned long sc_sigset[4]; [kernel's sigset_t] | |
899 | }; | |
900 | ||
901 | The RT signal frames look like this: | |
902 | ||
903 | struct rt_sigframe { | |
904 | u32 rs_ass[4]; [argument save space for o32] | |
eb195664 | 905 | u32 rs_code[2] [signal trampoline or fill] |
5792a79b DJ |
906 | struct siginfo rs_info; |
907 | struct ucontext rs_uc; | |
908 | }; | |
909 | ||
910 | struct ucontext { | |
911 | unsigned long uc_flags; | |
912 | struct ucontext *uc_link; | |
913 | stack_t uc_stack; | |
914 | [Alignment hole of four bytes] | |
915 | struct sigcontext uc_mcontext; | |
916 | sigset_t uc_sigmask; | |
917 | }; */ | |
918 | /* *INDENT-ON* */ | |
919 | ||
5792a79b DJ |
920 | #define SIGFRAME_SIGCONTEXT_OFFSET (6 * 4) |
921 | ||
922 | #define RTSIGFRAME_SIGINFO_SIZE 128 | |
923 | #define STACK_T_SIZE (3 * 4) | |
924 | #define UCONTEXT_SIGCONTEXT_OFFSET (2 * 4 + STACK_T_SIZE + 4) | |
925 | #define RTSIGFRAME_SIGCONTEXT_OFFSET (SIGFRAME_SIGCONTEXT_OFFSET \ | |
926 | + RTSIGFRAME_SIGINFO_SIZE \ | |
927 | + UCONTEXT_SIGCONTEXT_OFFSET) | |
928 | ||
929 | #define SIGCONTEXT_PC (1 * 8) | |
930 | #define SIGCONTEXT_REGS (2 * 8) | |
931 | #define SIGCONTEXT_FPREGS (34 * 8) | |
932 | #define SIGCONTEXT_FPCSR (66 * 8 + 4) | |
933 | #define SIGCONTEXT_HI (69 * 8) | |
934 | #define SIGCONTEXT_LO (70 * 8) | |
935 | #define SIGCONTEXT_CAUSE (71 * 8 + 0) | |
936 | #define SIGCONTEXT_BADVADDR (71 * 8 + 4) | |
937 | ||
938 | #define SIGCONTEXT_REG_SIZE 8 | |
939 | ||
940 | static void | |
941 | mips_linux_o32_sigframe_init (const struct tramp_frame *self, | |
b8a22b94 | 942 | struct frame_info *this_frame, |
5792a79b DJ |
943 | struct trad_frame_cache *this_cache, |
944 | CORE_ADDR func) | |
945 | { | |
b8a22b94 | 946 | struct gdbarch *gdbarch = get_frame_arch (this_frame); |
5792a79b | 947 | int ireg, reg_position; |
eb195664 DD |
948 | CORE_ADDR frame_sp = get_frame_sp (this_frame); |
949 | CORE_ADDR sigcontext_base; | |
2eb4d78b | 950 | const struct mips_regnum *regs = mips_regnum (gdbarch); |
37c4d197 | 951 | CORE_ADDR regs_base; |
5792a79b DJ |
952 | |
953 | if (self == &mips_linux_o32_sigframe) | |
eb195664 | 954 | sigcontext_base = frame_sp + SIGFRAME_SIGCONTEXT_OFFSET; |
5792a79b | 955 | else |
eb195664 | 956 | sigcontext_base = frame_sp + RTSIGFRAME_SIGCONTEXT_OFFSET; |
295093a4 MS |
957 | |
958 | /* I'm not proud of this hack. Eventually we will have the | |
959 | infrastructure to indicate the size of saved registers on a | |
960 | per-frame basis, but right now we don't; the kernel saves eight | |
37c4d197 DJ |
961 | bytes but we only want four. Use regs_base to access any |
962 | 64-bit fields. */ | |
2eb4d78b | 963 | if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) |
37c4d197 DJ |
964 | regs_base = sigcontext_base + 4; |
965 | else | |
966 | regs_base = sigcontext_base; | |
5792a79b | 967 | |
2eb4d78b | 968 | if (mips_linux_restart_reg_p (gdbarch)) |
822b6570 DJ |
969 | trad_frame_set_reg_addr (this_cache, |
970 | (MIPS_RESTART_REGNUM | |
2eb4d78b | 971 | + gdbarch_num_regs (gdbarch)), |
822b6570 | 972 | regs_base + SIGCONTEXT_REGS); |
5792a79b DJ |
973 | |
974 | for (ireg = 1; ireg < 32; ireg++) | |
295093a4 | 975 | trad_frame_set_reg_addr (this_cache, |
f57d151a | 976 | ireg + MIPS_ZERO_REGNUM |
2eb4d78b | 977 | + gdbarch_num_regs (gdbarch), |
37c4d197 | 978 | regs_base + SIGCONTEXT_REGS |
5792a79b DJ |
979 | + ireg * SIGCONTEXT_REG_SIZE); |
980 | ||
37c4d197 DJ |
981 | /* The way that floating point registers are saved, unfortunately, |
982 | depends on the architecture the kernel is built for. For the r3000 and | |
983 | tx39, four bytes of each register are at the beginning of each of the | |
984 | 32 eight byte slots. For everything else, the registers are saved | |
985 | using double precision; only the even-numbered slots are initialized, | |
986 | and the high bits are the odd-numbered register. Assume the latter | |
987 | layout, since we can't tell, and it's much more common. Which bits are | |
988 | the "high" bits depends on endianness. */ | |
5792a79b | 989 | for (ireg = 0; ireg < 32; ireg++) |
2eb4d78b | 990 | if ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) != (ireg & 1)) |
f57d151a UW |
991 | trad_frame_set_reg_addr (this_cache, |
992 | ireg + regs->fp0 + | |
2eb4d78b | 993 | gdbarch_num_regs (gdbarch), |
37c4d197 DJ |
994 | sigcontext_base + SIGCONTEXT_FPREGS + 4 |
995 | + (ireg & ~1) * SIGCONTEXT_REG_SIZE); | |
996 | else | |
f57d151a UW |
997 | trad_frame_set_reg_addr (this_cache, |
998 | ireg + regs->fp0 | |
2eb4d78b | 999 | + gdbarch_num_regs (gdbarch), |
37c4d197 DJ |
1000 | sigcontext_base + SIGCONTEXT_FPREGS |
1001 | + (ireg & ~1) * SIGCONTEXT_REG_SIZE); | |
5792a79b | 1002 | |
f57d151a | 1003 | trad_frame_set_reg_addr (this_cache, |
2eb4d78b | 1004 | regs->pc + gdbarch_num_regs (gdbarch), |
37c4d197 | 1005 | regs_base + SIGCONTEXT_PC); |
5792a79b | 1006 | |
295093a4 | 1007 | trad_frame_set_reg_addr (this_cache, |
f57d151a | 1008 | regs->fp_control_status |
2eb4d78b | 1009 | + gdbarch_num_regs (gdbarch), |
5792a79b | 1010 | sigcontext_base + SIGCONTEXT_FPCSR); |
f57d151a | 1011 | trad_frame_set_reg_addr (this_cache, |
2eb4d78b | 1012 | regs->hi + gdbarch_num_regs (gdbarch), |
37c4d197 | 1013 | regs_base + SIGCONTEXT_HI); |
f57d151a | 1014 | trad_frame_set_reg_addr (this_cache, |
2eb4d78b | 1015 | regs->lo + gdbarch_num_regs (gdbarch), |
37c4d197 | 1016 | regs_base + SIGCONTEXT_LO); |
f57d151a | 1017 | trad_frame_set_reg_addr (this_cache, |
2eb4d78b | 1018 | regs->cause + gdbarch_num_regs (gdbarch), |
5792a79b | 1019 | sigcontext_base + SIGCONTEXT_CAUSE); |
f57d151a | 1020 | trad_frame_set_reg_addr (this_cache, |
2eb4d78b | 1021 | regs->badvaddr + gdbarch_num_regs (gdbarch), |
5792a79b DJ |
1022 | sigcontext_base + SIGCONTEXT_BADVADDR); |
1023 | ||
1024 | /* Choice of the bottom of the sigframe is somewhat arbitrary. */ | |
eb195664 | 1025 | trad_frame_set_id (this_cache, frame_id_build (frame_sp, func)); |
5792a79b DJ |
1026 | } |
1027 | ||
1028 | /* *INDENT-OFF* */ | |
1029 | /* For N32/N64 things look different. There is no non-rt signal frame. | |
1030 | ||
1031 | struct rt_sigframe_n32 { | |
1032 | u32 rs_ass[4]; [ argument save space for o32 ] | |
eb195664 | 1033 | u32 rs_code[2]; [ signal trampoline or fill ] |
5792a79b DJ |
1034 | struct siginfo rs_info; |
1035 | struct ucontextn32 rs_uc; | |
1036 | }; | |
1037 | ||
1038 | struct ucontextn32 { | |
1039 | u32 uc_flags; | |
1040 | s32 uc_link; | |
1041 | stack32_t uc_stack; | |
1042 | struct sigcontext uc_mcontext; | |
1043 | sigset_t uc_sigmask; [ mask last for extensibility ] | |
1044 | }; | |
295093a4 | 1045 | |
e741f4d4 | 1046 | struct rt_sigframe { |
5792a79b DJ |
1047 | u32 rs_ass[4]; [ argument save space for o32 ] |
1048 | u32 rs_code[2]; [ signal trampoline ] | |
1049 | struct siginfo rs_info; | |
1050 | struct ucontext rs_uc; | |
1051 | }; | |
1052 | ||
1053 | struct ucontext { | |
1054 | unsigned long uc_flags; | |
1055 | struct ucontext *uc_link; | |
1056 | stack_t uc_stack; | |
1057 | struct sigcontext uc_mcontext; | |
1058 | sigset_t uc_sigmask; [ mask last for extensibility ] | |
1059 | }; | |
1060 | ||
1061 | And the sigcontext is different (this is for both n32 and n64): | |
1062 | ||
1063 | struct sigcontext { | |
1064 | unsigned long long sc_regs[32]; | |
1065 | unsigned long long sc_fpregs[32]; | |
1066 | unsigned long long sc_mdhi; | |
e741f4d4 DJ |
1067 | unsigned long long sc_hi1; |
1068 | unsigned long long sc_hi2; | |
1069 | unsigned long long sc_hi3; | |
5792a79b | 1070 | unsigned long long sc_mdlo; |
e741f4d4 DJ |
1071 | unsigned long long sc_lo1; |
1072 | unsigned long long sc_lo2; | |
1073 | unsigned long long sc_lo3; | |
5792a79b | 1074 | unsigned long long sc_pc; |
5792a79b | 1075 | unsigned int sc_fpc_csr; |
5792a79b | 1076 | unsigned int sc_used_math; |
e741f4d4 DJ |
1077 | unsigned int sc_dsp; |
1078 | unsigned int sc_reserved; | |
1079 | }; | |
1080 | ||
1081 | That is the post-2.6.12 definition of the 64-bit sigcontext; before | |
1082 | then, there were no hi1-hi3 or lo1-lo3. Cause and badvaddr were | |
1083 | included too. */ | |
5792a79b DJ |
1084 | /* *INDENT-ON* */ |
1085 | ||
1086 | #define N32_STACK_T_SIZE STACK_T_SIZE | |
1087 | #define N64_STACK_T_SIZE (2 * 8 + 4) | |
1088 | #define N32_UCONTEXT_SIGCONTEXT_OFFSET (2 * 4 + N32_STACK_T_SIZE + 4) | |
1089 | #define N64_UCONTEXT_SIGCONTEXT_OFFSET (2 * 8 + N64_STACK_T_SIZE + 4) | |
1090 | #define N32_SIGFRAME_SIGCONTEXT_OFFSET (SIGFRAME_SIGCONTEXT_OFFSET \ | |
1091 | + RTSIGFRAME_SIGINFO_SIZE \ | |
1092 | + N32_UCONTEXT_SIGCONTEXT_OFFSET) | |
1093 | #define N64_SIGFRAME_SIGCONTEXT_OFFSET (SIGFRAME_SIGCONTEXT_OFFSET \ | |
1094 | + RTSIGFRAME_SIGINFO_SIZE \ | |
1095 | + N64_UCONTEXT_SIGCONTEXT_OFFSET) | |
1096 | ||
1097 | #define N64_SIGCONTEXT_REGS (0 * 8) | |
1098 | #define N64_SIGCONTEXT_FPREGS (32 * 8) | |
1099 | #define N64_SIGCONTEXT_HI (64 * 8) | |
e741f4d4 DJ |
1100 | #define N64_SIGCONTEXT_LO (68 * 8) |
1101 | #define N64_SIGCONTEXT_PC (72 * 8) | |
1102 | #define N64_SIGCONTEXT_FPCSR (73 * 8) | |
5792a79b DJ |
1103 | |
1104 | #define N64_SIGCONTEXT_REG_SIZE 8 | |
295093a4 | 1105 | |
5792a79b DJ |
1106 | static void |
1107 | mips_linux_n32n64_sigframe_init (const struct tramp_frame *self, | |
b8a22b94 | 1108 | struct frame_info *this_frame, |
5792a79b DJ |
1109 | struct trad_frame_cache *this_cache, |
1110 | CORE_ADDR func) | |
1111 | { | |
b8a22b94 | 1112 | struct gdbarch *gdbarch = get_frame_arch (this_frame); |
5792a79b | 1113 | int ireg, reg_position; |
eb195664 DD |
1114 | CORE_ADDR frame_sp = get_frame_sp (this_frame); |
1115 | CORE_ADDR sigcontext_base; | |
2eb4d78b | 1116 | const struct mips_regnum *regs = mips_regnum (gdbarch); |
5792a79b DJ |
1117 | |
1118 | if (self == &mips_linux_n32_rt_sigframe) | |
eb195664 | 1119 | sigcontext_base = frame_sp + N32_SIGFRAME_SIGCONTEXT_OFFSET; |
5792a79b | 1120 | else |
eb195664 | 1121 | sigcontext_base = frame_sp + N64_SIGFRAME_SIGCONTEXT_OFFSET; |
295093a4 | 1122 | |
2eb4d78b | 1123 | if (mips_linux_restart_reg_p (gdbarch)) |
822b6570 DJ |
1124 | trad_frame_set_reg_addr (this_cache, |
1125 | (MIPS_RESTART_REGNUM | |
2eb4d78b | 1126 | + gdbarch_num_regs (gdbarch)), |
822b6570 | 1127 | sigcontext_base + N64_SIGCONTEXT_REGS); |
5792a79b DJ |
1128 | |
1129 | for (ireg = 1; ireg < 32; ireg++) | |
295093a4 | 1130 | trad_frame_set_reg_addr (this_cache, |
f57d151a | 1131 | ireg + MIPS_ZERO_REGNUM |
2eb4d78b | 1132 | + gdbarch_num_regs (gdbarch), |
5792a79b DJ |
1133 | sigcontext_base + N64_SIGCONTEXT_REGS |
1134 | + ireg * N64_SIGCONTEXT_REG_SIZE); | |
1135 | ||
1136 | for (ireg = 0; ireg < 32; ireg++) | |
f57d151a UW |
1137 | trad_frame_set_reg_addr (this_cache, |
1138 | ireg + regs->fp0 | |
2eb4d78b | 1139 | + gdbarch_num_regs (gdbarch), |
5792a79b DJ |
1140 | sigcontext_base + N64_SIGCONTEXT_FPREGS |
1141 | + ireg * N64_SIGCONTEXT_REG_SIZE); | |
1142 | ||
f57d151a | 1143 | trad_frame_set_reg_addr (this_cache, |
2eb4d78b | 1144 | regs->pc + gdbarch_num_regs (gdbarch), |
5792a79b DJ |
1145 | sigcontext_base + N64_SIGCONTEXT_PC); |
1146 | ||
295093a4 | 1147 | trad_frame_set_reg_addr (this_cache, |
f57d151a | 1148 | regs->fp_control_status |
2eb4d78b | 1149 | + gdbarch_num_regs (gdbarch), |
5792a79b | 1150 | sigcontext_base + N64_SIGCONTEXT_FPCSR); |
f57d151a | 1151 | trad_frame_set_reg_addr (this_cache, |
2eb4d78b | 1152 | regs->hi + gdbarch_num_regs (gdbarch), |
5792a79b | 1153 | sigcontext_base + N64_SIGCONTEXT_HI); |
f57d151a | 1154 | trad_frame_set_reg_addr (this_cache, |
2eb4d78b | 1155 | regs->lo + gdbarch_num_regs (gdbarch), |
5792a79b | 1156 | sigcontext_base + N64_SIGCONTEXT_LO); |
5792a79b DJ |
1157 | |
1158 | /* Choice of the bottom of the sigframe is somewhat arbitrary. */ | |
eb195664 | 1159 | trad_frame_set_id (this_cache, frame_id_build (frame_sp, func)); |
5792a79b DJ |
1160 | } |
1161 | ||
822b6570 | 1162 | static void |
61a1198a | 1163 | mips_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) |
822b6570 | 1164 | { |
2eb4d78b UW |
1165 | struct gdbarch *gdbarch = get_regcache_arch (regcache); |
1166 | regcache_cooked_write_unsigned (regcache, gdbarch_pc_regnum (gdbarch), pc); | |
822b6570 DJ |
1167 | |
1168 | /* Clear the syscall restart flag. */ | |
2eb4d78b | 1169 | if (mips_linux_restart_reg_p (gdbarch)) |
61a1198a | 1170 | regcache_cooked_write_unsigned (regcache, MIPS_RESTART_REGNUM, 0); |
822b6570 DJ |
1171 | } |
1172 | ||
1173 | /* Return 1 if MIPS_RESTART_REGNUM is usable. */ | |
1174 | ||
1175 | int | |
1176 | mips_linux_restart_reg_p (struct gdbarch *gdbarch) | |
1177 | { | |
1178 | /* If we do not have a target description with registers, then | |
1179 | MIPS_RESTART_REGNUM will not be included in the register set. */ | |
1180 | if (!tdesc_has_registers (gdbarch_target_desc (gdbarch))) | |
1181 | return 0; | |
1182 | ||
1183 | /* If we do, then MIPS_RESTART_REGNUM is safe to check; it will | |
1184 | either be GPR-sized or missing. */ | |
1185 | return register_size (gdbarch, MIPS_RESTART_REGNUM) > 0; | |
1186 | } | |
9f62d0e2 | 1187 | |
e38d4e1a DJ |
1188 | /* When FRAME is at a syscall instruction, return the PC of the next |
1189 | instruction to be executed. */ | |
1190 | ||
63807e1d | 1191 | static CORE_ADDR |
e38d4e1a DJ |
1192 | mips_linux_syscall_next_pc (struct frame_info *frame) |
1193 | { | |
1194 | CORE_ADDR pc = get_frame_pc (frame); | |
1195 | ULONGEST v0 = get_frame_register_unsigned (frame, MIPS_V0_REGNUM); | |
1196 | ||
1197 | /* If we are about to make a sigreturn syscall, use the unwinder to | |
1198 | decode the signal frame. */ | |
1199 | if (v0 == MIPS_NR_sigreturn | |
1200 | || v0 == MIPS_NR_rt_sigreturn | |
1201 | || v0 == MIPS_NR_N64_rt_sigreturn | |
1202 | || v0 == MIPS_NR_N32_rt_sigreturn) | |
c7ce8faa | 1203 | return frame_unwind_caller_pc (get_current_frame ()); |
e38d4e1a DJ |
1204 | |
1205 | return pc + 4; | |
1206 | } | |
1207 | ||
5792a79b DJ |
1208 | /* Initialize one of the GNU/Linux OS ABIs. */ |
1209 | ||
19ed69dd | 1210 | static void |
295093a4 MS |
1211 | mips_linux_init_abi (struct gdbarch_info info, |
1212 | struct gdbarch *gdbarch) | |
19ed69dd | 1213 | { |
96f026fc KB |
1214 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
1215 | enum mips_abi abi = mips_abi (gdbarch); | |
822b6570 | 1216 | struct tdesc_arch_data *tdesc_data = (void *) info.tdep_info; |
96f026fc | 1217 | |
a5ee0f0c PA |
1218 | linux_init_abi (info, gdbarch); |
1219 | ||
96f026fc KB |
1220 | switch (abi) |
1221 | { | |
1222 | case MIPS_ABI_O32: | |
1223 | set_gdbarch_get_longjmp_target (gdbarch, | |
1224 | mips_linux_get_longjmp_target); | |
1225 | set_solib_svr4_fetch_link_map_offsets | |
76a9d10f | 1226 | (gdbarch, svr4_ilp32_fetch_link_map_offsets); |
fb2be677 AC |
1227 | tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_sigframe); |
1228 | tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_rt_sigframe); | |
96f026fc KB |
1229 | break; |
1230 | case MIPS_ABI_N32: | |
1231 | set_gdbarch_get_longjmp_target (gdbarch, | |
1232 | mips_linux_get_longjmp_target); | |
1233 | set_solib_svr4_fetch_link_map_offsets | |
76a9d10f | 1234 | (gdbarch, svr4_ilp32_fetch_link_map_offsets); |
d05f6826 DJ |
1235 | set_gdbarch_long_double_bit (gdbarch, 128); |
1236 | /* These floatformats should probably be renamed. MIPS uses | |
1237 | the same 128-bit IEEE floating point format that IA-64 uses, | |
1238 | except that the quiet/signalling NaN bit is reversed (GDB | |
1239 | does not distinguish between quiet and signalling NaNs). */ | |
8da61cc4 | 1240 | set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad); |
fb2be677 | 1241 | tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n32_rt_sigframe); |
96f026fc KB |
1242 | break; |
1243 | case MIPS_ABI_N64: | |
1244 | set_gdbarch_get_longjmp_target (gdbarch, | |
1245 | mips64_linux_get_longjmp_target); | |
1246 | set_solib_svr4_fetch_link_map_offsets | |
76a9d10f | 1247 | (gdbarch, svr4_lp64_fetch_link_map_offsets); |
d05f6826 DJ |
1248 | set_gdbarch_long_double_bit (gdbarch, 128); |
1249 | /* These floatformats should probably be renamed. MIPS uses | |
1250 | the same 128-bit IEEE floating point format that IA-64 uses, | |
1251 | except that the quiet/signalling NaN bit is reversed (GDB | |
1252 | does not distinguish between quiet and signalling NaNs). */ | |
8da61cc4 | 1253 | set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad); |
fb2be677 | 1254 | tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n64_rt_sigframe); |
96f026fc KB |
1255 | break; |
1256 | default: | |
96f026fc KB |
1257 | break; |
1258 | } | |
6de918a6 DJ |
1259 | |
1260 | set_gdbarch_skip_solib_resolver (gdbarch, mips_linux_skip_resolver); | |
1261 | ||
0d0266c6 | 1262 | set_gdbarch_software_single_step (gdbarch, mips_software_single_step); |
b2756930 KB |
1263 | |
1264 | /* Enable TLS support. */ | |
1265 | set_gdbarch_fetch_tls_load_module_address (gdbarch, | |
1266 | svr4_fetch_objfile_link_map); | |
7d522c90 DJ |
1267 | |
1268 | /* Initialize this lazily, to avoid an initialization order | |
1269 | dependency on solib-svr4.c's _initialize routine. */ | |
1270 | if (mips_svr4_so_ops.in_dynsym_resolve_code == NULL) | |
1271 | { | |
1272 | mips_svr4_so_ops = svr4_so_ops; | |
1273 | mips_svr4_so_ops.in_dynsym_resolve_code | |
1274 | = mips_linux_in_dynsym_resolve_code; | |
1275 | } | |
1276 | set_solib_ops (gdbarch, &mips_svr4_so_ops); | |
822b6570 DJ |
1277 | |
1278 | set_gdbarch_write_pc (gdbarch, mips_linux_write_pc); | |
1279 | ||
4eb0ad19 DJ |
1280 | set_gdbarch_core_read_description (gdbarch, |
1281 | mips_linux_core_read_description); | |
1282 | ||
50e8a0d5 HZ |
1283 | set_gdbarch_regset_from_core_section (gdbarch, |
1284 | mips_linux_regset_from_core_section); | |
1285 | ||
e38d4e1a DJ |
1286 | tdep->syscall_next_pc = mips_linux_syscall_next_pc; |
1287 | ||
822b6570 DJ |
1288 | if (tdesc_data) |
1289 | { | |
1290 | const struct tdesc_feature *feature; | |
1291 | ||
1292 | /* If we have target-described registers, then we can safely | |
1293 | reserve a number for MIPS_RESTART_REGNUM (whether it is | |
1294 | described or not). */ | |
1295 | gdb_assert (gdbarch_num_regs (gdbarch) <= MIPS_RESTART_REGNUM); | |
1296 | set_gdbarch_num_regs (gdbarch, MIPS_RESTART_REGNUM + 1); | |
1297 | ||
1298 | /* If it's present, then assign it to the reserved number. */ | |
1299 | feature = tdesc_find_feature (info.target_desc, | |
1300 | "org.gnu.gdb.mips.linux"); | |
1301 | if (feature != NULL) | |
1302 | tdesc_numbered_register (feature, tdesc_data, MIPS_RESTART_REGNUM, | |
1303 | "restart"); | |
1304 | } | |
19ed69dd KB |
1305 | } |
1306 | ||
63807e1d PA |
1307 | /* Provide a prototype to silence -Wmissing-prototypes. */ |
1308 | extern initialize_file_ftype _initialize_mips_linux_tdep; | |
1309 | ||
2aa830e4 | 1310 | void |
d1bacddc | 1311 | _initialize_mips_linux_tdep (void) |
2aa830e4 | 1312 | { |
96f026fc KB |
1313 | const struct bfd_arch_info *arch_info; |
1314 | ||
96f026fc KB |
1315 | for (arch_info = bfd_lookup_arch (bfd_arch_mips, 0); |
1316 | arch_info != NULL; | |
1317 | arch_info = arch_info->next) | |
1318 | { | |
295093a4 MS |
1319 | gdbarch_register_osabi (bfd_arch_mips, arch_info->mach, |
1320 | GDB_OSABI_LINUX, | |
96f026fc KB |
1321 | mips_linux_init_abi); |
1322 | } | |
2aa830e4 | 1323 | } |