Commit | Line | Data |
---|---|---|
386c036b MK |
1 | /* Native-dependent code for NetBSD/sparc. |
2 | ||
3 | Copyright 2002, 2003, 2004 Free Software Foundation, Inc. | |
9ce5c36a JT |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | #include "defs.h" | |
a770d4ec | 23 | #include "regcache.h" |
1b9445c2 | 24 | #include "target.h" |
9ce5c36a | 25 | |
c139e7d9 | 26 | #include "sparc-tdep.h" |
386c036b | 27 | #include "sparc-nat.h" |
9ce5c36a | 28 | |
a770d4ec MK |
29 | /* Support for debugging kernel virtual memory images. */ |
30 | ||
31 | #include <sys/types.h> | |
32 | #include <machine/pcb.h> | |
33 | ||
34 | #include "bsd-kvm.h" | |
35 | ||
36 | static int | |
37 | sparc32nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) | |
38 | { | |
39 | /* The following is true for NetBSD 1.6.2: | |
40 | ||
bd921882 | 41 | The pcb contains %sp, %pc, %psr and %wim. From this information |
a770d4ec MK |
42 | we reconstruct the register state as it would look when we just |
43 | returned from cpu_switch(). */ | |
44 | ||
45 | /* The stack pointer shouldn't be zero. */ | |
46 | if (pcb->pcb_sp == 0) | |
47 | return 0; | |
48 | ||
49 | regcache_raw_supply (regcache, SPARC_SP_REGNUM, &pcb->pcb_sp); | |
50 | regcache_raw_supply (regcache, SPARC_O7_REGNUM, &pcb->pcb_pc); | |
51 | regcache_raw_supply (regcache, SPARC32_PSR_REGNUM, &pcb->pcb_psr); | |
52 | regcache_raw_supply (regcache, SPARC32_WIM_REGNUM, &pcb->pcb_wim); | |
53 | regcache_raw_supply (regcache, SPARC32_PC_REGNUM, &pcb->pcb_pc); | |
54 | ||
55 | sparc_supply_rwindow (regcache, pcb->pcb_sp, -1); | |
56 | ||
57 | return 1; | |
58 | } | |
59 | \f | |
60 | ||
386c036b MK |
61 | /* Provide a prototype to silence -Wmissing-prototypes. */ |
62 | void _initialize_sparcnbsd_nat (void); | |
9ce5c36a JT |
63 | |
64 | void | |
386c036b | 65 | _initialize_sparcnbsd_nat (void) |
9ce5c36a | 66 | { |
386c036b | 67 | sparc_gregset = &sparc32nbsd_gregset; |
a770d4ec | 68 | |
1b9445c2 MK |
69 | /* We've got nothing to add to the generic SPARC target. */ |
70 | add_target (sparc_target ()); | |
71 | ||
a770d4ec MK |
72 | /* Support debugging kernel virtual memory images. */ |
73 | bsd_kvm_add_target (sparc32nbsd_supply_pcb); | |
9ce5c36a | 74 | } |