1 /* Native-dependent code for GNU/Linux on MIPS processors.
3 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
4 Free Software Foundation, Inc.
6 This file is part of GDB.
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
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
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.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
24 #include "mips-tdep.h"
26 #include "linux-nat.h"
28 #include "gdb_proc_service.h"
30 #ifndef PTRACE_GET_THREAD_AREA
31 #define PTRACE_GET_THREAD_AREA 25
34 /* Pseudo registers can not be read. ptrace does not provide a way to
35 read (or set) MIPS_PS_REGNUM, and there's no point in reading or
36 setting MIPS_ZERO_REGNUM. We also can not set BADVADDR, CAUSE, or
37 FCRIR via ptrace(). */
40 mips_linux_cannot_fetch_register (int regno
)
42 if (regno
> MIPS_ZERO_REGNUM
&& regno
< MIPS_ZERO_REGNUM
+ 32)
44 else if (regno
>= mips_regnum (current_gdbarch
)->fp0
45 && regno
<= mips_regnum (current_gdbarch
)->fp0
+ 32)
47 else if (regno
== mips_regnum (current_gdbarch
)->lo
48 || regno
== mips_regnum (current_gdbarch
)->hi
49 || regno
== mips_regnum (current_gdbarch
)->badvaddr
50 || regno
== mips_regnum (current_gdbarch
)->cause
51 || regno
== mips_regnum (current_gdbarch
)->pc
52 || regno
== mips_regnum (current_gdbarch
)->fp_control_status
53 || regno
== mips_regnum (current_gdbarch
)->fp_implementation_revision
)
60 mips_linux_cannot_store_register (int regno
)
62 if (regno
> MIPS_ZERO_REGNUM
&& regno
< MIPS_ZERO_REGNUM
+ 32)
64 else if (regno
>= FP0_REGNUM
&& regno
<= FP0_REGNUM
+ 32)
66 else if (regno
== mips_regnum (current_gdbarch
)->lo
67 || regno
== mips_regnum (current_gdbarch
)->hi
68 || regno
== mips_regnum (current_gdbarch
)->pc
69 || regno
== mips_regnum (current_gdbarch
)->fp_control_status
)
75 /* Fetch the thread-local storage pointer for libthread_db. */
78 ps_get_thread_area (const struct ps_prochandle
*ph
,
79 lwpid_t lwpid
, int idx
, void **base
)
81 if (ptrace (PTRACE_GET_THREAD_AREA
, lwpid
, NULL
, base
) != 0)
84 /* IDX is the bias from the thread pointer to the beginning of the
85 thread descriptor. It has to be subtracted due to implementation
86 quirks in libthread_db. */
87 *base
= (void *) ((char *)*base
- idx
);
92 void _initialize_mips_linux_nat (void);
95 _initialize_mips_linux_nat (void)
97 add_target (linux_target ());