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

Collapse All | Expand All

(-)gdb/amd64fbsd-nat.c (-5 / +6 lines)
Lines 33-38 Link Here
33
#include "amd64-tdep.h"
33
#include "amd64-tdep.h"
34
#include "amd64-nat.h"
34
#include "amd64-nat.h"
35
#include "amd64bsd-nat.h"
35
#include "amd64bsd-nat.h"
36
#include "x86fbsd-nat.h"
36
#include "x86-nat.h"
37
#include "x86-nat.h"
37
38
38
39
Lines 214-224 _initialize_amd64fbsd_nat (void) Link Here
214
215
215
  x86_use_watchpoints (t);
216
  x86_use_watchpoints (t);
216
217
217
  x86_dr_low.set_control = amd64bsd_dr_set_control;
218
  x86_dr_low.set_control = x86fbsd_dr_set_control;
218
  x86_dr_low.set_addr = amd64bsd_dr_set_addr;
219
  x86_dr_low.set_addr = x86fbsd_dr_set_addr;
219
  x86_dr_low.get_addr = amd64bsd_dr_get_addr;
220
  x86_dr_low.get_addr = x86fbsd_dr_get_addr;
220
  x86_dr_low.get_status = amd64bsd_dr_get_status;
221
  x86_dr_low.get_status = x86fbsd_dr_get_status;
221
  x86_dr_low.get_control = amd64bsd_dr_get_control;
222
  x86_dr_low.get_control = x86fbsd_dr_get_control;
222
  x86_set_debug_register_length (8);
223
  x86_set_debug_register_length (8);
223
224
224
#endif /* HAVE_PT_GETDBREGS */
225
#endif /* HAVE_PT_GETDBREGS */
(-)gdb/config/i386/fbsd.mh (-1 / +1 lines)
Lines 1-7 Link Here
1
# Host: FreeBSD/i386
1
# Host: FreeBSD/i386
2
NATDEPFILES= fork-child.o inf-ptrace.o \
2
NATDEPFILES= fork-child.o inf-ptrace.o \
3
	fbsd-nat.o x86-nat.o x86-dregs.o i386bsd-nat.o i386fbsd-nat.o \
3
	fbsd-nat.o x86-nat.o x86-dregs.o i386bsd-nat.o i386fbsd-nat.o \
4
	bsd-kvm.o
4
	x86fbsd-nat.o bsd-kvm.o
5
NAT_FILE= nm-fbsd.h
5
NAT_FILE= nm-fbsd.h
6
HAVE_NATIVE_GCORE_HOST = 1
6
HAVE_NATIVE_GCORE_HOST = 1
7
7
(-)gdb/config/i386/fbsd64.mh (-1 / +1 lines)
Lines 1-7 Link Here
1
# Host: FreeBSD/amd64
1
# Host: FreeBSD/amd64
2
NATDEPFILES= fork-child.o inf-ptrace.o \
2
NATDEPFILES= fork-child.o inf-ptrace.o \
3
	fbsd-nat.o amd64-nat.o amd64bsd-nat.o amd64fbsd-nat.o \
3
	fbsd-nat.o amd64-nat.o amd64bsd-nat.o amd64fbsd-nat.o \
4
	bsd-kvm.o x86-nat.o x86-dregs.o
4
	x86fbsd-nat.o bsd-kvm.o x86-nat.o x86-dregs.o
5
HAVE_NATIVE_GCORE_HOST = 1
5
HAVE_NATIVE_GCORE_HOST = 1
6
6
7
LOADLIBES= -lkvm
7
LOADLIBES= -lkvm
(-)gdb/i386fbsd-nat.c (-5 / +6 lines)
Lines 31-36 Link Here
31
#include "i386-tdep.h"
31
#include "i386-tdep.h"
32
#include "x86-nat.h"
32
#include "x86-nat.h"
33
#include "i386bsd-nat.h"
33
#include "i386bsd-nat.h"
34
#include "x86fbsd-nat.h"
34
35
35
/* Resume execution of the inferior process.  If STEP is nonzero,
36
/* Resume execution of the inferior process.  If STEP is nonzero,
36
   single-step it.  If SIGNAL is nonzero, give it that signal.  */
37
   single-step it.  If SIGNAL is nonzero, give it that signal.  */
Lines 162-172 _initialize_i386fbsd_nat (void) Link Here
162
163
163
  x86_use_watchpoints (t);
164
  x86_use_watchpoints (t);
164
165
165
  x86_dr_low.set_control = i386bsd_dr_set_control;
166
  x86_dr_low.set_control = x86fbsd_dr_set_control;
166
  x86_dr_low.set_addr = i386bsd_dr_set_addr;
167
  x86_dr_low.set_addr = x86fbsd_dr_set_addr;
167
  x86_dr_low.get_addr = i386bsd_dr_get_addr;
168
  x86_dr_low.get_addr = x86fbsd_dr_get_addr;
168
  x86_dr_low.get_status = i386bsd_dr_get_status;
169
  x86_dr_low.get_status = x86fbsd_dr_get_status;
169
  x86_dr_low.get_control = i386bsd_dr_get_control;
170
  x86_dr_low.get_control = x86fbsd_dr_get_control;
170
  x86_set_debug_register_length (4);
171
  x86_set_debug_register_length (4);
171
172
172
#endif /* HAVE_PT_GETDBREGS */
173
#endif /* HAVE_PT_GETDBREGS */
(-)gdb/x86fbsd-nat.c (+128 lines)
Added Link Here
1
/* FreeBSD/x86 specific debug register support based on i386bsd-nat.c: */
2
/* Native-dependent code for modern i386 BSD's.
3
4
   Copyright (C) 2000-2016 Free Software Foundation, Inc.
5
6
   This file is part of GDB.
7
8
   This program is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 3 of the License, or
11
   (at your option) any later version.
12
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
18
   You should have received a copy of the GNU General Public License
19
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
21
#include "defs.h"
22
#include "gdbthread.h"
23
#include "inferior.h"
24
#include "regcache.h"
25
26
#include <signal.h>
27
#include <sys/types.h>
28
#include <sys/ptrace.h>
29
#include <machine/reg.h>
30
#include "x86fbsd-nat.h"
31
#include "inf-ptrace.h"
32
33
#ifdef HAVE_PT_GETDBREGS
34
35
#ifndef DBREG_DRX
36
#define DBREG_DRX(d, x) ((&d->dr0)[x])
37
#endif
38
39
static unsigned long
40
x86fbsd_dr_get (ptid_t ptid, int regnum)
41
{
42
  struct dbreg dbregs;
43
44
  if (ptrace (PT_GETDBREGS, get_ptrace_pid (ptid),
45
	      (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
46
    perror_with_name (_("Couldn't read debug registers"));
47
48
  return DBREG_DRX ((&dbregs), regnum);
49
}
50
51
static void
52
x86fbsd_dr_set (ptid_t ptid, int regnum, unsigned long value)
53
{
54
  struct dbreg dbregs;
55
56
  if (ptrace (PT_GETDBREGS, get_ptrace_pid (ptid),
57
              (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
58
    perror_with_name (_("Couldn't get debug registers"));
59
60
  /* For some mysterious reason, some of the reserved bits in the
61
     debug control register get set.  Mask these off, otherwise the
62
     ptrace call below will fail.  */
63
#if defined(__i386__)
64
  DBREG_DRX ((&dbregs), 7) &= ~(0x0000fc00);
65
#elif defined(__amd64__)
66
  DBREG_DRX ((&dbregs), 7) &= ~(0xffffffff0000fc00);
67
#endif
68
69
  DBREG_DRX ((&dbregs), regnum) = value;
70
71
  if (ptrace (PT_SETDBREGS, get_ptrace_pid (ptid),
72
              (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
73
    perror_with_name (_("Couldn't write debug registers"));
74
}
75
76
struct x86fbsd_dr_set_arg {
77
  int regnum;
78
  unsigned long value;
79
};
80
81
static int
82
x86fbsd_dr_set_cb(struct thread_info *thread, void *arg)
83
{
84
  struct x86fbsd_dr_set_arg *dsp = arg;
85
  x86fbsd_dr_set (thread->ptid, dsp->regnum, dsp->value);
86
  return 0;
87
}
88
89
void
90
x86fbsd_dr_set_control (unsigned long control)
91
{
92
  struct x86fbsd_dr_set_arg ds;
93
94
  ds.regnum = 7;
95
  ds.value = control;
96
  iterate_over_threads (x86fbsd_dr_set_cb, &ds);
97
}
98
99
void
100
x86fbsd_dr_set_addr (int regnum, CORE_ADDR addr)
101
{
102
  struct x86fbsd_dr_set_arg ds;
103
104
  gdb_assert (regnum >= 0 && regnum <= 4);
105
  ds.regnum = regnum;
106
  ds.value = addr;
107
  iterate_over_threads (x86fbsd_dr_set_cb, &ds);
108
}
109
110
CORE_ADDR
111
x86fbsd_dr_get_addr (int regnum)
112
{
113
  return x86fbsd_dr_get (inferior_ptid, regnum);
114
}
115
116
unsigned long
117
x86fbsd_dr_get_status (void)
118
{
119
  return x86fbsd_dr_get (inferior_ptid, 6);
120
}
121
122
unsigned long
123
x86fbsd_dr_get_control (void)
124
{
125
  return x86fbsd_dr_get (inferior_ptid, 7);
126
}
127
128
#endif /* HAVE_PT_GETDBREGS */
(-)gdb/x86fbsd-nat.h (+10 lines)
Added Link Here
1
#ifndef X86FBSD_NAT_H
2
#define X86FBSD_NAT_H
3
4
extern void x86fbsd_dr_set_control (unsigned long control);
5
extern void x86fbsd_dr_set_addr (int regnum, CORE_ADDR addr);
6
extern CORE_ADDR x86fbsd_dr_get_addr (int regnum);
7
extern unsigned long x86fbsd_dr_get_status (void);
8
extern unsigned long x86fbsd_dr_get_control (void);
9
10
#endif /* x86fbsd-nat.h */

Return to bug 157755