FreeBSD Bugzilla – Attachment 171767 Details for
Bug 157755
[patch] gdb(1) hardware watchpoints do not work correctly in multi-threaded programs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch for gdb-7.11.1 (for devel/gdb port)
patch-x86fbsd-nat.txt (text/plain), 6.61 KB, created by
takahiro.kurosawa
on 2016-06-24 23:49:47 UTC
(
hide
)
Description:
patch for gdb-7.11.1 (for devel/gdb port)
Filename:
MIME Type:
Creator:
takahiro.kurosawa
Created:
2016-06-24 23:49:47 UTC
Size:
6.61 KB
patch
obsolete
>diff --git gdb/amd64fbsd-nat.c gdb/amd64fbsd-nat.c >index 63a7197..6f373ce 100644 >--- gdb/amd64fbsd-nat.c >+++ gdb/amd64fbsd-nat.c >@@ -33,6 +33,7 @@ > #include "amd64-tdep.h" > #include "amd64-nat.h" > #include "amd64bsd-nat.h" >+#include "x86fbsd-nat.h" > #include "x86-nat.h" > > >@@ -214,11 +215,11 @@ _initialize_amd64fbsd_nat (void) > > x86_use_watchpoints (t); > >- x86_dr_low.set_control = amd64bsd_dr_set_control; >- x86_dr_low.set_addr = amd64bsd_dr_set_addr; >- x86_dr_low.get_addr = amd64bsd_dr_get_addr; >- x86_dr_low.get_status = amd64bsd_dr_get_status; >- x86_dr_low.get_control = amd64bsd_dr_get_control; >+ x86_dr_low.set_control = x86fbsd_dr_set_control; >+ x86_dr_low.set_addr = x86fbsd_dr_set_addr; >+ x86_dr_low.get_addr = x86fbsd_dr_get_addr; >+ x86_dr_low.get_status = x86fbsd_dr_get_status; >+ x86_dr_low.get_control = x86fbsd_dr_get_control; > x86_set_debug_register_length (8); > > #endif /* HAVE_PT_GETDBREGS */ >diff --git gdb/config/i386/fbsd.mh gdb/config/i386/fbsd.mh >index e5bff3a..463cbb2 100644 >--- gdb/config/i386/fbsd.mh >+++ gdb/config/i386/fbsd.mh >@@ -1,7 +1,7 @@ > # Host: FreeBSD/i386 > NATDEPFILES= fork-child.o inf-ptrace.o \ > fbsd-nat.o x86-nat.o x86-dregs.o i386bsd-nat.o i386fbsd-nat.o \ >- bsd-kvm.o >+ x86fbsd-nat.o bsd-kvm.o > NAT_FILE= nm-fbsd.h > HAVE_NATIVE_GCORE_HOST = 1 > >diff --git gdb/config/i386/fbsd64.mh gdb/config/i386/fbsd64.mh >index 329c526..4efa7c9 100644 >--- gdb/config/i386/fbsd64.mh >+++ gdb/config/i386/fbsd64.mh >@@ -1,7 +1,7 @@ > # Host: FreeBSD/amd64 > NATDEPFILES= fork-child.o inf-ptrace.o \ > fbsd-nat.o amd64-nat.o amd64bsd-nat.o amd64fbsd-nat.o \ >- bsd-kvm.o x86-nat.o x86-dregs.o >+ x86fbsd-nat.o bsd-kvm.o x86-nat.o x86-dregs.o > HAVE_NATIVE_GCORE_HOST = 1 > > LOADLIBES= -lkvm >diff --git gdb/i386fbsd-nat.c gdb/i386fbsd-nat.c >index d7772df..f5d8b6d 100644 >--- gdb/i386fbsd-nat.c >+++ gdb/i386fbsd-nat.c >@@ -31,6 +31,7 @@ > #include "i386-tdep.h" > #include "x86-nat.h" > #include "i386bsd-nat.h" >+#include "x86fbsd-nat.h" > > /* Resume execution of the inferior process. If STEP is nonzero, > single-step it. If SIGNAL is nonzero, give it that signal. */ >@@ -162,11 +163,11 @@ _initialize_i386fbsd_nat (void) > > x86_use_watchpoints (t); > >- x86_dr_low.set_control = i386bsd_dr_set_control; >- x86_dr_low.set_addr = i386bsd_dr_set_addr; >- x86_dr_low.get_addr = i386bsd_dr_get_addr; >- x86_dr_low.get_status = i386bsd_dr_get_status; >- x86_dr_low.get_control = i386bsd_dr_get_control; >+ x86_dr_low.set_control = x86fbsd_dr_set_control; >+ x86_dr_low.set_addr = x86fbsd_dr_set_addr; >+ x86_dr_low.get_addr = x86fbsd_dr_get_addr; >+ x86_dr_low.get_status = x86fbsd_dr_get_status; >+ x86_dr_low.get_control = x86fbsd_dr_get_control; > x86_set_debug_register_length (4); > > #endif /* HAVE_PT_GETDBREGS */ >diff --git gdb/x86fbsd-nat.c gdb/x86fbsd-nat.c >new file mode 100644 >index 0000000..87caf50 >--- /dev/null >+++ gdb/x86fbsd-nat.c >@@ -0,0 +1,128 @@ >+/* FreeBSD/x86 specific debug register support based on i386bsd-nat.c: */ >+/* Native-dependent code for modern i386 BSD's. >+ >+ Copyright (C) 2000-2016 Free Software Foundation, Inc. >+ >+ This file is part of GDB. >+ >+ This program is free software; you can redistribute it and/or modify >+ it under the terms of the GNU General Public License as published by >+ the Free Software Foundation; either version 3 of the License, or >+ (at your option) any later version. >+ >+ This program is distributed in the hope that it will be useful, >+ but WITHOUT ANY WARRANTY; without even the implied warranty of >+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+ GNU General Public License for more details. >+ >+ You should have received a copy of the GNU General Public License >+ along with this program. If not, see <http://www.gnu.org/licenses/>. */ >+ >+#include "defs.h" >+#include "gdbthread.h" >+#include "inferior.h" >+#include "regcache.h" >+ >+#include <signal.h> >+#include <sys/types.h> >+#include <sys/ptrace.h> >+#include <machine/reg.h> >+#include "x86fbsd-nat.h" >+#include "inf-ptrace.h" >+ >+#ifdef HAVE_PT_GETDBREGS >+ >+#ifndef DBREG_DRX >+#define DBREG_DRX(d, x) ((&d->dr0)[x]) >+#endif >+ >+static unsigned long >+x86fbsd_dr_get (ptid_t ptid, int regnum) >+{ >+ struct dbreg dbregs; >+ >+ if (ptrace (PT_GETDBREGS, get_ptrace_pid (ptid), >+ (PTRACE_TYPE_ARG3) &dbregs, 0) == -1) >+ perror_with_name (_("Couldn't read debug registers")); >+ >+ return DBREG_DRX ((&dbregs), regnum); >+} >+ >+static void >+x86fbsd_dr_set (ptid_t ptid, int regnum, unsigned long value) >+{ >+ struct dbreg dbregs; >+ >+ if (ptrace (PT_GETDBREGS, get_ptrace_pid (ptid), >+ (PTRACE_TYPE_ARG3) &dbregs, 0) == -1) >+ perror_with_name (_("Couldn't get debug registers")); >+ >+ /* For some mysterious reason, some of the reserved bits in the >+ debug control register get set. Mask these off, otherwise the >+ ptrace call below will fail. */ >+#if defined(__i386__) >+ DBREG_DRX ((&dbregs), 7) &= ~(0x0000fc00); >+#elif defined(__amd64__) >+ DBREG_DRX ((&dbregs), 7) &= ~(0xffffffff0000fc00); >+#endif >+ >+ DBREG_DRX ((&dbregs), regnum) = value; >+ >+ if (ptrace (PT_SETDBREGS, get_ptrace_pid (ptid), >+ (PTRACE_TYPE_ARG3) &dbregs, 0) == -1) >+ perror_with_name (_("Couldn't write debug registers")); >+} >+ >+struct x86fbsd_dr_set_arg { >+ int regnum; >+ unsigned long value; >+}; >+ >+static int >+x86fbsd_dr_set_cb(struct thread_info *thread, void *arg) >+{ >+ struct x86fbsd_dr_set_arg *dsp = arg; >+ x86fbsd_dr_set (thread->ptid, dsp->regnum, dsp->value); >+ return 0; >+} >+ >+void >+x86fbsd_dr_set_control (unsigned long control) >+{ >+ struct x86fbsd_dr_set_arg ds; >+ >+ ds.regnum = 7; >+ ds.value = control; >+ iterate_over_threads (x86fbsd_dr_set_cb, &ds); >+} >+ >+void >+x86fbsd_dr_set_addr (int regnum, CORE_ADDR addr) >+{ >+ struct x86fbsd_dr_set_arg ds; >+ >+ gdb_assert (regnum >= 0 && regnum <= 4); >+ ds.regnum = regnum; >+ ds.value = addr; >+ iterate_over_threads (x86fbsd_dr_set_cb, &ds); >+} >+ >+CORE_ADDR >+x86fbsd_dr_get_addr (int regnum) >+{ >+ return x86fbsd_dr_get (inferior_ptid, regnum); >+} >+ >+unsigned long >+x86fbsd_dr_get_status (void) >+{ >+ return x86fbsd_dr_get (inferior_ptid, 6); >+} >+ >+unsigned long >+x86fbsd_dr_get_control (void) >+{ >+ return x86fbsd_dr_get (inferior_ptid, 7); >+} >+ >+#endif /* HAVE_PT_GETDBREGS */ >diff --git gdb/x86fbsd-nat.h gdb/x86fbsd-nat.h >new file mode 100644 >index 0000000..3c26033 >--- /dev/null >+++ gdb/x86fbsd-nat.h >@@ -0,0 +1,10 @@ >+#ifndef X86FBSD_NAT_H >+#define X86FBSD_NAT_H >+ >+extern void x86fbsd_dr_set_control (unsigned long control); >+extern void x86fbsd_dr_set_addr (int regnum, CORE_ADDR addr); >+extern CORE_ADDR x86fbsd_dr_get_addr (int regnum); >+extern unsigned long x86fbsd_dr_get_status (void); >+extern unsigned long x86fbsd_dr_get_control (void); >+ >+#endif /* x86fbsd-nat.h */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 157755
:
115873
| 171767