gdb/sparc64fbsd-nat.c - gdb

Functions defined

Source code

  1. /* Native-dependent code for FreeBSD/sparc64.

  2.    Copyright (C) 2003-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 "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 (regcache, SPARC_SP_REGNUM, &pcb->pcb_sp);
  35.   regcache_raw_supply (regcache, SPARC64_PC_REGNUM, &pcb->pcb_pc);

  36.   /* Synthesize %npc.  */
  37.   pcb->pcb_pc += 4;
  38.   regcache_raw_supply (regcache, 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. /* Provide a prototype to silence -Wmissing-prototypes.  */
  44. void _initialize_sparc64fbsd_nat (void);

  45. void
  46. _initialize_sparc64fbsd_nat (void)
  47. {
  48.   struct target_ops *t;

  49.   /* Add some extra features to the generic SPARC target.  */
  50.   t = sparc_target ();
  51.   t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
  52.   t->to_find_memory_regions = fbsd_find_memory_regions;
  53.   add_target (t);

  54.   sparc_gregmap = &sparc64fbsd_gregmap;

  55.   /* Support debugging kernel virtual memory images.  */
  56.   bsd_kvm_add_target (sparc64fbsd_kvm_supply_pcb);
  57. }