GDB (xrefs)
Loading...
Searching...
No Matches
sh-netbsd-nat.c
Go to the documentation of this file.
1/* Native-dependent code for NetBSD/sh.
2
3 Copyright (C) 2002-2023 Free Software Foundation, Inc.
4
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
11 the Free Software Foundation; either version 3 of the License, or
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
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22#include "defs.h"
23#include "inferior.h"
24
25#include <sys/types.h>
26#include <sys/ptrace.h>
27#include <machine/reg.h>
28
29#include "sh-tdep.h"
30#include "inf-ptrace.h"
31#include "netbsd-nat.h"
32#include "regcache.h"
33
35{
36 void fetch_registers (struct regcache *, int) override;
37 void store_registers (struct regcache *, int) override;
38};
39
41
42/* Determine if PT_GETREGS fetches this register. */
43#define GETREGS_SUPPLIES(gdbarch, regno) \
44 (((regno) >= R0_REGNUM && (regno) <= (R0_REGNUM + 15)) \
45|| (regno) == gdbarch_pc_regnum (gdbarch) || (regno) == PR_REGNUM \
46|| (regno) == MACH_REGNUM || (regno) == MACL_REGNUM \
47|| (regno) == SR_REGNUM)
48
49/* Sizeof `struct reg' in <machine/reg.h>. */
50#define SHNBSD_SIZEOF_GREGS (21 * 4)
51
52void
54{
55 pid_t pid = regcache->ptid ().pid ();
56 int lwp = regcache->ptid ().lwp ();
57
58 if (regno == -1 || GETREGS_SUPPLIES (regcache->arch (), regno))
59 {
60 struct reg inferior_registers;
61
62 if (ptrace (PT_GETREGS, pid,
63 (PTRACE_TYPE_ARG3) &inferior_registers, lwp) == -1)
64 perror_with_name (_("Couldn't get registers"));
65
67 (char *) &inferior_registers,
69
70 if (regno != -1)
71 return;
72 }
73}
74
75void
77{
78 pid_t pid = regcache->ptid ().pid ();
79 int lwp = regcache->ptid ().lwp ();
80
81 if (regno == -1 || GETREGS_SUPPLIES (regcache->arch (), regno))
82 {
83 struct reg inferior_registers;
84
85 if (ptrace (PT_GETREGS, pid,
86 (PTRACE_TYPE_ARG3) &inferior_registers, lwp) == -1)
87 perror_with_name (_("Couldn't get registers"));
88
90 (char *) &inferior_registers,
92
93 if (ptrace (PT_SETREGS, pid,
94 (PTRACE_TYPE_ARG3) &inferior_registers, lwp) == -1)
95 perror_with_name (_("Couldn't set registers"));
96
97 if (regno != -1)
98 return;
99 }
100}
101
103void
gdbarch * arch() const
Definition regcache.c:231
ptid_t ptid() const
Definition regcache.h:408
#define ptrace(request, pid, addr, data)
Definition gdb_ptrace.h:141
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
Definition gnu-nat.c:1791
void add_inf_child_target(inf_child_target *target)
Definition inf-child.c:418
#define PTRACE_TYPE_ARG3
#define GETREGS_SUPPLIES(gdbarch, regno)
static sh_nbsd_nat_target the_sh_nbsd_nat_target
#define SHNBSD_SIZEOF_GREGS
void _initialize_shnbsd_nat()
void sh_corefile_supply_regset(const struct regset *regset, struct regcache *regcache, int regnum, const void *regs, size_t len)
Definition sh-tdep.c:2106
void sh_corefile_collect_regset(const struct regset *regset, const struct regcache *regcache, int regnum, void *regs, size_t len)
Definition sh-tdep.c:2132
const struct regset sh_corefile_gregset
Definition sh-tdep.c:2155
void store_registers(struct regcache *, int) override
void fetch_registers(struct regcache *, int) override