View | Details | Raw Unified | Return to bug 215938 | Differences between
and this patch

Collapse All | Expand All

(-)devel/gdb/Makefile (-9 / +9 lines)
Lines 3-8 Link Here
3
3
4
PORTNAME=	gdb
4
PORTNAME=	gdb
5
PORTVERSION=	7.12
5
PORTVERSION=	7.12
6
PORTREVISION=	1
6
CATEGORIES=	devel
7
CATEGORIES=	devel
7
MASTER_SITES=	GNU
8
MASTER_SITES=	GNU
8
9
Lines 30-61 CFLAGS:= ${CFLAGS:C/ +$//} # blanks at EOL creep in sometimes Link Here
30
CFLAGS+=	-DRL_NO_COMPAT -Wno-unused-function -Wno-unused-variable
31
CFLAGS+=	-DRL_NO_COMPAT -Wno-unused-function -Wno-unused-variable
31
EXCLUDE=	dejagnu expect sim texinfo intl
32
EXCLUDE=	dejagnu expect sim texinfo intl
32
EXTRACT_AFTER_ARGS=	${EXCLUDE:S/^/--exclude /}
33
EXTRACT_AFTER_ARGS=	${EXCLUDE:S/^/--exclude /}
34
EXTRA_PATCHES=	${FILESDIR}/commit-387360daf9 \
35
		${FILESDIR}/commit-b268007c68
33
LIB_DEPENDS+=	libexpat.so:textproc/expat2
36
LIB_DEPENDS+=	libexpat.so:textproc/expat2
34
37
35
VER=		${PORTVERSION:S/.//g}
38
VER=		${PORTVERSION:S/.//g}
36
PLIST_SUB=	VER=${VER}
39
PLIST_SUB=	VER=${VER}
37
40
38
ONLY_FOR_ARCHS=	i386 amd64 powerpc powerpc64 armv6	# untested elsewhere, might work
41
ONLY_FOR_ARCHS=	i386 amd64 powerpc powerpc64 armv6 mips	# untested elsewhere, might work
39
42
40
OPTIONS_DEFINE=	DEBUG GDB_LINK GUILE KGDB PYTHON TUI
43
OPTIONS_DEFINE=	DEBUG GDB_LINK GUILE KGDB PYTHON TUI
41
44
42
OPTIONS_DEFAULT=	GDB_LINK KGDB PYTHON TUI PORT_READLINE
45
OPTIONS_DEFAULT=	GDB_LINK KGDB PYTHON TUI PORT_READLINE
43
46
44
OPTIONS_SINGLE=	READLINE
47
OPTIONS_SINGLE=	READLINE
45
OPTIONS_SINGLE_READLINE=	BASE_READLINE BUNDLED_READLINE PORT_READLINE
48
OPTIONS_SINGLE_READLINE=	BUNDLED_READLINE PORT_READLINE
46
49
47
GDB_LINK_DESC=		Create ${PREFIX}/bin/gdb symlink
50
GDB_LINK_DESC=		Create ${PREFIX}/bin/gdb symlink
48
KGDB_DESC=		Kernel Debugging Support
51
KGDB_DESC=		Kernel Debugging Support
49
BASE_READLINE_DESC=	from base system
50
BUNDLED_READLINE_DESC=	from gdb distfile
52
BUNDLED_READLINE_DESC=	from gdb distfile
51
PORT_READLINE_DESC=	from devel/readline port
53
PORT_READLINE_DESC=	from devel/readline port
52
TUI_DESC=		Text User Interface enabled
54
TUI_DESC=		Text User Interface enabled
53
55
54
OPTIONS_SUB=	yes
56
OPTIONS_SUB=	yes
55
57
56
BASE_READLINE_USES=	readline
57
BASE_READLINE_CFLAGS=	-D_rl_echoing_p=readline_echoing_p
58
BASE_READLINE_EXTRA_PATCHES=	${FILESDIR}/extrapatch-base-readline
59
BUNDLED_READLINE_CONFIGURE_OFF=	--with-system-readline
58
BUNDLED_READLINE_CONFIGURE_OFF=	--with-system-readline
60
DEBUG_CFLAGS=		-g
59
DEBUG_CFLAGS=		-g
61
GUILE_CONFIGURE_WITH=	guile
60
GUILE_CONFIGURE_WITH=	guile
Lines 69-77 TUI_CONFIGURE_ENABLE= tui Link Here
69
68
70
.include <bsd.port.options.mk>
69
.include <bsd.port.options.mk>
71
70
72
# The option -Wno-extended-offsetof is supported by clang only
73
CFLAGS+=	-Wno-extended-offsetof
74
75
.if ! ${PORT_OPTIONS:MBUNDLED_READLINE}
71
.if ! ${PORT_OPTIONS:MBUNDLED_READLINE}
76
EXCLUDE+=	readline
72
EXCLUDE+=	readline
77
.endif
73
.endif
Lines 80-85 EXCLUDE+= readline Link Here
80
CONFIGURE_TARGET=	x86_64-portbld-freebsd${OSREL}
76
CONFIGURE_TARGET=	x86_64-portbld-freebsd${OSREL}
81
.endif
77
.endif
82
78
79
.if ${ARCH} != "mips"
80
CFLAGS+=	-Wno-extended-offsetof
81
.endif
82
83
post-patch:
83
post-patch:
84
	@${REINPLACE_CMD} -e 's|$$| [GDB v${PORTVERSION} for FreeBSD]|' \
84
	@${REINPLACE_CMD} -e 's|$$| [GDB v${PORTVERSION} for FreeBSD]|' \
85
		${WRKSRC}/gdb/version.in
85
		${WRKSRC}/gdb/version.in
(-)devel/gdb/distinfo (-1 / +1 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1480413713
1
TIMESTAMP = 1483525133
2
SHA256 (gdb-7.12.tar.xz) = 834ff3c5948b30718343ea57b11cbc3235d7995c6a4f3a5cecec8c8114164f94
2
SHA256 (gdb-7.12.tar.xz) = 834ff3c5948b30718343ea57b11cbc3235d7995c6a4f3a5cecec8c8114164f94
3
SIZE (gdb-7.12.tar.xz) = 19219556
3
SIZE (gdb-7.12.tar.xz) = 19219556
(-)devel/gdb/files/commit-387360daf9 (+680 lines)
Added Link Here
1
commit 9978d70207d8a6bc7ff3c570814053c68e78b913
2
Author: John Baldwin <jhb@FreeBSD.org>
3
Date:   Wed Jan 4 09:41:58 2017 -0800
4
5
    Add FreeBSD/mips architecture.
6
    
7
    This has been tested for the n64 and o32 ABIs.  Signal frame unwinders for
8
    both ABIs are provided.  FreeBSD/mips requires custom linkmap offsets since
9
    it contains an additional l_off member in 'struct link_map' that other
10
    FreeBSD platforms do not have.  Support for collecting and supplying
11
    general purpose and floating point register sets are provided.  Common
12
    routines for working with native format register sets are exported for
13
    use by the native target.
14
    
15
    gdb/ChangeLog:
16
    
17
            * Makefile.in (ALL_TARGET_OBS): Add mips-fbsd-tdep.o.
18
            (ALLDEPFILES): Add mips-fbsd-tdep.c.
19
            * NEWS: Mention new FreeBSD/mips target.
20
            * configure.tgt: Add mips*-*-freebsd*.
21
            * mips-fbsd-tdep.c: New file.
22
            * mips-fbsd-tdep.h: New file.
23
    
24
    gdb/doc/ChangeLog:
25
    
26
            * gdb.texinfo (Contributors): Add SRI International and University
27
            of Cambridge for FreeBSD/mips.
28
29
diff --git gdb/Makefile.in gdb/Makefile.in
30
index 7b2df86878..300c2cb702 100644
31
--- gdb/Makefile.in
32
+++ gdb/Makefile.in
33
@@ -685,6 +685,7 @@ ALL_TARGET_OBS = \
34
 	m88k-tdep.o \
35
 	mep-tdep.o \
36
 	microblaze-tdep.o microblaze-linux-tdep.o \
37
+	mips-fbsd-tdep.o \
38
 	mips-linux-tdep.o mips-sde-tdep.o \
39
 	mipsnbsd-tdep.o mips-tdep.o \
40
 	mn10300-linux-tdep.o mn10300-tdep.o \
41
@@ -1724,6 +1725,7 @@ ALLDEPFILES = \
42
 	m88k-tdep.c m88kbsd-nat.c \
43
 	microblaze-tdep.c microblaze-linux-tdep.c \
44
 	mingw-hdep.c common/mingw-strerror.c \
45
+	mips-fbsd-tdep.c \
46
 	mips-linux-nat.c mips-linux-tdep.c \
47
 	mips-sde-tdep.c \
48
 	mips-tdep.c \
49
diff --git gdb/configure.tgt gdb/configure.tgt
50
index 7f1aac3742..9ee9f7a799 100644
51
--- gdb/configure.tgt
52
+++ gdb/configure.tgt
53
@@ -358,6 +358,11 @@ mips*-*-netbsd* | mips*-*-knetbsd*-gnu)
54
 	gdb_target_obs="mips-tdep.o mipsnbsd-tdep.o solib-svr4.o nbsd-tdep.o"
55
 	gdb_sim=../sim/mips/libsim.a
56
 	;;
57
+mips*-*-freebsd*)
58
+	# Target: MIPS running FreeBSD
59
+	gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o solib-svr4.o fbsd-tdep.o"
60
+	gdb_sim=../sim/mips/libsim.a
61
+	;;
62
 mips64*-*-openbsd*)
63
 	# Target: OpenBSD/mips64
64
 	gdb_target_obs="mips-tdep.o mips64obsd-tdep.o obsd-tdep.o solib-svr4.o"
65
diff --git gdb/doc/gdb.texinfo gdb/doc/gdb.texinfo
66
index 067a45b2de..179da5cdb3 100644
67
--- gdb/doc/gdb.texinfo
68
+++ gdb/doc/gdb.texinfo
69
@@ -541,6 +541,11 @@ Steve Tjiang, John Newlin, and Scott Foehner.
70
 Michael Eager and staff of Xilinx, Inc., contributed support for the
71
 Xilinx MicroBlaze architecture.
72
 
73
+Initial support for the FreeBSD/mips target and native configuration
74
+was developed by SRI International and the University of Cambridge
75
+Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
76
+("CTSRD"), as part of the DARPA CRASH research programme.
77
+
78
 @node Sample Session
79
 @chapter A Sample @value{GDBN} Session
80
 
81
diff --git gdb/mips-fbsd-tdep.c gdb/mips-fbsd-tdep.c
82
new file mode 100644
83
index 0000000000..733534ddac
84
--- /dev/null
85
+++ gdb/mips-fbsd-tdep.c
86
@@ -0,0 +1,560 @@
87
+/* Target-dependent code for FreeBSD/mips.
88
+
89
+   Copyright (C) 2017 Free Software Foundation, Inc.
90
+
91
+   This file is part of GDB.
92
+
93
+   This program is free software; you can redistribute it and/or modify
94
+   it under the terms of the GNU General Public License as published by
95
+   the Free Software Foundation; either version 3 of the License, or
96
+   (at your option) any later version.
97
+
98
+   This program is distributed in the hope that it will be useful,
99
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
100
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
101
+   GNU General Public License for more details.
102
+
103
+   You should have received a copy of the GNU General Public License
104
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
105
+
106
+#include "defs.h"
107
+#include "osabi.h"
108
+#include "regset.h"
109
+#include "trad-frame.h"
110
+#include "tramp-frame.h"
111
+
112
+#include "fbsd-tdep.h"
113
+#include "mips-tdep.h"
114
+#include "mips-fbsd-tdep.h"
115
+
116
+#include "solib-svr4.h"
117
+
118
+/* Shorthand for some register numbers used below.  */
119
+#define MIPS_PC_REGNUM  MIPS_EMBED_PC_REGNUM
120
+#define MIPS_FP0_REGNUM MIPS_EMBED_FP0_REGNUM
121
+#define MIPS_FSR_REGNUM MIPS_EMBED_FP0_REGNUM + 32
122
+
123
+/* Core file support. */
124
+
125
+/* Number of registers in `struct reg' from <machine/reg.h>.  The
126
+   first 38 follow the standard MIPS layout.  The 39th holds
127
+   IC_INT_REG on RM7K and RM9K processors.  The 40th is a dummy for
128
+   padding.  */
129
+#define MIPS_FBSD_NUM_GREGS	40
130
+
131
+/* Number of registers in `struct fpreg' from <machine/reg.h>.  The
132
+   first 32 hold floating point registers.  33 holds the FSR.  The
133
+   34th is a dummy for padding.  */
134
+#define MIPS_FBSD_NUM_FPREGS	34
135
+
136
+/* Supply a single register.  If the source register size matches the
137
+   size the regcache expects, this can use regcache_raw_supply().  If
138
+   they are different, this copies the source register into a buffer
139
+   that can be passed to regcache_raw_supply().  */
140
+
141
+static void
142
+mips_fbsd_supply_reg (struct regcache *regcache, int regnum, const void *addr,
143
+		      size_t len)
144
+{
145
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
146
+
147
+  if (register_size (gdbarch, regnum) == len)
148
+    regcache_raw_supply (regcache, regnum, addr);
149
+  else
150
+    {
151
+      enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
152
+      gdb_byte buf[MAX_REGISTER_SIZE];
153
+      LONGEST val;
154
+
155
+      val = extract_signed_integer ((const gdb_byte *) addr, len, byte_order);
156
+      store_signed_integer (buf, register_size (gdbarch, regnum), byte_order,
157
+			    val);
158
+      regcache_raw_supply (regcache, regnum, buf);
159
+    }
160
+}
161
+
162
+/* Collect a single register.  If the destination register size
163
+   matches the size the regcache expects, this can use
164
+   regcache_raw_supply().  If they are different, this fetches the
165
+   register via regcache_raw_supply() into a buffer and then copies it
166
+   into the final destination.  */
167
+
168
+static void
169
+mips_fbsd_collect_reg (const struct regcache *regcache, int regnum, void *addr,
170
+		       size_t len)
171
+{
172
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
173
+
174
+  if (register_size (gdbarch, regnum) == len)
175
+    regcache_raw_collect (regcache, regnum, addr);
176
+  else
177
+    {
178
+      enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
179
+      gdb_byte buf[MAX_REGISTER_SIZE];
180
+      LONGEST val;
181
+
182
+      regcache_raw_collect (regcache, regnum, buf);
183
+      val = extract_signed_integer (buf, register_size (gdbarch, regnum),
184
+				    byte_order);
185
+      store_signed_integer ((gdb_byte *) addr, len, byte_order, val);
186
+    }
187
+}
188
+
189
+/* Supply the floating-point registers stored in FPREGS to REGCACHE.
190
+   Each floating-point register in FPREGS is REGSIZE bytes in
191
+   length.  */
192
+
193
+void
194
+mips_fbsd_supply_fpregs (struct regcache *regcache, int regnum,
195
+			 const void *fpregs, size_t regsize)
196
+{
197
+  const gdb_byte *regs = (const gdb_byte *) fpregs;
198
+  int i;
199
+
200
+  for (i = MIPS_FP0_REGNUM; i <= MIPS_FSR_REGNUM; i++)
201
+    if (regnum == i || regnum == -1)
202
+      mips_fbsd_supply_reg (regcache, i,
203
+			    regs + (i - MIPS_FP0_REGNUM) * regsize, regsize);
204
+}
205
+
206
+/* Supply the general-purpose registers stored in GREGS to REGCACHE.
207
+   Each general-purpose register in GREGS is REGSIZE bytes in
208
+   length.  */
209
+
210
+void
211
+mips_fbsd_supply_gregs (struct regcache *regcache, int regnum,
212
+			const void *gregs, size_t regsize)
213
+{
214
+  const gdb_byte *regs = (const gdb_byte *) gregs;
215
+  int i;
216
+
217
+  for (i = 0; i <= MIPS_PC_REGNUM; i++)
218
+    if (regnum == i || regnum == -1)
219
+      mips_fbsd_supply_reg (regcache, i, regs + i * regsize, regsize);
220
+}
221
+
222
+/* Collect the floating-point registers from REGCACHE and store them
223
+   in FPREGS.  Each floating-point register in FPREGS is REGSIZE bytes
224
+   in length.  */
225
+
226
+void
227
+mips_fbsd_collect_fpregs (const struct regcache *regcache, int regnum,
228
+			  void *fpregs, size_t regsize)
229
+{
230
+  gdb_byte *regs = (gdb_byte *) fpregs;
231
+  int i;
232
+
233
+  for (i = MIPS_FP0_REGNUM; i <= MIPS_FSR_REGNUM; i++)
234
+    if (regnum == i || regnum == -1)
235
+      mips_fbsd_collect_reg (regcache, i,
236
+			     regs + (i - MIPS_FP0_REGNUM) * regsize, regsize);
237
+}
238
+
239
+/* Collect the general-purpose registers from REGCACHE and store them
240
+   in GREGS.  Each general-purpose register in GREGS is REGSIZE bytes
241
+   in length.  */
242
+
243
+void
244
+mips_fbsd_collect_gregs (const struct regcache *regcache, int regnum,
245
+			 void *gregs, size_t regsize)
246
+{
247
+  gdb_byte *regs = (gdb_byte *) gregs;
248
+  int i;
249
+
250
+  for (i = 0; i <= MIPS_PC_REGNUM; i++)
251
+    if (regnum == i || regnum == -1)
252
+      mips_fbsd_collect_reg (regcache, i, regs + i * regsize, regsize);
253
+}
254
+
255
+/* Supply register REGNUM from the buffer specified by FPREGS and LEN
256
+   in the floating-point register set REGSET to register cache
257
+   REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */
258
+
259
+static void
260
+mips_fbsd_supply_fpregset (const struct regset *regset,
261
+			   struct regcache *regcache,
262
+			   int regnum, const void *fpregs, size_t len)
263
+{
264
+  size_t regsize = mips_abi_regsize (get_regcache_arch (regcache));
265
+
266
+  gdb_assert (len >= MIPS_FBSD_NUM_FPREGS * regsize);
267
+
268
+  mips_fbsd_supply_fpregs (regcache, regnum, fpregs, regsize);
269
+}
270
+
271
+/* Collect register REGNUM from the register cache REGCACHE and store
272
+   it in the buffer specified by FPREGS and LEN in the floating-point
273
+   register set REGSET.  If REGNUM is -1, do this for all registers in
274
+   REGSET.  */
275
+
276
+static void
277
+mips_fbsd_collect_fpregset (const struct regset *regset,
278
+			    const struct regcache *regcache,
279
+			    int regnum, void *fpregs, size_t len)
280
+{
281
+  size_t regsize = mips_abi_regsize (get_regcache_arch (regcache));
282
+
283
+  gdb_assert (len >= MIPS_FBSD_NUM_FPREGS * regsize);
284
+
285
+  mips_fbsd_collect_fpregs (regcache, regnum, fpregs, regsize);
286
+}
287
+
288
+/* Supply register REGNUM from the buffer specified by GREGS and LEN
289
+   in the general-purpose register set REGSET to register cache
290
+   REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */
291
+
292
+static void
293
+mips_fbsd_supply_gregset (const struct regset *regset,
294
+			  struct regcache *regcache, int regnum,
295
+			  const void *gregs, size_t len)
296
+{
297
+  size_t regsize = mips_abi_regsize (get_regcache_arch (regcache));
298
+
299
+  gdb_assert (len >= MIPS_FBSD_NUM_GREGS * regsize);
300
+
301
+  mips_fbsd_supply_gregs (regcache, regnum, gregs, regsize);
302
+}
303
+
304
+/* Collect register REGNUM from the register cache REGCACHE and store
305
+   it in the buffer specified by GREGS and LEN in the general-purpose
306
+   register set REGSET.  If REGNUM is -1, do this for all registers in
307
+   REGSET.  */
308
+
309
+static void
310
+mips_fbsd_collect_gregset (const struct regset *regset,
311
+			   const struct regcache *regcache,
312
+			   int regnum, void *gregs, size_t len)
313
+{
314
+  size_t regsize = mips_abi_regsize (get_regcache_arch (regcache));
315
+
316
+  gdb_assert (len >= MIPS_FBSD_NUM_GREGS * regsize);
317
+
318
+  mips_fbsd_collect_gregs (regcache, regnum, gregs, regsize);
319
+}
320
+
321
+/* FreeBSD/mips register sets.  */
322
+
323
+static const struct regset mips_fbsd_gregset =
324
+{
325
+  NULL,
326
+  mips_fbsd_supply_gregset,
327
+  mips_fbsd_collect_gregset,
328
+};
329
+
330
+static const struct regset mips_fbsd_fpregset =
331
+{
332
+  NULL,
333
+  mips_fbsd_supply_fpregset,
334
+  mips_fbsd_collect_fpregset,
335
+};
336
+
337
+/* Iterate over core file register note sections.  */
338
+
339
+static void
340
+mips_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
341
+					iterate_over_regset_sections_cb *cb,
342
+					void *cb_data,
343
+					const struct regcache *regcache)
344
+{
345
+  size_t regsize = mips_abi_regsize (gdbarch);
346
+
347
+  cb (".reg", MIPS_FBSD_NUM_GREGS * regsize, &mips_fbsd_gregset,
348
+      NULL, cb_data);
349
+  cb (".reg2", MIPS_FBSD_NUM_FPREGS * regsize, &mips_fbsd_fpregset,
350
+      NULL, cb_data);
351
+}
352
+
353
+/* Signal trampoline support.  */
354
+
355
+#define FBSD_SYS_sigreturn	417
356
+
357
+#define MIPS_INST_LI_V0_SIGRETURN 0x24020000 + FBSD_SYS_sigreturn
358
+#define MIPS_INST_SYSCALL	0x0000000c
359
+#define MIPS_INST_BREAK		0x0000000d
360
+
361
+#define O32_SIGFRAME_UCONTEXT_OFFSET	(16)
362
+#define O32_SIGSET_T_SIZE	(16)
363
+
364
+#define O32_UCONTEXT_ONSTACK	(O32_SIGSET_T_SIZE)
365
+#define O32_UCONTEXT_PC		(O32_UCONTEXT_ONSTACK + 4)
366
+#define O32_UCONTEXT_REGS	(O32_UCONTEXT_PC + 4)
367
+#define O32_UCONTEXT_SR		(O32_UCONTEXT_REGS + 4 * 32)
368
+#define O32_UCONTEXT_LO		(O32_UCONTEXT_SR + 4)
369
+#define O32_UCONTEXT_HI		(O32_UCONTEXT_LO + 4)
370
+#define O32_UCONTEXT_FPUSED	(O32_UCONTEXT_HI + 4)
371
+#define O32_UCONTEXT_FPREGS	(O32_UCONTEXT_FPUSED + 4)
372
+
373
+#define O32_UCONTEXT_REG_SIZE	4
374
+
375
+static void
376
+mips_fbsd_sigframe_init (const struct tramp_frame *self,
377
+			 struct frame_info *this_frame,
378
+			 struct trad_frame_cache *cache,
379
+			 CORE_ADDR func)
380
+{
381
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
382
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
383
+  CORE_ADDR sp, ucontext_addr, addr;
384
+  int regnum;
385
+  gdb_byte buf[4];
386
+
387
+  /* We find the appropriate instance of `ucontext_t' at a
388
+     fixed offset in the signal frame.  */
389
+  sp = get_frame_register_signed (this_frame,
390
+				  MIPS_SP_REGNUM + gdbarch_num_regs (gdbarch));
391
+  ucontext_addr = sp + O32_SIGFRAME_UCONTEXT_OFFSET;
392
+
393
+  /* PC.  */
394
+  regnum = mips_regnum (gdbarch)->pc;
395
+  trad_frame_set_reg_addr (cache,
396
+			   regnum + gdbarch_num_regs (gdbarch),
397
+			   ucontext_addr + O32_UCONTEXT_PC);
398
+
399
+  /* GPRs.  */
400
+  for (regnum = MIPS_ZERO_REGNUM, addr = ucontext_addr + O32_UCONTEXT_REGS;
401
+       regnum <= MIPS_RA_REGNUM; regnum++, addr += O32_UCONTEXT_REG_SIZE)
402
+    trad_frame_set_reg_addr (cache,
403
+			     regnum + gdbarch_num_regs (gdbarch),
404
+			     addr);
405
+
406
+  regnum = MIPS_PS_REGNUM;
407
+  trad_frame_set_reg_addr (cache,
408
+			   regnum + gdbarch_num_regs (gdbarch),
409
+			   ucontext_addr + O32_UCONTEXT_SR);
410
+
411
+  /* HI and LO.  */
412
+  regnum = mips_regnum (gdbarch)->lo;
413
+  trad_frame_set_reg_addr (cache,
414
+			   regnum + gdbarch_num_regs (gdbarch),
415
+			   ucontext_addr + O32_UCONTEXT_LO);
416
+  regnum = mips_regnum (gdbarch)->hi;
417
+  trad_frame_set_reg_addr (cache,
418
+			   regnum + gdbarch_num_regs (gdbarch),
419
+			   ucontext_addr + O32_UCONTEXT_HI);
420
+
421
+  if (target_read_memory (ucontext_addr + O32_UCONTEXT_FPUSED, buf, 4) == 0 &&
422
+      extract_unsigned_integer (buf, 4, byte_order) != 0)
423
+    {
424
+      for (regnum = 0, addr = ucontext_addr + O32_UCONTEXT_FPREGS;
425
+	   regnum < 32; regnum++, addr += O32_UCONTEXT_REG_SIZE)
426
+	trad_frame_set_reg_addr (cache,
427
+				 regnum + gdbarch_fp0_regnum (gdbarch),
428
+				 addr);
429
+      trad_frame_set_reg_addr (cache, mips_regnum (gdbarch)->fp_control_status,
430
+			       addr);
431
+    }
432
+
433
+  trad_frame_set_id (cache, frame_id_build (sp, func));
434
+}
435
+
436
+#define MIPS_INST_ADDIU_A0_SP_O32 (0x27a40000 \
437
+				   + O32_SIGFRAME_UCONTEXT_OFFSET)
438
+
439
+static const struct tramp_frame mips_fbsd_sigframe =
440
+{
441
+  SIGTRAMP_FRAME,
442
+  MIPS_INSN32_SIZE,
443
+  {
444
+    { MIPS_INST_ADDIU_A0_SP_O32, -1 },	/* addiu   a0, sp, SIGF_UC */
445
+    { MIPS_INST_LI_V0_SIGRETURN, -1 },	/* li      v0, SYS_sigreturn */
446
+    { MIPS_INST_SYSCALL, -1 },		/* syscall */
447
+    { MIPS_INST_BREAK, -1 },		/* break */
448
+    { TRAMP_SENTINEL_INSN, -1 }
449
+  },
450
+  mips_fbsd_sigframe_init
451
+};
452
+
453
+#define N64_SIGFRAME_UCONTEXT_OFFSET	(32)
454
+#define N64_SIGSET_T_SIZE	(16)
455
+
456
+#define N64_UCONTEXT_ONSTACK	(N64_SIGSET_T_SIZE)
457
+#define N64_UCONTEXT_PC		(N64_UCONTEXT_ONSTACK + 8)
458
+#define N64_UCONTEXT_REGS	(N64_UCONTEXT_PC + 8)
459
+#define N64_UCONTEXT_SR		(N64_UCONTEXT_REGS + 8 * 32)
460
+#define N64_UCONTEXT_LO		(N64_UCONTEXT_SR + 8)
461
+#define N64_UCONTEXT_HI		(N64_UCONTEXT_LO + 8)
462
+#define N64_UCONTEXT_FPUSED	(N64_UCONTEXT_HI + 8)
463
+#define N64_UCONTEXT_FPREGS	(N64_UCONTEXT_FPUSED + 8)
464
+
465
+#define N64_UCONTEXT_REG_SIZE	8
466
+
467
+static void
468
+mips64_fbsd_sigframe_init (const struct tramp_frame *self,
469
+			   struct frame_info *this_frame,
470
+			   struct trad_frame_cache *cache,
471
+			   CORE_ADDR func)
472
+{
473
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
474
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
475
+  CORE_ADDR sp, ucontext_addr, addr;
476
+  int regnum;
477
+  gdb_byte buf[4];
478
+
479
+  /* We find the appropriate instance of `ucontext_t' at a
480
+     fixed offset in the signal frame.  */
481
+  sp = get_frame_register_signed (this_frame,
482
+				  MIPS_SP_REGNUM + gdbarch_num_regs (gdbarch));
483
+  ucontext_addr = sp + N64_SIGFRAME_UCONTEXT_OFFSET;
484
+
485
+  /* PC.  */
486
+  regnum = mips_regnum (gdbarch)->pc;
487
+  trad_frame_set_reg_addr (cache,
488
+			   regnum + gdbarch_num_regs (gdbarch),
489
+			   ucontext_addr + N64_UCONTEXT_PC);
490
+
491
+  /* GPRs.  */
492
+  for (regnum = MIPS_ZERO_REGNUM, addr = ucontext_addr + N64_UCONTEXT_REGS;
493
+       regnum <= MIPS_RA_REGNUM; regnum++, addr += N64_UCONTEXT_REG_SIZE)
494
+    trad_frame_set_reg_addr (cache,
495
+			     regnum + gdbarch_num_regs (gdbarch),
496
+			     addr);
497
+
498
+  regnum = MIPS_PS_REGNUM;
499
+  trad_frame_set_reg_addr (cache,
500
+			   regnum + gdbarch_num_regs (gdbarch),
501
+			   ucontext_addr + N64_UCONTEXT_SR);
502
+
503
+  /* HI and LO.  */
504
+  regnum = mips_regnum (gdbarch)->lo;
505
+  trad_frame_set_reg_addr (cache,
506
+			   regnum + gdbarch_num_regs (gdbarch),
507
+			   ucontext_addr + N64_UCONTEXT_LO);
508
+  regnum = mips_regnum (gdbarch)->hi;
509
+  trad_frame_set_reg_addr (cache,
510
+			   regnum + gdbarch_num_regs (gdbarch),
511
+			   ucontext_addr + N64_UCONTEXT_HI);
512
+
513
+  if (target_read_memory (ucontext_addr + N64_UCONTEXT_FPUSED, buf, 4) == 0 &&
514
+      extract_unsigned_integer (buf, 4, byte_order) != 0)
515
+    {
516
+      for (regnum = 0, addr = ucontext_addr + N64_UCONTEXT_FPREGS;
517
+	   regnum < 32; regnum++, addr += N64_UCONTEXT_REG_SIZE)
518
+	trad_frame_set_reg_addr (cache,
519
+				 regnum + gdbarch_fp0_regnum (gdbarch),
520
+				 addr);
521
+      trad_frame_set_reg_addr (cache, mips_regnum (gdbarch)->fp_control_status,
522
+			       addr);
523
+    }
524
+
525
+  trad_frame_set_id (cache, frame_id_build (sp, func));
526
+}
527
+
528
+#define MIPS_INST_DADDIU_A0_SP_N64 (0x67a40000 \
529
+				    + N64_SIGFRAME_UCONTEXT_OFFSET)
530
+
531
+static const struct tramp_frame mips64_fbsd_sigframe =
532
+{
533
+  SIGTRAMP_FRAME,
534
+  MIPS_INSN32_SIZE,
535
+  {
536
+    { MIPS_INST_DADDIU_A0_SP_N64, -1 },	/* daddiu  a0, sp, SIGF_UC */
537
+    { MIPS_INST_LI_V0_SIGRETURN, -1 },	/* li      v0, SYS_sigreturn */
538
+    { MIPS_INST_SYSCALL, -1 },		/* syscall */
539
+    { MIPS_INST_BREAK, -1 },		/* break */
540
+    { TRAMP_SENTINEL_INSN, -1 }
541
+  },
542
+  mips64_fbsd_sigframe_init
543
+};
544
+
545
+/* Shared library support.  */
546
+
547
+/* FreeBSD/mips uses a slightly different `struct link_map' than the
548
+   other FreeBSD platforms as it includes an additional `l_off'
549
+   member.  */
550
+
551
+static struct link_map_offsets *
552
+mips_fbsd_ilp32_fetch_link_map_offsets (void)
553
+{
554
+  static struct link_map_offsets lmo;
555
+  static struct link_map_offsets *lmp = NULL;
556
+
557
+  if (lmp == NULL)
558
+    {
559
+      lmp = &lmo;
560
+
561
+      lmo.r_version_offset = 0;
562
+      lmo.r_version_size = 4;
563
+      lmo.r_map_offset = 4;
564
+      lmo.r_brk_offset = 8;
565
+      lmo.r_ldsomap_offset = -1;
566
+
567
+      lmo.link_map_size = 24;
568
+      lmo.l_addr_offset = 0;
569
+      lmo.l_name_offset = 8;
570
+      lmo.l_ld_offset = 12;
571
+      lmo.l_next_offset = 16;
572
+      lmo.l_prev_offset = 20;
573
+    }
574
+
575
+  return lmp;
576
+}
577
+
578
+static struct link_map_offsets *
579
+mips_fbsd_lp64_fetch_link_map_offsets (void)
580
+{
581
+  static struct link_map_offsets lmo;
582
+  static struct link_map_offsets *lmp = NULL;
583
+
584
+  if (lmp == NULL)
585
+    {
586
+      lmp = &lmo;
587
+
588
+      lmo.r_version_offset = 0;
589
+      lmo.r_version_size = 4;
590
+      lmo.r_map_offset = 8;
591
+      lmo.r_brk_offset = 16;
592
+      lmo.r_ldsomap_offset = -1;
593
+
594
+      lmo.link_map_size = 48;
595
+      lmo.l_addr_offset = 0;
596
+      lmo.l_name_offset = 16;
597
+      lmo.l_ld_offset = 24;
598
+      lmo.l_next_offset = 32;
599
+      lmo.l_prev_offset = 40;
600
+    }
601
+
602
+  return lmp;
603
+}
604
+
605
+static void
606
+mips_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
607
+{
608
+  enum mips_abi abi = mips_abi (gdbarch);
609
+
610
+  /* Generic FreeBSD support.  */
611
+  fbsd_init_abi (info, gdbarch);
612
+
613
+  set_gdbarch_software_single_step (gdbarch, mips_software_single_step);
614
+
615
+  switch (abi)
616
+    {
617
+      case MIPS_ABI_O32:
618
+	tramp_frame_prepend_unwinder (gdbarch, &mips_fbsd_sigframe);
619
+	break;
620
+      case MIPS_ABI_N32:
621
+	break;
622
+      case MIPS_ABI_N64:
623
+	tramp_frame_prepend_unwinder (gdbarch, &mips64_fbsd_sigframe);
624
+	break;
625
+    }
626
+
627
+  set_gdbarch_iterate_over_regset_sections
628
+    (gdbarch, mips_fbsd_iterate_over_regset_sections);
629
+
630
+  /* FreeBSD/mips has SVR4-style shared libraries.  */
631
+  set_solib_svr4_fetch_link_map_offsets
632
+    (gdbarch, (gdbarch_ptr_bit (gdbarch) == 32 ?
633
+	       mips_fbsd_ilp32_fetch_link_map_offsets :
634
+	       mips_fbsd_lp64_fetch_link_map_offsets));
635
+}
636
+
637
+
638
+/* Provide a prototype to silence -Wmissing-prototypes.  */
639
+void _initialize_mips_fbsd_tdep (void);
640
+
641
+void
642
+_initialize_mips_fbsd_tdep (void)
643
+{
644
+  gdbarch_register_osabi (bfd_arch_mips, 0, GDB_OSABI_FREEBSD_ELF,
645
+			  mips_fbsd_init_abi);
646
+}
647
diff --git gdb/mips-fbsd-tdep.h gdb/mips-fbsd-tdep.h
648
new file mode 100644
649
index 0000000000..8a197e6325
650
--- /dev/null
651
+++ gdb/mips-fbsd-tdep.h
652
@@ -0,0 +1,28 @@
653
+/* Common target dependent code for GDB on MIPS systems running FreeBSD.
654
+
655
+   Copyright (C) 2017 Free Software Foundation, Inc.
656
+
657
+   This file is part of GDB.
658
+
659
+   This program is free software; you can redistribute it and/or modify
660
+   it under the terms of the GNU General Public License as published by
661
+   the Free Software Foundation; either version 3 of the License, or
662
+   (at your option) any later version.
663
+
664
+   This program is distributed in the hope that it will be useful,
665
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
666
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
667
+   GNU General Public License for more details.
668
+
669
+   You should have received a copy of the GNU General Public License
670
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
671
+
672
+#ifndef MIPS_FBSD_TDEP_H
673
+#define MIPS_FBSD_TDEP_H
674
+
675
+void mips_fbsd_supply_fpregs (struct regcache *, int, const void *, size_t);
676
+void mips_fbsd_supply_gregs (struct regcache *, int, const void *, size_t);
677
+void mips_fbsd_collect_fpregs (const struct regcache *, int, void *, size_t);
678
+void mips_fbsd_collect_gregs (const struct regcache *, int, void *, size_t);
679
+
680
+#endif /* MIPS_FBSD_TDEP_H */
(-)devel/gdb/files/commit-b268007c68 (+191 lines)
Added Link Here
1
commit acde9e8dc95a053909e137c1fcda94c719eb8cc1
2
Author: John Baldwin <jhb@FreeBSD.org>
3
Date:   Wed Jan 4 09:41:58 2017 -0800
4
5
    Add native target for FreeBSD/mips.
6
    
7
    This supports the o32 and n64 ABIs.
8
    
9
    gdb/ChangeLog:
10
    
11
            * Makefile.in (ALLDEPFILES): Add mips-fbsd-nat.c.
12
            * NEWS: Mention new FreeBSD/mips native configuration.
13
            * config/mips/fbsd.mh: New file.
14
            * configure.host: Add mips*-*-freebsd*.
15
            * mips-fbsd-nat.c: New file.
16
17
diff --git gdb/Makefile.in gdb/Makefile.in
18
index 300c2cb702..433dd1203a 100644
19
--- gdb/Makefile.in
20
+++ gdb/Makefile.in
21
@@ -1725,6 +1725,7 @@ ALLDEPFILES = \
22
 	m88k-tdep.c m88kbsd-nat.c \
23
 	microblaze-tdep.c microblaze-linux-tdep.c \
24
 	mingw-hdep.c common/mingw-strerror.c \
25
+	mips-fbsd-nat.c \
26
 	mips-fbsd-tdep.c \
27
 	mips-linux-nat.c mips-linux-tdep.c \
28
 	mips-sde-tdep.c \
29
diff --git gdb/config/mips/fbsd.mh gdb/config/mips/fbsd.mh
30
new file mode 100644
31
index 0000000000..f433347a20
32
--- /dev/null
33
+++ gdb/config/mips/fbsd.mh
34
@@ -0,0 +1,3 @@
35
+# Host: FreeBSD/mips
36
+NATDEPFILES= fork-child.o inf-ptrace.o fbsd-nat.o mips-fbsd-nat.o
37
+HAVE_NATIVE_GCORE_HOST = 1
38
diff --git gdb/configure.host gdb/configure.host
39
index ef265ebe29..c45f61dbba 100644
40
--- gdb/configure.host
41
+++ gdb/configure.host
42
@@ -129,6 +129,7 @@ m88*-*-openbsd*)	gdb_host=obsd ;;
43
 mips*-*-linux*)		gdb_host=linux ;;
44
 mips*-*-netbsd* | mips*-*-knetbsd*-gnu)
45
 			gdb_host=nbsd ;;
46
+mips*-*-freebsd*)	gdb_host=fbsd ;;
47
 mips64*-*-openbsd*)	gdb_host=obsd64 ;;
48
 
49
 powerpc-*-aix* | rs6000-*-* | powerpc64-*-aix*)
50
diff --git gdb/mips-fbsd-nat.c gdb/mips-fbsd-nat.c
51
new file mode 100644
52
index 0000000000..0472df88f4
53
--- /dev/null
54
+++ gdb/mips-fbsd-nat.c
55
@@ -0,0 +1,136 @@
56
+/* Native-dependent code for FreeBSD/mips.
57
+
58
+   Copyright (C) 2017 Free Software Foundation, Inc.
59
+
60
+   This file is part of GDB.
61
+
62
+   This program is free software; you can redistribute it and/or modify
63
+   it under the terms of the GNU General Public License as published by
64
+   the Free Software Foundation; either version 3 of the License, or
65
+   (at your option) any later version.
66
+
67
+   This program is distributed in the hope that it will be useful,
68
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
69
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
70
+   GNU General Public License for more details.
71
+
72
+   You should have received a copy of the GNU General Public License
73
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
74
+
75
+#include "defs.h"
76
+#include "inferior.h"
77
+#include "regcache.h"
78
+#include "target.h"
79
+
80
+#include <sys/types.h>
81
+#include <sys/ptrace.h>
82
+#include <machine/reg.h>
83
+
84
+#include "fbsd-nat.h"
85
+#include "mips-tdep.h"
86
+#include "mips-fbsd-tdep.h"
87
+#include "inf-ptrace.h"
88
+
89
+/* Determine if PT_GETREGS fetches this register.  */
90
+
91
+static bool
92
+getregs_supplies (struct gdbarch *gdbarch, int regnum)
93
+{
94
+  return (regnum >= MIPS_ZERO_REGNUM
95
+	  && regnum <= gdbarch_pc_regnum (gdbarch));
96
+}
97
+
98
+/* Fetch register REGNUM from the inferior.  If REGNUM is -1, do this
99
+   for all registers.  */
100
+
101
+static void
102
+mips_fbsd_fetch_inferior_registers (struct target_ops *ops,
103
+				    struct regcache *regcache, int regnum)
104
+{
105
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
106
+  if (regnum == -1 || getregs_supplies (gdbarch, regnum))
107
+    {
108
+      struct reg regs;
109
+
110
+      if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
111
+		  (PTRACE_TYPE_ARG3) &regs, 0) == -1)
112
+	perror_with_name (_("Couldn't get registers"));
113
+
114
+      mips_fbsd_supply_gregs (regcache, regnum, &regs, sizeof (register_t));
115
+      if (regnum != -1)
116
+	return;
117
+    }
118
+
119
+  if (regnum == -1
120
+      || regnum >= gdbarch_fp0_regnum (get_regcache_arch (regcache)))
121
+    {
122
+      struct fpreg fpregs;
123
+
124
+      if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
125
+		  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
126
+	perror_with_name (_("Couldn't get floating point status"));
127
+
128
+      mips_fbsd_supply_fpregs (regcache, regnum, &fpregs,
129
+			       sizeof (f_register_t));
130
+    }
131
+}
132
+
133
+/* Store register REGNUM back into the inferior.  If REGNUM is -1, do
134
+   this for all registers.  */
135
+
136
+static void
137
+mips_fbsd_store_inferior_registers (struct target_ops *ops,
138
+				    struct regcache *regcache, int regnum)
139
+{
140
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
141
+  if (regnum == -1 || getregs_supplies (gdbarch, regnum))
142
+    {
143
+      struct reg regs;
144
+
145
+      if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
146
+		  (PTRACE_TYPE_ARG3) &regs, 0) == -1)
147
+	perror_with_name (_("Couldn't get registers"));
148
+
149
+      mips_fbsd_collect_gregs (regcache, regnum, (char *) &regs,
150
+			       sizeof (register_t));
151
+
152
+      if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
153
+		  (PTRACE_TYPE_ARG3) &regs, 0) == -1)
154
+	perror_with_name (_("Couldn't write registers"));
155
+
156
+      if (regnum != -1)
157
+	return;
158
+    }
159
+
160
+  if (regnum == -1
161
+      || regnum >= gdbarch_fp0_regnum (get_regcache_arch (regcache)))
162
+    {
163
+      struct fpreg fpregs;
164
+
165
+      if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
166
+		  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
167
+	perror_with_name (_("Couldn't get floating point status"));
168
+
169
+      mips_fbsd_collect_fpregs (regcache, regnum, (char *) &fpregs,
170
+				sizeof (f_register_t));
171
+
172
+      if (ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
173
+		  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
174
+	perror_with_name (_("Couldn't write floating point status"));
175
+    }
176
+}
177
+
178
+
179
+/* Provide a prototype to silence -Wmissing-prototypes.  */
180
+void _initialize_mips_fbsd_nat (void);
181
+
182
+void
183
+_initialize_mips_fbsd_nat (void)
184
+{
185
+  struct target_ops *t;
186
+
187
+  t = inf_ptrace_target ();
188
+  t->to_fetch_registers = mips_fbsd_fetch_inferior_registers;
189
+  t->to_store_registers = mips_fbsd_store_inferior_registers;
190
+  fbsd_nat_add_target (t);
191
+}
(-)devel/gdb/files/extrapatch-base-readline (-11 lines)
Removed Link Here
1
--- gdb/completer.c.orig	2016-05-10 14:11:58.546188879 +0200
2
+++ gdb/completer.c	2016-05-10 14:12:22.899187374 +0200
3
@@ -1767,6 +1767,8 @@
4
   return displayer->width;
5
 }
6
 
7
+_rl_completion_prefix_display_length=0;
8
+rl_sort_completion_matches=1;
9
 extern int _rl_completion_prefix_display_length;
10
 extern int _rl_print_completions_horizontally;
11
 
(-)devel/gdb/files/extrapatch-kgdb (-74 / +85 lines)
Lines 1-8 Link Here
1
diff --git gdb/Makefile.in gdb/Makefile.in
1
diff --git gdb/Makefile.in gdb/Makefile.in
2
index dfaa8a3..182d875 100644
2
index 5b6ccea764..f501cf29d1 100644
3
--- gdb/Makefile.in
3
--- gdb/Makefile.in
4
+++ gdb/Makefile.in
4
+++ gdb/Makefile.in
5
@@ -207,7 +207,8 @@
5
@@ -212,7 +212,8 @@ INCGNU = -I$(srcdir)/gnulib/import -I$(GNULIB_BUILDDIR)/import
6
 
6
 
7
 # Generated headers in the gnulib directory.  These must be listed
7
 # Generated headers in the gnulib directory.  These must be listed
8
 # so that they are generated before other files are compiled.
8
 # so that they are generated before other files are compiled.
Lines 12-18 index dfaa8a3..182d875 100644 Link Here
12
 
12
 
13
 #
13
 #
14
 # CLI sub directory definitons
14
 # CLI sub directory definitons
15
@@ -650,7 +650,8 @@ ALL_64_TARGET_OBS = \
15
@@ -653,7 +654,8 @@ ALL_64_TARGET_OBS = \
16
 	ia64-linux-tdep.o ia64-vms-tdep.o ia64-tdep.o \
16
 	ia64-linux-tdep.o ia64-vms-tdep.o ia64-tdep.o \
17
 	mips64obsd-tdep.o \
17
 	mips64obsd-tdep.o \
18
 	sparc64fbsd-tdep.o sparc64-linux-tdep.o sparc64nbsd-tdep.o \
18
 	sparc64fbsd-tdep.o sparc64-linux-tdep.o sparc64nbsd-tdep.o \
Lines 22-36 index dfaa8a3..182d875 100644 Link Here
22
 
22
 
23
 # All other target-dependent objects files (used with --enable-targets=all).
23
 # All other target-dependent objects files (used with --enable-targets=all).
24
 ALL_TARGET_OBS = \
24
 ALL_TARGET_OBS = \
25
@@ -672,6 +673,7 @@ ALL_TARGET_OBS = \
25
@@ -676,6 +678,8 @@ ALL_TARGET_OBS = \
26
 	i386-sol2-tdep.o i386-tdep.o i387-tdep.o \
26
 	i386-sol2-tdep.o i386-tdep.o i387-tdep.o \
27
 	i386-dicos-tdep.o i386-darwin-tdep.o \
27
 	i386-dicos-tdep.o i386-darwin-tdep.o \
28
 	iq2000-tdep.o \
28
 	iq2000-tdep.o \
29
+	fbsd-kld.o fbsd-kthr.o fbsd-kvm.o i386fbsd-kern.o ppcfbsd-kern.o \
29
+	fbsd-kld.o fbsd-kthr.o fbsd-kvm.o i386fbsd-kern.o ppcfbsd-kern.o \
30
+	mipsfbsd-kern.o \
30
 	linux-tdep.o \
31
 	linux-tdep.o \
31
 	lm32-tdep.o \
32
 	lm32-tdep.o \
32
 	m32c-tdep.o \
33
 	m32c-tdep.o \
33
@@ -1123,7 +1125,7 @@ generated_files = config.h observer.h observer.inc ada-lex.c jit-reader.h \
34
@@ -1133,7 +1137,7 @@ generated_files = config.h observer.h observer.inc ada-lex.c jit-reader.h \
34
 	$(COMPILE) $<
35
 	$(COMPILE) $<
35
 	$(POSTCOMPILE)
36
 	$(POSTCOMPILE)
36
 
37
 
Lines 39-45 index dfaa8a3..182d875 100644 Link Here
39
 	@$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=`echo $(SUBDIRS) | sed 's/testsuite//'`" subdir_do
40
 	@$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=`echo $(SUBDIRS) | sed 's/testsuite//'`" subdir_do
40
 
41
 
41
 installcheck:
42
 installcheck:
42
@@ -1393,6 +1395,12 @@ gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS)
43
@@ -1412,6 +1416,12 @@ gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS)
43
 		-o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) \
44
 		-o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) \
44
 		$(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES)
45
 		$(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES)
45
 
46
 
Lines 52-58 index dfaa8a3..182d875 100644 Link Here
52
 # Convenience rule to handle recursion.
53
 # Convenience rule to handle recursion.
53
 $(LIBGNU) $(GNULIB_H): all-lib
54
 $(LIBGNU) $(GNULIB_H): all-lib
54
 all-lib: $(GNULIB_BUILDDIR)/Makefile
55
 all-lib: $(GNULIB_BUILDDIR)/Makefile
55
@@ -1437,7 +1445,7 @@ clean mostlyclean: $(CONFIG_CLEAN)
56
@@ -1456,7 +1466,7 @@ clean mostlyclean: $(CONFIG_CLEAN)
56
 	@$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(CLEANDIRS)" subdir_do
57
 	@$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(CLEANDIRS)" subdir_do
57
 	rm -f *.o *.a $(ADD_FILES) *~ init.c-tmp init.l-tmp version.c-tmp
58
 	rm -f *.o *.a $(ADD_FILES) *~ init.c-tmp init.l-tmp version.c-tmp
58
 	rm -f init.c version.c observer.h observer.inc
59
 	rm -f init.c version.c observer.h observer.inc
Lines 61-77 index dfaa8a3..182d875 100644 Link Here
61
 	rm -f gdb[0-9]$(EXEEXT)
62
 	rm -f gdb[0-9]$(EXEEXT)
62
 	rm -f test-cp-name-parser$(EXEEXT)
63
 	rm -f test-cp-name-parser$(EXEEXT)
63
 	rm -f xml-builtin.c stamp-xml
64
 	rm -f xml-builtin.c stamp-xml
64
@@ -1667,6 +1675,9 @@ ALLDEPFILES = \
65
@@ -1688,6 +1698,9 @@ ALLDEPFILES = \
65
 	core-regset.c \
66
 	core-regset.c \
66
 	dcache.c dicos-tdep.c darwin-nat.c \
67
 	dcache.c dicos-tdep.c darwin-nat.c \
67
 	exec.c \
68
 	exec.c \
68
+	fbsd-kld.c fbsd-kthr.c fbsd-kvm.c \
69
+	fbsd-kld.c fbsd-kthr.c fbsd-kvm.c \
69
+	amd64fbsd-kern.c i386fbsd-kern.c ppcfbsd-kern.c \
70
+	amd64fbsd-kern.c i386fbsd-kern.c mipsfbsd-kern.c ppcfbsd-kern.c \
70
+	sparc64fbsd-kern.c \
71
+	sparc64fbsd-kern.c \
71
 	fbsd-nat.c \
72
 	fbsd-nat.c \
72
 	fbsd-tdep.c \
73
 	fbsd-tdep.c \
73
 	fork-child.c \
74
 	fork-child.c \
74
@@ -2740,7 +2752,7 @@
75
@@ -2761,7 +2774,7 @@ py-varobj.o: $(srcdir)/python/py-varobj.c
75
 
76
 
76
 # A list of all the objects we might care about in this build, for
77
 # A list of all the objects we might care about in this build, for
77
 # dependency tracking.
78
 # dependency tracking.
Lines 81-90 index dfaa8a3..182d875 100644 Link Here
81
 
82
 
82
 # Ensure that generated files are created early.  Use order-only
83
 # Ensure that generated files are created early.  Use order-only
83
diff --git gdb/config.in gdb/config.in
84
diff --git gdb/config.in gdb/config.in
84
index 9ef53b3..c55c01b 100644
85
index c82a5b4bac..34140b2d59 100644
85
--- gdb/config.in
86
--- gdb/config.in
86
+++ gdb/config.in
87
+++ gdb/config.in
87
@@ -216,6 +216,9 @@
88
@@ -219,6 +219,9 @@
88
 /* Define to 1 if your system has the kinfo_getvmmap function. */
89
 /* Define to 1 if your system has the kinfo_getvmmap function. */
89
 #undef HAVE_KINFO_GETVMMAP
90
 #undef HAVE_KINFO_GETVMMAP
90
 
91
 
Lines 95-104 index 9ef53b3..c55c01b 100644 Link Here
95
 #undef HAVE_LANGINFO_CODESET
96
 #undef HAVE_LANGINFO_CODESET
96
 
97
 
97
diff --git gdb/configure gdb/configure
98
diff --git gdb/configure gdb/configure
98
index 48acfe5..f0cd958 100755
99
index b5c045cf10..68299ff16c 100755
99
--- gdb/configure
100
--- gdb/configure
100
+++ gdb/configure
101
+++ gdb/configure
101
@@ -7104,6 +7104,66 @@ $as_echo "#define HAVE_KINFO_GETVMMAP 1" >>confdefs.h
102
@@ -7112,6 +7112,66 @@ $as_echo "#define HAVE_KINFO_GETVMMAP 1" >>confdefs.h
102
 fi
103
 fi
103
 
104
 
104
 
105
 
Lines 163-175 index 48acfe5..f0cd958 100755 Link Here
163
+
164
+
164
+
165
+
165
 
166
 
166
 
167
       if test "X$prefix" = "XNONE"; then
167
 
168
     acl_final_prefix="$ac_default_prefix"
168
diff --git gdb/configure.ac gdb/configure.ac
169
diff --git gdb/configure.ac gdb/configure.ac
169
index a40860a..9035d48 100644
170
index f774db7ea6..efccdd3fb1 100644
170
--- gdb/configure.ac
171
--- gdb/configure.ac
171
+++ gdb/configure.ac
172
+++ gdb/configure.ac
172
@@ -539,6 +539,11 @@ AC_SEARCH_LIBS(kinfo_getvmmap, util,
173
@@ -540,6 +540,11 @@ AC_SEARCH_LIBS(kinfo_getvmmap, util util-freebsd,
173
   [AC_DEFINE(HAVE_KINFO_GETVMMAP, 1,
174
   [AC_DEFINE(HAVE_KINFO_GETVMMAP, 1,
174
             [Define to 1 if your system has the kinfo_getvmmap function. ])])
175
             [Define to 1 if your system has the kinfo_getvmmap function. ])])
175
 
176
 
Lines 181-191 index a40860a..9035d48 100644 Link Here
181
 AM_ICONV
182
 AM_ICONV
182
 
183
 
183
 # GDB may fork/exec the iconv program to get the list of supported character
184
 # GDB may fork/exec the iconv program to get the list of supported character
185
diff --git gdb/configure.tgt gdb/configure.tgt
186
index 9ee9f7a799..fb14b19405 100644
187
--- gdb/configure.tgt
188
+++ gdb/configure.tgt
189
@@ -190,7 +190,13 @@ i[34567]86-*-dicos*)
190
 i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu)
191
 	# Target: FreeBSD/i386
192
 	gdb_target_obs="i386-tdep.o i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \
193
-			bsd-uthread.o fbsd-tdep.o solib-svr4.o"
194
+			bsd-uthread.o fbsd-tdep.o solib-svr4.o \
195
+			fbsd-kld.o fbsd-kthr.o fbsd-kvm.o i386fbsd-kern.o"
196
+	if test "x$enable_64_bit_bfd" = "xyes"; then
197
+	    # Target: FreeBSD amd64
198
+	    gdb_target_obs="amd64-tdep.o amd64fbsd-tdep.o amd64fbsd-kern.o \
199
+			    ${gdb_target_obs}"
200
+	fi
201
 	;;
202
 i[34567]86-*-netbsd* | i[34567]86-*-knetbsd*-gnu)
203
 	# Target: NetBSD/i386
204
@@ -360,7 +366,8 @@ mips*-*-netbsd* | mips*-*-knetbsd*-gnu)
205
 	;;
206
 mips*-*-freebsd*)
207
 	# Target: MIPS running FreeBSD
208
-	gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o solib-svr4.o fbsd-tdep.o"
209
+	gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o solib-svr4.o fbsd-tdep.o \
210
+			fbsd-kld.o fbsd-kthr.o fbsd-kvm.o mipsfbsd-kern.o"
211
 	gdb_sim=../sim/mips/libsim.a
212
 	;;
213
 mips64*-*-openbsd*)
214
@@ -419,7 +426,8 @@ powerpc*-*-freebsd*)
215
 	# Target: FreeBSD/powerpc
216
 	gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \
217
 		        ppcfbsd-tdep.o fbsd-tdep.o solib-svr4.o \
218
-			ravenscar-thread.o ppc-ravenscar-thread.o"
219
+			ravenscar-thread.o ppc-ravenscar-thread.o \
220
+			fbsd-kld.o fbsd-kthr.o fbsd-kvm.o ppcfbsd-kern.o"
221
 	;;
222
 
223
 powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu)
224
@@ -543,7 +551,8 @@ sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu)
225
 	# Target: FreeBSD/sparc64
226
 	gdb_target_obs="sparc-tdep.o sparc64-tdep.o sparc64fbsd-tdep.o \
227
 			fbsd-tdep.o solib-svr4.o \
228
-			ravenscar-thread.o sparc-ravenscar-thread.o"
229
+			ravenscar-thread.o sparc-ravenscar-thread.o \
230
+			fbsd-kld.o fbsd-kthr.o fbsd-kvm.o sparc64fbsd-kern.o"
231
 	;;
232
 sparc-*-netbsd* | sparc-*-knetbsd*-gnu)
233
 	# Target: NetBSD/sparc
234
@@ -674,7 +683,9 @@ x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
235
 	# Target: FreeBSD/amd64
236
 	gdb_target_obs="amd64-tdep.o amd64fbsd-tdep.o i386-tdep.o \
237
 			i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \
238
-			bsd-uthread.o fbsd-tdep.o solib-svr4.o"
239
+			bsd-uthread.o fbsd-tdep.o solib-svr4.o \
240
+			fbsd-kld.o fbsd-kthr.o fbsd-kvm.o amd64fbsd-kern.o \
241
+			i386fbsd-kern.o"
242
 	;;
243
 x86_64-*-mingw* | x86_64-*-cygwin*)
244
         # Target: MingW/amd64
184
diff --git gdb/defs.h gdb/defs.h
245
diff --git gdb/defs.h gdb/defs.h
185
index ccdab18..499944f 100644
246
index 9b44f44349..f176be1108 100644
186
--- gdb/defs.h
247
--- gdb/defs.h
187
+++ gdb/defs.h
248
+++ gdb/defs.h
188
@@ -549,6 +549,7 @@ enum gdb_osabi
249
@@ -598,6 +598,7 @@ enum gdb_osabi
189
   GDB_OSABI_LINUX,
250
   GDB_OSABI_LINUX,
190
   GDB_OSABI_FREEBSD_AOUT,
251
   GDB_OSABI_FREEBSD_AOUT,
191
   GDB_OSABI_FREEBSD_ELF,
252
   GDB_OSABI_FREEBSD_ELF,
Lines 194-200 index ccdab18..499944f 100644 Link Here
194
   GDB_OSABI_NETBSD_ELF,
255
   GDB_OSABI_NETBSD_ELF,
195
   GDB_OSABI_OPENBSD_ELF,
256
   GDB_OSABI_OPENBSD_ELF,
196
diff --git gdb/osabi.c gdb/osabi.c
257
diff --git gdb/osabi.c gdb/osabi.c
197
index f7d4e74..130ffef 100644
258
index f7d4e74239..130ffef37e 100644
198
--- gdb/osabi.c
259
--- gdb/osabi.c
199
+++ gdb/osabi.c
260
+++ gdb/osabi.c
200
@@ -66,6 +66,7 @@ static const struct osabi_names gdb_osabi_names[] =
261
@@ -66,6 +66,7 @@ static const struct osabi_names gdb_osabi_names[] =
Lines 206-212 index f7d4e74..130ffef 100644 Link Here
206
   { "NetBSD/ELF", NULL },
267
   { "NetBSD/ELF", NULL },
207
   { "OpenBSD/ELF", NULL },
268
   { "OpenBSD/ELF", NULL },
208
diff --git gdb/regcache.c gdb/regcache.c
269
diff --git gdb/regcache.c gdb/regcache.c
209
index a5c90a6..05044e5 100644
270
index a5c90a6314..05044e5293 100644
210
--- gdb/regcache.c
271
--- gdb/regcache.c
211
+++ gdb/regcache.c
272
+++ gdb/regcache.c
212
@@ -1083,6 +1083,20 @@ regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf)
273
@@ -1083,6 +1083,20 @@ regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf)
Lines 231-240 index a5c90a6..05044e5 100644 Link Here
231
 
292
 
232
 void
293
 void
233
diff --git gdb/regcache.h gdb/regcache.h
294
diff --git gdb/regcache.h gdb/regcache.h
234
index a9fb44b..a156918 100644
295
index 1bb0ce0ec8..65783b6355 100644
235
--- gdb/regcache.h
296
--- gdb/regcache.h
236
+++ gdb/regcache.h
297
+++ gdb/regcache.h
237
@@ -147,6 +147,8 @@ extern void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc);
298
@@ -135,6 +135,8 @@ extern void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc);
238
 
299
 
239
 extern void regcache_raw_supply (struct regcache *regcache,
300
 extern void regcache_raw_supply (struct regcache *regcache,
240
 				 int regnum, const void *buf);
301
 				 int regnum, const void *buf);
Lines 243-295 index a9fb44b..a156918 100644 Link Here
243
 extern void regcache_raw_collect (const struct regcache *regcache,
304
 extern void regcache_raw_collect (const struct regcache *regcache,
244
 				  int regnum, void *buf);
305
 				  int regnum, void *buf);
245
 
306
 
246
diff --git gdb/configure.tgt gdb/configure.tgt
247
index 4e4d6a9..57e4b3a 100644
248
--- gdb/configure.tgt
249
+++ gdb/configure.tgt
250
@@ -185,7 +185,13 @@ i[34567]86-*-dicos*)
251
 i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu)
252
 	# Target: FreeBSD/i386
253
 	gdb_target_obs="i386-tdep.o i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \
254
-			bsd-uthread.o fbsd-tdep.o solib-svr4.o"
255
+			bsd-uthread.o fbsd-tdep.o solib-svr4.o \
256
+			fbsd-kld.o fbsd-kthr.o fbsd-kvm.o i386fbsd-kern.o"
257
+	if test "x$enable_64_bit_bfd" = "xyes"; then
258
+	    # Target: FreeBSD amd64
259
+	    gdb_target_obs="amd64-tdep.o amd64fbsd-tdep.o amd64fbsd-kern.o \
260
+			    ${gdb_target_obs}"
261
+	fi
262
 	;;
263
 i[34567]86-*-netbsd* | i[34567]86-*-knetbsd*-gnu)
264
 	# Target: NetBSD/i386
265
@@ -405,7 +411,8 @@ powerpc*-*-freebsd*)
266
 	# Target: FreeBSD/powerpc
267
 	gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \
268
 		        ppcfbsd-tdep.o fbsd-tdep.o solib-svr4.o \
269
-			ravenscar-thread.o ppc-ravenscar-thread.o"
270
+			ravenscar-thread.o ppc-ravenscar-thread.o \
271
+			fbsd-kld.o fbsd-kthr.o fbsd-kvm.o ppcfbsd-kern.o"
272
 	;;
273
 
274
 powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu)
275
@@ -534,7 +541,8 @@ sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu)
276
 	# Target: FreeBSD/sparc64
277
 	gdb_target_obs="sparc-tdep.o sparc64-tdep.o sparc64fbsd-tdep.o \
278
 			fbsd-tdep.o solib-svr4.o \
279
-			ravenscar-thread.o sparc-ravenscar-thread.o"
280
+			ravenscar-thread.o sparc-ravenscar-thread.o \
281
+			fbsd-kld.o fbsd-kthr.o fbsd-kvm.o sparc64fbsd-kern.o"
282
 	;;
283
 sparc-*-netbsd* | sparc-*-knetbsd*-gnu)
284
 	# Target: NetBSD/sparc
285
@@ -662,7 +670,9 @@ x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
286
 	# Target: FreeBSD/amd64
287
 	gdb_target_obs="amd64-tdep.o amd64fbsd-tdep.o i386-tdep.o \
288
 			i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \
289
-			bsd-uthread.o fbsd-tdep.o solib-svr4.o"
290
+			bsd-uthread.o fbsd-tdep.o solib-svr4.o \
291
+			fbsd-kld.o fbsd-kthr.o fbsd-kvm.o amd64fbsd-kern.o \
292
+			i386fbsd-kern.o"
293
 	;;
294
 x86_64-*-mingw* | x86_64-*-cygwin*)
295
         # Target: MingW/amd64
(-)devel/gdb/files/kgdb/mipsfbsd-kern.c (+305 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2007 Juniper Networks, Inc.
3
 * Copyright (c) 2004 Marcel Moolenaar
4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions
8
 * are met:
9
 *
10
 * 1. Redistributions of source code must retain the above copyright
11
 *    notice, this list of conditions and the following disclaimer.
12
 * 2. Redistributions in binary form must reproduce the above copyright
13
 *    notice, this list of conditions and the following disclaimer in the
14
 *    documentation and/or other materials provided with the distribution.
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
17
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 *
27
 * from: src/gnu/usr.bin/gdb/kgdb/trgt_alpha.c,v 1.2.2.1 2005/09/15 05:32:10 marcel
28
 */
29
30
#include <sys/cdefs.h>
31
__FBSDID("$FreeBSD$");
32
33
#include <sys/types.h>
34
#ifdef __mips__
35
#include <machine/asm.h>
36
#include <machine/pcb.h>
37
#include <machine/frame.h>
38
#endif
39
#include <string.h>
40
41
#include <defs.h>
42
#include <frame-unwind.h>
43
//#include <target.h>
44
//#include <gdbthread.h>
45
//#include <inferior.h>
46
#include "osabi.h"
47
#include <regcache.h>
48
#include "solib.h"
49
#include "trad-frame.h"
50
#include <mips-tdep.h>
51
52
#include "kgdb.h"
53
54
/* Size of struct trapframe in registers. */
55
#define	TRAPFRAME_WORDS	74
56
57
/* From sys/mips/include/pcb.h.  Offsets in the pcb_context[] array. */
58
#define	FBSD_PCB_REG_S0	0
59
#define	FBSD_PCB_REG_S1	1
60
#define	FBSD_PCB_REG_S2	2
61
#define	FBSD_PCB_REG_S3	3
62
#define	FBSD_PCB_REG_S4	4
63
#define	FBSD_PCB_REG_S5	5
64
#define	FBSD_PCB_REG_S6	6
65
#define	FBSD_PCB_REG_S7	7
66
#define	FBSD_PCB_REG_SP	8
67
#define	FBSD_PCB_REG_S8	9
68
#define	FBSD_PCB_REG_RA	10
69
#define	FBSD_PCB_REG_SR	11
70
#define	FBSD_PCB_REG_GP	12
71
#define	FBSD_PCB_REG_PC	13
72
73
#ifdef __mips__
74
_Static_assert(TRAPFRAME_WORDS * sizeof(register_t) ==
75
	       sizeof(struct trapframe), "TRAPFRAME_WORDS mismatch");
76
_Static_assert(FBSD_PCB_REG_S0 == PCB_REG_S0, "PCB_REG_S0 mismatch");
77
_Static_assert(FBSD_PCB_REG_S1 == PCB_REG_S1, "PCB_REG_S1 mismatch");
78
_Static_assert(FBSD_PCB_REG_S2 == PCB_REG_S2, "PCB_REG_S2 mismatch");
79
_Static_assert(FBSD_PCB_REG_S3 == PCB_REG_S3, "PCB_REG_S3 mismatch");
80
_Static_assert(FBSD_PCB_REG_S4 == PCB_REG_S4, "PCB_REG_S4 mismatch");
81
_Static_assert(FBSD_PCB_REG_S5 == PCB_REG_S5, "PCB_REG_S5 mismatch");
82
_Static_assert(FBSD_PCB_REG_S6 == PCB_REG_S6, "PCB_REG_S6 mismatch");
83
_Static_assert(FBSD_PCB_REG_S7 == PCB_REG_S7, "PCB_REG_S7 mismatch");
84
_Static_assert(FBSD_PCB_REG_SP == PCB_REG_SP, "PCB_REG_SP mismatch");
85
_Static_assert(FBSD_PCB_REG_S8 == PCB_REG_S8, "PCB_REG_S8 mismatch");
86
_Static_assert(FBSD_PCB_REG_RA == PCB_REG_RA, "PCB_REG_RA mismatch");
87
_Static_assert(FBSD_PCB_REG_SR == PCB_REG_SR, "PCB_REG_SR mismatch");
88
_Static_assert(FBSD_PCB_REG_GP == PCB_REG_GP, "PCB_REG_GP mismatch");
89
_Static_assert(FBSD_PCB_REG_PC == PCB_REG_PC, "PCB_REG_PC mismatch");
90
#endif
91
92
static void
93
mipsfbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr)
94
{
95
  struct gdbarch *gdbarch = get_regcache_arch (regcache);
96
  size_t regsize = mips_isa_regsize (gdbarch);
97
  gdb_byte buf[regsize * (FBSD_PCB_REG_PC + 1)];
98
99
  /* Read the entire pcb_context[] array in one go.  The pcb_context[]
100
     array is after the pcb_regs member which is a trapframe.  */
101
  if (target_read_memory (pcb_addr + TRAPFRAME_WORDS * regsize, buf,
102
			  sizeof(buf)) != 0)
103
    return;
104
105
  regcache_raw_supply_unsigned (regcache, MIPS_ZERO_REGNUM, 0);
106
  regcache_raw_supply (regcache, MIPS_S2_REGNUM - 2,
107
		       buf + (regsize * FBSD_PCB_REG_S0));
108
  regcache_raw_supply (regcache, MIPS_S2_REGNUM - 1,
109
		       buf + (regsize * FBSD_PCB_REG_S1));
110
  regcache_raw_supply (regcache, MIPS_S2_REGNUM,
111
		       buf + (regsize * FBSD_PCB_REG_S2));
112
  regcache_raw_supply (regcache, MIPS_S2_REGNUM + 1,
113
		       buf + (regsize * FBSD_PCB_REG_S3));
114
  regcache_raw_supply (regcache, MIPS_S2_REGNUM + 2,
115
		       buf + (regsize * FBSD_PCB_REG_S4));
116
  regcache_raw_supply (regcache, MIPS_S2_REGNUM + 3,
117
		       buf + (regsize * FBSD_PCB_REG_S5));
118
  regcache_raw_supply (regcache, MIPS_S2_REGNUM + 4,
119
		       buf + (regsize * FBSD_PCB_REG_S6));
120
  regcache_raw_supply (regcache, MIPS_S2_REGNUM + 5,
121
		       buf + (regsize * FBSD_PCB_REG_S7));
122
  regcache_raw_supply (regcache, MIPS_SP_REGNUM,
123
		       buf + (regsize * FBSD_PCB_REG_SP));
124
  regcache_raw_supply (regcache, MIPS_S2_REGNUM + 6,
125
		       buf + (regsize * FBSD_PCB_REG_S8));
126
  regcache_raw_supply (regcache, MIPS_RA_REGNUM,
127
		       buf + (regsize * FBSD_PCB_REG_RA));
128
  regcache_raw_supply (regcache, MIPS_PS_REGNUM,
129
		       buf + (regsize * FBSD_PCB_REG_SR));
130
  regcache_raw_supply (regcache, MIPS_GP_REGNUM,
131
		       buf + (regsize * FBSD_PCB_REG_GP));
132
  regcache_raw_supply (regcache, MIPS_EMBED_PC_REGNUM,
133
		       buf + (regsize * FBSD_PCB_REG_PC));
134
}
135
136
static struct trad_frame_cache *
137
mipsfbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache)
138
{
139
  struct gdbarch *gdbarch = get_frame_arch (this_frame);
140
  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
141
  size_t regsize = mips_isa_regsize (gdbarch);
142
  struct trad_frame_cache *cache;
143
  CORE_ADDR addr, func, pc, sp;
144
  int regnum;
145
146
  if (*this_cache != NULL)
147
    return ((struct trad_frame_cache *)*this_cache);
148
149
  cache = trad_frame_cache_zalloc (this_frame);
150
  *this_cache = cache;
151
152
  func = get_frame_func (this_frame);
153
  sp = get_frame_register_signed (this_frame,
154
				  MIPS_SP_REGNUM + gdbarch_num_regs (gdbarch));
155
156
  /* Skip over CALLFRAME_SIZ.  */
157
  addr = sp;
158
  if (regsize == 8)
159
    addr += regsize * 4;
160
  else
161
    addr += regsize * (4 + 2);
162
163
  /* GPRs.  Skip zero.  */
164
  addr += regsize;
165
  for (regnum = MIPS_AT_REGNUM; regnum <= MIPS_RA_REGNUM; regnum++)
166
    {
167
      trad_frame_set_reg_addr (cache,
168
			       regnum + gdbarch_num_regs (gdbarch),
169
			       addr);
170
      addr += regsize;
171
    }
172
173
  regnum = MIPS_PS_REGNUM;
174
  trad_frame_set_reg_addr (cache,
175
			   regnum + gdbarch_num_regs (gdbarch),
176
			   addr);
177
  addr += regsize;
178
179
  /* HI and LO.  */
180
  regnum = mips_regnum (gdbarch)->lo;
181
  trad_frame_set_reg_addr (cache,
182
			   regnum + gdbarch_num_regs (gdbarch),
183
			   addr);
184
  addr += regsize;
185
  regnum = mips_regnum (gdbarch)->hi;
186
  trad_frame_set_reg_addr (cache,
187
			   regnum + gdbarch_num_regs (gdbarch),
188
			   addr);
189
  addr += regsize;
190
191
  /* BADVADDR.  */
192
  regnum = mips_regnum (gdbarch)->badvaddr;
193
  trad_frame_set_reg_addr (cache,
194
			   regnum + gdbarch_num_regs (gdbarch),
195
			   addr);
196
  addr += regsize;
197
198
  /* CAUSE.  */
199
  regnum = mips_regnum (gdbarch)->cause;
200
  trad_frame_set_reg_addr (cache,
201
			   regnum + gdbarch_num_regs (gdbarch),
202
			   addr);
203
  addr += regsize;
204
205
  /* PC.  */
206
  regnum = mips_regnum (gdbarch)->pc;
207
  trad_frame_set_reg_addr (cache,
208
			   regnum + gdbarch_num_regs (gdbarch),
209
			   addr);
210
  
211
  trad_frame_set_id (cache, frame_id_build (sp + TRAPFRAME_WORDS * regsize,
212
					    func));
213
  return cache;
214
}
215
216
static void
217
mipsfbsd_trapframe_this_id (struct frame_info *this_frame,
218
			    void **this_cache, struct frame_id *this_id)
219
{
220
  struct trad_frame_cache *cache =
221
    mipsfbsd_trapframe_cache (this_frame, this_cache);
222
  
223
  trad_frame_get_id (cache, this_id);
224
}
225
226
static struct value *
227
mipsfbsd_trapframe_prev_register (struct frame_info *this_frame,
228
				  void **this_cache, int regnum)
229
{
230
  struct trad_frame_cache *cache =
231
    mipsfbsd_trapframe_cache (this_frame, this_cache);
232
233
  return trad_frame_get_register (cache, this_frame, regnum);
234
}
235
236
static int
237
mipsfbsd_trapframe_sniffer (const struct frame_unwind *self,
238
			    struct frame_info *this_frame,
239
			    void **this_prologue_cache)
240
{
241
  const char *name;
242
243
  find_pc_partial_function (get_frame_func (this_frame), &name, NULL, NULL);
244
  return (name && ((strcmp(name, "MipsKernIntr") == 0) ||
245
		   (strcmp(name, "MipsKernGenException") == 0) ||
246
		   (strcmp(name, "MipsTLBInvalidException") == 0)));
247
}
248
249
static const struct frame_unwind mipsfbsd_trapframe_unwind = {
250
  SIGTRAMP_FRAME,
251
  default_frame_unwind_stop_reason,
252
  mipsfbsd_trapframe_this_id,
253
  mipsfbsd_trapframe_prev_register,
254
  NULL,
255
  mipsfbsd_trapframe_sniffer
256
};
257
258
static void
259
mipsfbsd_kernel_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
260
{
261
  enum mips_abi abi = mips_abi (gdbarch);
262
263
  set_gdbarch_software_single_step (gdbarch, mips_software_single_step);
264
265
  switch (abi)
266
    {
267
      case MIPS_ABI_O32:
268
	break;
269
      case MIPS_ABI_N32:
270
	set_gdbarch_long_double_bit (gdbarch, 128);
271
	/* These floatformats should probably be renamed.  MIPS uses
272
	   the same 128-bit IEEE floating point format that IA-64 uses,
273
	   except that the quiet/signalling NaN bit is reversed (GDB
274
	   does not distinguish between quiet and signalling NaNs).  */
275
	set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
276
	break;
277
      case MIPS_ABI_N64:
278
	set_gdbarch_long_double_bit (gdbarch, 128);
279
	/* These floatformats should probably be renamed.  MIPS uses
280
	   the same 128-bit IEEE floating point format that IA-64 uses,
281
	   except that the quiet/signalling NaN bit is reversed (GDB
282
	   does not distinguish between quiet and signalling NaNs).  */
283
	set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
284
	break;
285
    }
286
287
  frame_unwind_prepend_unwinder (gdbarch, &mipsfbsd_trapframe_unwind);
288
289
  set_solib_ops (gdbarch, &kld_so_ops);
290
291
  fbsd_vmcore_set_supply_pcb (gdbarch, mipsfbsd_supply_pcb);
292
  fbsd_vmcore_set_cpu_pcb_addr (gdbarch, kgdb_trgt_stop_pcb);
293
}
294
295
void _initialize_mips_kgdb_tdep (void);
296
297
void
298
_initialize_mips_kgdb_tdep (void)
299
{
300
  gdbarch_register_osabi_sniffer(bfd_arch_mips,
301
				 bfd_target_elf_flavour,
302
				 fbsd_kernel_osabi_sniffer);
303
  gdbarch_register_osabi (bfd_arch_mips, 0, GDB_OSABI_FREEBSD_ELF_KERNEL,
304
			  mipsfbsd_kernel_init_abi);
305
}
(-)devel/gdb/files/kgdb/ppcfbsd-kern.c (-1 / +1 lines)
Lines 58-64 ppcfbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr) Link Here
58
58
59
	tdep = gdbarch_tdep (target_gdbarch());
59
	tdep = gdbarch_tdep (target_gdbarch());
60
60
61
	if (target_read_memory(pcb_addr, &pcb, sizeof(pcb)) != 0)
61
	if (target_read_memory(pcb_addr, (gdb_byte *)&pcb, sizeof(pcb)) != 0)
62
		memset(&pcb, 0, sizeof(pcb));
62
		memset(&pcb, 0, sizeof(pcb));
63
63
64
	/*
64
	/*
(-)devel/gdb/files/kgdb/sparc64fbsd-kern.c (-3 / +3 lines)
Lines 55-61 sparc64fbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr) Link Here
55
{
55
{
56
	struct pcb pcb;
56
	struct pcb pcb;
57
57
58
	if (target_read_memory(pcb_addr, &pcb, sizeof(pcb)) != 0)
58
	if (target_read_memory(pcb_addr, (gdb_byte *)&pcb, sizeof(pcb)) != 0)
59
		memset(&pcb, 0, sizeof(pcb));
59
		memset(&pcb, 0, sizeof(pcb));
60
60
61
	regcache_raw_supply(regcache, SPARC_SP_REGNUM, (char *)&pcb.pcb_sp);
61
	regcache_raw_supply(regcache, SPARC_SP_REGNUM, (char *)&pcb.pcb_sp);
Lines 252-265 kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame, Link Here
252
			ofs = (regnum - SPARC_L0_REGNUM) * 8;
252
			ofs = (regnum - SPARC_L0_REGNUM) * 8;
253
			*addrp = cache->sp + BIAS + ofs;
253
			*addrp = cache->sp + BIAS + ofs;
254
			*lvalp = lval_memory;
254
			*lvalp = lval_memory;
255
			target_read_memory(*addrp, valuep, regsz);
255
			target_read_memory(*addrp, (gdb_byte *)valuep, regsz);
256
		}
256
		}
257
		return;
257
		return;
258
	}
258
	}
259
259
260
	*addrp = cache->fp + ofs;
260
	*addrp = cache->fp + ofs;
261
	*lvalp = lval_memory;
261
	*lvalp = lval_memory;
262
	target_read_memory(*addrp, valuep, regsz);
262
	target_read_memory(*addrp, (gdb_byte *)valuep, regsz);
263
}
263
}
264
264
265
static const struct frame_unwind kgdb_trgt_trapframe_unwind = {
265
static const struct frame_unwind kgdb_trgt_trapframe_unwind = {
(-)devel/gdb/files/patch-gdb-fbsd-nat.c (-3 / +13 lines)
Lines 1-6 Link Here
1
--- gdb/fbsd-nat.c.orig	2016-03-14 00:00:11.831889802 +0100
1
--- gdb/fbsd-nat.c.orig	2016-08-01 17:50:20.000000000 +0200
2
+++ gdb/fbsd-nat.c	2016-03-14 00:04:35.906871361 +0100
2
+++ gdb/fbsd-nat.c	2016-12-14 23:23:39.467449000 +0100
3
@@ -471,6 +471,14 @@
3
@@ -680,6 +680,9 @@
4
   if (!ptid_match (tp->ptid, *filter))
5
     return 0;
6
 
7
+  if (tp->state == THREAD_EXITED) {
8
+    return 0;
9
+  }
10
   if (ptrace (PT_RESUME, ptid_get_lwp (tp->ptid), NULL, 0) == -1)
11
     perror_with_name (("ptrace"));
12
   return 0;
13
@@ -710,6 +713,14 @@
4
 			ptid_get_tid (ptid));
14
 			ptid_get_tid (ptid));
5
   if (ptid_lwp_p (ptid))
15
   if (ptid_lwp_p (ptid))
6
     {
16
     {

Return to bug 215938