Thu Nov 30 00:13:29 2017 UTC ()
Fix 'last argument of ptrace is the thread id' on NetBSD.


(christos)
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/amd64-bsd-nat.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/i386-bsd-nat.c
diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/m88k-bsd-nat.c
diff -r1.2 -r1.3 src/external/gpl3/gdb/dist/gdb/m68k-bsd-nat.c
diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/vax-bsd-nat.c

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/amd64-bsd-nat.c (switch to unified diff)

--- src/external/gpl3/gdb/dist/gdb/amd64-bsd-nat.c 2017/11/28 18:18:06 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/amd64-bsd-nat.c 2017/11/30 00:13:29 1.2
@@ -1,155 +1,155 @@ @@ -1,155 +1,155 @@
1/* Native-dependent code for AMD64 BSD's. 1/* Native-dependent code for AMD64 BSD's.
2 2
3 Copyright (C) 2003-2017 Free Software Foundation, Inc. 3 Copyright (C) 2003-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#include "defs.h" 20#include "defs.h"
21#include "inferior.h" 21#include "inferior.h"
22#include "regcache.h" 22#include "regcache.h"
23#include "target.h" 23#include "target.h"
24 24
25/* We include <signal.h> to make sure `struct fxsave64' is defined on 25/* We include <signal.h> to make sure `struct fxsave64' is defined on
26 NetBSD, since NetBSD's <machine/reg.h> needs it. */ 26 NetBSD, since NetBSD's <machine/reg.h> needs it. */
27#include <signal.h> 27#include <signal.h>
28#include <sys/types.h> 28#include <sys/types.h>
29#include <sys/ptrace.h> 29#include <sys/ptrace.h>
30#include <machine/reg.h> 30#include <machine/reg.h>
31 31
32#include "amd64-tdep.h" 32#include "amd64-tdep.h"
33#include "amd64-nat.h" 33#include "amd64-nat.h"
34#include "x86-bsd-nat.h" 34#include "x86-bsd-nat.h"
35#include "inf-ptrace.h" 35#include "inf-ptrace.h"
36  36
37 37
38/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this 38/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
39 for all registers (including the floating-point registers). */ 39 for all registers (including the floating-point registers). */
40 40
41static void 41static void
42amd64bsd_fetch_inferior_registers (struct target_ops *ops, 42amd64bsd_fetch_inferior_registers (struct target_ops *ops,
43 struct regcache *regcache, int regnum) 43 struct regcache *regcache, int regnum)
44{ 44{
45 struct gdbarch *gdbarch = get_regcache_arch (regcache); 45 struct gdbarch *gdbarch = get_regcache_arch (regcache);
46 pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache)); 46 pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
47 47
48 if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum)) 48 if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum))
49 { 49 {
50 struct reg regs; 50 struct reg regs;
51 51
52 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1) 52 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
53 perror_with_name (_("Couldn't get registers")); 53 perror_with_name (_("Couldn't get registers"));
54 54
55 amd64_supply_native_gregset (regcache, &regs, -1); 55 amd64_supply_native_gregset (regcache, &regs, -1);
56 if (regnum != -1) 56 if (regnum != -1)
57 return; 57 return;
58 } 58 }
59 59
60 if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum)) 60 if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum))
61 { 61 {
62 struct fpreg fpregs; 62 struct fpreg fpregs;
63#ifdef PT_GETXSTATE_INFO 63#ifdef PT_GETXSTATE_INFO
64 void *xstateregs; 64 void *xstateregs;
65 65
66 if (x86bsd_xsave_len != 0) 66 if (x86bsd_xsave_len != 0)
67 { 67 {
68 xstateregs = alloca (x86bsd_xsave_len); 68 xstateregs = alloca (x86bsd_xsave_len);
69 if (ptrace (PT_GETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs, 0) 69 if (ptrace (PT_GETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs, ptid_get_lwp (inferior_ptid))
70 == -1) 70 == -1)
71 perror_with_name (_("Couldn't get extended state status")); 71 perror_with_name (_("Couldn't get extended state status"));
72 72
73 amd64_supply_xsave (regcache, -1, xstateregs); 73 amd64_supply_xsave (regcache, -1, xstateregs);
74 return; 74 return;
75 } 75 }
76#endif 76#endif
77 77
78 if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 78 if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
79 perror_with_name (_("Couldn't get floating point status")); 79 perror_with_name (_("Couldn't get floating point status"));
80 80
81 amd64_supply_fxsave (regcache, -1, &fpregs); 81 amd64_supply_fxsave (regcache, -1, &fpregs);
82 } 82 }
83} 83}
84 84
85/* Store register REGNUM back into the inferior. If REGNUM is -1, do 85/* Store register REGNUM back into the inferior. If REGNUM is -1, do
86 this for all registers (including the floating-point registers). */ 86 this for all registers (including the floating-point registers). */
87 87
88static void 88static void
89amd64bsd_store_inferior_registers (struct target_ops *ops, 89amd64bsd_store_inferior_registers (struct target_ops *ops,
90 struct regcache *regcache, int regnum) 90 struct regcache *regcache, int regnum)
91{ 91{
92 struct gdbarch *gdbarch = get_regcache_arch (regcache); 92 struct gdbarch *gdbarch = get_regcache_arch (regcache);
93 pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache)); 93 pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
94 94
95 if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum)) 95 if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum))
96 { 96 {
97 struct reg regs; 97 struct reg regs;
98 98
99 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1) 99 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
100 perror_with_name (_("Couldn't get registers")); 100 perror_with_name (_("Couldn't get registers"));
101 101
102 amd64_collect_native_gregset (regcache, &regs, regnum); 102 amd64_collect_native_gregset (regcache, &regs, regnum);
103 103
104 if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1) 104 if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
105 perror_with_name (_("Couldn't write registers")); 105 perror_with_name (_("Couldn't write registers"));
106 106
107 if (regnum != -1) 107 if (regnum != -1)
108 return; 108 return;
109 } 109 }
110 110
111 if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum)) 111 if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum))
112 { 112 {
113 struct fpreg fpregs; 113 struct fpreg fpregs;
114#ifdef PT_GETXSTATE_INFO 114#ifdef PT_GETXSTATE_INFO
115 void *xstateregs; 115 void *xstateregs;
116 116
117 if (x86bsd_xsave_len != 0) 117 if (x86bsd_xsave_len != 0)
118 { 118 {
119 xstateregs = alloca (x86bsd_xsave_len); 119 xstateregs = alloca (x86bsd_xsave_len);
120 if (ptrace (PT_GETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs, 0) 120 if (ptrace (PT_GETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs, ptid_get_lwp (inferior_ptid))
121 == -1) 121 == -1)
122 perror_with_name (_("Couldn't get extended state status")); 122 perror_with_name (_("Couldn't get extended state status"));
123 123
124 amd64_collect_xsave (regcache, regnum, xstateregs, 0); 124 amd64_collect_xsave (regcache, regnum, xstateregs, ptid_get_lwp (inferior_ptid));
125 125
126 if (ptrace (PT_SETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs, 126 if (ptrace (PT_SETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs,
127 x86bsd_xsave_len) == -1) 127 x86bsd_xsave_len) == -1)
128 perror_with_name (_("Couldn't write extended state status")); 128 perror_with_name (_("Couldn't write extended state status"));
129 return; 129 return;
130 } 130 }
131#endif 131#endif
132 132
133 if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 133 if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
134 perror_with_name (_("Couldn't get floating point status")); 134 perror_with_name (_("Couldn't get floating point status"));
135 135
136 amd64_collect_fxsave (regcache, regnum, &fpregs); 136 amd64_collect_fxsave (regcache, regnum, &fpregs);
137 137
138 if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 138 if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
139 perror_with_name (_("Couldn't write floating point status")); 139 perror_with_name (_("Couldn't write floating point status"));
140 } 140 }
141} 141}
142 142
143/* Create a prototype *BSD/amd64 target. The client can override it 143/* Create a prototype *BSD/amd64 target. The client can override it
144 with local methods. */ 144 with local methods. */
145 145
146struct target_ops * 146struct target_ops *
147amd64bsd_target (void) 147amd64bsd_target (void)
148{ 148{
149 struct target_ops *t; 149 struct target_ops *t;
150 150
151 t = x86bsd_target (); 151 t = x86bsd_target ();
152 t->to_fetch_registers = amd64bsd_fetch_inferior_registers; 152 t->to_fetch_registers = amd64bsd_fetch_inferior_registers;
153 t->to_store_registers = amd64bsd_store_inferior_registers; 153 t->to_store_registers = amd64bsd_store_inferior_registers;
154 return t; 154 return t;
155} 155}

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/i386-bsd-nat.c (switch to unified diff)

--- src/external/gpl3/gdb/dist/gdb/i386-bsd-nat.c 2017/11/28 18:18:07 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/i386-bsd-nat.c 2017/11/30 00:13:29 1.2
@@ -1,362 +1,362 @@ @@ -1,362 +1,362 @@
1/* Native-dependent code for modern i386 BSD's. 1/* Native-dependent code for modern i386 BSD's.
2 2
3 Copyright (C) 2000-2017 Free Software Foundation, Inc. 3 Copyright (C) 2000-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#include "defs.h" 20#include "defs.h"
21#include "inferior.h" 21#include "inferior.h"
22#include "regcache.h" 22#include "regcache.h"
23 23
24#include <signal.h> 24#include <signal.h>
25#include <sys/types.h> 25#include <sys/types.h>
26#include <sys/ptrace.h> 26#include <sys/ptrace.h>
27#include <machine/reg.h> 27#include <machine/reg.h>
28#include <machine/frame.h> 28#include <machine/frame.h>
29 29
30#include "i386-tdep.h" 30#include "i386-tdep.h"
31#include "i387-tdep.h" 31#include "i387-tdep.h"
32#include "x86-bsd-nat.h" 32#include "x86-bsd-nat.h"
33#include "i386-bsd-nat.h" 33#include "i386-bsd-nat.h"
34#include "inf-ptrace.h" 34#include "inf-ptrace.h"
35  35
36 36
37/* In older BSD versions we cannot get at some of the segment 37/* In older BSD versions we cannot get at some of the segment
38 registers. FreeBSD for example didn't support the %fs and %gs 38 registers. FreeBSD for example didn't support the %fs and %gs
39 registers until the 3.0 release. We have autoconf checks for their 39 registers until the 3.0 release. We have autoconf checks for their
40 presence, and deal gracefully with their absence. */ 40 presence, and deal gracefully with their absence. */
41 41
42/* Offset in `struct reg' where MEMBER is stored. */ 42/* Offset in `struct reg' where MEMBER is stored. */
43#define REG_OFFSET(member) offsetof (struct reg, member) 43#define REG_OFFSET(member) offsetof (struct reg, member)
44 44
45/* At i386bsd_reg_offset[REGNUM] you'll find the offset in `struct 45/* At i386bsd_reg_offset[REGNUM] you'll find the offset in `struct
46 reg' where the GDB register REGNUM is stored. Unsupported 46 reg' where the GDB register REGNUM is stored. Unsupported
47 registers are marked with `-1'. */ 47 registers are marked with `-1'. */
48static int i386bsd_r_reg_offset[] = 48static int i386bsd_r_reg_offset[] =
49{ 49{
50 REG_OFFSET (r_eax), 50 REG_OFFSET (r_eax),
51 REG_OFFSET (r_ecx), 51 REG_OFFSET (r_ecx),
52 REG_OFFSET (r_edx), 52 REG_OFFSET (r_edx),
53 REG_OFFSET (r_ebx), 53 REG_OFFSET (r_ebx),
54 REG_OFFSET (r_esp), 54 REG_OFFSET (r_esp),
55 REG_OFFSET (r_ebp), 55 REG_OFFSET (r_ebp),
56 REG_OFFSET (r_esi), 56 REG_OFFSET (r_esi),
57 REG_OFFSET (r_edi), 57 REG_OFFSET (r_edi),
58 REG_OFFSET (r_eip), 58 REG_OFFSET (r_eip),
59 REG_OFFSET (r_eflags), 59 REG_OFFSET (r_eflags),
60 REG_OFFSET (r_cs), 60 REG_OFFSET (r_cs),
61 REG_OFFSET (r_ss), 61 REG_OFFSET (r_ss),
62 REG_OFFSET (r_ds), 62 REG_OFFSET (r_ds),
63 REG_OFFSET (r_es), 63 REG_OFFSET (r_es),
64#ifdef HAVE_STRUCT_REG_R_FS 64#ifdef HAVE_STRUCT_REG_R_FS
65 REG_OFFSET (r_fs), 65 REG_OFFSET (r_fs),
66#else 66#else
67 -1, 67 -1,
68#endif 68#endif
69#ifdef HAVE_STRUCT_REG_R_GS 69#ifdef HAVE_STRUCT_REG_R_GS
70 REG_OFFSET (r_gs) 70 REG_OFFSET (r_gs)
71#else 71#else
72 -1 72 -1
73#endif 73#endif
74}; 74};
75 75
76/* Macro to determine if a register is fetched with PT_GETREGS. */ 76/* Macro to determine if a register is fetched with PT_GETREGS. */
77#define GETREGS_SUPPLIES(regnum) \ 77#define GETREGS_SUPPLIES(regnum) \
78 ((0 <= (regnum) && (regnum) <= 15)) 78 ((0 <= (regnum) && (regnum) <= 15))
79 79
80#ifdef HAVE_PT_GETXMMREGS 80#ifdef HAVE_PT_GETXMMREGS
81/* Set to 1 if the kernel supports PT_GETXMMREGS. Initialized to -1 81/* Set to 1 if the kernel supports PT_GETXMMREGS. Initialized to -1
82 so that we try PT_GETXMMREGS the first time around. */ 82 so that we try PT_GETXMMREGS the first time around. */
83static int have_ptrace_xmmregs = -1; 83static int have_ptrace_xmmregs = -1;
84#endif 84#endif
85  85
86 86
87/* Supply the general-purpose registers in GREGS, to REGCACHE. */ 87/* Supply the general-purpose registers in GREGS, to REGCACHE. */
88 88
89static void 89static void
90i386bsd_supply_gregset (struct regcache *regcache, const void *gregs) 90i386bsd_supply_gregset (struct regcache *regcache, const void *gregs)
91{ 91{
92 const char *regs = (const char *) gregs; 92 const char *regs = (const char *) gregs;
93 int regnum; 93 int regnum;
94 94
95 for (regnum = 0; regnum < ARRAY_SIZE (i386bsd_r_reg_offset); regnum++) 95 for (regnum = 0; regnum < ARRAY_SIZE (i386bsd_r_reg_offset); regnum++)
96 { 96 {
97 int offset = i386bsd_r_reg_offset[regnum]; 97 int offset = i386bsd_r_reg_offset[regnum];
98 98
99 if (offset != -1) 99 if (offset != -1)
100 regcache_raw_supply (regcache, regnum, regs + offset); 100 regcache_raw_supply (regcache, regnum, regs + offset);
101 } 101 }
102} 102}
103 103
104/* Collect register REGNUM from REGCACHE and store its contents in 104/* Collect register REGNUM from REGCACHE and store its contents in
105 GREGS. If REGNUM is -1, collect and store all appropriate 105 GREGS. If REGNUM is -1, collect and store all appropriate
106 registers. */ 106 registers. */
107 107
108static void 108static void
109i386bsd_collect_gregset (const struct regcache *regcache, 109i386bsd_collect_gregset (const struct regcache *regcache,
110 void *gregs, int regnum) 110 void *gregs, int regnum)
111{ 111{
112 char *regs = (char *) gregs; 112 char *regs = (char *) gregs;
113 int i; 113 int i;
114 114
115 for (i = 0; i < ARRAY_SIZE (i386bsd_r_reg_offset); i++) 115 for (i = 0; i < ARRAY_SIZE (i386bsd_r_reg_offset); i++)
116 { 116 {
117 if (regnum == -1 || regnum == i) 117 if (regnum == -1 || regnum == i)
118 { 118 {
119 int offset = i386bsd_r_reg_offset[i]; 119 int offset = i386bsd_r_reg_offset[i];
120 120
121 if (offset != -1) 121 if (offset != -1)
122 regcache_raw_collect (regcache, i, regs + offset); 122 regcache_raw_collect (regcache, i, regs + offset);
123 } 123 }
124 } 124 }
125} 125}
126 126
127/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this 127/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
128 for all registers (including the floating point registers). */ 128 for all registers (including the floating point registers). */
129 129
130static void 130static void
131i386bsd_fetch_inferior_registers (struct target_ops *ops, 131i386bsd_fetch_inferior_registers (struct target_ops *ops,
132 struct regcache *regcache, int regnum) 132 struct regcache *regcache, int regnum)
133{ 133{
134 pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache)); 134 pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
135 135
136 if (regnum == -1 || GETREGS_SUPPLIES (regnum)) 136 if (regnum == -1 || GETREGS_SUPPLIES (regnum))
137 { 137 {
138 struct reg regs; 138 struct reg regs;
139 139
140 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1) 140 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
141 perror_with_name (_("Couldn't get registers")); 141 perror_with_name (_("Couldn't get registers"));
142 142
143 i386bsd_supply_gregset (regcache, &regs); 143 i386bsd_supply_gregset (regcache, &regs);
144 if (regnum != -1) 144 if (regnum != -1)
145 return; 145 return;
146 } 146 }
147 147
148 if (regnum == -1 || regnum >= I386_ST0_REGNUM) 148 if (regnum == -1 || regnum >= I386_ST0_REGNUM)
149 { 149 {
150 struct fpreg fpregs; 150 struct fpreg fpregs;
151#ifdef HAVE_PT_GETXMMREGS 151#ifdef HAVE_PT_GETXMMREGS
152 char xmmregs[512]; 152 char xmmregs[512];
153#endif 153#endif
154 154
155#ifdef PT_GETXSTATE_INFO 155#ifdef PT_GETXSTATE_INFO
156 if (x86bsd_xsave_len != 0) 156 if (x86bsd_xsave_len != 0)
157 { 157 {
158 void *xstateregs; 158 void *xstateregs;
159 159
160 xstateregs = alloca (x86bsd_xsave_len); 160 xstateregs = alloca (x86bsd_xsave_len);
161 if (ptrace (PT_GETXSTATE, pid, 161 if (ptrace (PT_GETXSTATE, pid,
162 (PTRACE_TYPE_ARG3) xstateregs, 0) == -1) 162 (PTRACE_TYPE_ARG3) xstateregs, ptid_get_lwp (inferior_ptid)) == -1)
163 perror_with_name (_("Couldn't get extended state status")); 163 perror_with_name (_("Couldn't get extended state status"));
164 164
165 i387_supply_xsave (regcache, -1, xstateregs); 165 i387_supply_xsave (regcache, -1, xstateregs);
166 return; 166 return;
167 } 167 }
168#endif 168#endif
169  169
170#ifdef HAVE_PT_GETXMMREGS 170#ifdef HAVE_PT_GETXMMREGS
171 if (have_ptrace_xmmregs != 0 171 if (have_ptrace_xmmregs != 0
172 && ptrace(PT_GETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, 0) == 0) 172 && ptrace(PT_GETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, ptid_get_lwp (inferior_ptid)) == 0)
173 { 173 {
174 have_ptrace_xmmregs = 1; 174 have_ptrace_xmmregs = 1;
175 i387_supply_fxsave (regcache, -1, xmmregs); 175 i387_supply_fxsave (regcache, -1, xmmregs);
176 } 176 }
177 else 177 else
178 { 178 {
179 have_ptrace_xmmregs = 0; 179 have_ptrace_xmmregs = 0;
180#endif 180#endif
181 if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 181 if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
182 perror_with_name (_("Couldn't get floating point status")); 182 perror_with_name (_("Couldn't get floating point status"));
183 183
184 i387_supply_fsave (regcache, -1, &fpregs); 184 i387_supply_fsave (regcache, -1, &fpregs);
185#ifdef HAVE_PT_GETXMMREGS 185#ifdef HAVE_PT_GETXMMREGS
186 } 186 }
187#endif 187#endif
188 } 188 }
189} 189}
190 190
191/* Store register REGNUM back into the inferior. If REGNUM is -1, do 191/* Store register REGNUM back into the inferior. If REGNUM is -1, do
192 this for all registers (including the floating point registers). */ 192 this for all registers (including the floating point registers). */
193 193
194static void 194static void
195i386bsd_store_inferior_registers (struct target_ops *ops, 195i386bsd_store_inferior_registers (struct target_ops *ops,
196 struct regcache *regcache, int regnum) 196 struct regcache *regcache, int regnum)
197{ 197{
198 pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache)); 198 pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
199 199
200 if (regnum == -1 || GETREGS_SUPPLIES (regnum)) 200 if (regnum == -1 || GETREGS_SUPPLIES (regnum))
201 { 201 {
202 struct reg regs; 202 struct reg regs;
203 203
204 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1) 204 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
205 perror_with_name (_("Couldn't get registers")); 205 perror_with_name (_("Couldn't get registers"));
206 206
207 i386bsd_collect_gregset (regcache, &regs, regnum); 207 i386bsd_collect_gregset (regcache, &regs, regnum);
208 208
209 if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1) 209 if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
210 perror_with_name (_("Couldn't write registers")); 210 perror_with_name (_("Couldn't write registers"));
211 211
212 if (regnum != -1) 212 if (regnum != -1)
213 return; 213 return;
214 } 214 }
215 215
216 if (regnum == -1 || regnum >= I386_ST0_REGNUM) 216 if (regnum == -1 || regnum >= I386_ST0_REGNUM)
217 { 217 {
218 struct fpreg fpregs; 218 struct fpreg fpregs;
219#ifdef HAVE_PT_GETXMMREGS 219#ifdef HAVE_PT_GETXMMREGS
220 char xmmregs[512]; 220 char xmmregs[512];
221#endif 221#endif
222 222
223#ifdef PT_GETXSTATE_INFO 223#ifdef PT_GETXSTATE_INFO
224 if (x86bsd_xsave_len != 0) 224 if (x86bsd_xsave_len != 0)
225 { 225 {
226 void *xstateregs; 226 void *xstateregs;
227 227
228 xstateregs = alloca (x86bsd_xsave_len); 228 xstateregs = alloca (x86bsd_xsave_len);
229 if (ptrace (PT_GETXSTATE, pid, 229 if (ptrace (PT_GETXSTATE, pid,
230 (PTRACE_TYPE_ARG3) xstateregs, 0) == -1) 230 (PTRACE_TYPE_ARG3) xstateregs, ptid_get_lwp (inferior_ptid)) == -1)
231 perror_with_name (_("Couldn't get extended state status")); 231 perror_with_name (_("Couldn't get extended state status"));
232 232
233 i387_collect_xsave (regcache, -1, xstateregs, 0); 233 i387_collect_xsave (regcache, -1, xstateregs, ptid_get_lwp (inferior_ptid));
234 234
235 if (ptrace (PT_SETXSTATE, pid, 235 if (ptrace (PT_SETXSTATE, pid,
236 (PTRACE_TYPE_ARG3) xstateregs, x86bsd_xsave_len) == -1) 236 (PTRACE_TYPE_ARG3) xstateregs, x86bsd_xsave_len) == -1)
237 perror_with_name (_("Couldn't write extended state status")); 237 perror_with_name (_("Couldn't write extended state status"));
238 return; 238 return;
239 } 239 }
240#endif 240#endif
241 241
242#ifdef HAVE_PT_GETXMMREGS 242#ifdef HAVE_PT_GETXMMREGS
243 if (have_ptrace_xmmregs != 0 243 if (have_ptrace_xmmregs != 0
244 && ptrace(PT_GETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, 0) == 0) 244 && ptrace(PT_GETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, ptid_get_lwp (inferior_ptid)) == 0)
245 { 245 {
246 have_ptrace_xmmregs = 1; 246 have_ptrace_xmmregs = 1;
247 247
248 i387_collect_fxsave (regcache, regnum, xmmregs); 248 i387_collect_fxsave (regcache, regnum, xmmregs);
249 249
250 if (ptrace (PT_SETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, 0) == -1) 250 if (ptrace (PT_SETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, ptid_get_lwp (inferior_ptid)) == -1)
251 perror_with_name (_("Couldn't write XMM registers")); 251 perror_with_name (_("Couldn't write XMM registers"));
252 } 252 }
253 else 253 else
254 { 254 {
255 have_ptrace_xmmregs = 0; 255 have_ptrace_xmmregs = 0;
256#endif 256#endif
257 if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 257 if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
258 perror_with_name (_("Couldn't get floating point status")); 258 perror_with_name (_("Couldn't get floating point status"));
259 259
260 i387_collect_fsave (regcache, regnum, &fpregs); 260 i387_collect_fsave (regcache, regnum, &fpregs);
261 261
262 if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 262 if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
263 perror_with_name (_("Couldn't write floating point status")); 263 perror_with_name (_("Couldn't write floating point status"));
264#ifdef HAVE_PT_GETXMMREGS 264#ifdef HAVE_PT_GETXMMREGS
265 } 265 }
266#endif 266#endif
267 } 267 }
268} 268}
269 269
270/* Create a prototype *BSD/i386 target. The client can override it 270/* Create a prototype *BSD/i386 target. The client can override it
271 with local methods. */ 271 with local methods. */
272 272
273struct target_ops * 273struct target_ops *
274i386bsd_target (void) 274i386bsd_target (void)
275{ 275{
276 struct target_ops *t; 276 struct target_ops *t;
277 277
278 t = x86bsd_target (); 278 t = x86bsd_target ();
279 t->to_fetch_registers = i386bsd_fetch_inferior_registers; 279 t->to_fetch_registers = i386bsd_fetch_inferior_registers;
280 t->to_store_registers = i386bsd_store_inferior_registers; 280 t->to_store_registers = i386bsd_store_inferior_registers;
281 return t; 281 return t;
282} 282}
283  283
284 284
285/* Provide a prototype to silence -Wmissing-prototypes. */ 285/* Provide a prototype to silence -Wmissing-prototypes. */
286void _initialize_i386bsd_nat (void); 286void _initialize_i386bsd_nat (void);
287 287
288void 288void
289_initialize_i386bsd_nat (void) 289_initialize_i386bsd_nat (void)
290{ 290{
291 int offset; 291 int offset;
292 292
293 /* To support the recognition of signal handlers, i386-bsd-tdep.c 293 /* To support the recognition of signal handlers, i386-bsd-tdep.c
294 hardcodes some constants. Inclusion of this file means that we 294 hardcodes some constants. Inclusion of this file means that we
295 are compiling a native debugger, which means that we can use the 295 are compiling a native debugger, which means that we can use the
296 system header files and sysctl(3) to get at the relevant 296 system header files and sysctl(3) to get at the relevant
297 information. */ 297 information. */
298 298
299#if defined (__FreeBSD_version) && __FreeBSD_version >= 400011 299#if defined (__FreeBSD_version) && __FreeBSD_version >= 400011
300#define SC_REG_OFFSET i386fbsd4_sc_reg_offset 300#define SC_REG_OFFSET i386fbsd4_sc_reg_offset
301#elif defined (__FreeBSD_version) && __FreeBSD_version >= 300005 301#elif defined (__FreeBSD_version) && __FreeBSD_version >= 300005
302#define SC_REG_OFFSET i386fbsd_sc_reg_offset 302#define SC_REG_OFFSET i386fbsd_sc_reg_offset
303#elif defined (NetBSD) || defined (__NetBSD_Version__) 303#elif defined (NetBSD) || defined (__NetBSD_Version__)
304#define SC_REG_OFFSET i386nbsd_sc_reg_offset 304#define SC_REG_OFFSET i386nbsd_sc_reg_offset
305#elif defined (OpenBSD) 305#elif defined (OpenBSD)
306#define SC_REG_OFFSET i386obsd_sc_reg_offset 306#define SC_REG_OFFSET i386obsd_sc_reg_offset
307#endif 307#endif
308 308
309#ifdef SC_REG_OFFSET 309#ifdef SC_REG_OFFSET
310 310
311 /* We only check the program counter, stack pointer and frame 311 /* We only check the program counter, stack pointer and frame
312 pointer since these members of `struct sigcontext' are essential 312 pointer since these members of `struct sigcontext' are essential
313 for providing backtraces. More checks could be added, but would 313 for providing backtraces. More checks could be added, but would
314 involve adding configure checks for the appropriate structure 314 involve adding configure checks for the appropriate structure
315 members, since older BSD's don't provide all of them. */ 315 members, since older BSD's don't provide all of them. */
316 316
317#define SC_PC_OFFSET SC_REG_OFFSET[I386_EIP_REGNUM] 317#define SC_PC_OFFSET SC_REG_OFFSET[I386_EIP_REGNUM]
318#define SC_SP_OFFSET SC_REG_OFFSET[I386_ESP_REGNUM] 318#define SC_SP_OFFSET SC_REG_OFFSET[I386_ESP_REGNUM]
319#define SC_FP_OFFSET SC_REG_OFFSET[I386_EBP_REGNUM] 319#define SC_FP_OFFSET SC_REG_OFFSET[I386_EBP_REGNUM]
320 320
321 /* Override the default value for the offset of the program counter 321 /* Override the default value for the offset of the program counter
322 in the sigcontext structure. */ 322 in the sigcontext structure. */
323 offset = offsetof (struct sigcontext, sc_pc); 323 offset = offsetof (struct sigcontext, sc_pc);
324 324
325 if (SC_PC_OFFSET != offset) 325 if (SC_PC_OFFSET != offset)
326 { 326 {
327 warning (_("\ 327 warning (_("\
328offsetof (struct sigcontext, sc_pc) yields %d instead of %d.\n\ 328offsetof (struct sigcontext, sc_pc) yields %d instead of %d.\n\
329Please report this to <bug-gdb@gnu.org>."),  329Please report this to <bug-gdb@gnu.org>."),
330 offset, SC_PC_OFFSET); 330 offset, SC_PC_OFFSET);
331 } 331 }
332 332
333 SC_PC_OFFSET = offset; 333 SC_PC_OFFSET = offset;
334 334
335 /* Likewise for the stack pointer. */ 335 /* Likewise for the stack pointer. */
336 offset = offsetof (struct sigcontext, sc_sp); 336 offset = offsetof (struct sigcontext, sc_sp);
337 337
338 if (SC_SP_OFFSET != offset) 338 if (SC_SP_OFFSET != offset)
339 { 339 {
340 warning (_("\ 340 warning (_("\
341offsetof (struct sigcontext, sc_sp) yields %d instead of %d.\n\ 341offsetof (struct sigcontext, sc_sp) yields %d instead of %d.\n\
342Please report this to <bug-gdb@gnu.org>."), 342Please report this to <bug-gdb@gnu.org>."),
343 offset, SC_SP_OFFSET); 343 offset, SC_SP_OFFSET);
344 } 344 }
345 345
346 SC_SP_OFFSET = offset; 346 SC_SP_OFFSET = offset;
347 347
348 /* And the frame pointer. */ 348 /* And the frame pointer. */
349 offset = offsetof (struct sigcontext, sc_fp); 349 offset = offsetof (struct sigcontext, sc_fp);
350 350
351 if (SC_FP_OFFSET != offset) 351 if (SC_FP_OFFSET != offset)
352 { 352 {
353 warning (_("\ 353 warning (_("\
354offsetof (struct sigcontext, sc_fp) yields %d instead of %d.\n\ 354offsetof (struct sigcontext, sc_fp) yields %d instead of %d.\n\
355Please report this to <bug-gdb@gnu.org>."), 355Please report this to <bug-gdb@gnu.org>."),
356 offset, SC_FP_OFFSET); 356 offset, SC_FP_OFFSET);
357 } 357 }
358 358
359 SC_FP_OFFSET = offset; 359 SC_FP_OFFSET = offset;
360 360
361#endif /* SC_REG_OFFSET */ 361#endif /* SC_REG_OFFSET */
362} 362}

cvs diff -r1.1.1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/Attic/m88k-bsd-nat.c (switch to unified diff)

--- src/external/gpl3/gdb/dist/gdb/Attic/m88k-bsd-nat.c 2017/11/28 18:18:03 1.1.1.1
+++ src/external/gpl3/gdb/dist/gdb/Attic/m88k-bsd-nat.c 2017/11/30 00:13:29 1.2
@@ -1,111 +1,111 @@ @@ -1,111 +1,111 @@
1/* Native-dependent code for Motorola 88000 BSD's. 1/* Native-dependent code for Motorola 88000 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#include "defs.h" 20#include "defs.h"
21#include "inferior.h" 21#include "inferior.h"
22#include "regcache.h" 22#include "regcache.h"
23#include "target.h" 23#include "target.h"
24 24
25#include <sys/types.h> 25#include <sys/types.h>
26#include <sys/ptrace.h> 26#include <sys/ptrace.h>
27#include <machine/reg.h> 27#include <machine/reg.h>
28 28
29#include "m88k-tdep.h" 29#include "m88k-tdep.h"
30#include "inf-ptrace.h" 30#include "inf-ptrace.h"
31 31
32/* Supply the general-purpose registers stored in GREGS to REGCACHE. */ 32/* Supply the general-purpose registers stored in GREGS to REGCACHE. */
33 33
34static void 34static void
35m88kbsd_supply_gregset (struct regcache *regcache, const void *gregs) 35m88kbsd_supply_gregset (struct regcache *regcache, const void *gregs)
36{ 36{
37 const char *regs = gregs; 37 const char *regs = gregs;
38 int regnum; 38 int regnum;
39 39
40 for (regnum = 0; regnum < M88K_NUM_REGS; regnum++) 40 for (regnum = 0; regnum < M88K_NUM_REGS; regnum++)
41 regcache_raw_supply (regcache, regnum, regs + regnum * 4); 41 regcache_raw_supply (regcache, regnum, regs + regnum * 4);
42} 42}
43 43
44/* Collect the general-purpose registers from REGCACHE and store them 44/* Collect the general-purpose registers from REGCACHE and store them
45 in GREGS. */ 45 in GREGS. */
46 46
47static void 47static void
48m88kbsd_collect_gregset (const struct regcache *regcache, 48m88kbsd_collect_gregset (const struct regcache *regcache,
49 void *gregs, int regnum) 49 void *gregs, int regnum)
50{ 50{
51 char *regs = gregs; 51 char *regs = gregs;
52 int i; 52 int i;
53 53
54 for (i = 0; i < M88K_NUM_REGS; i++) 54 for (i = 0; i < M88K_NUM_REGS; i++)
55 { 55 {
56 if (regnum == -1 || regnum == i) 56 if (regnum == -1 || regnum == i)
57 regcache_raw_collect (regcache, i, regs + i * 4); 57 regcache_raw_collect (regcache, i, regs + i * 4);
58 } 58 }
59} 59}
60  60
61 61
62/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this 62/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
63 for all registers. */ 63 for all registers. */
64 64
65static void 65static void
66m88kbsd_fetch_inferior_registers (struct target_ops *ops, 66m88kbsd_fetch_inferior_registers (struct target_ops *ops,
67 struct regcache *regcache, int regnum) 67 struct regcache *regcache, int regnum)
68{ 68{
69 struct reg regs; 69 struct reg regs;
70 70
71 if (ptrace (PT_GETREGS, ptid_get_pid (regcache_get_ptid (regcache)), 71 if (ptrace (PT_GETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
72 (PTRACE_TYPE_ARG3) &regs, 0) == -1) 72 (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
73 perror_with_name (_("Couldn't get registers")); 73 perror_with_name (_("Couldn't get registers"));
74 74
75 m88kbsd_supply_gregset (regcache, &regs); 75 m88kbsd_supply_gregset (regcache, &regs);
76} 76}
77 77
78/* Store register REGNUM back into the inferior. If REGNUM is -1, do 78/* Store register REGNUM back into the inferior. If REGNUM is -1, do
79 this for all registers. */ 79 this for all registers. */
80 80
81static void 81static void
82m88kbsd_store_inferior_registers (struct target_ops *ops, 82m88kbsd_store_inferior_registers (struct target_ops *ops,
83 struct regcache *regcache, int regnum) 83 struct regcache *regcache, int regnum)
84{ 84{
85 struct reg regs; 85 struct reg regs;
86 86
87 if (ptrace (PT_GETREGS, ptid_get_pid (regcache_get_ptid (regcache)), 87 if (ptrace (PT_GETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
88 (PTRACE_TYPE_ARG3) &regs, 0) == -1) 88 (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
89 perror_with_name (_("Couldn't get registers")); 89 perror_with_name (_("Couldn't get registers"));
90 90
91 m88kbsd_collect_gregset (regcache, &regs, regnum); 91 m88kbsd_collect_gregset (regcache, &regs, regnum);
92 92
93 if (ptrace (PT_SETREGS, ptid_get_pid (regcache_get_ptid (regcache)), 93 if (ptrace (PT_SETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
94 (PTRACE_TYPE_ARG3) &regs, 0) == -1) 94 (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
95 perror_with_name (_("Couldn't write registers")); 95 perror_with_name (_("Couldn't write registers"));
96} 96}
97  97
98 98
99/* Provide a prototype to silence -Wmissing-prototypes. */ 99/* Provide a prototype to silence -Wmissing-prototypes. */
100void _initialize_m88kbsd_nat (void); 100void _initialize_m88kbsd_nat (void);
101 101
102void 102void
103_initialize_m88kbsd_nat (void) 103_initialize_m88kbsd_nat (void)
104{ 104{
105 struct target_ops *t; 105 struct target_ops *t;
106 106
107 t = inf_ptrace_target (); 107 t = inf_ptrace_target ();
108 t->to_fetch_registers = m88kbsd_fetch_inferior_registers; 108 t->to_fetch_registers = m88kbsd_fetch_inferior_registers;
109 t->to_store_registers = m88kbsd_store_inferior_registers; 109 t->to_store_registers = m88kbsd_store_inferior_registers;
110 add_target (t); 110 add_target (t);
111} 111}

cvs diff -r1.2 -r1.3 src/external/gpl3/gdb/dist/gdb/m68k-bsd-nat.c (switch to unified diff)

--- src/external/gpl3/gdb/dist/gdb/m68k-bsd-nat.c 2017/11/29 18:15:29 1.2
+++ src/external/gpl3/gdb/dist/gdb/m68k-bsd-nat.c 2017/11/30 00:13:29 1.3
@@ -1,235 +1,235 @@ @@ -1,235 +1,235 @@
1/* Native-dependent code for Motorola 68000 BSD's. 1/* Native-dependent code for Motorola 68000 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#include "defs.h" 20#include "defs.h"
21#include "gdbcore.h" 21#include "gdbcore.h"
22#include "inferior.h" 22#include "inferior.h"
23#include "regcache.h" 23#include "regcache.h"
24 24
25#include <sys/types.h> 25#include <sys/types.h>
26#include <sys/ptrace.h> 26#include <sys/ptrace.h>
27#include <machine/reg.h> 27#include <machine/reg.h>
28 28
29#include "m68k-tdep.h" 29#include "m68k-tdep.h"
30#include "inf-ptrace.h" 30#include "inf-ptrace.h"
31 31
32static int 32static int
33m68kbsd_gregset_supplies_p (int regnum) 33m68kbsd_gregset_supplies_p (int regnum)
34{ 34{
35 return (regnum >= M68K_D0_REGNUM && regnum <= M68K_PC_REGNUM); 35 return (regnum >= M68K_D0_REGNUM && regnum <= M68K_PC_REGNUM);
36} 36}
37 37
38static int 38static int
39m68kbsd_fpregset_supplies_p (int regnum) 39m68kbsd_fpregset_supplies_p (int regnum)
40{ 40{
41 return (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM); 41 return (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM);
42} 42}
43 43
44/* Supply the general-purpose registers stored in GREGS to REGCACHE. */ 44/* Supply the general-purpose registers stored in GREGS to REGCACHE. */
45 45
46static void 46static void
47m68kbsd_supply_gregset (struct regcache *regcache, const void *gregs) 47m68kbsd_supply_gregset (struct regcache *regcache, const void *gregs)
48{ 48{
49 const char *regs = (const char *)gregs; 49 const char *regs = (const char *)gregs;
50 int regnum; 50 int regnum;
51 51
52 for (regnum = M68K_D0_REGNUM; regnum <= M68K_PC_REGNUM; regnum++) 52 for (regnum = M68K_D0_REGNUM; regnum <= M68K_PC_REGNUM; regnum++)
53 regcache_raw_supply (regcache, regnum, regs + regnum * 4); 53 regcache_raw_supply (regcache, regnum, regs + regnum * 4);
54} 54}
55 55
56/* Supply the floating-point registers stored in FPREGS to REGCACHE. */ 56/* Supply the floating-point registers stored in FPREGS to REGCACHE. */
57 57
58static void 58static void
59m68kbsd_supply_fpregset (struct regcache *regcache, const void *fpregs) 59m68kbsd_supply_fpregset (struct regcache *regcache, const void *fpregs)
60{ 60{
61 struct gdbarch *gdbarch = get_regcache_arch (regcache); 61 struct gdbarch *gdbarch = get_regcache_arch (regcache);
62 const char *regs = (const char *)fpregs; 62 const char *regs = (const char *)fpregs;
63 int regnum; 63 int regnum;
64 64
65 for (regnum = M68K_FP0_REGNUM; regnum <= M68K_FPI_REGNUM; regnum++) 65 for (regnum = M68K_FP0_REGNUM; regnum <= M68K_FPI_REGNUM; regnum++)
66 regcache_raw_supply (regcache, regnum, 66 regcache_raw_supply (regcache, regnum,
67 regs + m68kbsd_fpreg_offset (gdbarch, regnum)); 67 regs + m68kbsd_fpreg_offset (gdbarch, regnum));
68} 68}
69 69
70/* Collect the general-purpose registers from REGCACHE and store them 70/* Collect the general-purpose registers from REGCACHE and store them
71 in GREGS. */ 71 in GREGS. */
72 72
73static void 73static void
74m68kbsd_collect_gregset (const struct regcache *regcache, 74m68kbsd_collect_gregset (const struct regcache *regcache,
75 void *gregs, int regnum) 75 void *gregs, int regnum)
76{ 76{
77 char *regs = (char *)gregs; 77 char *regs = (char *)gregs;
78 int i; 78 int i;
79 79
80 for (i = M68K_D0_REGNUM; i <= M68K_PC_REGNUM; i++) 80 for (i = M68K_D0_REGNUM; i <= M68K_PC_REGNUM; i++)
81 { 81 {
82 if (regnum == -1 || regnum == i) 82 if (regnum == -1 || regnum == i)
83 regcache_raw_collect (regcache, i, regs + i * 4); 83 regcache_raw_collect (regcache, i, regs + i * 4);
84 } 84 }
85} 85}
86 86
87/* Collect the floating-point registers from REGCACHE and store them 87/* Collect the floating-point registers from REGCACHE and store them
88 in FPREGS. */ 88 in FPREGS. */
89 89
90static void 90static void
91m68kbsd_collect_fpregset (struct regcache *regcache, 91m68kbsd_collect_fpregset (struct regcache *regcache,
92 void *fpregs, int regnum) 92 void *fpregs, int regnum)
93{ 93{
94 struct gdbarch *gdbarch = get_regcache_arch (regcache); 94 struct gdbarch *gdbarch = get_regcache_arch (regcache);
95 char *regs = (char *)fpregs; 95 char *regs = (char *)fpregs;
96 int i; 96 int i;
97 97
98 for (i = M68K_FP0_REGNUM; i <= M68K_FPI_REGNUM; i++) 98 for (i = M68K_FP0_REGNUM; i <= M68K_FPI_REGNUM; i++)
99 { 99 {
100 if (regnum == -1 || regnum == i) 100 if (regnum == -1 || regnum == i)
101 regcache_raw_collect (regcache, i, 101 regcache_raw_collect (regcache, i,
102 regs + m68kbsd_fpreg_offset (gdbarch, i)); 102 regs + m68kbsd_fpreg_offset (gdbarch, i));
103 } 103 }
104} 104}
105  105
106 106
107/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this 107/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
108 for all registers (including the floating-point registers). */ 108 for all registers (including the floating-point registers). */
109 109
110static void 110static void
111m68kbsd_fetch_inferior_registers (struct target_ops *ops, 111m68kbsd_fetch_inferior_registers (struct target_ops *ops,
112 struct regcache *regcache, int regnum) 112 struct regcache *regcache, int regnum)
113{ 113{
114 pid_t pid = ptid_get_pid (regcache_get_ptid (regcache)); 114 pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
115 115
116 if (regnum == -1 || m68kbsd_gregset_supplies_p (regnum)) 116 if (regnum == -1 || m68kbsd_gregset_supplies_p (regnum))
117 { 117 {
118 struct reg regs; 118 struct reg regs;
119 119
120 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1) 120 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
121 perror_with_name (_("Couldn't get registers")); 121 perror_with_name (_("Couldn't get registers"));
122 122
123 m68kbsd_supply_gregset (regcache, &regs); 123 m68kbsd_supply_gregset (regcache, &regs);
124 } 124 }
125 125
126 if (regnum == -1 || m68kbsd_fpregset_supplies_p (regnum)) 126 if (regnum == -1 || m68kbsd_fpregset_supplies_p (regnum))
127 { 127 {
128 struct fpreg fpregs; 128 struct fpreg fpregs;
129 129
130 if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 130 if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
131 perror_with_name (_("Couldn't get floating point status")); 131 perror_with_name (_("Couldn't get floating point status"));
132 132
133 m68kbsd_supply_fpregset (regcache, &fpregs); 133 m68kbsd_supply_fpregset (regcache, &fpregs);
134 } 134 }
135} 135}
136 136
137/* Store register REGNUM back into the inferior. If REGNUM is -1, do 137/* Store register REGNUM back into the inferior. If REGNUM is -1, do
138 this for all registers (including the floating-point registers). */ 138 this for all registers (including the floating-point registers). */
139 139
140static void 140static void
141m68kbsd_store_inferior_registers (struct target_ops *ops, 141m68kbsd_store_inferior_registers (struct target_ops *ops,
142 struct regcache *regcache, int regnum) 142 struct regcache *regcache, int regnum)
143{ 143{
144 pid_t pid = ptid_get_pid (regcache_get_ptid (regcache)); 144 pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
145 145
146 if (regnum == -1 || m68kbsd_gregset_supplies_p (regnum)) 146 if (regnum == -1 || m68kbsd_gregset_supplies_p (regnum))
147 { 147 {
148 struct reg regs; 148 struct reg regs;
149 149
150 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1) 150 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
151 perror_with_name (_("Couldn't get registers")); 151 perror_with_name (_("Couldn't get registers"));
152 152
153 m68kbsd_collect_gregset (regcache, &regs, regnum); 153 m68kbsd_collect_gregset (regcache, &regs, regnum);
154 154
155 if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1) 155 if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
156 perror_with_name (_("Couldn't write registers")); 156 perror_with_name (_("Couldn't write registers"));
157 } 157 }
158 158
159 if (regnum == -1 || m68kbsd_fpregset_supplies_p (regnum)) 159 if (regnum == -1 || m68kbsd_fpregset_supplies_p (regnum))
160 { 160 {
161 struct fpreg fpregs; 161 struct fpreg fpregs;
162 162
163 if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 163 if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
164 perror_with_name (_("Couldn't get floating point status")); 164 perror_with_name (_("Couldn't get floating point status"));
165 165
166 m68kbsd_collect_fpregset (regcache, &fpregs, regnum); 166 m68kbsd_collect_fpregset (regcache, &fpregs, regnum);
167 167
168 if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) 168 if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, ptid_get_lwp (inferior_ptid)) == -1)
169 perror_with_name (_("Couldn't write floating point status")); 169 perror_with_name (_("Couldn't write floating point status"));
170 } 170 }
171} 171}
172  172
173 173
174/* Support for debugging kernel virtual memory images. */ 174/* Support for debugging kernel virtual memory images. */
175 175
176#include <machine/pcb.h> 176#include <machine/pcb.h>
177 177
178#include "bsd-kvm.h" 178#include "bsd-kvm.h"
179 179
180/* OpenBSD doesn't have these. */ 180/* OpenBSD doesn't have these. */
181#ifndef PCB_REGS_FP 181#ifndef PCB_REGS_FP
182#define PCB_REGS_FP 10 182#define PCB_REGS_FP 10
183#endif 183#endif
184#ifndef PCB_REGS_SP 184#ifndef PCB_REGS_SP
185#define PCB_REGS_SP 11 185#define PCB_REGS_SP 11
186#endif 186#endif
187 187
188static int 188static int
189m68kbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) 189m68kbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
190{ 190{
191 int regnum, tmp; 191 int regnum, tmp;
192 int i = 0; 192 int i = 0;
193 193
194 /* The following is true for NetBSD 1.6.2: 194 /* The following is true for NetBSD 1.6.2:
195 195
196 The pcb contains %d2...%d7, %a2...%a7 and %ps. This accounts for 196 The pcb contains %d2...%d7, %a2...%a7 and %ps. This accounts for
197 all callee-saved registers. From this information we reconstruct 197 all callee-saved registers. From this information we reconstruct
198 the register state as it would look when we just returned from 198 the register state as it would look when we just returned from
199 cpu_switch(). */ 199 cpu_switch(). */
200 200
201 /* The stack pointer shouldn't be zero. */ 201 /* The stack pointer shouldn't be zero. */
202 if (pcb->pcb_regs[PCB_REGS_SP] == 0) 202 if (pcb->pcb_regs[PCB_REGS_SP] == 0)
203 return 0; 203 return 0;
204 204
205 for (regnum = M68K_D2_REGNUM; regnum <= M68K_D7_REGNUM; regnum++) 205 for (regnum = M68K_D2_REGNUM; regnum <= M68K_D7_REGNUM; regnum++)
206 regcache_raw_supply (regcache, regnum, &pcb->pcb_regs[i++]); 206 regcache_raw_supply (regcache, regnum, &pcb->pcb_regs[i++]);
207 for (regnum = M68K_A2_REGNUM; regnum <= M68K_SP_REGNUM; regnum++) 207 for (regnum = M68K_A2_REGNUM; regnum <= M68K_SP_REGNUM; regnum++)
208 regcache_raw_supply (regcache, regnum, &pcb->pcb_regs[i++]); 208 regcache_raw_supply (regcache, regnum, &pcb->pcb_regs[i++]);
209 209
210 tmp = pcb->pcb_ps & 0xffff; 210 tmp = pcb->pcb_ps & 0xffff;
211 regcache_raw_supply (regcache, M68K_PS_REGNUM, &tmp); 211 regcache_raw_supply (regcache, M68K_PS_REGNUM, &tmp);
212 212
213 read_memory (pcb->pcb_regs[PCB_REGS_FP] + 4, (gdb_byte *) &tmp, sizeof tmp); 213 read_memory (pcb->pcb_regs[PCB_REGS_FP] + 4, (gdb_byte *) &tmp, sizeof tmp);
214 regcache_raw_supply (regcache, M68K_PC_REGNUM, &tmp); 214 regcache_raw_supply (regcache, M68K_PC_REGNUM, &tmp);
215 215
216 return 1; 216 return 1;
217} 217}
218  218
219 219
220/* Provide a prototype to silence -Wmissing-prototypes. */ 220/* Provide a prototype to silence -Wmissing-prototypes. */
221void _initialize_m68kbsd_nat (void); 221void _initialize_m68kbsd_nat (void);
222 222
223void 223void
224_initialize_m68kbsd_nat (void) 224_initialize_m68kbsd_nat (void)
225{ 225{
226 struct target_ops *t; 226 struct target_ops *t;
227 227
228 t = inf_ptrace_target (); 228 t = inf_ptrace_target ();
229 t->to_fetch_registers = m68kbsd_fetch_inferior_registers; 229 t->to_fetch_registers = m68kbsd_fetch_inferior_registers;
230 t->to_store_registers = m68kbsd_store_inferior_registers; 230 t->to_store_registers = m68kbsd_store_inferior_registers;
231 add_target (t); 231 add_target (t);
232 232
233 /* Support debugging kernel virtual memory images. */ 233 /* Support debugging kernel virtual memory images. */
234 bsd_kvm_add_target (m68kbsd_supply_pcb); 234 bsd_kvm_add_target (m68kbsd_supply_pcb);
235} 235}

cvs diff -r1.3 -r1.4 src/external/gpl3/gdb/dist/gdb/vax-bsd-nat.c (switch to unified diff)

--- src/external/gpl3/gdb/dist/gdb/vax-bsd-nat.c 2017/11/29 21:35:26 1.3
+++ src/external/gpl3/gdb/dist/gdb/vax-bsd-nat.c 2017/11/30 00:13:29 1.4
@@ -1,148 +1,148 @@ @@ -1,148 +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#ifndef _KERNTYPES
21#define _KERNTYPES 21#define _KERNTYPES
22#endif 22#endif
23#include "defs.h" 23#include "defs.h"
24#include "inferior.h" 24#include "inferior.h"
25#include "regcache.h" 25#include "regcache.h"
26#include "target.h" 26#include "target.h"
27 27
28#include <sys/types.h> 28#include <sys/types.h>
29#include <sys/ptrace.h> 29#include <sys/ptrace.h>
30#include <machine/reg.h> 30#include <machine/reg.h>
31 31
32#include "vax-tdep.h" 32#include "vax-tdep.h"
33#include "inf-ptrace.h" 33#include "inf-ptrace.h"
34 34
35/* Supply the general-purpose registers stored in GREGS to REGCACHE. */ 35/* Supply the general-purpose registers stored in GREGS to REGCACHE. */
36 36
37static void 37static void
38vaxbsd_supply_gregset (struct regcache *regcache, const void *gregs) 38vaxbsd_supply_gregset (struct regcache *regcache, const void *gregs)
39{ 39{
40 const gdb_byte *regs = (const gdb_byte *)gregs; 40 const gdb_byte *regs = (const gdb_byte *)gregs;
41 int regnum; 41 int regnum;
42 42
43 for (regnum = 0; regnum < VAX_NUM_REGS; regnum++) 43 for (regnum = 0; regnum < VAX_NUM_REGS; regnum++)
44 regcache_raw_supply (regcache, regnum, regs + regnum * 4); 44 regcache_raw_supply (regcache, regnum, regs + regnum * 4);
45} 45}
46 46
47/* Collect the general-purpose registers from REGCACHE and store them 47/* Collect the general-purpose registers from REGCACHE and store them
48 in GREGS. */ 48 in GREGS. */
49 49
50static void 50static void
51vaxbsd_collect_gregset (const struct regcache *regcache, 51vaxbsd_collect_gregset (const struct regcache *regcache,
52 void *gregs, int regnum) 52 void *gregs, int regnum)
53{ 53{
54 gdb_byte *regs = (gdb_byte *)gregs; 54 gdb_byte *regs = (gdb_byte *)gregs;
55 int i; 55 int i;
56 56
57 for (i = 0; i <= VAX_NUM_REGS; i++) 57 for (i = 0; i <= VAX_NUM_REGS; i++)
58 { 58 {
59 if (regnum == -1 || regnum == i) 59 if (regnum == -1 || regnum == i)
60 regcache_raw_collect (regcache, i, regs + i * 4); 60 regcache_raw_collect (regcache, i, regs + i * 4);
61 } 61 }
62} 62}
63  63
64 64
65/* 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
66 for all registers. */ 66 for all registers. */
67 67
68static void 68static void
69vaxbsd_fetch_inferior_registers (struct target_ops *ops, 69vaxbsd_fetch_inferior_registers (struct target_ops *ops,
70 struct regcache *regcache, int regnum) 70 struct regcache *regcache, int regnum)
71{ 71{
72 struct reg regs; 72 struct reg regs;
73 pid_t pid = ptid_get_pid (regcache_get_ptid (regcache)); 73 pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
74 74
75 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1) 75 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
76 perror_with_name (_("Couldn't get registers")); 76 perror_with_name (_("Couldn't get registers"));
77 77
78 vaxbsd_supply_gregset (regcache, &regs); 78 vaxbsd_supply_gregset (regcache, &regs);
79} 79}
80 80
81/* 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
82 this for all registers. */ 82 this for all registers. */
83 83
84static void 84static void
85vaxbsd_store_inferior_registers (struct target_ops *ops, 85vaxbsd_store_inferior_registers (struct target_ops *ops,
86 struct regcache *regcache, int regnum) 86 struct regcache *regcache, int regnum)
87{ 87{
88 struct reg regs; 88 struct reg regs;
89 pid_t pid = ptid_get_pid (regcache_get_ptid (regcache)); 89 pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
90 90
91 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1) 91 if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
92 perror_with_name (_("Couldn't get registers")); 92 perror_with_name (_("Couldn't get registers"));
93 93
94 vaxbsd_collect_gregset (regcache, &regs, regnum); 94 vaxbsd_collect_gregset (regcache, &regs, regnum);
95 95
96 if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1) 96 if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, ptid_get_lwp (inferior_ptid)) == -1)
97 perror_with_name (_("Couldn't write registers")); 97 perror_with_name (_("Couldn't write registers"));
98} 98}
99  99
100 100
101/* Support for debugging kernel virtual memory images. */ 101/* Support for debugging kernel virtual memory images. */
102 102
103#include <machine/pcb.h> 103#include <machine/pcb.h>
104 104
105#include "bsd-kvm.h" 105#include "bsd-kvm.h"
106 106
107static int 107static int
108vaxbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) 108vaxbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
109{ 109{
110 int regnum; 110 int regnum;
111 111
112 /* The following is true for OpenBSD 3.5: 112 /* The following is true for OpenBSD 3.5:
113 113
114 The pcb contains the register state at the context switch inside 114 The pcb contains the register state at the context switch inside
115 cpu_switch(). */ 115 cpu_switch(). */
116 116
117 /* The stack pointer shouldn't be zero. */ 117 /* The stack pointer shouldn't be zero. */
118 if (pcb->KSP == 0) 118 if (pcb->KSP == 0)
119 return 0; 119 return 0;
120 120
121 for (regnum = VAX_R0_REGNUM; regnum < VAX_AP_REGNUM; regnum++) 121 for (regnum = VAX_R0_REGNUM; regnum < VAX_AP_REGNUM; regnum++)
122 regcache_raw_supply (regcache, regnum, &pcb->R[regnum - VAX_R0_REGNUM]); 122 regcache_raw_supply (regcache, regnum, &pcb->R[regnum - VAX_R0_REGNUM]);
123 regcache_raw_supply (regcache, VAX_AP_REGNUM, &pcb->AP); 123 regcache_raw_supply (regcache, VAX_AP_REGNUM, &pcb->AP);
124 regcache_raw_supply (regcache, VAX_FP_REGNUM, &pcb->FP); 124 regcache_raw_supply (regcache, VAX_FP_REGNUM, &pcb->FP);
125 regcache_raw_supply (regcache, VAX_SP_REGNUM, &pcb->KSP); 125 regcache_raw_supply (regcache, VAX_SP_REGNUM, &pcb->KSP);
126 regcache_raw_supply (regcache, VAX_PC_REGNUM, &pcb->PC); 126 regcache_raw_supply (regcache, VAX_PC_REGNUM, &pcb->PC);
127 regcache_raw_supply (regcache, VAX_PS_REGNUM, &pcb->PSL); 127 regcache_raw_supply (regcache, VAX_PS_REGNUM, &pcb->PSL);
128 128
129 return 1; 129 return 1;
130} 130}
131  131
132 132
133/* Provide a prototype to silence -Wmissing-prototypes. */ 133/* Provide a prototype to silence -Wmissing-prototypes. */
134void _initialize_vaxbsd_nat (void); 134void _initialize_vaxbsd_nat (void);
135 135
136void 136void
137_initialize_vaxbsd_nat (void) 137_initialize_vaxbsd_nat (void)
138{ 138{
139 struct target_ops *t; 139 struct target_ops *t;
140 140
141 t = inf_ptrace_target (); 141 t = inf_ptrace_target ();
142 t->to_fetch_registers = vaxbsd_fetch_inferior_registers; 142 t->to_fetch_registers = vaxbsd_fetch_inferior_registers;
143 t->to_store_registers = vaxbsd_store_inferior_registers; 143 t->to_store_registers = vaxbsd_store_inferior_registers;
144 add_target (t); 144 add_target (t);
145 145
146 /* Support debugging kernel virtual memory images. */ 146 /* Support debugging kernel virtual memory images. */
147 bsd_kvm_add_target (vaxbsd_supply_pcb); 147 bsd_kvm_add_target (vaxbsd_supply_pcb);
148} 148}