Commit | Line | Data |
---|---|---|
8b39fe56 MK |
1 | /* Native-dependent code for FreeBSD/sparc64. |
2 | ||
6aba47ca | 3 | Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc. |
8b39fe56 MK |
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 | |
197e01b6 EZ |
19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | Boston, MA 02110-1301, USA. */ | |
8b39fe56 MK |
21 | |
22 | #include "defs.h" | |
37191c9c | 23 | #include "regcache.h" |
936df4b3 | 24 | #include "target.h" |
8b39fe56 | 25 | |
ca5807d9 | 26 | #include "fbsd-nat.h" |
8b39fe56 | 27 | #include "sparc64-tdep.h" |
386c036b | 28 | #include "sparc-nat.h" |
37191c9c MK |
29 | \f |
30 | ||
31 | /* Support for debugging kernel virtual memory images. */ | |
32 | ||
33 | #include <sys/types.h> | |
34 | #include <machine/pcb.h> | |
35 | ||
36 | #include "bsd-kvm.h" | |
37 | ||
38 | static int | |
39 | sparc64fbsd_kvm_supply_pcb (struct regcache *regcache, struct pcb *pcb) | |
40 | { | |
41 | /* The following is true for FreeBSD 5.4: | |
42 | ||
43 | The pcb contains %sp and %pc. Since the register windows are | |
44 | explicitly flushed, we can find the `local' and `in' registers on | |
45 | the stack. */ | |
46 | ||
47 | /* The stack pointer shouldn't be zero. */ | |
48 | if (pcb->pcb_sp == 0) | |
49 | return 0; | |
50 | ||
51 | regcache_raw_supply (regcache, SPARC_SP_REGNUM, &pcb->pcb_sp); | |
52 | regcache_raw_supply (regcache, SPARC64_PC_REGNUM, &pcb->pcb_pc); | |
53 | ||
54 | /* Synthesize %npc. */ | |
55 | pcb->pcb_pc += 4; | |
56 | regcache_raw_supply (regcache, SPARC64_NPC_REGNUM, &pcb->pcb_pc); | |
57 | ||
58 | /* Read `local' and `in' registers from the stack. */ | |
59 | sparc_supply_rwindow (regcache, pcb->pcb_sp, -1); | |
60 | ||
61 | return 1; | |
62 | } | |
63 | \f | |
8b39fe56 MK |
64 | |
65 | /* Provide a prototype to silence -Wmissing-prototypes. */ | |
66 | void _initialize_sparc64fbsd_nat (void); | |
67 | ||
68 | void | |
69 | _initialize_sparc64fbsd_nat (void) | |
70 | { | |
ca5807d9 MK |
71 | struct target_ops *t; |
72 | ||
73 | /* Add some extra features to the generic SPARC target. */ | |
74 | t = sparc_target (); | |
75 | t->to_pid_to_exec_file = fbsd_pid_to_exec_file; | |
76 | t->to_find_memory_regions = fbsd_find_memory_regions; | |
77 | t->to_make_corefile_notes = fbsd_make_corefile_notes; | |
78 | add_target (t); | |
f5ccf7a2 | 79 | |
ca5807d9 | 80 | sparc_gregset = &sparc64fbsd_gregset; |
37191c9c MK |
81 | |
82 | /* Support debugging kernel virtual memory images. */ | |
83 | bsd_kvm_add_target (sparc64fbsd_kvm_supply_pcb); | |
8b39fe56 | 84 | } |