* [RFA] hardware breakoints in target vector
@ 2002-07-30 18:34 Grace Sainsbury
2002-07-31 9:32 ` Eli Zaretskii
2002-08-01 14:04 ` Andrew Cagney
0 siblings, 2 replies; 3+ messages in thread
From: Grace Sainsbury @ 2002-07-30 18:34 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 738 bytes --]
This is the first patch for inserting hardware breakpoints into the
target vector. let me know if it's all right.
grace
2002-07-30 Grace Sainsbury <graces@redhat.com>
* target.h: Add to_insert_hw_breakpoint, to_remove_hw_breakpoint,
to_insert_watchpoint, to_remove_watchpoint,
to_stopped_by_watchpoint, to_stopped_data_address,
to_region_size_ok_for_hw_watchpoint, to_can_use_hw_breakpoint to
target vecctor. Define their corresponding macros so they call
them.
* target.c: Add default and debug versions of for
to_insert_hw_breakpoint, to_remove_hw_breakpoint,
to_insert_watchpoint, to_remove_watchpoint,
to_stopped_by_watchpoint, to_stopped_data_address,
to_region_size_ok_for_hw_watchpoint, to_can_use_hw_breakpoint.
[-- Attachment #2: watch.patch --]
[-- Type: text/plain, Size: 10852 bytes --]
Index: target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.38
diff -u -r1.38 target.c
--- target.c 11 Jul 2002 13:50:49 -0000 1.38
+++ target.c 30 Jul 2002 20:15:35 -0000
@@ -52,6 +52,8 @@
static void default_terminal_info (char *, int);
+static int default_region_size_ok_for_hw_watchpoint (int);
+
static int nosymbol (char *, CORE_ADDR *);
static void tcomplain (void);
@@ -62,6 +64,8 @@
static int return_one (void);
+static int return_minus_one (void);
+
void target_ignore (void);
static void target_command (char *, int);
@@ -112,6 +116,22 @@
static int debug_to_remove_breakpoint (CORE_ADDR, char *);
+static int debug_to_can_use_hw_breakpoint (int, int, int);
+
+static int debug_to_insert_hw_breakpoint (CORE_ADDR, char *);
+
+static int debug_to_remove_hw_breakpoint (CORE_ADDR, char *);
+
+static int debug_to_insert_watchpoint (CORE_ADDR, int, int);
+
+static int debug_to_remove_watchpoint (CORE_ADDR, int, int);
+
+static int debug_to_stopped_by_watchpoint (void);
+
+static CORE_ADDR debug_to_stopped_data_address (void);
+
+static int debug_to_region_size_ok_for_hw_watchpoint (int);
+
static void debug_to_terminal_init (void);
static void debug_to_terminal_inferior (void);
@@ -390,6 +410,29 @@
memory_insert_breakpoint);
de_fault (to_remove_breakpoint,
memory_remove_breakpoint);
+ de_fault (to_can_use_hw_breakpoint,
+ (int (*) (int, int, int))
+ return_zero);
+ de_fault (to_insert_hw_breakpoint,
+ (int (*) (CORE_ADDR, char *))
+ return_minus_one);
+ de_fault (to_remove_hw_breakpoint,
+ (int (*) (CORE_ADDR, char *))
+ return_minus_one);
+ de_fault (to_insert_watchpoint,
+ (int (*) (CORE_ADDR, int, int))
+ return_minus_one);
+ de_fault (to_remove_watchpoint,
+ (int (*) (CORE_ADDR, int, int))
+ return_minus_one);
+ de_fault (to_stopped_by_watchpoint,
+ (int (*) (void))
+ return_zero);
+ de_fault (to_stopped_data_address,
+ (CORE_ADDR (*) (void))
+ return_zero);
+ de_fault (to_region_size_ok_for_hw_watchpoint,
+ default_region_size_ok_for_hw_watchpoint);
de_fault (to_terminal_init,
(void (*) (void))
target_ignore);
@@ -553,6 +596,14 @@
INHERIT (to_files_info, t);
INHERIT (to_insert_breakpoint, t);
INHERIT (to_remove_breakpoint, t);
+ INHERIT (to_can_use_hw_breakpoint, t);
+ INHERIT (to_insert_hw_breakpoint, t);
+ INHERIT (to_remove_hw_breakpoint, t);
+ INHERIT (to_insert_watchpoint, t);
+ INHERIT (to_remove_watchpoint, t);
+ INHERIT (to_stopped_data_address, t);
+ INHERIT (to_stopped_by_watchpoint, t);
+ INHERIT (to_region_size_ok_for_hw_watchpoint, t);
INHERIT (to_terminal_init, t);
INHERIT (to_terminal_inferior, t);
INHERIT (to_terminal_ours_for_output, t);
@@ -1227,6 +1278,12 @@
}
static int
+default_region_size_ok_for_hw_watchpoint (int byte_count)
+{
+ return ((LONGEST)byte_count <= REGISTER_SIZE);
+}
+
+static int
return_zero (void)
{
return 0;
@@ -1238,6 +1295,12 @@
return 1;
}
+static int
+return_minus_one (void)
+{
+ return -1;
+}
+
/*
* Resize the to_sections pointer. Also make sure that anyone that
* was holding on to an old value of it gets updated.
@@ -1774,6 +1837,116 @@
return retval;
}
+static int
+debug_to_can_use_hw_breakpoint (int type, int cnt, int from_tty)
+{
+ int retval;
+
+ retval = debug_target.to_can_use_hw_breakpoint (type, cnt, from_tty);
+
+ fprintf_unfiltered (gdb_stdlog,
+ "target_can_use_hw_breakpoint (%ld, %ld, %ld) = %ld\n",
+ (unsigned long) type,
+ (unsigned long) cnt,
+ (unsigned long) from_tty,
+ (unsigned long) retval);
+ return retval;
+}
+
+static int
+debug_to_region_size_ok_for_hw_watchpoint (int byte_count)
+{
+ CORE_ADDR retval;
+
+ retval = debug_target.to_region_size_ok_for_hw_watchpoint (byte_count);
+
+ fprintf_unfiltered (gdb_stdlog,
+ "TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT (%ld) = 0x%lx\n",
+ (unsigned long) byte_count,
+ (unsigned long) retval);
+ return retval;
+}
+
+static int
+debug_to_stopped_by_watchpoint (void)
+{
+ int retval;
+
+ retval = debug_target.to_stopped_by_watchpoint ();
+
+ fprintf_unfiltered (gdb_stdlog,
+ "STOPPED_BY_WATCHPOINT () = %ld\n",
+ (unsigned long) retval);
+ return retval;
+}
+
+static CORE_ADDR
+debug_to_stopped_data_address (void)
+{
+ CORE_ADDR retval;
+
+ retval = debug_target.to_stopped_data_address ();
+
+ fprintf_unfiltered (gdb_stdlog,
+ "target_stopped_data_address () = 0x%lx\n",
+ (unsigned long) retval);
+ return retval;
+}
+
+static int
+debug_to_insert_hw_breakpoint (CORE_ADDR addr, char *save)
+{
+ int retval;
+
+ retval = debug_target.to_insert_hw_breakpoint (addr, save);
+
+ fprintf_unfiltered (gdb_stdlog,
+ "target_insert_hw_breakpoint (0x%lx, xxx) = %ld\n",
+ (unsigned long) addr,
+ (unsigned long) retval);
+ return retval;
+}
+
+static int
+debug_to_remove_hw_breakpoint (CORE_ADDR addr, char *save)
+{
+ int retval;
+
+ retval = debug_target.to_remove_hw_breakpoint (addr, save);
+
+ fprintf_unfiltered (gdb_stdlog,
+ "target_remove_hw_breakpoint (0x%lx, xxx) = %ld\n",
+ (unsigned long) addr,
+ (unsigned long) retval);
+ return retval;
+}
+
+static int
+debug_to_insert_watchpoint (CORE_ADDR addr, int len, int type)
+{
+ int retval;
+
+ retval = debug_target.to_insert_watchpoint (addr, len, type);
+
+ fprintf_unfiltered (gdb_stdlog,
+ "target_insert_watchpoint (0x%lx, %d, %d) = %ld\n",
+ (unsigned long) addr, len, type, (unsigned long) retval);
+ return retval;
+}
+
+static int
+debug_to_remove_watchpoint (CORE_ADDR addr, int len, int type)
+{
+ int retval;
+
+ retval = debug_target.to_insert_watchpoint (addr, len, type);
+
+ fprintf_unfiltered (gdb_stdlog,
+ "target_insert_watchpoint (0x%lx, %d, %d) = %ld\n",
+ (unsigned long) addr, len, type, (unsigned long) retval);
+ return retval;
+}
+
static void
debug_to_terminal_init (void)
{
@@ -2220,6 +2393,14 @@
current_target.to_files_info = debug_to_files_info;
current_target.to_insert_breakpoint = debug_to_insert_breakpoint;
current_target.to_remove_breakpoint = debug_to_remove_breakpoint;
+ current_target.to_can_use_hw_breakpoint = debug_to_can_use_hw_breakpoint;
+ current_target.to_insert_hw_breakpoint = debug_to_insert_hw_breakpoint;
+ current_target.to_remove_hw_breakpoint = debug_to_remove_hw_breakpoint;
+ current_target.to_insert_watchpoint = debug_to_insert_watchpoint;
+ current_target.to_remove_watchpoint = debug_to_remove_watchpoint;
+ current_target.to_stopped_by_watchpoint = debug_to_stopped_by_watchpoint;
+ current_target.to_stopped_data_address = debug_to_stopped_data_address;
+ current_target.to_region_size_ok_for_hw_watchpoint = debug_to_region_size_ok_for_hw_watchpoint;
current_target.to_terminal_init = debug_to_terminal_init;
current_target.to_terminal_inferior = debug_to_terminal_inferior;
current_target.to_terminal_ours_for_output = debug_to_terminal_ours_for_output;
Index: target.h
===================================================================
RCS file: /cvs/src/src/gdb/target.h,v
retrieving revision 1.24
diff -u -r1.24 target.h
--- target.h 18 Apr 2002 18:09:06 -0000 1.24
+++ target.h 30 Jul 2002 20:15:36 -0000
@@ -252,6 +252,14 @@
void (*to_files_info) (struct target_ops *);
int (*to_insert_breakpoint) (CORE_ADDR, char *);
int (*to_remove_breakpoint) (CORE_ADDR, char *);
+ int (*to_can_use_hw_breakpoint) (int, int, int);
+ int (*to_insert_hw_breakpoint) (CORE_ADDR, char *);
+ int (*to_remove_hw_breakpoint) (CORE_ADDR, char *);
+ int (*to_remove_watchpoint) (CORE_ADDR, int, int);
+ int (*to_insert_watchpoint) (CORE_ADDR, int, int);
+ int (*to_stopped_by_watchpoint) (void);
+ CORE_ADDR (*to_stopped_data_address) (void);
+ int (*to_region_size_ok_for_hw_watchpoint) (int);
void (*to_terminal_init) (void);
void (*to_terminal_inferior) (void);
void (*to_terminal_ours_for_output) (void);
@@ -1041,7 +1049,8 @@
write). */
#ifndef STOPPED_BY_WATCHPOINT
-#define STOPPED_BY_WATCHPOINT(w) 0
+#define STOPPED_BY_WATCHPOINT(w) \
+ (*current_target.to_stopped_by_watchpoint) ()
#endif
/* HP-UX supplies these operations, which respectively disable and enable
@@ -1056,20 +1065,24 @@
#define TARGET_ENABLE_HW_WATCHPOINTS(pid)
#endif
-/* Provide defaults for systems that don't support hardware watchpoints. */
+/* Provide defaults for hardware watchpoint functions. */
-#ifndef TARGET_HAS_HARDWARE_WATCHPOINTS
+/* If the *_hw_beakpoint functions have not been defined
+ elsewhere use the definitions in the target vector. */
/* Returns non-zero if we can set a hardware watchpoint of type TYPE. TYPE is
one of bp_hardware_watchpoint, bp_read_watchpoint, bp_write_watchpoint, or
bp_hardware_breakpoint. CNT is the number of such watchpoints used so far
(including this one?). OTHERTYPE is who knows what... */
-#define TARGET_CAN_USE_HARDWARE_WATCHPOINT(TYPE,CNT,OTHERTYPE) 0
+#ifndef TARGET_CAN_USE_HARDWARE_WATCHPOINT
+#define TARGET_CAN_USE_HARDWARE_WATCHPOINT(TYPE,CNT,OTHERTYPE) \
+ (*current_target.to_can_use_hw_breakpoint) (TYPE, CNT, OTHERTYPE);
+#endif
#if !defined(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT)
#define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(byte_count) \
- ((LONGEST)(byte_count) <= REGISTER_SIZE)
+ (*current_target.to_region_size_ok_for_hw_watchpoint) (byte_count)
#endif
@@ -1077,18 +1090,25 @@
for write, 1 for read, and 2 for read/write accesses. Returns 0 for
success, non-zero for failure. */
-#define target_remove_watchpoint(ADDR,LEN,TYPE) -1
-#define target_insert_watchpoint(ADDR,LEN,TYPE) -1
+#ifndef target_insert_watchpoint
+#define target_insert_watchpoint(addr, len, type) \
+ (*current_target.to_insert_watchpoint) (addr, len, type)
-#endif /* TARGET_HAS_HARDWARE_WATCHPOINTS */
+#define target_remove_watchpoint(addr, len, type) \
+ (*current_target.to_remove_watchpoint) (addr, len, type)
+#endif
#ifndef target_insert_hw_breakpoint
-#define target_remove_hw_breakpoint(ADDR,SHADOW) -1
-#define target_insert_hw_breakpoint(ADDR,SHADOW) -1
+#define target_insert_hw_breakpoint(addr, save) \
+ (*current_target.to_insert_hw_breakpoint) (addr, save)
+
+#define target_remove_hw_breakpoint(addr, save) \
+ (*current_target.to_remove_hw_breakpoint) (addr, save)
#endif
#ifndef target_stopped_data_address
-#define target_stopped_data_address() 0
+#define target_stopped_data_address() \
+ (*current_target.to_stopped_data_address) ()
#endif
/* If defined, then we need to decr pc by this much after a hardware break-
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFA] hardware breakoints in target vector
2002-07-30 18:34 [RFA] hardware breakoints in target vector Grace Sainsbury
@ 2002-07-31 9:32 ` Eli Zaretskii
2002-08-01 14:04 ` Andrew Cagney
1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2002-07-31 9:32 UTC (permalink / raw)
To: graces; +Cc: gdb-patches
> Date: Tue, 30 Jul 2002 16:16:11 -0400
> From: Grace Sainsbury <graces@redhat.com>
>
> This is the first patch for inserting hardware breakpoints into the
> target vector. let me know if it's all right.
I'd be more happy if this was accompanied by some docs patch for
gdbint.texinfo. Right now, watchpoints are described there as a
native-only feature.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] hardware breakoints in target vector
2002-07-30 18:34 [RFA] hardware breakoints in target vector Grace Sainsbury
2002-07-31 9:32 ` Eli Zaretskii
@ 2002-08-01 14:04 ` Andrew Cagney
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Cagney @ 2002-08-01 14:04 UTC (permalink / raw)
To: Grace Sainsbury; +Cc: gdb-patches
+ return ((LONGEST)byte_count <= REGISTER_SIZE);
BTW, I think the conversion of the macro to a function made the cast
redundant.
> This is the first patch for inserting hardware breakpoints into the
> target vector. let me know if it's all right.
>
> grace
>
> 2002-07-30 Grace Sainsbury <graces@redhat.com>
>
> * target.h: Add to_insert_hw_breakpoint, to_remove_hw_breakpoint,
> to_insert_watchpoint, to_remove_watchpoint,
> to_stopped_by_watchpoint, to_stopped_data_address,
> to_region_size_ok_for_hw_watchpoint, to_can_use_hw_breakpoint to
> target vecctor. Define their corresponding macros so they call
> them.
>
> * target.c: Add default and debug versions of for
> to_insert_hw_breakpoint, to_remove_hw_breakpoint,
> to_insert_watchpoint, to_remove_watchpoint,
> to_stopped_by_watchpoint, to_stopped_data_address,
> to_region_size_ok_for_hw_watchpoint, to_can_use_hw_breakpoint.
>
Yes, ok. As Eli has noted, I guess updating the doco is one of those
other patches.
I see you've picked up gdb/161, ya!
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-08-01 21:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-30 18:34 [RFA] hardware breakoints in target vector Grace Sainsbury
2002-07-31 9:32 ` Eli Zaretskii
2002-08-01 14:04 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox