gdb/sparcnbsd-nat.c - gdb

Functions defined

Source code

  1. /* Native-dependent code for NetBSD/sparc.

  2.    Copyright (C) 2002-2015 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 (regcache, SPARC_SP_REGNUM, &pcb->pcb_sp);
  34.   regcache_raw_supply (regcache, SPARC_O7_REGNUM, &pcb->pcb_pc);
  35.   regcache_raw_supply (regcache, SPARC32_PSR_REGNUM, &pcb->pcb_psr);
  36.   regcache_raw_supply (regcache, SPARC32_WIM_REGNUM, &pcb->pcb_wim);
  37.   regcache_raw_supply (regcache, SPARC32_PC_REGNUM, &pcb->pcb_pc);

  38.   sparc_supply_rwindow (regcache, pcb->pcb_sp, -1);

  39.   return 1;
  40. }


  41. /* Provide a prototype to silence -Wmissing-prototypes.  */
  42. void _initialize_sparcnbsd_nat (void);

  43. void
  44. _initialize_sparcnbsd_nat (void)
  45. {
  46.   sparc_gregmap = &sparc32nbsd_gregmap;
  47.   sparc_fpregmap = &sparc32_bsd_fpregmap;

  48.   /* We've got nothing to add to the generic SPARC target.  */
  49.   add_target (sparc_target ());

  50.   /* Support debugging kernel virtual memory images.  */
  51.   bsd_kvm_add_target (sparc32nbsd_supply_pcb);
  52. }