| @@ -14,37 +14,49 @@ | | | @@ -14,37 +14,49 @@ |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | | 16 | GNU General Public License for more details. |
17 | | | 17 | |
18 | You should have received a copy of the GNU General Public License | | 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/>. */ | | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
20 | | | 20 | |
21 | #include "defs.h" | | 21 | #include "defs.h" |
22 | #include "gdbcore.h" | | 22 | #include "gdbcore.h" |
23 | #include "regcache.h" | | 23 | #include "regcache.h" |
24 | #include "target.h" | | 24 | #include "target.h" |
25 | | | 25 | |
26 | #include "i386-tdep.h" | | 26 | #include "i386-tdep.h" |
| | | 27 | #include "i387-tdep.h" |
27 | #include "i386bsd-nat.h" | | 28 | #include "i386bsd-nat.h" |
28 | | | 29 | |
29 | /* Support for debugging kernel virtual memory images. */ | | 30 | /* Support for debugging kernel virtual memory images. */ |
30 | | | 31 | |
31 | #include <sys/types.h> | | 32 | #include <sys/types.h> |
| | | 33 | #include <machine/reg.h> |
32 | #include <machine/frame.h> | | 34 | #include <machine/frame.h> |
33 | #include <machine/pcb.h> | | 35 | #include <machine/pcb.h> |
34 | | | 36 | |
35 | #include "nbsd-nat.h" | | 37 | #include "nbsd-nat.h" |
36 | #include "bsd-kvm.h" | | 38 | #include "bsd-kvm.h" |
37 | | | 39 | |
| | | 40 | #ifndef HAVE_GREGSET_T |
| | | 41 | typedef struct reg gregset_t; |
| | | 42 | #endif |
| | | 43 | |
| | | 44 | #ifndef HAVE_FPREGSET_T |
| | | 45 | typedef struct fpreg fpregset_t; |
| | | 46 | #endif |
| | | 47 | |
| | | 48 | #include "gregset.h" |
| | | 49 | |
38 | static int | | 50 | static int |
39 | i386nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) | | 51 | i386nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) |
40 | { | | 52 | { |
41 | struct switchframe sf; | | 53 | struct switchframe sf; |
42 | | | 54 | |
43 | /* The following is true for NetBSD 1.6.2 and after: | | 55 | /* The following is true for NetBSD 1.6.2 and after: |
44 | | | 56 | |
45 | The pcb contains %esp and %ebp at the point of the context switch | | 57 | The pcb contains %esp and %ebp at the point of the context switch |
46 | in cpu_switch()/cpu_switchto(). At that point we have a stack frame as | | 58 | in cpu_switch()/cpu_switchto(). At that point we have a stack frame as |
47 | described by `struct switchframe', which for NetBSD (2.0 and later) has | | 59 | described by `struct switchframe', which for NetBSD (2.0 and later) has |
48 | the following layout: | | 60 | the following layout: |
49 | | | 61 | |
50 | %edi | | 62 | %edi |
| @@ -87,26 +99,65 @@ i386nbsd_supply_pcb (struct regcache *re | | | @@ -87,26 +99,65 @@ i386nbsd_supply_pcb (struct regcache *re |
87 | dumpsys(). Use the frame pointer to recover enough state. */ | | 99 | dumpsys(). Use the frame pointer to recover enough state. */ |
88 | | | 100 | |
89 | read_memory (pcb->pcb_ebp, (gdb_byte *) &fp, sizeof(fp)); | | 101 | read_memory (pcb->pcb_ebp, (gdb_byte *) &fp, sizeof(fp)); |
90 | read_memory (pcb->pcb_ebp + 4, (gdb_byte *) &pc, sizeof(pc)); | | 102 | read_memory (pcb->pcb_ebp + 4, (gdb_byte *) &pc, sizeof(pc)); |
91 | | | 103 | |
92 | regcache_raw_supply (regcache, I386_ESP_REGNUM, &pcb->pcb_ebp); | | 104 | regcache_raw_supply (regcache, I386_ESP_REGNUM, &pcb->pcb_ebp); |
93 | regcache_raw_supply (regcache, I386_EBP_REGNUM, &fp); | | 105 | regcache_raw_supply (regcache, I386_EBP_REGNUM, &fp); |
94 | regcache_raw_supply (regcache, I386_EIP_REGNUM, &pc); | | 106 | regcache_raw_supply (regcache, I386_EIP_REGNUM, &pc); |
95 | } | | 107 | } |
96 | | | 108 | |
97 | return 1; | | 109 | return 1; |
98 | } | | 110 | } |
99 | | | 111 | |
| | | 112 | void |
| | | 113 | supply_gregset (struct regcache *regcache, const gregset_t *gregsetp) |
| | | 114 | { |
| | | 115 | i386bsd_supply_gregset (regcache, gregsetp); |
| | | 116 | } |
| | | 117 | |
| | | 118 | /* Fill register REGNUM (if it is a general-purpose register) in |
| | | 119 | *GREGSETP with the value in GDB's register cache. If REGNUM is -1, |
| | | 120 | do this for all registers. */ |
| | | 121 | |
| | | 122 | void |
| | | 123 | fill_gregset (const struct regcache *regcache, |
| | | 124 | gregset_t *gregsetp, int regnum) |
| | | 125 | { |
| | | 126 | i386bsd_collect_gregset (regcache, gregsetp, regnum); |
| | | 127 | } |
| | | 128 | |
| | | 129 | /* Transfering floating-point registers between GDB, inferiors and cores. */ |
| | | 130 | |
| | | 131 | /* Fill GDB's register cache with the floating-point and SSE register |
| | | 132 | values in *FPREGSETP. */ |
| | | 133 | |
| | | 134 | void |
| | | 135 | supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp) |
| | | 136 | { |
| | | 137 | i387_supply_fsave (regcache, -1, fpregsetp); |
| | | 138 | } |
| | | 139 | |
| | | 140 | /* Fill register REGNUM (if it is a floating-point or SSE register) in |
| | | 141 | *FPREGSETP with the value in GDB's register cache. If REGNUM is |
| | | 142 | -1, do this for all registers. */ |
| | | 143 | |
| | | 144 | void |
| | | 145 | fill_fpregset (const struct regcache *regcache, |
| | | 146 | fpregset_t *fpregsetp, int regnum) |
| | | 147 | { |
| | | 148 | i387_collect_fsave (regcache, regnum, fpregsetp); |
| | | 149 | } |
| | | 150 | |
100 | | | 151 | |
101 | /* Provide a prototype to silence -Wmissing-prototypes. */ | | 152 | /* Provide a prototype to silence -Wmissing-prototypes. */ |
102 | void _initialize_i386nbsd_nat (void); | | 153 | void _initialize_i386nbsd_nat (void); |
103 | | | 154 | |
104 | void | | 155 | void |
105 | _initialize_i386nbsd_nat (void) | | 156 | _initialize_i386nbsd_nat (void) |
106 | { | | 157 | { |
107 | struct target_ops *t; | | 158 | struct target_ops *t; |
108 | | | 159 | |
109 | /* Add some extra features to the common *BSD/i386 target. */ | | 160 | /* Add some extra features to the common *BSD/i386 target. */ |
110 | t = i386bsd_target (); | | 161 | t = i386bsd_target (); |
111 | t->to_pid_to_exec_file = nbsd_pid_to_exec_file; | | 162 | t->to_pid_to_exec_file = nbsd_pid_to_exec_file; |
112 | add_target (t); | | 163 | add_target (t); |