Remove path name from test case
[binutils-gdb.git] / gdb / x86-fbsd-nat.c
1 /* Native-dependent code for FreeBSD x86.
2
3 Copyright (C) 2022-2023 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 #include "defs.h"
21 #include "x86-fbsd-nat.h"
22 #ifdef PT_GETXSTATE_INFO
23 #include "nat/x86-xstate.h"
24 #endif
25
26 /* Implement the virtual fbsd_nat_target::low_new_fork method. */
27
28 void
29 x86_fbsd_nat_target::low_new_fork (ptid_t parent, pid_t child)
30 {
31 struct x86_debug_reg_state *parent_state, *child_state;
32
33 /* If there is no parent state, no watchpoints nor breakpoints have
34 been set, so there is nothing to do. */
35 parent_state = x86_lookup_debug_reg_state (parent.pid ());
36 if (parent_state == nullptr)
37 return;
38
39 /* The kernel clears debug registers in the new child process after
40 fork, but GDB core assumes the child inherits the watchpoints/hw
41 breakpoints of the parent, and will remove them all from the
42 forked off process. Copy the debug registers mirrors into the
43 new process so that all breakpoints and watchpoints can be
44 removed together. */
45
46 child_state = x86_debug_reg_state (child);
47 *child_state = *parent_state;
48 }
49
50 #ifdef PT_GETXSTATE_INFO
51 void
52 x86_fbsd_nat_target::probe_xsave_layout (pid_t pid)
53 {
54 if (m_xsave_probed)
55 return;
56
57 m_xsave_probed = true;
58
59 if (ptrace (PT_GETXSTATE_INFO, pid, (PTRACE_TYPE_ARG3) &m_xsave_info,
60 sizeof (m_xsave_info)) != 0)
61 return;
62 if (m_xsave_info.xsave_len != 0)
63 m_xsave_layout = x86_fetch_xsave_layout (m_xsave_info.xsave_mask,
64 m_xsave_info.xsave_len);
65 }
66 #endif