arm-fbsd-nat.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* Native-dependent code for FreeBSD/arm.
  2. Copyright (C) 2017-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 "target.h"
  16. #include <sys/types.h>
  17. #include <sys/ptrace.h>
  18. #include <machine/reg.h>
  19. #include "fbsd-nat.h"
  20. #include "arm-fbsd-tdep.h"
  21. #include "inf-ptrace.h"
  22. struct arm_fbsd_nat_target : public fbsd_nat_target
  23. {
  24. void fetch_registers (struct regcache *, int) override;
  25. void store_registers (struct regcache *, int) override;
  26. const struct target_desc *read_description () override;
  27. };
  28. static arm_fbsd_nat_target the_arm_fbsd_nat_target;
  29. /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
  30. for all registers. */
  31. void
  32. arm_fbsd_nat_target::fetch_registers (struct regcache *regcache, int regnum)
  33. {
  34. fetch_register_set<struct reg> (regcache, regnum, PT_GETREGS,
  35. &arm_fbsd_gregset);
  36. #ifdef PT_GETVFPREGS
  37. fetch_register_set<struct vfpreg> (regcache, regnum, PT_GETVFPREGS,
  38. &arm_fbsd_vfpregset);
  39. #endif
  40. }
  41. /* Store register REGNUM back into the inferior. If REGNUM is -1, do
  42. this for all registers. */
  43. void
  44. arm_fbsd_nat_target::store_registers (struct regcache *regcache, int regnum)
  45. {
  46. store_register_set<struct reg> (regcache, regnum, PT_GETREGS, PT_SETREGS,
  47. &arm_fbsd_gregset);
  48. #ifdef PT_GETVFPREGS
  49. store_register_set<struct vfpreg> (regcache, regnum, PT_GETVFPREGS,
  50. PT_SETVFPREGS, &arm_fbsd_vfpregset);
  51. #endif
  52. }
  53. /* Implement the to_read_description method. */
  54. const struct target_desc *
  55. arm_fbsd_nat_target::read_description ()
  56. {
  57. const struct target_desc *desc;
  58. desc = arm_fbsd_read_description_auxv (this);
  59. if (desc == NULL)
  60. desc = this->beneath ()->read_description ();
  61. return desc;
  62. }
  63. void _initialize_arm_fbsd_nat ();
  64. void
  65. _initialize_arm_fbsd_nat ()
  66. {
  67. add_inf_child_target (&the_arm_fbsd_nat_target);
  68. }