x86-fbsd-nat.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* Native-dependent code for FreeBSD x86.
  2. Copyright (C) 2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #include "defs.h"
  15. #include "x86-fbsd-nat.h"
  16. /* Implement the virtual fbsd_nat_target::low_new_fork method. */
  17. void
  18. x86_fbsd_nat_target::low_new_fork (ptid_t parent, pid_t child)
  19. {
  20. struct x86_debug_reg_state *parent_state, *child_state;
  21. /* If there is no parent state, no watchpoints nor breakpoints have
  22. been set, so there is nothing to do. */
  23. parent_state = x86_lookup_debug_reg_state (parent.pid ());
  24. if (parent_state == nullptr)
  25. return;
  26. /* The kernel clears debug registers in the new child process after
  27. fork, but GDB core assumes the child inherits the watchpoints/hw
  28. breakpoints of the parent, and will remove them all from the
  29. forked off process. Copy the debug registers mirrors into the
  30. new process so that all breakpoints and watchpoints can be
  31. removed together. */
  32. child_state = x86_debug_reg_state (child);
  33. *child_state = *parent_state;
  34. }