Link Here
|
|
|
1 |
diff --git a/gdb/Makefile.in b/gdb/Makefile.in |
2 |
index ea27cf5..d17752f 100644 |
3 |
--- gdb/Makefile.in |
4 |
+++ gdb/Makefile.in |
5 |
@@ -668,6 +668,7 @@ ALL_TARGET_OBS = \ |
6 |
xtensa-config.o xtensa-tdep.o xtensa-linux-tdep.o \ |
7 |
glibc-tdep.o \ |
8 |
bsd-uthread.o \ |
9 |
+ fbsd-threads.o \ |
10 |
nbsd-tdep.o obsd-tdep.o \ |
11 |
sol2-tdep.o \ |
12 |
solib-frv.o solib-irix.o solib-svr4.o \ |
13 |
@@ -1327,7 +1328,7 @@ libgdb.a: $(LIBGDB_OBS) |
14 |
# Removing the old gdb first works better if it is running, at least on SunOS. |
15 |
gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS) |
16 |
rm -f gdb$(EXEEXT) |
17 |
- $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \ |
18 |
+ $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) -Wl,-E \ |
19 |
-o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) \ |
20 |
$(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES) |
21 |
|
22 |
@@ -1600,7 +1601,7 @@ ALLDEPFILES = \ |
23 |
armnbsd-nat.c armbsd-tdep.c armnbsd-tdep.c armobsd-tdep.c \ |
24 |
avr-tdep.c \ |
25 |
bfin-linux-tdep.c bfin-tdep.c \ |
26 |
- bsd-uthread.c bsd-kvm.c \ |
27 |
+ bsd-uthread.c fbsd-threads.c bsd-kvm.c \ |
28 |
core-regset.c \ |
29 |
dcache.c dicos-tdep.c darwin-nat.c \ |
30 |
exec.c \ |
31 |
diff --git a/gdb/amd64bsd-nat.c b/gdb/amd64bsd-nat.c |
32 |
index 9e6a0df..7aff6f0 100644 |
33 |
--- gdb/amd64bsd-nat.c |
34 |
+++ gdb/amd64bsd-nat.c |
35 |
@@ -41,6 +41,19 @@ |
36 |
size_t x86_xsave_len; |
37 |
#endif |
38 |
|
39 |
+static pid_t |
40 |
+ptrace_pid (ptid_t ptid) |
41 |
+{ |
42 |
+ pid_t pid; |
43 |
+ |
44 |
+#ifdef __FreeBSD__ |
45 |
+ pid = ptid_get_lwp (ptid); |
46 |
+ if (pid == 0) |
47 |
+#endif |
48 |
+ pid = ptid_get_pid (ptid); |
49 |
+ return pid; |
50 |
+} |
51 |
+ |
52 |
/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this |
53 |
for all registers (including the floating-point registers). */ |
54 |
|
55 |
@@ -54,7 +67,7 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops, |
56 |
{ |
57 |
struct reg regs; |
58 |
|
59 |
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), |
60 |
+ if (ptrace (PT_GETREGS, ptrace_pid (inferior_ptid), |
61 |
(PTRACE_TYPE_ARG3) ®s, 0) == -1) |
62 |
perror_with_name (_("Couldn't get registers")); |
63 |
|
64 |
@@ -72,7 +85,7 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops, |
65 |
if (x86_xsave_len != 0) |
66 |
{ |
67 |
xstateregs = alloca(x86_xsave_len); |
68 |
- if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid), |
69 |
+ if (ptrace (PT_GETXSTATE, ptrace_pid (inferior_ptid), |
70 |
(PTRACE_TYPE_ARG3) xstateregs, 0) == -1) |
71 |
perror_with_name (_("Couldn't get extended state status")); |
72 |
|
73 |
@@ -81,7 +94,7 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops, |
74 |
} |
75 |
#endif |
76 |
|
77 |
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid), |
78 |
+ if (ptrace (PT_GETFPREGS, ptrace_pid (inferior_ptid), |
79 |
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1) |
80 |
perror_with_name (_("Couldn't get floating point status")); |
81 |
|
82 |
@@ -104,11 +117,11 @@ amd64bsd_store_inferior_registers (struct target_ops *ops, |
83 |
|
84 |
memset( ®s, 0, sizeof(struct reg)); |
85 |
memset( &oldregs, 0, sizeof(struct reg)); |
86 |
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), |
87 |
+ if (ptrace (PT_GETREGS, ptrace_pid (inferior_ptid), |
88 |
(PTRACE_TYPE_ARG3) ®s, 0) == -1) |
89 |
perror_with_name (_("Couldn't get registers")); |
90 |
|
91 |
- ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), |
92 |
+ ptrace (PT_GETREGS, ptrace_pid (inferior_ptid), |
93 |
(PTRACE_TYPE_ARG3) &oldregs, 0); |
94 |
amd64_collect_native_gregset (regcache, ®s, regnum); |
95 |
|
96 |
@@ -118,7 +131,7 @@ amd64bsd_store_inferior_registers (struct target_ops *ops, |
97 |
regs.r_rflags ^= (regs.r_rflags ^ oldregs.r_rflags ) & ~PSL_USERCHANGE; |
98 |
//printf(" allowed regs.r_rflags = 0x%8.8X\n", regs.r_rflags ); |
99 |
} |
100 |
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid), |
101 |
+ if (ptrace (PT_SETREGS, ptrace_pid (inferior_ptid), |
102 |
(PTRACE_TYPE_ARG3) ®s, 0) == -1) |
103 |
perror_with_name (_("Couldn't write registers")); |
104 |
|
105 |
@@ -135,26 +148,26 @@ amd64bsd_store_inferior_registers (struct target_ops *ops, |
106 |
if (x86_xsave_len != 0) |
107 |
{ |
108 |
xstateregs = alloca(x86_xsave_len); |
109 |
- if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid), |
110 |
+ if (ptrace (PT_GETXSTATE, ptrace_pid (inferior_ptid), |
111 |
(PTRACE_TYPE_ARG3) xstateregs, 0) == -1) |
112 |
perror_with_name (_("Couldn't get extended state status")); |
113 |
|
114 |
amd64_collect_xsave (regcache, regnum, xstateregs, 0); |
115 |
|
116 |
- if (ptrace (PT_SETXSTATE, ptid_get_pid (inferior_ptid), |
117 |
+ if (ptrace (PT_SETXSTATE, ptrace_pid (inferior_ptid), |
118 |
(PTRACE_TYPE_ARG3) xstateregs, x86_xsave_len) == -1) |
119 |
perror_with_name (_("Couldn't write extended state status")); |
120 |
return; |
121 |
} |
122 |
#endif |
123 |
|
124 |
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid), |
125 |
+ if (ptrace (PT_GETFPREGS, ptrace_pid (inferior_ptid), |
126 |
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1) |
127 |
perror_with_name (_("Couldn't get floating point status")); |
128 |
|
129 |
amd64_collect_fxsave (regcache, regnum, &fpregs); |
130 |
|
131 |
- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid), |
132 |
+ if (ptrace (PT_SETFPREGS, ptrace_pid (inferior_ptid), |
133 |
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1) |
134 |
perror_with_name (_("Couldn't write floating point status")); |
135 |
} |
136 |
@@ -184,7 +197,7 @@ amd64bsd_dr_get (ptid_t ptid, int regnum) |
137 |
{ |
138 |
struct dbreg dbregs; |
139 |
|
140 |
- if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid), |
141 |
+ if (ptrace (PT_GETDBREGS, ptrace_pid (inferior_ptid), |
142 |
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1) |
143 |
perror_with_name (_("Couldn't read debug registers")); |
144 |
|
145 |
@@ -196,7 +209,7 @@ amd64bsd_dr_set (int regnum, unsigned long value) |
146 |
{ |
147 |
struct dbreg dbregs; |
148 |
|
149 |
- if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid), |
150 |
+ if (ptrace (PT_GETDBREGS, ptrace_pid (inferior_ptid), |
151 |
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1) |
152 |
perror_with_name (_("Couldn't get debug registers")); |
153 |
|
154 |
@@ -207,7 +220,7 @@ amd64bsd_dr_set (int regnum, unsigned long value) |
155 |
|
156 |
DBREG_DRX ((&dbregs), regnum) = value; |
157 |
|
158 |
- if (ptrace (PT_SETDBREGS, ptid_get_pid (inferior_ptid), |
159 |
+ if (ptrace (PT_SETDBREGS, ptrace_pid (inferior_ptid), |
160 |
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1) |
161 |
perror_with_name (_("Couldn't write debug registers")); |
162 |
} |
163 |
diff --git a/gdb/amd64fbsd-nat.c b/gdb/amd64fbsd-nat.c |
164 |
index eea2472..9ce6a54 100644 |
165 |
--- gdb/amd64fbsd-nat.c |
166 |
+++ gdb/amd64fbsd-nat.c |
167 |
@@ -18,6 +18,7 @@ |
168 |
along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
169 |
|
170 |
#include "defs.h" |
171 |
+#include "gregset.h" |
172 |
#include "inferior.h" |
173 |
#include "regcache.h" |
174 |
#include "target.h" |
175 |
@@ -95,6 +96,46 @@ static int amd64fbsd32_r_reg_offset[I386_NUM_GREGS] = |
176 |
}; |
177 |
|
178 |
|
179 |
+/* Transfering the registers between GDB, inferiors and core files. */ |
180 |
+ |
181 |
+/* Fill GDB's register array with the general-purpose register values |
182 |
+ in *GREGSETP. */ |
183 |
+ |
184 |
+void |
185 |
+supply_gregset (struct regcache *regcache, const gregset_t *gregsetp) |
186 |
+{ |
187 |
+ amd64_supply_native_gregset (regcache, gregsetp, -1); |
188 |
+} |
189 |
+ |
190 |
+/* Fill register REGNUM (if it is a general-purpose register) in |
191 |
+ *GREGSETPS with the value in GDB's register array. If REGNUM is -1, |
192 |
+ do this for all registers. */ |
193 |
+ |
194 |
+void |
195 |
+fill_gregset (const struct regcache *regcache, gdb_gregset_t *gregsetp, int regnum) |
196 |
+{ |
197 |
+ amd64_collect_native_gregset (regcache, gregsetp, regnum); |
198 |
+} |
199 |
+ |
200 |
+/* Fill GDB's register array with the floating-point register values |
201 |
+ in *FPREGSETP. */ |
202 |
+ |
203 |
+void |
204 |
+supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp) |
205 |
+{ |
206 |
+ amd64_supply_fxsave (regcache, -1, fpregsetp); |
207 |
+} |
208 |
+ |
209 |
+/* Fill register REGNUM (if it is a floating-point register) in |
210 |
+ *FPREGSETP with the value in GDB's register array. If REGNUM is -1, |
211 |
+ do this for all registers. */ |
212 |
+ |
213 |
+void |
214 |
+fill_fpregset (const struct regcache *regcache, gdb_fpregset_t *fpregsetp, int regnum) |
215 |
+{ |
216 |
+ amd64_collect_fxsave (regcache, regnum, fpregsetp); |
217 |
+} |
218 |
+ |
219 |
/* Support for debugging kernel virtual memory images. */ |
220 |
|
221 |
#include <machine/pcb.h> |
222 |
diff --git a/gdb/amd64fbsd-tdep.c b/gdb/amd64fbsd-tdep.c |
223 |
index 582ae50..8e07369 100644 |
224 |
--- gdb/amd64fbsd-tdep.c |
225 |
+++ gdb/amd64fbsd-tdep.c |
226 |
@@ -31,7 +31,6 @@ |
227 |
#include <string.h> |
228 |
|
229 |
#include "amd64-tdep.h" |
230 |
-#include "bsd-uthread.h" |
231 |
#include "solib-svr4.h" |
232 |
|
233 |
/* Supported register note sections. */ |
234 |
@@ -178,46 +177,6 @@ amd64fbsd_core_read_description (struct gdbarch *gdbarch, |
235 |
} |
236 |
|
237 |
static void |
238 |
-amd64fbsd_supply_uthread (struct regcache *regcache, |
239 |
- int regnum, CORE_ADDR addr) |
240 |
-{ |
241 |
- gdb_byte buf[8]; |
242 |
- int i; |
243 |
- |
244 |
- gdb_assert (regnum >= -1); |
245 |
- |
246 |
- for (i = 0; i < ARRAY_SIZE (amd64fbsd_jmp_buf_reg_offset); i++) |
247 |
- { |
248 |
- if (amd64fbsd_jmp_buf_reg_offset[i] != -1 |
249 |
- && (regnum == -1 || regnum == i)) |
250 |
- { |
251 |
- read_memory (addr + amd64fbsd_jmp_buf_reg_offset[i], buf, 8); |
252 |
- regcache_raw_supply (regcache, i, buf); |
253 |
- } |
254 |
- } |
255 |
-} |
256 |
- |
257 |
-static void |
258 |
-amd64fbsd_collect_uthread (const struct regcache *regcache, |
259 |
- int regnum, CORE_ADDR addr) |
260 |
-{ |
261 |
- gdb_byte buf[8]; |
262 |
- int i; |
263 |
- |
264 |
- gdb_assert (regnum >= -1); |
265 |
- |
266 |
- for (i = 0; i < ARRAY_SIZE (amd64fbsd_jmp_buf_reg_offset); i++) |
267 |
- { |
268 |
- if (amd64fbsd_jmp_buf_reg_offset[i] != -1 |
269 |
- && (regnum == -1 || regnum == i)) |
270 |
- { |
271 |
- regcache_raw_collect (regcache, i, buf); |
272 |
- write_memory (addr + amd64fbsd_jmp_buf_reg_offset[i], buf, 8); |
273 |
- } |
274 |
- } |
275 |
-} |
276 |
- |
277 |
-static void |
278 |
amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
279 |
{ |
280 |
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
281 |
@@ -245,10 +204,6 @@ amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
282 |
set_gdbarch_core_read_description (gdbarch, |
283 |
amd64fbsd_core_read_description); |
284 |
|
285 |
- /* FreeBSD provides a user-level threads implementation. */ |
286 |
- bsd_uthread_set_supply_uthread (gdbarch, amd64fbsd_supply_uthread); |
287 |
- bsd_uthread_set_collect_uthread (gdbarch, amd64fbsd_collect_uthread); |
288 |
- |
289 |
/* FreeBSD uses SVR4-style shared libraries. */ |
290 |
set_solib_svr4_fetch_link_map_offsets |
291 |
(gdbarch, svr4_lp64_fetch_link_map_offsets); |
292 |
diff --git a/gdb/configure.tgt b/gdb/configure.tgt |
293 |
index 01311b2..0929a25 100644 |
294 |
--- gdb/configure.tgt |
295 |
+++ gdb/configure.tgt |
296 |
@@ -189,7 +189,7 @@ i[34567]86-*-dicos*) |
297 |
i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu) |
298 |
# Target: FreeBSD/i386 |
299 |
gdb_target_obs="i386-tdep.o i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \ |
300 |
- bsd-uthread.o solib-svr4.o" |
301 |
+ fbsd-threads.o solib-svr4.o" |
302 |
;; |
303 |
i[34567]86-*-netbsd* | i[34567]86-*-knetbsd*-gnu) |
304 |
# Target: NetBSD/i386 |
305 |
@@ -415,7 +415,7 @@ nios2*-*-*) |
306 |
powerpc*-*-freebsd*) |
307 |
# Target: FreeBSD/powerpc |
308 |
gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \ |
309 |
- ppcfbsd-tdep.o solib-svr4.o \ |
310 |
+ ppcfbsd-tdep.o solib-svr4.o fbsd-threads.o \ |
311 |
ravenscar-thread.o ppc-ravenscar-thread.o" |
312 |
;; |
313 |
|
314 |
@@ -667,7 +667,7 @@ x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu) |
315 |
# Target: FreeBSD/amd64 |
316 |
gdb_target_obs="amd64-tdep.o amd64fbsd-tdep.o i386-tdep.o \ |
317 |
i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \ |
318 |
- bsd-uthread.o solib-svr4.o" |
319 |
+ fbsd-threads.o solib-svr4.o" |
320 |
;; |
321 |
x86_64-*-mingw* | x86_64-*-cygwin*) |
322 |
# Target: MingW/amd64 |
323 |
diff --git a/gdb/i386bsd-nat.c b/gdb/i386bsd-nat.c |
324 |
index c26e830..246acdd 100644 |
325 |
--- gdb/i386bsd-nat.c |
326 |
+++ gdb/i386bsd-nat.c |
327 |
@@ -89,9 +89,22 @@ size_t x86_xsave_len; |
328 |
#endif |
329 |
|
330 |
|
331 |
+static pid_t |
332 |
+ptrace_pid (ptid_t ptid) |
333 |
+{ |
334 |
+ pid_t pid; |
335 |
+ |
336 |
+#ifdef __FreeBSD__ |
337 |
+ pid = ptid_get_lwp (ptid); |
338 |
+ if (pid == 0) |
339 |
+#endif |
340 |
+ pid = ptid_get_pid (ptid); |
341 |
+ return pid; |
342 |
+} |
343 |
+ |
344 |
/* Supply the general-purpose registers in GREGS, to REGCACHE. */ |
345 |
|
346 |
-static void |
347 |
+void |
348 |
i386bsd_supply_gregset (struct regcache *regcache, const void *gregs) |
349 |
{ |
350 |
const char *regs = gregs; |
351 |
@@ -110,7 +123,7 @@ i386bsd_supply_gregset (struct regcache *regcache, const void *gregs) |
352 |
GREGS. If REGNUM is -1, collect and store all appropriate |
353 |
registers. */ |
354 |
|
355 |
-static void |
356 |
+void |
357 |
i386bsd_collect_gregset (const struct regcache *regcache, |
358 |
void *gregs, int regnum) |
359 |
{ |
360 |
@@ -140,7 +153,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops, |
361 |
{ |
362 |
struct reg regs; |
363 |
|
364 |
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), |
365 |
+ if (ptrace (PT_GETREGS, ptrace_pid (inferior_ptid), |
366 |
(PTRACE_TYPE_ARG3) ®s, 0) == -1) |
367 |
perror_with_name (_("Couldn't get registers")); |
368 |
|
369 |
@@ -162,7 +175,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops, |
370 |
char *xstateregs; |
371 |
|
372 |
xstateregs = alloca(x86_xsave_len); |
373 |
- if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid), |
374 |
+ if (ptrace (PT_GETXSTATE, ptrace_pid (inferior_ptid), |
375 |
(PTRACE_TYPE_ARG3) xstateregs, 0) == -1) |
376 |
perror_with_name (_("Couldn't get extended state status")); |
377 |
|
378 |
@@ -174,7 +187,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops, |
379 |
|
380 |
#ifdef HAVE_PT_GETXMMREGS |
381 |
if (have_ptrace_xmmregs != 0 |
382 |
- && ptrace(PT_GETXMMREGS, ptid_get_pid (inferior_ptid), |
383 |
+ && ptrace(PT_GETXMMREGS, ptrace_pid (inferior_ptid), |
384 |
(PTRACE_TYPE_ARG3) xmmregs, 0) == 0) |
385 |
{ |
386 |
have_ptrace_xmmregs = 1; |
387 |
@@ -184,7 +197,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops, |
388 |
{ |
389 |
have_ptrace_xmmregs = 0; |
390 |
#endif |
391 |
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid), |
392 |
+ if (ptrace (PT_GETFPREGS, ptrace_pid (inferior_ptid), |
393 |
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1) |
394 |
perror_with_name (_("Couldn't get floating point status")); |
395 |
|
396 |
@@ -206,13 +219,13 @@ i386bsd_store_inferior_registers (struct target_ops *ops, |
397 |
{ |
398 |
struct reg regs; |
399 |
|
400 |
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), |
401 |
+ if (ptrace (PT_GETREGS, ptrace_pid (inferior_ptid), |
402 |
(PTRACE_TYPE_ARG3) ®s, 0) == -1) |
403 |
perror_with_name (_("Couldn't get registers")); |
404 |
|
405 |
i386bsd_collect_gregset (regcache, ®s, regnum); |
406 |
|
407 |
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid), |
408 |
+ if (ptrace (PT_SETREGS, ptrace_pid (inferior_ptid), |
409 |
(PTRACE_TYPE_ARG3) ®s, 0) == -1) |
410 |
perror_with_name (_("Couldn't write registers")); |
411 |
|
412 |
@@ -233,13 +246,13 @@ i386bsd_store_inferior_registers (struct target_ops *ops, |
413 |
char *xstateregs; |
414 |
|
415 |
xstateregs = alloca(x86_xsave_len); |
416 |
- if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid), |
417 |
+ if (ptrace (PT_GETXSTATE, ptrace_pid (inferior_ptid), |
418 |
(PTRACE_TYPE_ARG3) xstateregs, 0) == -1) |
419 |
perror_with_name (_("Couldn't get extended state status")); |
420 |
|
421 |
i387_collect_xsave (regcache, -1, xstateregs, 0); |
422 |
|
423 |
- if (ptrace (PT_SETXSTATE, ptid_get_pid (inferior_ptid), |
424 |
+ if (ptrace (PT_SETXSTATE, ptrace_pid (inferior_ptid), |
425 |
(PTRACE_TYPE_ARG3) xstateregs, x86_xsave_len) == -1) |
426 |
perror_with_name (_("Couldn't write extended state status")); |
427 |
} |
428 |
@@ -247,14 +260,14 @@ i386bsd_store_inferior_registers (struct target_ops *ops, |
429 |
|
430 |
#ifdef HAVE_PT_GETXMMREGS |
431 |
if (have_ptrace_xmmregs != 0 |
432 |
- && ptrace(PT_GETXMMREGS, ptid_get_pid (inferior_ptid), |
433 |
+ && ptrace(PT_GETXMMREGS, ptrace_pid (inferior_ptid), |
434 |
(PTRACE_TYPE_ARG3) xmmregs, 0) == 0) |
435 |
{ |
436 |
have_ptrace_xmmregs = 1; |
437 |
|
438 |
i387_collect_fxsave (regcache, regnum, xmmregs); |
439 |
|
440 |
- if (ptrace (PT_SETXMMREGS, ptid_get_pid (inferior_ptid), |
441 |
+ if (ptrace (PT_SETXMMREGS, ptrace_pid (inferior_ptid), |
442 |
(PTRACE_TYPE_ARG3) xmmregs, 0) == -1) |
443 |
perror_with_name (_("Couldn't write XMM registers")); |
444 |
} |
445 |
@@ -262,13 +275,13 @@ i386bsd_store_inferior_registers (struct target_ops *ops, |
446 |
{ |
447 |
have_ptrace_xmmregs = 0; |
448 |
#endif |
449 |
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid), |
450 |
+ if (ptrace (PT_GETFPREGS, ptrace_pid (inferior_ptid), |
451 |
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1) |
452 |
perror_with_name (_("Couldn't get floating point status")); |
453 |
|
454 |
i387_collect_fsave (regcache, regnum, &fpregs); |
455 |
|
456 |
- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid), |
457 |
+ if (ptrace (PT_SETFPREGS, ptrace_pid (inferior_ptid), |
458 |
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1) |
459 |
perror_with_name (_("Couldn't write floating point status")); |
460 |
#ifdef HAVE_PT_GETXMMREGS |
461 |
@@ -307,7 +320,7 @@ i386bsd_dr_get (ptid_t ptid, int regnum) |
462 |
{ |
463 |
struct dbreg dbregs; |
464 |
|
465 |
- if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid), |
466 |
+ if (ptrace (PT_GETDBREGS, ptrace_pid (inferior_ptid), |
467 |
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1) |
468 |
perror_with_name (_("Couldn't read debug registers")); |
469 |
|
470 |
@@ -319,7 +332,7 @@ i386bsd_dr_set (int regnum, unsigned int value) |
471 |
{ |
472 |
struct dbreg dbregs; |
473 |
|
474 |
- if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid), |
475 |
+ if (ptrace (PT_GETDBREGS, ptrace_pid (inferior_ptid), |
476 |
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1) |
477 |
perror_with_name (_("Couldn't get debug registers")); |
478 |
|
479 |
@@ -330,7 +343,7 @@ i386bsd_dr_set (int regnum, unsigned int value) |
480 |
|
481 |
DBREG_DRX ((&dbregs), regnum) = value; |
482 |
|
483 |
- if (ptrace (PT_SETDBREGS, ptid_get_pid (inferior_ptid), |
484 |
+ if (ptrace (PT_SETDBREGS, ptrace_pid (inferior_ptid), |
485 |
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1) |
486 |
perror_with_name (_("Couldn't write debug registers")); |
487 |
} |
488 |
diff --git a/gdb/i386bsd-nat.h b/gdb/i386bsd-nat.h |
489 |
index 044f530..2fca773 100644 |
490 |
--- gdb/i386bsd-nat.h |
491 |
+++ gdb/i386bsd-nat.h |
492 |
@@ -38,6 +38,14 @@ extern CORE_ADDR i386bsd_dr_get_addr (int regnum); |
493 |
|
494 |
extern unsigned long i386bsd_dr_get_status (void); |
495 |
|
496 |
+/* low level i386 register functions used in i386fbsd-nat.c. */ |
497 |
+ |
498 |
+extern void i386bsd_supply_gregset (struct regcache *regcache, |
499 |
+ const void *gregs); |
500 |
+ |
501 |
+extern void i386bsd_collect_gregset (const struct regcache *regcache, |
502 |
+ void *gregs, int regnum); |
503 |
+ |
504 |
extern unsigned long i386bsd_dr_get_control (void); |
505 |
|
506 |
#endif /* i386bsd-nat.h */ |
507 |
diff --git a/gdb/i386fbsd-nat.c b/gdb/i386fbsd-nat.c |
508 |
index b9620e1..71abcdf 100644 |
509 |
--- gdb/i386fbsd-nat.c |
510 |
+++ gdb/i386fbsd-nat.c |
511 |
@@ -21,6 +21,7 @@ |
512 |
#include "inferior.h" |
513 |
#include "regcache.h" |
514 |
#include "target.h" |
515 |
+#include "gregset.h" |
516 |
|
517 |
#include <sys/types.h> |
518 |
#include <sys/ptrace.h> |
519 |
@@ -82,6 +83,49 @@ i386fbsd_resume (struct target_ops *ops, |
520 |
} |
521 |
|
522 |
|
523 |
+/* Transfering the registers between GDB, inferiors and core files. */ |
524 |
+ |
525 |
+/* Fill GDB's register array with the general-purpose register values |
526 |
+ in *GREGSETP. */ |
527 |
+ |
528 |
+void |
529 |
+supply_gregset (struct regcache *regcache, const gregset_t *gregsetp) |
530 |
+{ |
531 |
+ i386bsd_supply_gregset (regcache, gregsetp); |
532 |
+} |
533 |
+ |
534 |
+/* Fill register REGNUM (if it is a general-purpose register) in |
535 |
+ *GREGSETPS with the value in GDB's register array. If REGNUM is -1, |
536 |
+ do this for all registers. */ |
537 |
+ |
538 |
+void |
539 |
+fill_gregset (const struct regcache *regcache, gdb_gregset_t *gregsetp, int regnum) |
540 |
+{ |
541 |
+ i386bsd_collect_gregset (regcache, gregsetp, regnum); |
542 |
+} |
543 |
+ |
544 |
+#include "i387-tdep.h" |
545 |
+ |
546 |
+/* Fill GDB's register array with the floating-point register values |
547 |
+ in *FPREGSETP. */ |
548 |
+ |
549 |
+void |
550 |
+supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp) |
551 |
+{ |
552 |
+ i387_supply_fsave (regcache, -1, fpregsetp); |
553 |
+} |
554 |
+ |
555 |
+/* Fill register REGNUM (if it is a floating-point register) in |
556 |
+ *FPREGSETP with the value in GDB's register array. If REGNUM is -1, |
557 |
+ do this for all registers. */ |
558 |
+ |
559 |
+void |
560 |
+fill_fpregset (const struct regcache *regcache, gdb_fpregset_t *fpregsetp, int regnum) |
561 |
+{ |
562 |
+ i387_collect_fsave (regcache, regnum, fpregsetp); |
563 |
+} |
564 |
+ |
565 |
+ |
566 |
/* Support for debugging kernel virtual memory images. */ |
567 |
|
568 |
#include <machine/pcb.h> |
569 |
diff --git a/gdb/i386fbsd-tdep.c b/gdb/i386fbsd-tdep.c |
570 |
index 8f7109f..fcb85d8 100644 |
571 |
--- gdb/i386fbsd-tdep.c |
572 |
+++ gdb/i386fbsd-tdep.c |
573 |
@@ -30,7 +30,6 @@ |
574 |
|
575 |
#include "i386-tdep.h" |
576 |
#include "i387-tdep.h" |
577 |
-#include "bsd-uthread.h" |
578 |
#include "solib-svr4.h" |
579 |
|
580 |
/* FreeBSD 3.0-RELEASE or later. */ |
581 |
@@ -153,46 +152,6 @@ i386fbsd_core_read_description (struct gdbarch *gdbarch, |
582 |
} |
583 |
|
584 |
static void |
585 |
-i386fbsd_supply_uthread (struct regcache *regcache, |
586 |
- int regnum, CORE_ADDR addr) |
587 |
-{ |
588 |
- gdb_byte buf[4]; |
589 |
- int i; |
590 |
- |
591 |
- gdb_assert (regnum >= -1); |
592 |
- |
593 |
- for (i = 0; i < ARRAY_SIZE (i386fbsd_jmp_buf_reg_offset); i++) |
594 |
- { |
595 |
- if (i386fbsd_jmp_buf_reg_offset[i] != -1 |
596 |
- && (regnum == -1 || regnum == i)) |
597 |
- { |
598 |
- read_memory (addr + i386fbsd_jmp_buf_reg_offset[i], buf, 4); |
599 |
- regcache_raw_supply (regcache, i, buf); |
600 |
- } |
601 |
- } |
602 |
-} |
603 |
- |
604 |
-static void |
605 |
-i386fbsd_collect_uthread (const struct regcache *regcache, |
606 |
- int regnum, CORE_ADDR addr) |
607 |
-{ |
608 |
- gdb_byte buf[4]; |
609 |
- int i; |
610 |
- |
611 |
- gdb_assert (regnum >= -1); |
612 |
- |
613 |
- for (i = 0; i < ARRAY_SIZE (i386fbsd_jmp_buf_reg_offset); i++) |
614 |
- { |
615 |
- if (i386fbsd_jmp_buf_reg_offset[i] != -1 |
616 |
- && (regnum == -1 || regnum == i)) |
617 |
- { |
618 |
- regcache_raw_collect (regcache, i, buf); |
619 |
- write_memory (addr + i386fbsd_jmp_buf_reg_offset[i], buf, 4); |
620 |
- } |
621 |
- } |
622 |
-} |
623 |
- |
624 |
-static void |
625 |
i386fbsdaout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
626 |
{ |
627 |
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
628 |
@@ -217,10 +176,6 @@ i386fbsdaout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
629 |
/* FreeBSD has a more complete `struct sigcontext'. */ |
630 |
tdep->sc_reg_offset = i386fbsd_sc_reg_offset; |
631 |
tdep->sc_num_regs = ARRAY_SIZE (i386fbsd_sc_reg_offset); |
632 |
- |
633 |
- /* FreeBSD provides a user-level threads implementation. */ |
634 |
- bsd_uthread_set_supply_uthread (gdbarch, i386fbsd_supply_uthread); |
635 |
- bsd_uthread_set_collect_uthread (gdbarch, i386fbsd_collect_uthread); |
636 |
} |
637 |
|
638 |
static void |
639 |
diff --git a/gdb/ppcfbsd-nat.c b/gdb/ppcfbsd-nat.c |
640 |
index 079bd12..74922f2 100644 |
641 |
--- gdb/ppcfbsd-nat.c |
642 |
+++ gdb/ppcfbsd-nat.c |
643 |
@@ -39,6 +39,19 @@ |
644 |
#include "inf-ptrace.h" |
645 |
#include "bsd-kvm.h" |
646 |
|
647 |
+static pid_t |
648 |
+ptrace_pid (ptid_t ptid) |
649 |
+{ |
650 |
+ pid_t pid; |
651 |
+ |
652 |
+#ifdef __FreeBSD__ |
653 |
+ pid = ptid_get_lwp (ptid); |
654 |
+ if (pid == 0) |
655 |
+#endif |
656 |
+ pid = ptid_get_pid (ptid); |
657 |
+ return pid; |
658 |
+} |
659 |
+ |
660 |
/* Fill GDB's register array with the general-purpose register values |
661 |
in *GREGSETP. */ |
662 |
|
663 |
@@ -123,7 +136,7 @@ ppcfbsd_fetch_inferior_registers (struct target_ops *ops, |
664 |
{ |
665 |
gdb_gregset_t regs; |
666 |
|
667 |
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), |
668 |
+ if (ptrace (PT_GETREGS, ptrace_pid (inferior_ptid), |
669 |
(PTRACE_TYPE_ARG3) ®s, 0) == -1) |
670 |
perror_with_name (_("Couldn't get registers")); |
671 |
|
672 |
@@ -134,7 +147,7 @@ ppcfbsd_fetch_inferior_registers (struct target_ops *ops, |
673 |
const struct regset *fpregset = ppc_fbsd_fpregset (); |
674 |
gdb_fpregset_t fpregs; |
675 |
|
676 |
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid), |
677 |
+ if (ptrace (PT_GETFPREGS, ptrace_pid (inferior_ptid), |
678 |
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1) |
679 |
perror_with_name (_("Couldn't get FP registers")); |
680 |
|
681 |
@@ -151,13 +164,13 @@ ppcfbsd_store_inferior_registers (struct target_ops *ops, |
682 |
{ |
683 |
gdb_gregset_t regs; |
684 |
|
685 |
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), |
686 |
+ if (ptrace (PT_GETREGS, ptrace_pid (inferior_ptid), |
687 |
(PTRACE_TYPE_ARG3) ®s, 0) == -1) |
688 |
perror_with_name (_("Couldn't get registers")); |
689 |
|
690 |
fill_gregset (regcache, ®s, regno); |
691 |
|
692 |
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid), |
693 |
+ if (ptrace (PT_SETREGS, ptrace_pid (inferior_ptid), |
694 |
(PTRACE_TYPE_ARG3) ®s, 0) == -1) |
695 |
perror_with_name (_("Couldn't write registers")); |
696 |
|
697 |
@@ -165,13 +178,13 @@ ppcfbsd_store_inferior_registers (struct target_ops *ops, |
698 |
{ |
699 |
gdb_fpregset_t fpregs; |
700 |
|
701 |
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid), |
702 |
+ if (ptrace (PT_GETFPREGS, ptrace_pid (inferior_ptid), |
703 |
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1) |
704 |
perror_with_name (_("Couldn't get FP registers")); |
705 |
|
706 |
fill_fpregset (regcache, &fpregs, regno); |
707 |
|
708 |
- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid), |
709 |
+ if (ptrace (PT_SETFPREGS, ptrace_pid (inferior_ptid), |
710 |
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1) |
711 |
perror_with_name (_("Couldn't set FP registers")); |
712 |
} |