* i386-linux-tdep.c (I386_LINUX_RECORD_SIZE_*,
[deliverable/binutils-gdb.git] / gdb / shnbsd-nat.c
CommitLineData
bd372731
MK
1/* Native-dependent code for NetBSD/sh.
2
0fb0cc75 3 Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009
9b254dd1 4 Free Software Foundation, Inc.
9f8e0089 5
13a38d45
JT
6 Contributed by Wasabi Systems, Inc.
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
a9762ec7 12 the Free Software Foundation; either version 3 of the License, or
13a38d45
JT
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
a9762ec7 21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
13a38d45 22
bd372731
MK
23#include "defs.h"
24#include "inferior.h"
25
13a38d45
JT
26#include <sys/types.h>
27#include <sys/ptrace.h>
28#include <machine/reg.h>
29
97a5b208 30#include "sh-tdep.h"
4015edd1 31#include "shnbsd-tdep.h"
bd372731 32#include "inf-ptrace.h"
4e3269e3
UW
33#include "regcache.h"
34
13a38d45
JT
35
36/* Determine if PT_GETREGS fetches this register. */
40a6adc1 37#define GETREGS_SUPPLIES(gdbarch, regno) \
13a38d45 38 (((regno) >= R0_REGNUM && (regno) <= (R0_REGNUM + 15)) \
40a6adc1 39|| (regno) == gdbarch_pc_regnum (gdbarch) || (regno) == PR_REGNUM \
13a38d45
JT
40|| (regno) == MACH_REGNUM || (regno) == MACL_REGNUM \
41|| (regno) == SR_REGNUM)
42
bd372731 43static void
28439f5e
PA
44shnbsd_fetch_inferior_registers (struct target_ops *ops,
45 struct regcache *regcache, int regno)
13a38d45 46{
40a6adc1 47 if (regno == -1 || GETREGS_SUPPLIES (get_regcache_arch (regcache), regno))
13a38d45
JT
48 {
49 struct reg inferior_registers;
50
51 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
dfeafa2f 52 (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
e2e0b3e5 53 perror_with_name (_("Couldn't get registers"));
13a38d45 54
56be3814 55 shnbsd_supply_reg (regcache, (char *) &inferior_registers, regno);
13a38d45
JT
56
57 if (regno != -1)
58 return;
59 }
60}
61
bd372731 62static void
28439f5e
PA
63shnbsd_store_inferior_registers (struct target_ops *ops,
64 struct regcache *regcache, int regno)
13a38d45 65{
40a6adc1 66 if (regno == -1 || GETREGS_SUPPLIES (get_regcache_arch (regcache), regno))
13a38d45
JT
67 {
68 struct reg inferior_registers;
69
70 if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
dfeafa2f 71 (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
e2e0b3e5 72 perror_with_name (_("Couldn't get registers"));
13a38d45 73
56be3814 74 shnbsd_fill_reg (regcache, (char *) &inferior_registers, regno);
13a38d45
JT
75
76 if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
dfeafa2f 77 (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
e2e0b3e5 78 perror_with_name (_("Couldn't set registers"));
13a38d45
JT
79
80 if (regno != -1)
81 return;
82 }
83}
bd372731
MK
84
85/* Provide a prototype to silence -Wmissing-prototypes. */
86void _initialize_shnbsd_nat (void);
87
88void
89_initialize_shnbsd_nat (void)
90{
91 struct target_ops *t;
92
93 t = inf_ptrace_target ();
94 t->to_fetch_registers = shnbsd_fetch_inferior_registers;
95 t->to_store_registers = shnbsd_store_inferior_registers;
96 add_target (t);
97}
This page took 0.667593 seconds and 4 git commands to generate.