1 /* Native-dependent code for SuperH running NetBSD, for GDB.
3 Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
4 Contributed by Wasabi Systems, 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. */
23 #include <sys/types.h>
24 #include <sys/ptrace.h>
25 #include <machine/reg.h>
32 #include "shnbsd-tdep.h"
33 #include "inf-ptrace.h"
37 /* Determine if PT_GETREGS fetches this register. */
38 #define GETREGS_SUPPLIES(regno) \
39 (((regno) >= R0_REGNUM && (regno) <= (R0_REGNUM + 15)) \
40 || (regno) == PC_REGNUM || (regno) == PR_REGNUM \
41 || (regno) == MACH_REGNUM || (regno) == MACL_REGNUM \
42 || (regno) == SR_REGNUM || (regno) == GBR_REGNUM)
45 fetch_inferior_registers (int regno
)
47 if (regno
== -1 || GETREGS_SUPPLIES (regno
))
49 struct reg inferior_registers
;
51 if (ptrace (PT_GETREGS
, PIDGET (inferior_ptid
),
52 (PTRACE_TYPE_ARG3
) &inferior_registers
, TIDGET (inferior_ptid
)) == -1)
53 perror_with_name (_("Couldn't get registers"));
55 shnbsd_supply_reg (current_regcache
, (char *) &inferior_registers
, regno
);
63 store_inferior_registers (int regno
)
65 if (regno
== -1 || GETREGS_SUPPLIES (regno
))
67 struct reg inferior_registers
;
69 if (ptrace (PT_GETREGS
, PIDGET (inferior_ptid
),
70 (PTRACE_TYPE_ARG3
) &inferior_registers
, TIDGET (inferior_ptid
)) == -1)
71 perror_with_name (_("Couldn't get registers"));
73 shnbsd_fill_reg (current_regcache
, (char *) &inferior_registers
, regno
);
75 if (ptrace (PT_SETREGS
, PIDGET (inferior_ptid
),
76 (PTRACE_TYPE_ARG3
) &inferior_registers
, TIDGET (inferior_ptid
)) == -1)
77 perror_with_name (_("Couldn't set registers"));
84 /* Provide a prototype to silence -Wmissing-prototypes. */
85 void _initialize_shnbsd_nat (void);
88 _initialize_shnbsd_nat (void)
92 t
= inf_ptrace_target ();
93 t
->to_fetch_registers
= fetch_inferior_registers
;
94 t
->to_store_registers
= store_inferior_registers
;
95 t
->to_pid_to_exec_file
= nbsd_pid_to_exec_file
;