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

Collapse All | Expand All

(-)devel/gdb/Makefile (+1 lines)
Lines 83-88 Link Here
83
	@${REINPLACE_CMD} -e 's/$$/ [GDB v${PORTVERSION} for FreeBSD]/' \
83
	@${REINPLACE_CMD} -e 's/$$/ [GDB v${PORTVERSION} for FreeBSD]/' \
84
		${WRKSRC}/gdb/version.in
84
		${WRKSRC}/gdb/version.in
85
	@${CP} ${FILESDIR}/fbsd-threads.c ${WRKSRC}/gdb
85
	@${CP} ${FILESDIR}/fbsd-threads.c ${WRKSRC}/gdb
86
	@${CP} ${FILESDIR}/amd64bsd-nat.h ${WRKSRC}/gdb
86
87
87
do-install:
88
do-install:
88
	${INSTALL_PROGRAM} ${WRKSRC}/gdb/gdb ${PREFIX}/bin/gdb${VER}
89
	${INSTALL_PROGRAM} ${WRKSRC}/gdb/gdb ${PREFIX}/bin/gdb${VER}
(-)devel/gdb/files/amd64bsd-nat.h (+38 lines)
Line 0 Link Here
1
/* Native-dependent code for amd64 BSD's.
2
3
   Copyright (C) 2011 Free Software Foundation, Inc.
4
5
   This file is part of GDB.
6
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
9
   the Free Software Foundation; either version 3 of the License, or
10
   (at your option) any later version.
11
12
   This program is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
16
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/>.  */
19
20
#ifndef AMD64BSD_NAT_H
21
#define AMD64BSD_NAT_H
22
23
/* Create a prototype *BSD/amd64 target.  The client can override it
24
   with local methods.  */
25
26
extern struct target_ops *amd64bsd_target (void);
27
28
/* low level amd64 debug register functions used in amd64fbsd-nat.c.  */
29
30
extern void amd64bsd_dr_set_control (unsigned long control);
31
32
extern void amd64bsd_dr_set_addr (int regnum, CORE_ADDR addr);
33
34
extern void amd64bsd_dr_reset_addr (int regnum);
35
36
extern unsigned long amd64bsd_dr_get_status (void);
37
38
#endif /* amd64bsd-nat.h */
(-)devel/gdb/files/patch-gdb-Makefile.in (-2 / +11 lines)
Lines 1-5 Link Here
1
--- gdb/Makefile.in	2011-03-30 08:55:39.000000000 +0200
1
--- gdb/Makefile.in.orig	2011-03-30 07:55:39.000000000 +0100
2
+++ gdb/Makefile.in	2011-09-12 17:40:33.000000000 +0200
2
+++ gdb/Makefile.in	2011-10-29 08:02:29.600973609 +0100
3
@@ -571,7 +571,7 @@
3
@@ -571,7 +571,7 @@
4
 	xstormy16-tdep.o \
4
 	xstormy16-tdep.o \
5
 	xtensa-config.o xtensa-tdep.o xtensa-linux-tdep.o \
5
 	xtensa-config.o xtensa-tdep.o xtensa-linux-tdep.o \
Lines 9-14 Link Here
9
 	nbsd-tdep.o obsd-tdep.o \
9
 	nbsd-tdep.o obsd-tdep.o \
10
 	sol2-tdep.o \
10
 	sol2-tdep.o \
11
 	solib-frv.o solib-irix.o solib-svr4.o solib-target.o \
11
 	solib-frv.o solib-irix.o solib-svr4.o solib-target.o \
12
@@ -758,7 +758,7 @@
13
 osf-share/cma_deb_core.h osf-share/AT386/cma_thread_io.h \
14
 osf-share/cma_sched.h proc-utils.h arm-tdep.h ax-gdb.h ppcnbsd-tdep.h \
15
 cli-out.h gdb_expat.h breakpoint.h infcall.h obsd-tdep.h \
16
-exec.h m32r-tdep.h osabi.h gdbcore.h solib-som.h \
17
+exec.h m32r-tdep.h osabi.h gdbcore.h solib-som.h amd64bsd-nat.h \
18
 i386bsd-nat.h xml-support.h xml-tdesc.h alphabsd-tdep.h gdb_obstack.h \
19
 ia64-tdep.h ada-lang.h varobj.h frv-tdep.h nto-tdep.h serial.h \
20
 c-lang.h d-lang.h frame.h event-loop.h block.h cli/cli-setshow.h	\
12
@@ -768,7 +768,7 @@
21
@@ -768,7 +768,7 @@
13
 gnulib/stdint.in.h remote.h gdb.h sparc-nat.h \
22
 gnulib/stdint.in.h remote.h gdb.h sparc-nat.h \
14
 gdbthread.h dwarf2-frame.h nbsd-nat.h dcache.h \
23
 gdbthread.h dwarf2-frame.h nbsd-nat.h dcache.h \
(-)devel/gdb/files/patch-gdb-amd64-nat.h (+12 lines)
Line 0 Link Here
1
--- gdb/amd64-nat.h.orig	2011-09-23 01:36:54.874780473 +0100
2
+++ gdb/amd64-nat.h	2011-09-23 01:28:46.964218514 +0100
3
@@ -50,9 +50,4 @@
4
 extern void amd64_collect_native_gregset (const struct regcache *regcache,
5
 					  void *gregs, int regnum);
6
 
7
-/* Create a prototype *BSD/amd64 target.  The client can override it
8
-   with local methods.  */
9
-
10
-extern struct target_ops *amd64bsd_target (void);
11
-
12
 #endif /* amd64-nat.h */
(-)devel/gdb/files/patch-gdb-amd64bsd-nat.c (+91 lines)
Line 0 Link Here
1
--- gdb/amd64bsd-nat.c.orig	2011-09-23 01:35:24.211306143 +0100
2
+++ gdb/amd64bsd-nat.c	2011-09-23 01:28:28.444487431 +0100
3
@@ -33,6 +33,7 @@
4
 
5
 #include "amd64-tdep.h"
6
 #include "amd64-nat.h"
7
+#include "amd64bsd-nat.h"
8
 #include "inf-ptrace.h"
9
 
10
 
11
@@ -126,3 +127,80 @@
12
   t->to_store_registers = amd64bsd_store_inferior_registers;
13
   return t;
14
 }
15
+
16
+
17
+/* Support for debug registers.  */
18
+
19
+#ifdef HAVE_PT_GETDBREGS
20
+
21
+/* Not all versions of FreeBSD/i386 that support the debug registers
22
+   have this macro.  */
23
+#ifndef DBREG_DRX
24
+#define DBREG_DRX(d, x) ((&d->dr0)[x])
25
+#endif
26
+
27
+static void
28
+amd64bsd_dr_set (int regnum, unsigned long value)
29
+{
30
+  struct dbreg dbregs;
31
+
32
+  if (ptrace (PT_GETDBREGS, PIDGET (inferior_ptid),
33
+              (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
34
+    perror_with_name (_("Couldn't get debug registers"));
35
+
36
+  /* For some mysterious reason, some of the reserved bits in the
37
+     debug control register get set.  Mask these off, otherwise the
38
+     ptrace call below will fail.  */
39
+  DBREG_DRX ((&dbregs), 7) &= ~(0x0000fc00);
40
+
41
+  DBREG_DRX ((&dbregs), regnum) = value;
42
+
43
+  if (ptrace (PT_SETDBREGS, PIDGET (inferior_ptid),
44
+              (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
45
+    perror_with_name (_("Couldn't write debug registers"));
46
+}
47
+
48
+void
49
+amd64bsd_dr_set_control (unsigned long control)
50
+{
51
+  amd64bsd_dr_set (7, control);
52
+}
53
+
54
+void
55
+amd64bsd_dr_set_addr (int regnum, CORE_ADDR addr)
56
+{
57
+  gdb_assert (regnum >= 0 && regnum <= 4);
58
+
59
+  amd64bsd_dr_set (regnum, addr);
60
+}
61
+
62
+void
63
+amd64bsd_dr_reset_addr (int regnum)
64
+{
65
+  gdb_assert (regnum >= 0 && regnum <= 4);
66
+
67
+  amd64bsd_dr_set (regnum, 0);
68
+}
69
+
70
+unsigned long
71
+amd64bsd_dr_get_status (void)
72
+{
73
+  struct dbreg dbregs;
74
+
75
+  /* FIXME: kettenis/2001-03-31: Calling perror_with_name if the
76
+     ptrace call fails breaks debugging remote targets.  The correct
77
+     way to fix this is to add the hardware breakpoint and watchpoint
78
+     stuff to the target vector.  For now, just return zero if the
79
+     ptrace call fails.  */
80
+  if (ptrace (PT_GETDBREGS, PIDGET (inferior_ptid),
81
+	      (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
82
+#if 0
83
+    perror_with_name (_("Couldn't read debug registers"));
84
+#else
85
+    return 0;
86
+#endif
87
+
88
+  return DBREG_DRX ((&dbregs), 6);
89
+}
90
+
91
+#endif /* PT_GETDBREGS */
(-)devel/gdb/files/patch-gdb-amd64fbsd-nat.c (-3 / +32 lines)
Lines 1-5 Link Here
1
--- gdb/amd64fbsd-nat.c.orig	2010-10-13 14:53:14.425152000 -0400
1
--- gdb/amd64fbsd-nat.c.orig	2010-02-03 15:30:25.000000000 +0000
2
+++ gdb/amd64fbsd-nat.c	2010-10-13 15:15:01.080198000 -0400
2
+++ gdb/amd64fbsd-nat.c	2011-09-23 03:08:51.942111416 +0100
3
@@ -27,6 +27,7 @@
3
@@ -27,6 +27,7 @@
4
 #include <signal.h>
4
 #include <signal.h>
5
 #include <stddef.h>
5
 #include <stddef.h>
Lines 8-14 Link Here
8
 #include <sys/ptrace.h>
8
 #include <sys/ptrace.h>
9
 #include <sys/sysctl.h>
9
 #include <sys/sysctl.h>
10
 #include <machine/reg.h>
10
 #include <machine/reg.h>
11
@@ -92,6 +93,47 @@
11
@@ -34,6 +35,8 @@
12
 #include "fbsd-nat.h"
13
 #include "amd64-tdep.h"
14
 #include "amd64-nat.h"
15
+#include "amd64bsd-nat.h"
16
+#include "i386-nat.h"
17
 
18
 
19
 /* Offset in `struct reg' where MEMBER is stored.  */
20
@@ -92,6 +95,47 @@
12
 };
21
 };
13
 
22
 
14
 
23
 
Lines 56-58 Link Here
56
 /* Support for debugging kernel virtual memory images.  */
65
 /* Support for debugging kernel virtual memory images.  */
57
 
66
 
58
 #include <sys/types.h>
67
 #include <sys/types.h>
68
@@ -155,6 +199,19 @@
69
 
70
   /* Add some extra features to the common *BSD/i386 target.  */
71
   t = amd64bsd_target ();
72
+
73
+#ifdef HAVE_PT_GETDBREGS
74
+
75
+  i386_use_watchpoints (t);
76
+
77
+  i386_dr_low.set_control = amd64bsd_dr_set_control;
78
+  i386_dr_low.set_addr = amd64bsd_dr_set_addr;
79
+  i386_dr_low.reset_addr = amd64bsd_dr_reset_addr;
80
+  i386_dr_low.get_status = amd64bsd_dr_get_status;
81
+  i386_set_debug_register_length (8);
82
+
83
+#endif /* HAVE_PT_GETDBREGS */
84
+
85
   t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
86
   t->to_find_memory_regions = fbsd_find_memory_regions;
87
   t->to_make_corefile_notes = fbsd_make_corefile_notes;
(-)devel/gdb/files/patch-gdb-config-i386-fbsd64.mh (+10 lines)
Line 0 Link Here
1
--- gdb/config/i386/fbsd64.mh.orig	2011-09-23 03:15:43.254648862 +0100
2
+++ gdb/config/i386/fbsd64.mh	2011-09-23 03:14:06.843804785 +0100
3
@@ -1,6 +1,6 @@
4
 # Host: FreeBSD/amd64
5
 NATDEPFILES= fork-child.o inf-ptrace.o \
6
-	fbsd-nat.o amd64-nat.o amd64bsd-nat.o amd64fbsd-nat.o \
7
+	fbsd-nat.o i386-nat.o amd64-nat.o amd64bsd-nat.o amd64fbsd-nat.o \
8
 	bsd-kvm.o
9
 
10
 LOADLIBES= -lkvm

Return to bug 160930