* regcache.h (struct thread_info): Forward declare.
[binutils-gdb.git] / gdb / sparcnbsd-nat.c
blob1be331fba3a5f9ccf31b58f36dc15080830f1645
1 /* Native-dependent code for NetBSD/sparc.
3 Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "defs.h"
22 #include "regcache.h"
23 #include "target.h"
25 #include "sparc-tdep.h"
26 #include "sparc-nat.h"
28 /* Support for debugging kernel virtual memory images. */
30 #include <sys/types.h>
31 #include <machine/pcb.h>
33 #include "bsd-kvm.h"
35 static int
36 sparc32nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
38 /* The following is true for NetBSD 1.6.2:
40 The pcb contains %sp, %pc, %psr and %wim. From this information
41 we reconstruct the register state as it would look when we just
42 returned from cpu_switch(). */
44 /* The stack pointer shouldn't be zero. */
45 if (pcb->pcb_sp == 0)
46 return 0;
48 regcache_raw_supply (regcache, SPARC_SP_REGNUM, &pcb->pcb_sp);
49 regcache_raw_supply (regcache, SPARC_O7_REGNUM, &pcb->pcb_pc);
50 regcache_raw_supply (regcache, SPARC32_PSR_REGNUM, &pcb->pcb_psr);
51 regcache_raw_supply (regcache, SPARC32_WIM_REGNUM, &pcb->pcb_wim);
52 regcache_raw_supply (regcache, SPARC32_PC_REGNUM, &pcb->pcb_pc);
54 sparc_supply_rwindow (regcache, pcb->pcb_sp, -1);
56 return 1;
60 /* Provide a prototype to silence -Wmissing-prototypes. */
61 void _initialize_sparcnbsd_nat (void);
63 void
64 _initialize_sparcnbsd_nat (void)
66 sparc_gregset = &sparc32nbsd_gregset;
68 /* We've got nothing to add to the generic SPARC target. */
69 add_target (sparc_target ());
71 /* Support debugging kernel virtual memory images. */
72 bsd_kvm_add_target (sparc32nbsd_supply_pcb);