]> Git Repo - binutils.git/blame - gdb/fbsd-nat.h
Automatic date update in version.in
[binutils.git] / gdb / fbsd-nat.h
CommitLineData
578c1c03
MK
1/* Native-dependent code for FreeBSD.
2
4a94e368 3 Copyright (C) 2004-2022 Free Software Foundation, Inc.
578c1c03
MK
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
578c1c03
MK
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
578c1c03
MK
19
20#ifndef FBSD_NAT_H
21#define FBSD_NAT_H
22
d55e5aa6 23#include "inf-ptrace.h"
5a680bf9
JB
24#include "regcache.h"
25#include "regset.h"
ddce1758 26#include <osreldate.h>
4de283e4 27#include <sys/proc.h>
d55e5aa6 28
ddce1758
JB
29/* FreeBSD kernels 11.3 and later report valid si_code values for
30 SIGTRAP on all architectures. Older FreeBSD kernels that supported
31 TRAP_BRKPT did not report valid values for MIPS and sparc64. Even
32 older kernels without TRAP_BRKPT support did not report valid
33 values on any architecture. */
34#if (__FreeBSD_kernel_version >= 1102502) || (__FreeBSD_version >= 1102502)
35# define USE_SIGTRAP_SIGINFO
36#elif defined(TRAP_BRKPT)
f6ac5f3d
PA
37# if !defined(__mips__) && !defined(__sparc64__)
38# define USE_SIGTRAP_SIGINFO
39# endif
40#endif
41
42/* A prototype FreeBSD target. */
43
44class fbsd_nat_target : public inf_ptrace_target
45{
46public:
0e90c441 47 const char *pid_to_exec_file (int pid) override;
f6ac5f3d 48
bd583225 49 int find_memory_regions (find_memory_region_ftype func, void *data) override;
f6ac5f3d 50
bd583225 51 bool info_proc (const char *, enum info_proc_what) override;
f6ac5f3d 52
f6ac5f3d
PA
53 enum target_xfer_status xfer_partial (enum target_object object,
54 const char *annex,
55 gdb_byte *readbuf,
56 const gdb_byte *writebuf,
57 ULONGEST offset, ULONGEST len,
58 ULONGEST *xfered_len) override;
f6ac5f3d 59
57810aa7 60 bool thread_alive (ptid_t ptid) override;
a068643d 61 std::string pid_to_str (ptid_t) override;
f6ac5f3d
PA
62
63#ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME
64 const char *thread_name (struct thread_info *) override;
65#endif
66
67 void update_thread_list () override;
68
9385df2a 69 bool can_async_p () override;
9385df2a 70
4a570176 71 void async (bool) override;
9385df2a 72
f6ac5f3d
PA
73 thread_control_capabilities get_thread_control_capabilities () override
74 { return tc_schedlock; }
75
09db4332
JB
76 void create_inferior (const char *, const std::string &,
77 char **, int) override;
78
f6ac5f3d
PA
79 void resume (ptid_t, int, enum gdb_signal) override;
80
b60cea74 81 ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
f6ac5f3d 82
f6ac5f3d
PA
83 void post_attach (int) override;
84
85#ifdef USE_SIGTRAP_SIGINFO
57810aa7
PA
86 bool supports_stopped_by_sw_breakpoint () override;
87 bool stopped_by_sw_breakpoint () override;
f6ac5f3d
PA
88#endif
89
90#ifdef TDP_RFPPWAIT
82d1f134 91 void follow_fork (inferior *, ptid_t, target_waitkind, bool, bool) override;
f6ac5f3d
PA
92
93 int insert_fork_catchpoint (int) override;
94 int remove_fork_catchpoint (int) override;
95
96 int insert_vfork_catchpoint (int) override;
97 int remove_vfork_catchpoint (int) override;
98#endif
99
f6ac5f3d
PA
100 int insert_exec_catchpoint (int) override;
101 int remove_exec_catchpoint (int) override;
f6ac5f3d
PA
102
103#ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE
104 int set_syscall_catchpoint (int, bool, int, gdb::array_view<const int>)
105 override;
106#endif
54904d81
JB
107
108 bool supports_multi_process () override;
09db4332
JB
109
110 bool supports_disable_randomization () override;
5a680bf9 111
c77282d8
JB
112 /* Methods meant to be overridden by arch-specific target
113 classes. */
114
115 virtual void low_new_fork (ptid_t parent, pid_t child)
116 {}
117
983b1119
JB
118 /* The method to call, if any, when a thread is destroyed. */
119 virtual void low_delete_thread (thread_info *)
120 {}
121
a3627b54
JB
122 /* Hook to call prior to resuming a thread. */
123 virtual void low_prepare_to_resume (thread_info *)
124 {}
125
200fd287
AB
126protected:
127
128 void post_startup_inferior (ptid_t) override;
129
5a680bf9 130private:
9385df2a
JB
131 ptid_t wait_1 (ptid_t, struct target_waitstatus *, target_wait_flags);
132
5a680bf9
JB
133 /* Helper routines for use in fetch_registers and store_registers in
134 subclasses. These routines fetch and store a single set of
135 registers described by REGSET. The REGSET's 'regmap' field must
a141d32c
JB
136 point to an array of 'struct regcache_map_entry'. The valid
137 register numbers in the register map are relative to REGBASE.
5a680bf9
JB
138
139 FETCH_OP is a ptrace operation to fetch the set of registers from
140 a native thread. STORE_OP is a ptrace operation to store the set
141 of registers to a native thread.
142
143 The caller must provide storage for the set of registers in REGS,
b95a31ed 144 and SIZE is the size of the storage.
5a680bf9 145
b95a31ed 146 Returns true if the register set was transferred due to a
a141d32c 147 matching REGNUM. */
b95a31ed
JB
148
149 bool fetch_register_set (struct regcache *regcache, int regnum, int fetch_op,
a141d32c
JB
150 const struct regset *regset, int regbase, void *regs,
151 size_t size);
5a680bf9 152
b95a31ed 153 bool store_register_set (struct regcache *regcache, int regnum, int fetch_op,
5a680bf9 154 int store_op, const struct regset *regset,
a141d32c 155 int regbase, void *regs, size_t size);
40c23d88
JB
156
157 /* Helper routines which use PT_GETREGSET and PT_SETREGSET for the
158 specified NOTE instead of regset-specific fetch and store
159 ops. */
160
161 bool fetch_regset (struct regcache *regcache, int regnum, int note,
a141d32c
JB
162 const struct regset *regset, int regbase, void *regs,
163 size_t size);
40c23d88
JB
164
165 bool store_regset (struct regcache *regcache, int regnum, int note,
a141d32c
JB
166 const struct regset *regset, int regbase, void *regs,
167 size_t size);
40c23d88 168
5a680bf9
JB
169protected:
170 /* Wrapper versions of the above helpers which accept a register set
171 type such as 'struct reg' or 'struct fpreg'. */
172
173 template <class Regset>
b95a31ed 174 bool fetch_register_set (struct regcache *regcache, int regnum, int fetch_op,
a141d32c 175 const struct regset *regset, int regbase = 0)
5a680bf9
JB
176 {
177 Regset regs;
a141d32c
JB
178 return fetch_register_set (regcache, regnum, fetch_op, regset, regbase,
179 &regs, sizeof (regs));
5a680bf9
JB
180 }
181
182 template <class Regset>
b95a31ed 183 bool store_register_set (struct regcache *regcache, int regnum, int fetch_op,
a141d32c
JB
184 int store_op, const struct regset *regset,
185 int regbase = 0)
5a680bf9
JB
186 {
187 Regset regs;
b95a31ed 188 return store_register_set (regcache, regnum, fetch_op, store_op, regset,
a141d32c 189 regbase, &regs, sizeof (regs));
5a680bf9 190 }
40c23d88
JB
191
192 /* Helper routine for use in read_description in subclasses. This
193 routine checks if the register set for the specified NOTE is
194 present for a given PTID. If the register set is present, the
195 the size of the register set is returned. If the register set is
196 not present, zero is returned. */
197
13db4a0c 198 size_t have_regset (ptid_t ptid, int note);
40c23d88
JB
199
200 /* Wrapper versions of the PT_GETREGSET and PT_REGSET helpers which
201 accept a register set type. */
202
203 template <class Regset>
204 bool fetch_regset (struct regcache *regcache, int regnum, int note,
a141d32c 205 const struct regset *regset, int regbase = 0)
40c23d88
JB
206 {
207 Regset regs;
a141d32c
JB
208 return fetch_regset (regcache, regnum, note, regset, regbase, &regs,
209 sizeof (regs));
40c23d88
JB
210 }
211
212 template <class Regset>
213 bool store_regset (struct regcache *regcache, int regnum, int note,
a141d32c 214 const struct regset *regset, int regbase = 0)
40c23d88
JB
215 {
216 Regset regs;
a141d32c
JB
217 return store_regset (regcache, regnum, note, regset, regbase, &regs,
218 sizeof (regs));
40c23d88 219 }
f6ac5f3d 220};
578c1c03 221
6719bc69
JB
222/* Fetch the signal information for PTID and store it in *SIGINFO.
223 Return true if successful. */
224bool fbsd_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo);
225
578c1c03 226#endif /* fbsd-nat.h */
This page took 2.864384 seconds and 5 git commands to generate.