This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: breakpoints/735: Getting the i386 watchpoints into the targetvector?


The following reply was made to PR breakpoints/735; it has been noted by GNATS.

From: Petr Vandrovec <petr@vmware.com>
To: gdb-gnats@sources.redhat.com
Cc:  
Subject: Re: breakpoints/735: Getting the i386 watchpoints into the target
 vector?
Date: Sun, 02 Jul 2006 23:52:34 +0200

 This is a multi-part message in MIME format.
 --------------030001040709060000060608
 Content-Type: text/plain; charset=us-ascii; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Hello,
    what about this solution to i386 watchpoints & hardware breakpoints problem ? 
   It seems to work fine locally, and with my remote debug server.  Diff is 
 against current CVS tree, but applies to Debian's 6.4.90-debian as well.
 							Thanks,
 								Petr Vandrovec
 
 --------------030001040709060000060608
 Content-Type: text/x-patch;
  name="gdb-i386-hwdebug.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="gdb-i386-hwdebug.diff"
 
 diff -udrN gdb.orig/gdb/amd64-linux-nat.c gdb/gdb/amd64-linux-nat.c
 --- gdb.orig/gdb/amd64-linux-nat.c	2006-03-25 00:08:16.000000000 +0100
 +++ gdb/gdb/amd64-linux-nat.c	2006-07-02 23:44:55.000000000 +0200
 @@ -398,6 +398,7 @@
    /* Add our register access methods.  */
    t->to_fetch_registers = amd64_linux_fetch_inferior_registers;
    t->to_store_registers = amd64_linux_store_inferior_registers;
 +  i386_target_hw_debug(t);
  
    /* Register the target.  */
    linux_nat_add_target (t);
 diff -udrN gdb.orig/gdb/amd64bsd-nat.c gdb/gdb/amd64bsd-nat.c
 --- gdb.orig/gdb/amd64bsd-nat.c	2005-12-17 23:33:59.000000000 +0100
 +++ gdb/gdb/amd64bsd-nat.c	2006-07-02 23:44:55.000000000 +0200
 @@ -119,5 +119,6 @@
    t = inf_ptrace_target ();
    t->to_fetch_registers = amd64bsd_fetch_inferior_registers;
    t->to_store_registers = amd64bsd_store_inferior_registers;
 +  i386_target_hw_debug(t);
    return t;
  }
 diff -udrN gdb.orig/gdb/config/i386/nm-i386.h gdb/gdb/config/i386/nm-i386.h
 --- gdb.orig/gdb/config/i386/nm-i386.h	2006-04-18 21:20:06.000000000 +0200
 +++ gdb/gdb/config/i386/nm-i386.h	2006-07-02 23:44:55.000000000 +0200
 @@ -29,16 +29,6 @@
  /* 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);
 @@ -52,15 +42,6 @@
     true.  Otherwise, return false.  */
  extern int i386_stopped_data_address (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);
 -
  /* Returns the number of hardware watchpoints of type TYPE that we can
     set.  Value is positive if we can set CNT watchpoints, zero if
     setting watchpoints of type TYPE is not supported, and negative if
 @@ -98,24 +79,17 @@
  
  #define target_stopped_data_address(target, x)  i386_stopped_data_address(x)
  
 -/* Use these macros for watchpoint insertion/removal.  */
 -
 -#define target_insert_watchpoint(addr, len, type) \
 -  i386_insert_watchpoint (addr, len, type)
 -
 -#define target_remove_watchpoint(addr, len, type) \
 -  i386_remove_watchpoint (addr, len, type)
 -
 -#define target_insert_hw_breakpoint(bp_tgt) \
 -  i386_insert_hw_breakpoint (bp_tgt)
 -
 -#define target_remove_hw_breakpoint(bp_tgt) \
 -  i386_remove_hw_breakpoint (bp_tgt)
 +struct target_ops;
 +extern void i386_target_hw_debug(struct target_ops *t);
  
  /* child_post_startup_inferior used to
     reset all debug registers by calling i386_cleanup_dregs ().  */ 
  #define CHILD_POST_STARTUP_INFERIOR
  
 +#else /* I386_USE_GENERIC_WATCHPOINTS */
 +
 +#define i386_target_hw_debug(t)       do { } while (0)
 +
  #endif /* I386_USE_GENERIC_WATCHPOINTS */
  
  #endif /* NM_I386_H */
 diff -udrN gdb.orig/gdb/go32-nat.c gdb/gdb/go32-nat.c
 --- gdb.orig/gdb/go32-nat.c	2006-01-24 23:09:28.000000000 +0100
 +++ gdb/gdb/go32-nat.c	2006-07-02 23:44:55.000000000 +0200
 @@ -883,6 +883,7 @@
    go32_ops.to_has_registers = 1;
    go32_ops.to_has_execution = 1;
    go32_ops.to_magic = OPS_MAGIC;
 +  i386_target_hw_debug(&go32_ops);
  
    /* Initialize child's cwd as empty to be initialized when starting
       the child.  */
 diff -udrN gdb.orig/gdb/i386-linux-nat.c gdb/gdb/i386-linux-nat.c
 --- gdb.orig/gdb/i386-linux-nat.c	2006-03-25 00:08:16.000000000 +0100
 +++ gdb/gdb/i386-linux-nat.c	2006-07-02 23:44:55.000000000 +0200
 @@ -843,6 +843,8 @@
    t->to_fetch_registers = i386_linux_fetch_inferior_registers;
    t->to_store_registers = i386_linux_store_inferior_registers;
  
 +  i386_target_hw_debug(t);
 +
    /* Register the target.  */
    linux_nat_add_target (t);
  }
 diff -udrN gdb.orig/gdb/i386-nat.c gdb/gdb/i386-nat.c
 --- gdb.orig/gdb/i386-nat.c	2006-04-18 21:20:06.000000000 +0200
 +++ gdb/gdb/i386-nat.c	2006-07-02 23:44:55.000000000 +0200
 @@ -23,6 +23,7 @@
  #include "breakpoint.h"
  #include "command.h"
  #include "gdbcmd.h"
 +#include "target.h"
  
  /* Support for hardware watchpoints and breakpoints using the i386
     debug registers.
 @@ -501,7 +502,7 @@
     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;
 @@ -525,7 +526,7 @@
  /* 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;
 @@ -627,7 +628,7 @@
  
  /* 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);
 @@ -643,7 +644,7 @@
  /* 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);
 @@ -656,6 +657,16 @@
    return retval;
  }
  
 +void
 +i386_target_hw_debug (struct target_ops *t)
 +{
 +  /* Hardware debugging.  */
 +  t->to_insert_watchpoint = i386_insert_watchpoint;
 +  t->to_remove_watchpoint = i386_remove_watchpoint;
 +  t->to_insert_hw_breakpoint = i386_insert_hw_breakpoint;
 +  t->to_remove_hw_breakpoint = i386_remove_hw_breakpoint;
 +}
 +
  #endif /* I386_USE_GENERIC_WATCHPOINTS */
  
  
 diff -udrN gdb.orig/gdb/i386bsd-nat.c gdb/gdb/i386bsd-nat.c
 --- gdb.orig/gdb/i386bsd-nat.c	2005-12-17 23:34:01.000000000 +0100
 +++ gdb/gdb/i386bsd-nat.c	2006-07-02 23:44:55.000000000 +0200
 @@ -250,6 +250,7 @@
    t = inf_ptrace_target ();
    t->to_fetch_registers = i386bsd_fetch_inferior_registers;
    t->to_store_registers = i386bsd_store_inferior_registers;
 +  i386_target_hw_debug(t);
    return t;
  }
  
 diff -udrN gdb.orig/gdb/win32-nat.c gdb/gdb/win32-nat.c
 --- gdb.orig/gdb/win32-nat.c	2006-05-22 01:04:39.000000000 +0200
 +++ gdb/gdb/win32-nat.c	2006-07-02 23:44:55.000000000 +0200
 @@ -2398,6 +2398,7 @@
    win32_ops.to_has_execution = 1;
    win32_ops.to_magic = OPS_MAGIC;
    win32_ops.to_pid_to_exec_file = win32_pid_to_exec_file;
 +  i386_target_hw_debug(&win32_ops);
  
    win32_so_ops.relocate_section_addresses = win32_relocate_section_addresses;
    win32_so_ops.free_so = win32_free_so;
 
 --------------030001040709060000060608--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]