| @@ -1,146 +1,148 @@ | | | @@ -1,146 +1,148 @@ |
1 | /* Native-dependent code for modern VAX BSD's. | | 1 | /* Native-dependent code for modern VAX BSD's. |
2 | | | 2 | |
3 | Copyright (C) 2004-2017 Free Software Foundation, Inc. | | 3 | Copyright (C) 2004-2017 Free Software Foundation, Inc. |
4 | | | 4 | |
5 | This file is part of GDB. | | 5 | This file is part of GDB. |
6 | | | 6 | |
7 | This program is free software; you can redistribute it and/or modify | | 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 | | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 3 of the License, or | | 9 | the Free Software Foundation; either version 3 of the License, or |
10 | (at your option) any later version. | | 10 | (at your option) any later version. |
11 | | | 11 | |
12 | This program is distributed in the hope that it will be useful, | | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. | | 15 | GNU General Public License for more details. |
16 | | | 16 | |
17 | You should have received a copy of the GNU General Public License | | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
19 | | | 19 | |
| | | 20 | #ifndef _KERNTYPES |
20 | #define _KERNTYPES | | 21 | #define _KERNTYPES |
| | | 22 | #endif |
21 | #include "defs.h" | | 23 | #include "defs.h" |
22 | #include "inferior.h" | | 24 | #include "inferior.h" |
23 | #include "regcache.h" | | 25 | #include "regcache.h" |
24 | #include "target.h" | | 26 | #include "target.h" |
25 | | | 27 | |
26 | #include <sys/types.h> | | 28 | #include <sys/types.h> |
27 | #include <sys/ptrace.h> | | 29 | #include <sys/ptrace.h> |
28 | #include <machine/reg.h> | | 30 | #include <machine/reg.h> |
29 | | | 31 | |
30 | #include "vax-tdep.h" | | 32 | #include "vax-tdep.h" |
31 | #include "inf-ptrace.h" | | 33 | #include "inf-ptrace.h" |
32 | | | 34 | |
33 | /* Supply the general-purpose registers stored in GREGS to REGCACHE. */ | | 35 | /* Supply the general-purpose registers stored in GREGS to REGCACHE. */ |
34 | | | 36 | |
35 | static void | | 37 | static void |
36 | vaxbsd_supply_gregset (struct regcache *regcache, const void *gregs) | | 38 | vaxbsd_supply_gregset (struct regcache *regcache, const void *gregs) |
37 | { | | 39 | { |
38 | const gdb_byte *regs = (const gdb_byte *)gregs; | | 40 | const gdb_byte *regs = (const gdb_byte *)gregs; |
39 | int regnum; | | 41 | int regnum; |
40 | | | 42 | |
41 | for (regnum = 0; regnum < VAX_NUM_REGS; regnum++) | | 43 | for (regnum = 0; regnum < VAX_NUM_REGS; regnum++) |
42 | regcache_raw_supply (regcache, regnum, regs + regnum * 4); | | 44 | regcache_raw_supply (regcache, regnum, regs + regnum * 4); |
43 | } | | 45 | } |
44 | | | 46 | |
45 | /* Collect the general-purpose registers from REGCACHE and store them | | 47 | /* Collect the general-purpose registers from REGCACHE and store them |
46 | in GREGS. */ | | 48 | in GREGS. */ |
47 | | | 49 | |
48 | static void | | 50 | static void |
49 | vaxbsd_collect_gregset (const struct regcache *regcache, | | 51 | vaxbsd_collect_gregset (const struct regcache *regcache, |
50 | void *gregs, int regnum) | | 52 | void *gregs, int regnum) |
51 | { | | 53 | { |
52 | gdb_byte *regs = (gdb_byte *)gregs; | | 54 | gdb_byte *regs = (gdb_byte *)gregs; |
53 | int i; | | 55 | int i; |
54 | | | 56 | |
55 | for (i = 0; i <= VAX_NUM_REGS; i++) | | 57 | for (i = 0; i <= VAX_NUM_REGS; i++) |
56 | { | | 58 | { |
57 | if (regnum == -1 || regnum == i) | | 59 | if (regnum == -1 || regnum == i) |
58 | regcache_raw_collect (regcache, i, regs + i * 4); | | 60 | regcache_raw_collect (regcache, i, regs + i * 4); |
59 | } | | 61 | } |
60 | } | | 62 | } |
61 | | | 63 | |
62 | | | 64 | |
63 | /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this | | 65 | /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this |
64 | for all registers. */ | | 66 | for all registers. */ |
65 | | | 67 | |
66 | static void | | 68 | static void |
67 | vaxbsd_fetch_inferior_registers (struct target_ops *ops, | | 69 | vaxbsd_fetch_inferior_registers (struct target_ops *ops, |
68 | struct regcache *regcache, int regnum) | | 70 | struct regcache *regcache, int regnum) |
69 | { | | 71 | { |
70 | struct reg regs; | | 72 | struct reg regs; |
71 | pid_t pid = ptid_get_pid (regcache_get_ptid (regcache)); | | 73 | pid_t pid = ptid_get_pid (regcache_get_ptid (regcache)); |
72 | | | 74 | |
73 | if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) | | 75 | if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) |
74 | perror_with_name (_("Couldn't get registers")); | | 76 | perror_with_name (_("Couldn't get registers")); |
75 | | | 77 | |
76 | vaxbsd_supply_gregset (regcache, ®s); | | 78 | vaxbsd_supply_gregset (regcache, ®s); |
77 | } | | 79 | } |
78 | | | 80 | |
79 | /* Store register REGNUM back into the inferior. If REGNUM is -1, do | | 81 | /* Store register REGNUM back into the inferior. If REGNUM is -1, do |
80 | this for all registers. */ | | 82 | this for all registers. */ |
81 | | | 83 | |
82 | static void | | 84 | static void |
83 | vaxbsd_store_inferior_registers (struct target_ops *ops, | | 85 | vaxbsd_store_inferior_registers (struct target_ops *ops, |
84 | struct regcache *regcache, int regnum) | | 86 | struct regcache *regcache, int regnum) |
85 | { | | 87 | { |
86 | struct reg regs; | | 88 | struct reg regs; |
87 | pid_t pid = ptid_get_pid (regcache_get_ptid (regcache)); | | 89 | pid_t pid = ptid_get_pid (regcache_get_ptid (regcache)); |
88 | | | 90 | |
89 | if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) | | 91 | if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) |
90 | perror_with_name (_("Couldn't get registers")); | | 92 | perror_with_name (_("Couldn't get registers")); |
91 | | | 93 | |
92 | vaxbsd_collect_gregset (regcache, ®s, regnum); | | 94 | vaxbsd_collect_gregset (regcache, ®s, regnum); |
93 | | | 95 | |
94 | if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) | | 96 | if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) |
95 | perror_with_name (_("Couldn't write registers")); | | 97 | perror_with_name (_("Couldn't write registers")); |
96 | } | | 98 | } |
97 | | | 99 | |
98 | | | 100 | |
99 | /* Support for debugging kernel virtual memory images. */ | | 101 | /* Support for debugging kernel virtual memory images. */ |
100 | | | 102 | |
101 | #include <machine/pcb.h> | | 103 | #include <machine/pcb.h> |
102 | | | 104 | |
103 | #include "bsd-kvm.h" | | 105 | #include "bsd-kvm.h" |
104 | | | 106 | |
105 | static int | | 107 | static int |
106 | vaxbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) | | 108 | vaxbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) |
107 | { | | 109 | { |
108 | int regnum; | | 110 | int regnum; |
109 | | | 111 | |
110 | /* The following is true for OpenBSD 3.5: | | 112 | /* The following is true for OpenBSD 3.5: |
111 | | | 113 | |
112 | The pcb contains the register state at the context switch inside | | 114 | The pcb contains the register state at the context switch inside |
113 | cpu_switch(). */ | | 115 | cpu_switch(). */ |
114 | | | 116 | |
115 | /* The stack pointer shouldn't be zero. */ | | 117 | /* The stack pointer shouldn't be zero. */ |
116 | if (pcb->KSP == 0) | | 118 | if (pcb->KSP == 0) |
117 | return 0; | | 119 | return 0; |
118 | | | 120 | |
119 | for (regnum = VAX_R0_REGNUM; regnum < VAX_AP_REGNUM; regnum++) | | 121 | for (regnum = VAX_R0_REGNUM; regnum < VAX_AP_REGNUM; regnum++) |
120 | regcache_raw_supply (regcache, regnum, &pcb->R[regnum - VAX_R0_REGNUM]); | | 122 | regcache_raw_supply (regcache, regnum, &pcb->R[regnum - VAX_R0_REGNUM]); |
121 | regcache_raw_supply (regcache, VAX_AP_REGNUM, &pcb->AP); | | 123 | regcache_raw_supply (regcache, VAX_AP_REGNUM, &pcb->AP); |
122 | regcache_raw_supply (regcache, VAX_FP_REGNUM, &pcb->FP); | | 124 | regcache_raw_supply (regcache, VAX_FP_REGNUM, &pcb->FP); |
123 | regcache_raw_supply (regcache, VAX_SP_REGNUM, &pcb->KSP); | | 125 | regcache_raw_supply (regcache, VAX_SP_REGNUM, &pcb->KSP); |
124 | regcache_raw_supply (regcache, VAX_PC_REGNUM, &pcb->PC); | | 126 | regcache_raw_supply (regcache, VAX_PC_REGNUM, &pcb->PC); |
125 | regcache_raw_supply (regcache, VAX_PS_REGNUM, &pcb->PSL); | | 127 | regcache_raw_supply (regcache, VAX_PS_REGNUM, &pcb->PSL); |
126 | | | 128 | |
127 | return 1; | | 129 | return 1; |
128 | } | | 130 | } |
129 | | | 131 | |
130 | | | 132 | |
131 | /* Provide a prototype to silence -Wmissing-prototypes. */ | | 133 | /* Provide a prototype to silence -Wmissing-prototypes. */ |
132 | void _initialize_vaxbsd_nat (void); | | 134 | void _initialize_vaxbsd_nat (void); |
133 | | | 135 | |
134 | void | | 136 | void |
135 | _initialize_vaxbsd_nat (void) | | 137 | _initialize_vaxbsd_nat (void) |
136 | { | | 138 | { |
137 | struct target_ops *t; | | 139 | struct target_ops *t; |
138 | | | 140 | |
139 | t = inf_ptrace_target (); | | 141 | t = inf_ptrace_target (); |
140 | t->to_fetch_registers = vaxbsd_fetch_inferior_registers; | | 142 | t->to_fetch_registers = vaxbsd_fetch_inferior_registers; |
141 | t->to_store_registers = vaxbsd_store_inferior_registers; | | 143 | t->to_store_registers = vaxbsd_store_inferior_registers; |
142 | add_target (t); | | 144 | add_target (t); |
143 | | | 145 | |
144 | /* Support debugging kernel virtual memory images. */ | | 146 | /* Support debugging kernel virtual memory images. */ |
145 | bsd_kvm_add_target (vaxbsd_supply_pcb); | | 147 | bsd_kvm_add_target (vaxbsd_supply_pcb); |
146 | } | | 148 | } |