1 /* Native-dependent code for NetBSD/sh.
3 Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
5 Contributed by Wasabi Systems, Inc.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. */
27 #include <sys/types.h>
28 #include <sys/ptrace.h>
29 #include <machine/reg.h>
32 #include "shnbsd-tdep.h"
33 #include "inf-ptrace.h"
35 /* Determine if PT_GETREGS fetches this register. */
36 #define GETREGS_SUPPLIES(regno) \
37 (((regno) >= R0_REGNUM && (regno) <= (R0_REGNUM + 15)) \
38 || (regno) == PC_REGNUM || (regno) == PR_REGNUM \
39 || (regno) == MACH_REGNUM || (regno) == MACL_REGNUM \
40 || (regno) == SR_REGNUM)
43 shnbsd_fetch_inferior_registers (int regno
)
45 if (regno
== -1 || GETREGS_SUPPLIES (regno
))
47 struct reg inferior_registers
;
49 if (ptrace (PT_GETREGS
, PIDGET (inferior_ptid
),
50 (PTRACE_TYPE_ARG3
) &inferior_registers
, 0) == -1)
51 perror_with_name (_("Couldn't get registers"));
53 shnbsd_supply_reg ((char *) &inferior_registers
, regno
);
61 shnbsd_store_inferior_registers (int regno
)
63 if (regno
== -1 || GETREGS_SUPPLIES (regno
))
65 struct reg inferior_registers
;
67 if (ptrace (PT_GETREGS
, PIDGET (inferior_ptid
),
68 (PTRACE_TYPE_ARG3
) &inferior_registers
, 0) == -1)
69 perror_with_name (_("Couldn't get registers"));
71 shnbsd_fill_reg ((char *) &inferior_registers
, regno
);
73 if (ptrace (PT_SETREGS
, PIDGET (inferior_ptid
),
74 (PTRACE_TYPE_ARG3
) &inferior_registers
, 0) == -1)
75 perror_with_name (_("Couldn't set registers"));
82 /* Provide a prototype to silence -Wmissing-prototypes. */
83 void _initialize_shnbsd_nat (void);
86 _initialize_shnbsd_nat (void)
90 t
= inf_ptrace_target ();
91 t
->to_fetch_registers
= shnbsd_fetch_inferior_registers
;
92 t
->to_store_registers
= shnbsd_store_inferior_registers
;