]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/sh-nbsd-nat.c
Remove "cmd_type" function
[thirdparty/binutils-gdb.git] / gdb / sh-nbsd-nat.c
CommitLineData
bd372731
MK
1/* Native-dependent code for NetBSD/sh.
2
b811d2c2 3 Copyright (C) 2002-2020 Free Software Foundation, Inc.
9f8e0089 4
13a38d45
JT
5 Contributed by Wasabi Systems, Inc.
6
7 This file is part of GDB.
8
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
a9762ec7 11 the Free Software Foundation; either version 3 of the License, or
13a38d45
JT
12 (at your option) any later version.
13
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.
18
19 You should have received a copy of the GNU General Public License
a9762ec7 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
13a38d45 21
bd372731
MK
22#include "defs.h"
23#include "inferior.h"
24
13a38d45
JT
25#include <sys/types.h>
26#include <sys/ptrace.h>
27#include <machine/reg.h>
28
97a5b208 29#include "sh-tdep.h"
bd372731 30#include "inf-ptrace.h"
98097623 31#include "nbsd-nat.h"
4e3269e3
UW
32#include "regcache.h"
33
98097623 34struct sh_nbsd_nat_target final : public nbsd_nat_target
f6ac5f3d
PA
35{
36 void fetch_registers (struct regcache *, int) override;
37 void store_registers (struct regcache *, int) override;
38};
39
40static sh_nbsd_nat_target the_sh_nbsd_nat_target;
13a38d45 41
c378eb4e 42/* Determine if PT_GETREGS fetches this register. */
40a6adc1 43#define GETREGS_SUPPLIES(gdbarch, regno) \
13a38d45 44 (((regno) >= R0_REGNUM && (regno) <= (R0_REGNUM + 15)) \
40a6adc1 45|| (regno) == gdbarch_pc_regnum (gdbarch) || (regno) == PR_REGNUM \
13a38d45
JT
46|| (regno) == MACH_REGNUM || (regno) == MACL_REGNUM \
47|| (regno) == SR_REGNUM)
48
c9ac0a72
AS
49/* Sizeof `struct reg' in <machine/reg.h>. */
50#define SHNBSD_SIZEOF_GREGS (21 * 4)
51
f6ac5f3d
PA
52void
53sh_nbsd_nat_target::fetch_registers (struct regcache *regcache, int regno)
13a38d45 54{
e99b03dc 55 pid_t pid = regcache->ptid ().pid ();
a225c9a8 56 int lwp = regcache->ptid ().lwp ();
bcc0c096 57
ac7936df 58 if (regno == -1 || GETREGS_SUPPLIES (regcache->arch (), regno))
13a38d45
JT
59 {
60 struct reg inferior_registers;
61
bcc0c096 62 if (ptrace (PT_GETREGS, pid,
a225c9a8 63 (PTRACE_TYPE_ARG3) &inferior_registers, lwp) == -1)
e2e0b3e5 64 perror_with_name (_("Couldn't get registers"));
13a38d45 65
c9ac0a72
AS
66 sh_corefile_supply_regset (&sh_corefile_gregset, regcache, regno,
67 (char *) &inferior_registers,
68 SHNBSD_SIZEOF_GREGS);
13a38d45
JT
69
70 if (regno != -1)
71 return;
72 }
73}
74
f6ac5f3d
PA
75void
76sh_nbsd_nat_target::store_registers (struct regcache *regcache, int regno)
13a38d45 77{
e99b03dc 78 pid_t pid = regcache->ptid ().pid ();
a225c9a8 79 int lwp = regcache->ptid ().lwp ();
bcc0c096 80
ac7936df 81 if (regno == -1 || GETREGS_SUPPLIES (regcache->arch (), regno))
13a38d45
JT
82 {
83 struct reg inferior_registers;
84
bcc0c096 85 if (ptrace (PT_GETREGS, pid,
a225c9a8 86 (PTRACE_TYPE_ARG3) &inferior_registers, lwp) == -1)
e2e0b3e5 87 perror_with_name (_("Couldn't get registers"));
13a38d45 88
c9ac0a72
AS
89 sh_corefile_collect_regset (&sh_corefile_gregset, regcache, regno,
90 (char *) &inferior_registers,
91 SHNBSD_SIZEOF_GREGS);
13a38d45 92
bcc0c096 93 if (ptrace (PT_SETREGS, pid,
a225c9a8 94 (PTRACE_TYPE_ARG3) &inferior_registers, lwp) == -1)
e2e0b3e5 95 perror_with_name (_("Couldn't set registers"));
13a38d45
JT
96
97 if (regno != -1)
98 return;
99 }
100}
bd372731 101
6c265988 102void _initialize_shnbsd_nat ();
bd372731 103void
6c265988 104_initialize_shnbsd_nat ()
bd372731 105{
d9f719f1 106 add_inf_child_target (&the_sh_nbsd_nat_target);
bd372731 107}