This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA-v3] Remove i386 low level debug register function from nm- header file.
- From: "Pierre Muller" <muller at ics dot u-strasbg dot fr>
- To: "'Ulrich Weigand'" <uweigand at de dot ibm dot com>
- Cc: <gdb-patches at sourceware dot org>, "'Pedro Alves'" <pedro at codesourcery dot com>, "'Eli Zaretskii'" <eliz at gnu dot org>
- Date: Thu, 14 May 2009 01:39:36 +0200
- Subject: [RFA-v3] Remove i386 low level debug register function from nm- header file.
- References: <000601c9d348$92580d80$b7082880$@u-strasbg.fr> from "Pierre Muller" at May 12, 2009 11:28:18 PM <200905131533.n4DFXcvm019686@d12av02.megacenter.de.ibm.com>
Thanks to everyone for the feeback.
I tried to handle all your remarks.
I tested compilation on
go32v2, i386 windows and amd64 linux.
All three went OK.
I saw nothing special on testsuite for
the two last ones.
Pierre
2009-05-13 Pierre Muller <muller.u-strasbg.fr>
Remove all i386 debug register low level macros in config nm files.
(I386_DR_LOW_SET_ADDR, I386_DR_LOW_RESET_ADDR): Remove.
(I386_DR_LOW_GET_STATUS, I386_DR_LOW_SET_CONTROL): Remove.
(I386_USE_GENERIC_WATCHPOIINTS): Remove.
* i386-nat.h: New file (adapted from config/i386/nm-i386.h).
(struct i386_dr_low_type): New type.
(i386_dr_low): New global variable.
* i386-nat.c (TARGET_HAS_DR_LEN_8): Update macro.
(i386_insert_aligned_watchpoint): Replace i386 dr low macros by
i386_dr_low struct variable fields.
(i386_remove_aligned_watchpoint): Likewise.
(i386_stopped_data_address): Likewise.
(i386_stopped_by_hwbp): Likewise.
(show_debug_regs_command_added): New static variable.
(add_show_debug_regs_command): New static function.
(i386_use_watchpoints): Call add_show_debug_regs_command if not
done.
(i386_set_debug_register_length): New function.
(_initialize_i386_nat): Delete.
* amd64-linux-nat.c: Include "i386-nat.h".
(amd64_linux_dr_set_control): Change to static.
(amd64_linux_dr_get_status): Change to static.
(amd64_linux_dr_set_addr,amd64_linux_dr_reset_addr): Likewise.
(_initialize_amd64_linux_nat): Set i386_dr_low variable fields.
* go32-nat.c: Include "i386-nat.h".
(go32_set_addr): Change to static.
(go32_set_dr7): Change to static. Change arg type to unisgned long.
(go32_get_dr6): Change to static. Change return type to unisnged
long.
(init_go32_ops): Set i386_dr_low variable fields.
* i386-linux-nat.c: Include "i386-nat.h".
(i386_linux_dr_set_control, i386_linux_dr_get_status): Change to
static.
(i386_linux_dr_set_addr, i386_linux_dr_reset_addr): Idem.
(_initialize_i386_linux_nat): Set i386_dr_low variable fields.
* i386bsd-nat.h: Declare functions used for
i386_dr_low fields in i386fbsd-nat.c.
* i386fbsd-nat.c: Include "i386-nat.h".
(_initialize_i386fbsd_nat): Set i386_dr_low variable fields.
* windows-nat.c: Include "i386-nat.h".
(cygwin_set_dr, cygwin_get_dr6, cygwin_set_dr7): Add prototypes.
Change to static.
(cygwin_get_dr6): Change return type to unisnged long.
(cygwin_set_dr7): Change arg type to unisgned long.
(init_windows_ops): Set i386_dr_low function fields.
* amd64-windows-nat.c (_initialize_amd64_windows_nat): Call
i386_set_debug_register_length.
* i386-windows-nat.c (_initialize_i386_windows_nat): Likewise.
* config/i386/nm-cygwin.h: Remove all I386_* macros.
* config/i386/nm-cygwin64.h: Likewise.
* config/i386/nm-fbsd.h: Likewise.
* config/i386/nm-linux.h: Likewise.
* config/i386/nm-i386.h: Remove completely.
* config/i386/nm-go32.h: Remove completely.
* config/i386/nm-linux64.h: Remove completely.
* config/i386/go32.mh (NAT_FILE): Remove entry.
* config/i386/linux64.h (NAT_FILE): Change to config/nm-linux.h.
Index: src/gdb/amd64-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/amd64-linux-nat.c,v
retrieving revision 1.25
diff -u -p -r1.25 amd64-linux-nat.c
--- src/gdb/amd64-linux-nat.c 17 Mar 2009 18:39:08 -0000 1.25
+++ src/gdb/amd64-linux-nat.c 13 May 2009 22:06:49 -0000
@@ -50,6 +50,7 @@
#include "amd64-tdep.h"
#include "i386-linux-tdep.h"
#include "amd64-nat.h"
+#include "i386-nat.h"
/* Mapping between the general-purpose registers in GNU/Linux x86-64
`struct user' format and GDB's register cache layout. */
@@ -285,7 +286,7 @@ amd64_linux_dr_set (ptid_t ptid, int reg
perror_with_name (_("Couldn't write debug register"));
}
-void
+static void
amd64_linux_dr_set_control (unsigned long control)
{
struct lwp_info *lp;
@@ -296,7 +297,7 @@ amd64_linux_dr_set_control (unsigned lon
amd64_linux_dr_set (ptid, DR_CONTROL, control);
}
-void
+static void
amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr)
{
struct lwp_info *lp;
@@ -309,13 +310,13 @@ amd64_linux_dr_set_addr (int regnum, COR
amd64_linux_dr_set (ptid, DR_FIRSTADDR + regnum, addr);
}
-void
+static void
amd64_linux_dr_reset_addr (int regnum)
{
amd64_linux_dr_set_addr (regnum, 0);
}
-unsigned long
+static unsigned long
amd64_linux_dr_get_status (void)
{
return amd64_linux_dr_get (inferior_ptid, DR_STATUS);
@@ -667,6 +668,12 @@ _initialize_amd64_linux_nat (void)
i386_use_watchpoints (t);
+ i386_dr_low.set_control = amd64_linux_dr_set_control;
+ i386_dr_low.set_addr = amd64_linux_dr_set_addr;
+ i386_dr_low.reset_addr = amd64_linux_dr_reset_addr;
+ i386_dr_low.get_status = amd64_linux_dr_get_status;
+ i386_set_debug_register_length (8);
+
/* Override the GNU/Linux inferior startup hook. */
super_post_startup_inferior = t->to_post_startup_inferior;
t->to_post_startup_inferior = amd64_linux_child_post_startup_inferior;
Index: src/gdb/amd64-windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/amd64-windows-nat.c,v
retrieving revision 1.3
diff -u -p -r1.3 amd64-windows-nat.c
--- src/gdb/amd64-windows-nat.c 13 Jan 2009 04:14:07 -0000 1.3
+++ src/gdb/amd64-windows-nat.c 13 May 2009 22:06:49 -0000
@@ -17,7 +17,7 @@
#include "defs.h"
#include "windows-nat.h"
-
+#include "i386-nat.h"
#include <windows.h>
#define context_offset(x) (offsetof (CONTEXT, x))
@@ -89,4 +89,5 @@ void
_initialize_amd64_windows_nat (void)
{
windows_set_context_register_offsets (mappings);
+ i386_set_debug_register_length (8);
}
Index: src/gdb/go32-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/go32-nat.c,v
retrieving revision 1.74
diff -u -p -r1.74 go32-nat.c
--- src/gdb/go32-nat.c 4 May 2009 09:54:17 -0000 1.74
+++ src/gdb/go32-nat.c 13 May 2009 22:06:50 -0000
@@ -85,6 +85,7 @@
#include <fcntl.h>
#include "defs.h"
+#include "i386-nat.h"
#include "inferior.h"
#include "gdbthread.h"
#include "gdb_wait.h"
@@ -768,7 +769,7 @@ go32_can_run (void)
/* Pass the address ADDR to the inferior in the I'th debug register.
Here we just store the address in D_REGS, the watchpoint will be
actually set up when go32_wait runs the debuggee. */
-void
+static void
go32_set_dr (int i, CORE_ADDR addr)
{
if (i < 0 || i > 3)
@@ -780,8 +781,8 @@ go32_set_dr (int i, CORE_ADDR addr)
/* Pass the value VAL to the inferior in the DR7 debug control
register. Here we just store the address in D_REGS, the watchpoint
will be actually set up when go32_wait runs the debuggee. */
-void
-go32_set_dr7 (unsigned val)
+static void
+go32_set_dr7 (unsigned long val)
{
CONTROL = val;
}
@@ -789,7 +790,7 @@ go32_set_dr7 (unsigned val)
/* Get the value of the DR6 debug status register from the inferior.
Here we just return the value stored in D_REGS, as we've got it
from the last go32_wait call. */
-unsigned
+static unsigned long
go32_get_dr6 (void)
{
return STATUS;
@@ -975,6 +976,13 @@ init_go32_ops (void)
i386_use_watchpoints (&go32_ops);
+
+ i386_dr_low.set_control = go32_set_dr7;
+ i386_dr_low.set_addr = go32_set_dr;
+ i386_dr_low.reset_addr = NULL;
+ i386_dr_low.get_status = go32_get_dr6;
+ i386_set_debug_register_length (4);
+
go32_ops.to_magic = OPS_MAGIC;
/* Initialize child's cwd as empty to be initialized when starting
Index: src/gdb/i386-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-linux-nat.c,v
retrieving revision 1.90
diff -u -p -r1.90 i386-linux-nat.c
--- src/gdb/i386-linux-nat.c 23 Feb 2009 00:42:06 -0000 1.90
+++ src/gdb/i386-linux-nat.c 13 May 2009 22:06:50 -0000
@@ -19,6 +19,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "defs.h"
+#include "i386-nat.h"
#include "inferior.h"
#include "gdbcore.h"
#include "regcache.h"
@@ -629,7 +630,7 @@ i386_linux_dr_set (ptid_t ptid, int regn
perror_with_name (_("Couldn't write debug register"));
}
-void
+static void
i386_linux_dr_set_control (unsigned long control)
{
struct lwp_info *lp;
@@ -640,7 +641,7 @@ i386_linux_dr_set_control (unsigned long
i386_linux_dr_set (ptid, DR_CONTROL, control);
}
-void
+static void
i386_linux_dr_set_addr (int regnum, CORE_ADDR addr)
{
struct lwp_info *lp;
@@ -653,13 +654,13 @@ i386_linux_dr_set_addr (int regnum, CORE
i386_linux_dr_set (ptid, DR_FIRSTADDR + regnum, addr);
}
-void
+static void
i386_linux_dr_reset_addr (int regnum)
{
i386_linux_dr_set_addr (regnum, 0);
}
-unsigned long
+static unsigned long
i386_linux_dr_get_status (void)
{
return i386_linux_dr_get (inferior_ptid, DR_STATUS);
@@ -825,6 +826,12 @@ _initialize_i386_linux_nat (void)
i386_use_watchpoints (t);
+ i386_dr_low.set_control = i386_linux_dr_set_control;
+ i386_dr_low.set_addr = i386_linux_dr_set_addr;
+ i386_dr_low.reset_addr = i386_linux_dr_reset_addr;
+ i386_dr_low.get_status = i386_linux_dr_get_status;
+ i386_set_debug_register_length (4);
+
/* Override the default ptrace resume method. */
t->to_resume = i386_linux_resume;
Index: src/gdb/i386-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-nat.c,v
retrieving revision 1.21
diff -u -p -r1.21 i386-nat.c
--- src/gdb/i386-nat.c 12 May 2009 16:51:12 -0000 1.21
+++ src/gdb/i386-nat.c 13 May 2009 22:06:50 -0000
@@ -18,11 +18,13 @@
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 "i386-nat.h"
#include "defs.h"
#include "breakpoint.h"
#include "command.h"
#include "gdbcmd.h"
#include "target.h"
+#include "gdb_assert.h"
/* Support for hardware watchpoints and breakpoints using the i386
debug registers.
@@ -32,38 +34,14 @@
more of the watchpoints triggered and at what address, checking
whether a given region can be watched, etc.
- A target which wants to use these functions should define several
- macros, such as `target_insert_watchpoint' and
- `target_stopped_data_address', listed in target.h, to call the
- appropriate functions below. It should also define
- I386_USE_GENERIC_WATCHPOINTS in its tm.h file.
-
- In addition, each target should provide several low-level macros
- that will be called to insert watchpoints and hardware breakpoints
- into the inferior, remove them, and check their status. These
- macros are:
-
- I386_DR_LOW_SET_CONTROL -- set the debug control (DR7)
- register to a given value
-
- I386_DR_LOW_SET_ADDR -- put an address into one debug
- register
-
- I386_DR_LOW_RESET_ADDR -- reset the address stored in
- one debug register
-
- I386_DR_LOW_GET_STATUS -- return the value of the debug
- status (DR6) register.
-
The functions below implement debug registers sharing by reference
counts, and allow to watch regions up to 16 bytes long. */
-#ifdef I386_USE_GENERIC_WATCHPOINTS
+struct i386_dr_low_type i386_dr_low;
+
/* Support for 8-byte wide hw watchpoints. */
-#ifndef TARGET_HAS_DR_LEN_8
-#define TARGET_HAS_DR_LEN_8 0
-#endif
+#define TARGET_HAS_DR_LEN_8 (i386_dr_low.debug_register_length == 8)
/* Debug registers' indices. */
#define DR_NADDR 4 /* The number of debug address registers.
*/
@@ -168,7 +146,7 @@
/* Mirror the inferior's DRi registers. We keep the status and
control registers separated because they don't hold addresses. */
static CORE_ADDR dr_mirror[DR_NADDR];
-static unsigned dr_status_mirror, dr_control_mirror;
+static unsigned long dr_status_mirror, dr_control_mirror;
/* Reference counts for each debug register. */
static int dr_ref_count[DR_NADDR];
@@ -256,8 +234,8 @@ i386_show_dr (const char *func, CORE_ADD
here. */
: "??unknown??"))));
puts_unfiltered (":\n");
- printf_unfiltered ("\tCONTROL (DR7): %08x STATUS (DR6): %08x\n",
- dr_control_mirror, dr_status_mirror);
+ printf_unfiltered ("\tCONTROL (DR7): %s STATUS (DR6): %s\n",
+ phex (dr_control_mirror, 8), phex (dr_status_mirror,
8));
ALL_DEBUG_REGISTERS(i)
{
printf_unfiltered ("\
@@ -330,6 +308,9 @@ i386_insert_aligned_watchpoint (CORE_ADD
{
int i;
+ if (!i386_dr_low.set_addr || !i386_dr_low.set_control)
+ return -1;
+
/* First, look for an occupied debug register with the same address
and the same RW and LEN definitions. If we find one, we can
reuse it for this watchpoint as well (and save a register). */
@@ -373,8 +354,8 @@ i386_insert_aligned_watchpoint (CORE_ADD
dr_control_mirror &= I386_DR_CONTROL_MASK;
/* Finally, actually pass the info to the inferior. */
- I386_DR_LOW_SET_ADDR (i, addr);
- I386_DR_LOW_SET_CONTROL (dr_control_mirror);
+ i386_dr_low.set_addr (i, addr);
+ i386_dr_low.set_control (dr_control_mirror);
return 0;
}
@@ -402,8 +383,9 @@ i386_remove_aligned_watchpoint (CORE_ADD
dr_mirror[i] = 0;
I386_DR_DISABLE (i);
/* Reset it in the inferior. */
- I386_DR_LOW_SET_CONTROL (dr_control_mirror);
- I386_DR_LOW_RESET_ADDR (i);
+ i386_dr_low.set_control (dr_control_mirror);
+ if (i386_dr_low.reset_addr)
+ i386_dr_low.reset_addr (i);
}
retval = 0;
}
@@ -492,7 +474,7 @@ Invalid value %d of operation in i386_ha
address ADDR and whose length is LEN bytes. Watch memory accesses
of the type TYPE. Return 0 on success, -1 on failure. */
-int
+static int
i386_insert_watchpoint (CORE_ADDR addr, int len, int type)
{
int retval;
@@ -516,7 +498,7 @@ i386_insert_watchpoint (CORE_ADDR addr,
/* Remove a watchpoint that watched the memory region which starts at
address ADDR, whose length is LEN bytes, and for accesses of the
type TYPE. Return 0 on success, -1 on failure. */
-int
+static int
i386_remove_watchpoint (CORE_ADDR addr, int len, int type)
{
int retval;
@@ -540,7 +522,7 @@ i386_remove_watchpoint (CORE_ADDR addr,
/* Return non-zero if we can watch a memory region that starts at
address ADDR and whose length is LEN bytes. */
-int
+static int
i386_region_ok_for_watchpoint (CORE_ADDR addr, int len)
{
int nregs;
@@ -555,14 +537,14 @@ i386_region_ok_for_watchpoint (CORE_ADDR
address associated with that watchpoint and return non-zero.
Otherwise, return zero. */
-int
+static int
i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
{
CORE_ADDR addr = 0;
int i;
int rc = 0;
- dr_status_mirror = I386_DR_LOW_GET_STATUS ();
+ dr_status_mirror = i386_dr_low.get_status ();
ALL_DEBUG_REGISTERS(i)
{
@@ -588,7 +570,7 @@ i386_stopped_data_address (struct target
return rc;
}
-int
+static int
i386_stopped_by_watchpoint (void)
{
CORE_ADDR addr = 0;
@@ -598,12 +580,12 @@ i386_stopped_by_watchpoint (void)
/* Return non-zero if the inferior has some break/watchpoint that
triggered. */
-int
+static int
i386_stopped_by_hwbp (void)
{
int i;
- dr_status_mirror = I386_DR_LOW_GET_STATUS ();
+ dr_status_mirror = i386_dr_low.get_status ();
if (maint_show_dr)
i386_show_dr ("stopped_by_hwbp", 0, 0, hw_execute);
@@ -618,7 +600,7 @@ i386_stopped_by_hwbp (void)
/* Insert a hardware-assisted breakpoint at BP_TGT->placed_address.
Return 0 on success, EBUSY on failure. */
-int
+static int
i386_insert_hw_breakpoint (struct bp_target_info *bp_tgt)
{
unsigned len_rw = i386_length_and_rw_bits (1, hw_execute);
@@ -634,7 +616,7 @@ i386_insert_hw_breakpoint (struct bp_tar
/* Remove a hardware-assisted breakpoint at BP_TGT->placed_address.
Return 0 on success, -1 on failure. */
-int
+static int
i386_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
{
unsigned len_rw = i386_length_and_rw_bits (1, hw_execute);
@@ -670,6 +652,27 @@ i386_can_use_hw_breakpoint (int type, in
return 1;
}
+static void
+add_show_debug_regs_command (void)
+{
+ /* A maintenance command to enable printing the internal DRi mirror
+ variables. */
+ add_setshow_boolean_cmd ("show-debug-regs", class_maintenance,
+ &maint_show_dr, _("\
+Set whether to show variables that mirror the x86 debug registers."), _("\
+Show whether to show variables that mirror the x86 debug registers."), _("\
+Use \"on\" to enable, \"off\" to disable.\n\
+If enabled, the debug registers values are shown when GDB inserts\n\
+or removes a hardware breakpoint or watchpoint, and when the inferior\n\
+triggers a breakpoint or watchpoint."),
+ NULL,
+ NULL,
+ &maintenance_set_cmdlist,
+ &maintenance_show_cmdlist);
+}
+
+/* There are only two global functions left. */
+
void
i386_use_watchpoints (struct target_ops *t)
{
@@ -688,29 +691,12 @@ i386_use_watchpoints (struct target_ops
t->to_remove_hw_breakpoint = i386_remove_hw_breakpoint;
}
-#endif /* I386_USE_GENERIC_WATCHPOINTS */
-
-
-/* Provide a prototype to silence -Wmissing-prototypes. */
-void _initialize_i386_nat (void);
-
void
-_initialize_i386_nat (void)
+i386_set_debug_register_length (int len)
{
-#ifdef I386_USE_GENERIC_WATCHPOINTS
- /* A maintenance command to enable printing the internal DRi mirror
- variables. */
- add_setshow_boolean_cmd ("show-debug-regs", class_maintenance,
- &maint_show_dr, _("\
-Set whether to show variables that mirror the x86 debug registers."), _("\
-Show whether to show variables that mirror the x86 debug registers."), _("\
-Use \"on\" to enable, \"off\" to disable.\n\
-If enabled, the debug registers values are shown when GDB inserts\n\
-or removes a hardware breakpoint or watchpoint, and when the inferior\n\
-triggers a breakpoint or watchpoint."),
- NULL,
- NULL,
- &maintenance_set_cmdlist,
- &maintenance_show_cmdlist);
-#endif
+ /* This function should be called only once for each native target. */
+ gdb_assert (i386_dr_low.debug_register_length == 0);
+ gdb_assert (len == 4 || len == 8);
+ i386_dr_low.debug_register_length = len;
+ add_show_debug_regs_command ();
}
Index: src/gdb/i386-nat.h
===================================================================
RCS file: i386-nat.h
diff -N i386-nat.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/gdb/i386-nat.h 13 May 2009 22:06:51 -0000
@@ -0,0 +1,89 @@
+/* Native-dependent code for the i386.
+
+ Low level functions to implement Oeprating System specific
+ code to manipulate I386 debug registers.
+
+ Copyright (C) 2009
+ 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"
+
+#ifndef I386_NAT_H
+#define I386_NAT_H 1
+
+/* Hardware-assisted breakpoints and watchpoints. */
+
+/* Add watchpoint methods to the provided target_ops.
+ Targets using i386 family debug registers for watchpoints should call
+ this. */
+struct target_ops;
+extern void i386_use_watchpoints (struct target_ops *);
+
+/* Support for hardware watchpoints and breakpoints using the i386
+ debug registers.
+
+ This provides several functions for inserting and removing
+ hardware-assisted breakpoints and watchpoints, testing if one or
+ more of the watchpoints triggered and at what address, checking
+ whether a given region can be watched, etc.
+
+ In addition, each target should provide several low-level functions
+ regrouped into i386_dr_low_type struct below. These functions
+ that will be called to insert watchpoints and hardware breakpoints
+ into the inferior, remove them, and check their status. These
+ functions are:
+
+ set_control -- set the debug control (DR7)
+ register to a given value
+
+ set_addr -- put an address into one debug
+ register
+
+ reset_addr -- reset the address stored in
+ one debug register
+
+ get_status -- return the value of the debug
+ status (DR6) register.
+
+ Additionally, the native file should set the debug_register_length
+ field to 4 or 8 depending on the number of bytes used for
+ deubg registers. */
+
+struct i386_dr_low_type
+ {
+ void (*set_control) (unsigned long);
+ void (*set_addr) (int, CORE_ADDR);
+ void (*reset_addr) (int);
+ unsigned long (*get_status) (void);
+ int debug_register_length;
+ };
+
+extern struct i386_dr_low_type i386_dr_low;
+
+/* Use this function to set i386_dr_low debug_register_length field
+ rather than setting it directly to check that the length is only
+ set once. It also enables the 'maint set/show show-debug-regs'
+ command. */
+
+extern void i386_set_debug_register_length (int len);
+
+/* Use this function to reset the i386-nat.c debug register state. */
+
+extern void i386_cleanup_dregs (void);
+
+#endif /* I386_NAT_H */
Index: src/gdb/i386-windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-windows-nat.c,v
retrieving revision 1.3
diff -u -p -r1.3 i386-windows-nat.c
--- src/gdb/i386-windows-nat.c 13 Jan 2009 04:14:07 -0000 1.3
+++ src/gdb/i386-windows-nat.c 13 May 2009 22:06:51 -0000
@@ -17,6 +17,7 @@
#include "defs.h"
#include "windows-nat.h"
+#include "i386-nat.h"
#include <windows.h>
@@ -73,4 +74,5 @@ void
_initialize_i386_windows_nat (void)
{
windows_set_context_register_offsets (mappings);
+ i386_set_debug_register_length (4);
}
Index: src/gdb/i386bsd-nat.h
===================================================================
RCS file: /cvs/src/src/gdb/i386bsd-nat.h,v
retrieving revision 1.6
diff -u -p -r1.6 i386bsd-nat.h
--- src/gdb/i386bsd-nat.h 3 Jan 2009 05:57:52 -0000 1.6
+++ src/gdb/i386bsd-nat.h 13 May 2009 22:06:51 -0000
@@ -25,4 +25,14 @@
extern struct target_ops *i386bsd_target (void);
+/* low level i386 debug register functions used in i386fbsd-nat.c. */
+
+extern void i386bsd_dr_set_control (unsigned long control);
+
+extern void i386bsd_dr_set_addr (int regnum, CORE_ADDR addr);
+
+extern void i386bsd_dr_reset_addr (int regnum);
+
+extern unsigned long i386bsd_dr_get_status (void);
+
#endif /* i386bsd-nat.h */
Index: src/gdb/i386fbsd-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386fbsd-nat.c,v
retrieving revision 1.18
diff -u -p -r1.18 i386fbsd-nat.c
--- src/gdb/i386fbsd-nat.c 23 Feb 2009 00:03:49 -0000 1.18
+++ src/gdb/i386fbsd-nat.c 13 May 2009 22:06:51 -0000
@@ -29,6 +29,7 @@
#include "fbsd-nat.h"
#include "i386-tdep.h"
+#include "i386-nat.h"
#include "i386bsd-nat.h"
/* Resume execution of the inferior process. If STEP is nonzero,
@@ -126,7 +127,20 @@ _initialize_i386fbsd_nat (void)
/* Add some extra features to the common *BSD/i386 target. */
t = i386bsd_target ();
+
+#ifdef HAVE_PT_GETDBREGS
+
i386_use_watchpoints (t);
+
+ i386_dr_low.set_control = i386bsd_dr_set_control;
+ i386_dr_low.set_addr = i386bsd_dr_set_addr;
+ i386_dr_low.reset_addr = i386bsd_dr_reset_addr;
+ i386_dr_low.get_status = i386bsd_dr_get_status;
+ i386_set_debug_register_length (4);
+
+#endif /* HAVE_PT_GETDBREGS */
+
+
t->to_resume = i386fbsd_resume;
t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
t->to_find_memory_regions = fbsd_find_memory_regions;
Index: src/gdb/windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.189
diff -u -p -r1.189 windows-nat.c
--- src/gdb/windows-nat.c 17 Apr 2009 15:44:28 -0000 1.189
+++ src/gdb/windows-nat.c 13 May 2009 22:06:52 -0000
@@ -63,6 +63,7 @@
#include "windows-tdep.h"
#include "windows-nat.h"
+#include "i386-nat.h"
#define AdjustTokenPrivileges dyn_AdjustTokenPrivileges
#define DebugActiveProcessStop dyn_DebugActiveProcessStop
@@ -140,6 +141,10 @@ static void windows_stop (ptid_t);
static int windows_thread_alive (struct target_ops *, ptid_t);
static void windows_kill_inferior (struct target_ops *);
+static void cygwin_set_dr (int i, CORE_ADDR addr);
+static void cygwin_set_dr7 (unsigned long val);
+static unsigned long cygwin_get_dr6 (void);
+
static enum target_signal last_sig = TARGET_SIGNAL_0;
/* Set if a signal was received from the debugged process */
@@ -2166,8 +2171,18 @@ init_windows_ops (void)
windows_ops.to_has_execution = 1;
windows_ops.to_pid_to_exec_file = windows_pid_to_exec_file;
windows_ops.to_get_ada_task_ptid = windows_get_ada_task_ptid;
+
i386_use_watchpoints (&windows_ops);
+ i386_dr_low.set_control = cygwin_set_dr7;
+ i386_dr_low.set_addr = cygwin_set_dr;
+ i386_dr_low.reset_addr = NULL;
+ i386_dr_low.get_status = cygwin_get_dr6;
+
+ /* i386_dr_low.debug_register_length field is set by
+ calling i386_set_debug_register_length function
+ in processor windows specific native file. */
+
windows_ops.to_magic = OPS_MAGIC;
}
@@ -2265,7 +2280,7 @@ Show whether to display kernel exception
/* Pass the address ADDR to the inferior in the I'th debug register.
Here we just store the address in dr array, the registers will be
actually set up when windows_continue is called. */
-void
+static void
cygwin_set_dr (int i, CORE_ADDR addr)
{
if (i < 0 || i > 3)
@@ -2279,10 +2294,10 @@ cygwin_set_dr (int i, CORE_ADDR addr)
/* Pass the value VAL to the inferior in the DR7 debug control
register. Here we just store the address in D_REGS, the watchpoint
will be actually set up in windows_wait. */
-void
-cygwin_set_dr7 (unsigned val)
+static void
+cygwin_set_dr7 (unsigned long val)
{
- dr[7] = val;
+ dr[7] = (CORE_ADDR) val;
debug_registers_changed = 1;
debug_registers_used = 1;
}
@@ -2290,10 +2305,10 @@ cygwin_set_dr7 (unsigned val)
/* Get the value of the DR6 debug status register from the inferior.
Here we just return the value stored in dr[6]
by the last call to thread_rec for current_event.dwThreadId id. */
-unsigned
+static unsigned long
cygwin_get_dr6 (void)
{
- return dr[6];
+ return (unsigned long) dr[6];
}
/* Determine if the thread referenced by "ptid" is alive
Index: src/gdb/config/i386/go32.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/go32.mh,v
retrieving revision 1.10
diff -u -p -r1.10 go32.mh
--- src/gdb/config/i386/go32.mh 19 Apr 2009 18:29:34 -0000 1.10
+++ src/gdb/config/i386/go32.mh 13 May 2009 22:06:52 -0000
@@ -3,7 +3,6 @@
# We include several header files from config/djgpp
MH_CFLAGS= -I$(srcdir)/config/djgpp
-NAT_FILE= nm-go32.h
NATDEPFILES= go32-nat.o i386-nat.o
HOST_IPC=
Index: src/gdb/config/i386/linux64.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/linux64.mh,v
retrieving revision 1.7
diff -u -p -r1.7 linux64.mh
--- src/gdb/config/i386/linux64.mh 4 Jan 2006 19:33:11 -0000 1.7
+++ src/gdb/config/i386/linux64.mh 13 May 2009 22:06:52 -0000
@@ -2,7 +2,7 @@
NATDEPFILES= inf-ptrace.o fork-child.o \
i386-nat.o amd64-nat.o amd64-linux-nat.o linux-nat.o \
proc-service.o linux-thread-db.o gcore.o linux-fork.o
-NAT_FILE= nm-linux64.h
+NAT_FILE= config/nm-linux.h
# The dynamically loaded libthread_db needs access to symbols in the
# gdb executable.
Index: src/gdb/config/i386/nm-cygwin.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-cygwin.h,v
retrieving revision 1.10
diff -u -p -r1.10 nm-cygwin.h
--- src/gdb/config/i386/nm-cygwin.h 26 Mar 2009 00:18:46 -0000 1.10
+++ src/gdb/config/i386/nm-cygwin.h 13 May 2009 22:06:52 -0000
@@ -18,20 +18,3 @@
#define ADD_SHARED_SYMBOL_FILES dll_symbol_command
void dll_symbol_command (char *, int);
-
-#define I386_USE_GENERIC_WATCHPOINTS
-
-#include "i386/nm-i386.h"
-
-/* Support for hardware-assisted breakpoints and watchpoints. */
-
-#define I386_DR_LOW_SET_CONTROL(VAL) cygwin_set_dr7 (VAL)
-extern void cygwin_set_dr7 (unsigned);
-
-#define I386_DR_LOW_SET_ADDR(N,ADDR) cygwin_set_dr (N,ADDR)
-extern void cygwin_set_dr (int, CORE_ADDR);
-
-#define I386_DR_LOW_RESET_ADDR(N)
-
-#define I386_DR_LOW_GET_STATUS() cygwin_get_dr6 ()
-extern unsigned cygwin_get_dr6 (void);
Index: src/gdb/config/i386/nm-cygwin64.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-cygwin64.h,v
retrieving revision 1.3
diff -u -p -r1.3 nm-cygwin64.h
--- src/gdb/config/i386/nm-cygwin64.h 26 Mar 2009 00:18:46 -0000 1.3
+++ src/gdb/config/i386/nm-cygwin64.h 13 May 2009 22:06:52 -0000
@@ -17,20 +17,3 @@
#define ADD_SHARED_SYMBOL_FILES dll_symbol_command
void dll_symbol_command (char *, int);
-
-#define I386_USE_GENERIC_WATCHPOINTS
-
-#include "i386/nm-i386.h"
-
-/* Support for hardware-assisted breakpoints and watchpoints. */
-
-#define I386_DR_LOW_SET_CONTROL(VAL) cygwin_set_dr7 (VAL)
-extern void cygwin_set_dr7 (unsigned);
-
-#define I386_DR_LOW_SET_ADDR(N,ADDR) cygwin_set_dr (N,ADDR)
-extern void cygwin_set_dr (int, CORE_ADDR);
-
-#define I386_DR_LOW_RESET_ADDR(N)
-
-#define I386_DR_LOW_GET_STATUS() cygwin_get_dr6 ()
-extern unsigned cygwin_get_dr6 (void);
Index: src/gdb/config/i386/nm-fbsd.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-fbsd.h,v
retrieving revision 1.20
diff -u -p -r1.20 nm-fbsd.h
--- src/gdb/config/i386/nm-fbsd.h 26 Mar 2009 00:18:46 -0000 1.20
+++ src/gdb/config/i386/nm-fbsd.h 13 May 2009 22:06:52 -0000
@@ -21,33 +21,8 @@
#ifndef NM_FBSD_H
#define NM_FBSD_H
-#ifdef HAVE_PT_GETDBREGS
-#define I386_USE_GENERIC_WATCHPOINTS
-#endif
-
-#include "i386/nm-i386.h"
-
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
-/* Provide access to the i386 hardware debugging registers. */
-
-#define I386_DR_LOW_SET_CONTROL(control) \
- i386bsd_dr_set_control (control)
-extern void i386bsd_dr_set_control (unsigned long control);
-
-#define I386_DR_LOW_SET_ADDR(regnum, addr) \
- i386bsd_dr_set_addr (regnum, addr)
-extern void i386bsd_dr_set_addr (int regnum, CORE_ADDR addr);
-
-#define I386_DR_LOW_RESET_ADDR(regnum) \
- i386bsd_dr_reset_addr (regnum)
-extern void i386bsd_dr_reset_addr (int regnum);
-
-#define I386_DR_LOW_GET_STATUS() \
- i386bsd_dr_get_status ()
-extern unsigned long i386bsd_dr_get_status (void);
-
-
#endif /* nm-fbsd.h */
Index: src/gdb/config/i386/nm-go32.h
===================================================================
RCS file: config/i386/nm-go32.h
diff -N config/i386/nm-go32.h
--- src/gdb/config/i386/nm-go32.h 26 Mar 2009 00:18:46 -0000 1.10
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,35 +0,0 @@
-/* Native definitions for Intel x86 running DJGPP.
- Copyright 1997, 1998, 1999, 2001, 2002, 2007, 2008, 2009
- 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/>.
*/
-
-#define I386_USE_GENERIC_WATCHPOINTS
-
-#include "i386/nm-i386.h"
-
-/* Support for hardware-assisted breakpoints and watchpoints. */
-
-#define I386_DR_LOW_SET_CONTROL(VAL) go32_set_dr7 (VAL)
-extern void go32_set_dr7 (unsigned);
-
-#define I386_DR_LOW_SET_ADDR(N,ADDR) go32_set_dr (N,ADDR)
-extern void go32_set_dr (int, CORE_ADDR);
-
-#define I386_DR_LOW_RESET_ADDR(N)
-
-#define I386_DR_LOW_GET_STATUS() go32_get_dr6 ()
-extern unsigned go32_get_dr6 (void);
Index: src/gdb/config/i386/nm-i386.h
===================================================================
RCS file: config/i386/nm-i386.h
diff -N config/i386/nm-i386.h
--- src/gdb/config/i386/nm-i386.h 26 Mar 2009 00:18:46 -0000 1.15
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,72 +0,0 @@
-/* Native macro definitions for GDB on an Intel i[3456]86.
- Copyright 2001, 2004, 2007, 2008, 2009 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/>.
*/
-
-#ifndef NM_I386_H
-#define NM_I386_H 1
-
-/* Hardware-assisted breakpoints and watchpoints. */
-
-/* Targets should define this to use the generic x86 watchpoint support.
*/
-#ifdef I386_USE_GENERIC_WATCHPOINTS
-
-/* Add watchpoint methods to the provided target_ops.
- Targets which define I386_USE_GENERIC_WATCHPOINTS must
- call this function. */
-struct target_ops;
-void i386_use_watchpoints (struct target_ops *);
-
-/* Clear the reference counts and forget everything we knew about DRi. */
-extern void i386_cleanup_dregs (void);
-
-/* Insert a watchpoint to watch a memory region which starts at
- address ADDR and whose length is LEN bytes. Watch memory accesses
- of the type TYPE. Return 0 on success, -1 on failure. */
-extern int i386_insert_watchpoint (CORE_ADDR addr, int len, int type);
-
-/* Remove a watchpoint that watched the memory region which starts at
- address ADDR, whose length is LEN bytes, and for accesses of the
- type TYPE. Return 0 on success, -1 on failure. */
-extern int i386_remove_watchpoint (CORE_ADDR addr, int len, int type);
-
-/* Return non-zero if we can watch a memory region that starts at
- address ADDR and whose length is LEN bytes. */
-extern int i386_region_ok_for_watchpoint (CORE_ADDR addr, int len);
-
-/* Return non-zero if the inferior has some break/watchpoint that
- triggered. */
-extern int i386_stopped_by_hwbp (void);
-
-/* If the inferior has some break/watchpoint that triggered, set
- the address associated with that break/watchpoint and return
- true. Otherwise, return false. */
-extern int i386_stopped_data_address (struct target_ops *, CORE_ADDR *);
-
-/* Insert a hardware-assisted breakpoint at BP_TGT->placed_address.
- Return 0 on success, EBUSY on failure. */
-struct bp_target_info;
-extern int i386_insert_hw_breakpoint (struct bp_target_info *bp_tgt);
-
-/* Remove a hardware-assisted breakpoint at BP_TGT->placed_address.
- Return 0 on success, -1 on failure. */
-extern int i386_remove_hw_breakpoint (struct bp_target_info *bp_tgt);
-
-extern int i386_stopped_by_watchpoint (void);
-
-#endif /* I386_USE_GENERIC_WATCHPOINTS */
-
-#endif /* NM_I386_H */
Index: src/gdb/config/i386/nm-linux.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-linux.h,v
retrieving revision 1.30
diff -u -p -r1.30 nm-linux.h
--- src/gdb/config/i386/nm-linux.h 26 Mar 2009 00:18:46 -0000 1.30
+++ src/gdb/config/i386/nm-linux.h 13 May 2009 22:06:52 -0000
@@ -22,31 +22,8 @@
#ifndef NM_LINUX_H
#define NM_LINUX_H
-/* GNU/Linux supports the i386 hardware debugging registers. */
-#define I386_USE_GENERIC_WATCHPOINTS
-
-#include "i386/nm-i386.h"
#include "config/nm-linux.h"
-/* Provide access to the i386 hardware debugging registers. */
-
-extern void i386_linux_dr_set_control (unsigned long control);
-#define I386_DR_LOW_SET_CONTROL(control) \
- i386_linux_dr_set_control (control)
-
-extern void i386_linux_dr_set_addr (int regnum, CORE_ADDR addr);
-#define I386_DR_LOW_SET_ADDR(regnum, addr) \
- i386_linux_dr_set_addr (regnum, addr)
-
-extern void i386_linux_dr_reset_addr (int regnum);
-#define I386_DR_LOW_RESET_ADDR(regnum) \
- i386_linux_dr_reset_addr (regnum)
-
-extern unsigned long i386_linux_dr_get_status (void);
-#define I386_DR_LOW_GET_STATUS() \
- i386_linux_dr_get_status ()
-
-
#ifdef HAVE_PTRACE_GETFPXREGS
/* Include register set support for the SSE registers. */
#define FILL_FPXREGSET
Index: src/gdb/config/i386/nm-linux64.h
===================================================================
RCS file: config/i386/nm-linux64.h
diff -N config/i386/nm-linux64.h
--- src/gdb/config/i386/nm-linux64.h 26 Mar 2009 00:18:46 -0000 1.10
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,53 +0,0 @@
-/* Native support for GNU/Linux x86-64.
-
- Copyright 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
- Free Software Foundation, Inc.
-
- Contributed by Jiri Smid, SuSE Labs.
-
- 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/>.
*/
-
-#ifndef NM_LINUX64_H
-#define NM_LINUX64_H
-
-/* GNU/Linux supports the i386 hardware debugging registers. */
-#define I386_USE_GENERIC_WATCHPOINTS
-
-#include "i386/nm-i386.h"
-#include "config/nm-linux.h"
-
-/* Support for 8-byte wide hardware watchpoints. */
-#define TARGET_HAS_DR_LEN_8 1
-
-/* Provide access to the i386 hardware debugging registers. */
-
-extern void amd64_linux_dr_set_control (unsigned long control);
-#define I386_DR_LOW_SET_CONTROL(control) \
- amd64_linux_dr_set_control (control)
-
-extern void amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr);
-#define I386_DR_LOW_SET_ADDR(regnum, addr) \
- amd64_linux_dr_set_addr (regnum, addr)
-
-extern void amd64_linux_dr_reset_addr (int regnum);
-#define I386_DR_LOW_RESET_ADDR(regnum) \
- amd64_linux_dr_reset_addr (regnum)
-
-extern unsigned long amd64_linux_dr_get_status (void);
-#define I386_DR_LOW_GET_STATUS() \
- amd64_linux_dr_get_status ()
-
-#endif /* nm-linux64.h */