1 /* Native-dependent code for FreeBSD.
3 Copyright (C) 2004-2020 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
23 #include "inf-ptrace.h"
24 #include <osreldate.h>
27 /* FreeBSD kernels 11.3 and later report valid si_code values for
28 SIGTRAP on all architectures. Older FreeBSD kernels that supported
29 TRAP_BRKPT did not report valid values for MIPS and sparc64. Even
30 older kernels without TRAP_BRKPT support did not report valid
31 values on any architecture. */
32 #if (__FreeBSD_kernel_version >= 1102502) || (__FreeBSD_version >= 1102502)
33 # define USE_SIGTRAP_SIGINFO
34 #elif defined(TRAP_BRKPT)
35 # if !defined(__mips__) && !defined(__sparc64__)
36 # define USE_SIGTRAP_SIGINFO
40 /* A prototype FreeBSD target. */
42 class fbsd_nat_target
: public inf_ptrace_target
45 char *pid_to_exec_file (int pid
) override
;
47 int find_memory_regions (find_memory_region_ftype func
, void *data
) override
;
49 bool info_proc (const char *, enum info_proc_what
) override
;
51 enum target_xfer_status
xfer_partial (enum target_object object
,
54 const gdb_byte
*writebuf
,
55 ULONGEST offset
, ULONGEST len
,
56 ULONGEST
*xfered_len
) override
;
59 bool thread_alive (ptid_t ptid
) override
;
60 std::string
pid_to_str (ptid_t
) override
;
62 #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME
63 const char *thread_name (struct thread_info
*) override
;
66 void update_thread_list () override
;
68 thread_control_capabilities
get_thread_control_capabilities () override
69 { return tc_schedlock
; }
71 void resume (ptid_t
, int, enum gdb_signal
) override
;
73 ptid_t
wait (ptid_t
, struct target_waitstatus
*, int) override
;
75 void post_startup_inferior (ptid_t
) override
;
76 void post_attach (int) override
;
78 #ifdef USE_SIGTRAP_SIGINFO
79 bool supports_stopped_by_sw_breakpoint () override
;
80 bool stopped_by_sw_breakpoint () override
;
84 bool follow_fork (bool, bool) override
;
86 int insert_fork_catchpoint (int) override
;
87 int remove_fork_catchpoint (int) override
;
89 int insert_vfork_catchpoint (int) override
;
90 int remove_vfork_catchpoint (int) override
;
94 int insert_exec_catchpoint (int) override
;
95 int remove_exec_catchpoint (int) override
;
98 #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE
99 int set_syscall_catchpoint (int, bool, int, gdb::array_view
<const int>)
102 #endif /* PT_LWPINFO */
104 bool supports_multi_process () override
;
107 #endif /* fbsd-nat.h */