GDB (API)
/home/stan/gdb/src/gdb/sparc64fbsd-nat.c
Go to the documentation of this file.
00001 /* Native-dependent code for FreeBSD/sparc64.
00002 
00003    Copyright (C) 2003-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #include "defs.h"
00021 #include "regcache.h"
00022 #include "target.h"
00023 
00024 #include "fbsd-nat.h"
00025 #include "sparc64-tdep.h"
00026 #include "sparc-nat.h"
00027 
00028 
00029 /* Support for debugging kernel virtual memory images.  */
00030 
00031 #include <sys/types.h>
00032 #include <machine/pcb.h>
00033 
00034 #include "bsd-kvm.h"
00035 
00036 static int
00037 sparc64fbsd_kvm_supply_pcb (struct regcache *regcache, struct pcb *pcb)
00038 {
00039   /* The following is true for FreeBSD 5.4:
00040 
00041      The pcb contains %sp and %pc.  Since the register windows are
00042      explicitly flushed, we can find the `local' and `in' registers on
00043      the stack.  */
00044 
00045   /* The stack pointer shouldn't be zero.  */
00046   if (pcb->pcb_sp == 0)
00047     return 0;
00048 
00049   regcache_raw_supply (regcache, SPARC_SP_REGNUM, &pcb->pcb_sp);
00050   regcache_raw_supply (regcache, SPARC64_PC_REGNUM, &pcb->pcb_pc);
00051 
00052   /* Synthesize %npc.  */
00053   pcb->pcb_pc += 4;
00054   regcache_raw_supply (regcache, SPARC64_NPC_REGNUM, &pcb->pcb_pc);
00055 
00056   /* Read `local' and `in' registers from the stack.  */
00057   sparc_supply_rwindow (regcache, pcb->pcb_sp, -1);
00058 
00059   return 1;
00060 }
00061 
00062 
00063 /* Provide a prototype to silence -Wmissing-prototypes.  */
00064 void _initialize_sparc64fbsd_nat (void);
00065 
00066 void
00067 _initialize_sparc64fbsd_nat (void)
00068 {
00069   struct target_ops *t;
00070 
00071   /* Add some extra features to the generic SPARC target.  */
00072   t = sparc_target ();
00073   t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
00074   t->to_find_memory_regions = fbsd_find_memory_regions;
00075   t->to_make_corefile_notes = fbsd_make_corefile_notes;
00076   add_target (t);
00077 
00078   sparc_gregset = &sparc64fbsd_gregset;
00079 
00080   /* Support debugging kernel virtual memory images.  */
00081   bsd_kvm_add_target (sparc64fbsd_kvm_supply_pcb);
00082 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines