sparc-netbsd-nat.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Native-dependent code for NetBSD/sparc.
  2. Copyright (C) 2002-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 "regcache.h"
  16. #include "target.h"
  17. #include "sparc-tdep.h"
  18. #include "sparc-nat.h"
  19. /* Support for debugging kernel virtual memory images. */
  20. #include <sys/types.h>
  21. #include <machine/pcb.h>
  22. #include "bsd-kvm.h"
  23. static int
  24. sparc32nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
  25. {
  26. /* The following is true for NetBSD 1.6.2:
  27. The pcb contains %sp, %pc, %psr and %wim. From this information
  28. we reconstruct the register state as it would look when we just
  29. returned from cpu_switch(). */
  30. /* The stack pointer shouldn't be zero. */
  31. if (pcb->pcb_sp == 0)
  32. return 0;
  33. regcache->raw_supply (SPARC_SP_REGNUM, &pcb->pcb_sp);
  34. regcache->raw_supply (SPARC_O7_REGNUM, &pcb->pcb_pc);
  35. regcache->raw_supply (SPARC32_PSR_REGNUM, &pcb->pcb_psr);
  36. regcache->raw_supply (SPARC32_WIM_REGNUM, &pcb->pcb_wim);
  37. regcache->raw_supply (SPARC32_PC_REGNUM, &pcb->pcb_pc);
  38. sparc_supply_rwindow (regcache, pcb->pcb_sp, -1);
  39. return 1;
  40. }
  41. static sparc_target<inf_ptrace_target> the_sparc_nbsd_nat_target;
  42. void _initialize_sparcnbsd_nat ();
  43. void
  44. _initialize_sparcnbsd_nat ()
  45. {
  46. sparc_gregmap = &sparc32nbsd_gregmap;
  47. sparc_fpregmap = &sparc32_bsd_fpregmap;
  48. add_inf_child_target (&sparc_nbsd_nat_target);
  49. /* Support debugging kernel virtual memory images. */
  50. bsd_kvm_add_target (sparc32nbsd_supply_pcb);
  51. }