Commit | Line | Data |
---|---|---|
13a38d45 | 1 | /* Native-dependent code for SuperH running NetBSD, for GDB. |
9f8e0089 MK |
2 | |
3 | Copyright 2002, 2003, 2004 Free Software Foundation, Inc. | |
13a38d45 JT |
4 | Contributed by Wasabi Systems, Inc. |
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 | |
10 | the Free Software Foundation; either version 2 of the License, or | |
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 | |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 59 Temple Place - Suite 330, | |
21 | Boston, MA 02111-1307, USA. */ | |
22 | ||
23 | #include <sys/types.h> | |
24 | #include <sys/ptrace.h> | |
25 | #include <machine/reg.h> | |
26 | ||
27 | #include "defs.h" | |
28 | #include "inferior.h" | |
29 | ||
97a5b208 | 30 | #include "sh-tdep.h" |
4015edd1 | 31 | #include "shnbsd-tdep.h" |
13a38d45 JT |
32 | |
33 | /* Determine if PT_GETREGS fetches this register. */ | |
34 | #define GETREGS_SUPPLIES(regno) \ | |
35 | (((regno) >= R0_REGNUM && (regno) <= (R0_REGNUM + 15)) \ | |
36 | || (regno) == PC_REGNUM || (regno) == PR_REGNUM \ | |
37 | || (regno) == MACH_REGNUM || (regno) == MACL_REGNUM \ | |
38 | || (regno) == SR_REGNUM) | |
39 | ||
40 | void | |
41 | fetch_inferior_registers (int regno) | |
42 | { | |
43 | if (regno == -1 || GETREGS_SUPPLIES (regno)) | |
44 | { | |
45 | struct reg inferior_registers; | |
46 | ||
47 | if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), | |
dfeafa2f | 48 | (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1) |
e2e0b3e5 | 49 | perror_with_name (_("Couldn't get registers")); |
13a38d45 | 50 | |
20cb8cda | 51 | shnbsd_supply_reg ((char *) &inferior_registers, regno); |
13a38d45 JT |
52 | |
53 | if (regno != -1) | |
54 | return; | |
55 | } | |
56 | } | |
57 | ||
58 | void | |
59 | store_inferior_registers (int regno) | |
60 | { | |
61 | if (regno == -1 || GETREGS_SUPPLIES (regno)) | |
62 | { | |
63 | struct reg inferior_registers; | |
64 | ||
65 | if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), | |
dfeafa2f | 66 | (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1) |
e2e0b3e5 | 67 | perror_with_name (_("Couldn't get registers")); |
13a38d45 | 68 | |
20cb8cda | 69 | shnbsd_fill_reg ((char *) &inferior_registers, regno); |
13a38d45 JT |
70 | |
71 | if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), | |
dfeafa2f | 72 | (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1) |
e2e0b3e5 | 73 | perror_with_name (_("Couldn't set registers")); |
13a38d45 JT |
74 | |
75 | if (regno != -1) | |
76 | return; | |
77 | } | |
78 | } |