sparc64-fbsd-nat.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Native-dependent code for FreeBSD/sparc64.
  2. Copyright (C) 2003-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 "fbsd-nat.h"
  18. #include "sparc64-tdep.h"
  19. #include "sparc-nat.h"
  20. /* Support for debugging kernel virtual memory images. */
  21. #include <sys/types.h>
  22. #include <machine/pcb.h>
  23. #include "bsd-kvm.h"
  24. static int
  25. sparc64fbsd_kvm_supply_pcb (struct regcache *regcache, struct pcb *pcb)
  26. {
  27. /* The following is true for FreeBSD 5.4:
  28. The pcb contains %sp and %pc. Since the register windows are
  29. explicitly flushed, we can find the `local' and `in' registers on
  30. the stack. */
  31. /* The stack pointer shouldn't be zero. */
  32. if (pcb->pcb_sp == 0)
  33. return 0;
  34. regcache->raw_supply (SPARC_SP_REGNUM, &pcb->pcb_sp);
  35. regcache->raw_supply (SPARC64_PC_REGNUM, &pcb->pcb_pc);
  36. /* Synthesize %npc. */
  37. pcb->pcb_pc += 4;
  38. regcache->raw_supply (SPARC64_NPC_REGNUM, &pcb->pcb_pc);
  39. /* Read `local' and `in' registers from the stack. */
  40. sparc_supply_rwindow (regcache, pcb->pcb_sp, -1);
  41. return 1;
  42. }
  43. /* Add some extra features to the generic SPARC target. */
  44. static sparc_target<fbsd_nat_target> the_sparc64_fbsd_nat_target;
  45. void _initialize_sparc64fbsd_nat ();
  46. void
  47. _initialize_sparc64fbsd_nat ()
  48. {
  49. add_inf_child_target (&the_sparc64_fbsd_nat_target);
  50. sparc_gregmap = &sparc64fbsd_gregmap;
  51. /* Support debugging kernel virtual memory images. */
  52. bsd_kvm_add_target (sparc64fbsd_kvm_supply_pcb);
  53. }