gdb: include gdbsupport/buildargv.h in ser-mingw.c
[binutils-gdb.git] / gdb / fbsd-nat.h
1 /* Native-dependent code for FreeBSD.
2
3 Copyright (C) 2004-2022 Free Software Foundation, Inc.
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
9 the Free Software Foundation; either version 3 of the License, or
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
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #ifndef FBSD_NAT_H
21 #define FBSD_NAT_H
22
23 #include "inf-ptrace.h"
24 #include "regcache.h"
25 #include "regset.h"
26 #include <osreldate.h>
27 #include <sys/proc.h>
28
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)
37 # if !defined(__mips__) && !defined(__sparc64__)
38 # define USE_SIGTRAP_SIGINFO
39 # endif
40 #endif
41
42 /* A prototype FreeBSD target. */
43
44 class fbsd_nat_target : public inf_ptrace_target
45 {
46 public:
47 char *pid_to_exec_file (int pid) override;
48
49 int find_memory_regions (find_memory_region_ftype func, void *data) override;
50
51 bool info_proc (const char *, enum info_proc_what) override;
52
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;
59
60 bool thread_alive (ptid_t ptid) override;
61 std::string pid_to_str (ptid_t) override;
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
69 thread_control_capabilities get_thread_control_capabilities () override
70 { return tc_schedlock; }
71
72 void create_inferior (const char *, const std::string &,
73 char **, int) override;
74
75 void resume (ptid_t, int, enum gdb_signal) override;
76
77 ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
78
79 void post_attach (int) override;
80
81 #ifdef USE_SIGTRAP_SIGINFO
82 bool supports_stopped_by_sw_breakpoint () override;
83 bool stopped_by_sw_breakpoint () override;
84 #endif
85
86 #ifdef TDP_RFPPWAIT
87 void follow_fork (inferior *, ptid_t, target_waitkind, bool, bool) override;
88
89 int insert_fork_catchpoint (int) override;
90 int remove_fork_catchpoint (int) override;
91
92 int insert_vfork_catchpoint (int) override;
93 int remove_vfork_catchpoint (int) override;
94 #endif
95
96 int insert_exec_catchpoint (int) override;
97 int remove_exec_catchpoint (int) override;
98
99 #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE
100 int set_syscall_catchpoint (int, bool, int, gdb::array_view<const int>)
101 override;
102 #endif
103
104 bool supports_multi_process () override;
105
106 bool supports_disable_randomization () override;
107
108 protected:
109
110 void post_startup_inferior (ptid_t) override;
111
112 private:
113 /* Helper routines for use in fetch_registers and store_registers in
114 subclasses. These routines fetch and store a single set of
115 registers described by REGSET. The REGSET's 'regmap' field must
116 point to an array of 'struct regcache_map_entry'.
117
118 FETCH_OP is a ptrace operation to fetch the set of registers from
119 a native thread. STORE_OP is a ptrace operation to store the set
120 of registers to a native thread.
121
122 The caller must provide storage for the set of registers in REGS,
123 and SIZE is the size of the storage. */
124
125 void fetch_register_set (struct regcache *regcache, int regnum, int fetch_op,
126 const struct regset *regset, void *regs, size_t size);
127
128 void store_register_set (struct regcache *regcache, int regnum, int fetch_op,
129 int store_op, const struct regset *regset,
130 void *regs, size_t size);
131 protected:
132 /* Wrapper versions of the above helpers which accept a register set
133 type such as 'struct reg' or 'struct fpreg'. */
134
135 template <class Regset>
136 void fetch_register_set (struct regcache *regcache, int regnum, int fetch_op,
137 const struct regset *regset)
138 {
139 Regset regs;
140 fetch_register_set (regcache, regnum, fetch_op, regset, &regs,
141 sizeof (regs));
142 }
143
144 template <class Regset>
145 void store_register_set (struct regcache *regcache, int regnum, int fetch_op,
146 int store_op, const struct regset *regset)
147 {
148 Regset regs;
149 store_register_set (regcache, regnum, fetch_op, store_op, regset, &regs,
150 sizeof (regs));
151 }
152 };
153
154 #endif /* fbsd-nat.h */