This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
hw watch/breakpoint support change
- From: Mark Salter <msalter at redhat dot com>
- To: ecos-patches at sources dot redhat dot com
- Date: Thu, 29 Aug 2002 12:18:00 -0400
- Subject: hw watch/breakpoint support change
This gets around a GDB problem where GDB tries to access watched memory
before it removes a watchpoint.
--Mark
Index: hal/arm/iq80310/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/iq80310/current/ChangeLog,v
retrieving revision 1.19
diff -u -p -5 -r1.19 ChangeLog
--- hal/arm/iq80310/current/ChangeLog 12 Aug 2002 21:28:25 -0000 1.19
+++ hal/arm/iq80310/current/ChangeLog 29 Aug 2002 16:14:00 -0000
@@ -1,5 +1,10 @@
+2002-08-29 Mark Salter <msalter@redhat.com>
+
+ * include/plf_stub.h: Add HAL_STUB_HW_BREAKPOINT_LIST_SIZE and
+ HAL_STUB_HW_WATCHPOINT_LIST_SIZE.
+
2002-08-12 Mark Salter <msalter@redhat.com>
* cdl/hal_arm_iq80310.cdl: Remove CYGSEM_REDBOOT_ARM_LINUX_BOOT ref.
* misc/redboot_ROM.ecm: Ditto.
* misc/redboot_RAM.ecm: Ditto.
Index: hal/arm/iq80310/current/include/plf_stub.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/iq80310/current/include/plf_stub.h,v
retrieving revision 1.3
diff -u -p -5 -r1.3 plf_stub.h
--- hal/arm/iq80310/current/include/plf_stub.h 23 May 2002 23:02:07 -0000 1.3
+++ hal/arm/iq80310/current/include/plf_stub.h 29 Aug 2002 16:14:00 -0000
@@ -84,10 +84,13 @@ externC void cyg_hal_plf_comms_init(void
extern int cyg_hal_plf_hw_breakpoint(int setflag, void *addr, int len);
extern int cyg_hal_plf_hw_watchpoint(int setflag, void *addr, int len, int type);
extern int cyg_hal_plf_is_stopped_by_hardware(void **paddr);
+#define HAL_STUB_HW_BREAKPOINT_LIST_SIZE 2
+#define HAL_STUB_HW_WATCHPOINT_LIST_SIZE 1
+
#define HAL_STUB_HW_BREAKPOINT(f,a,l) cyg_hal_plf_hw_breakpoint((f),(a),(l))
#define HAL_STUB_HW_WATCHPOINT(f,a,l,t) cyg_hal_plf_hw_watchpoint((f),(a),(l),(t))
#define HAL_STUB_IS_STOPPED_BY_HARDWARE(p) cyg_hal_plf_is_stopped_by_hardware(&(p))
//-----------------------------------------------------------------------------
Index: hal/arm/xscale/verde/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/xscale/verde/current/ChangeLog,v
retrieving revision 1.5
diff -u -p -5 -r1.5 ChangeLog
--- hal/arm/xscale/verde/current/ChangeLog 12 Aug 2002 21:28:29 -0000 1.5
+++ hal/arm/xscale/verde/current/ChangeLog 29 Aug 2002 16:14:00 -0000
@@ -1,5 +1,10 @@
+2002-08-29 Mark Salter <msalter@redhat.com>
+
+ * include/plf_stub.h: Add HAL_STUB_HW_BREAKPOINT_LIST_SIZE and
+ HAL_STUB_HW_WATCHPOINT_LIST_SIZE.
+
2002-08-12 Mark Salter <msalter@redhat.com>
* cdl/hal_arm_xscale_verde.cdl: Remove CYGSEM_REDBOOT_ARM_LINUX_BOOT
requirement.
Index: hal/arm/xscale/verde/current/include/plf_stub.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/xscale/verde/current/include/plf_stub.h,v
retrieving revision 1.2
diff -u -p -5 -r1.2 plf_stub.h
--- hal/arm/xscale/verde/current/include/plf_stub.h 23 May 2002 23:02:34 -0000 1.2
+++ hal/arm/xscale/verde/current/include/plf_stub.h 29 Aug 2002 16:14:00 -0000
@@ -80,10 +80,13 @@ externC void cyg_hal_plf_comms_init(void
extern int cyg_hal_plf_hw_breakpoint(int setflag, void *addr, int len);
extern int cyg_hal_plf_hw_watchpoint(int setflag, void *addr, int len, int type);
extern int cyg_hal_plf_is_stopped_by_hardware(void **paddr);
+#define HAL_STUB_HW_BREAKPOINT_LIST_SIZE 2
+#define HAL_STUB_HW_WATCHPOINT_LIST_SIZE 1
+
#define HAL_STUB_HW_BREAKPOINT(f,a,l) cyg_hal_plf_hw_breakpoint((f),(a),(l))
#define HAL_STUB_HW_WATCHPOINT(f,a,l,t) cyg_hal_plf_hw_watchpoint((f),(a),(l),(t))
#define HAL_STUB_IS_STOPPED_BY_HARDWARE(p) cyg_hal_plf_is_stopped_by_hardware(&(p))
#endif // ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
Index: hal/common/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/common/current/ChangeLog,v
retrieving revision 1.78
diff -u -p -5 -r1.78 ChangeLog
--- hal/common/current/ChangeLog 23 May 2002 23:02:44 -0000 1.78
+++ hal/common/current/ChangeLog 29 Aug 2002 16:14:02 -0000
@@ -1,5 +1,14 @@
+2002-08-29 Mark Salter <msalter@redhat.com>
+
+ * include/generic-stub.h: Add defines for Z packet types.
+ * src/bplist-dynamic.c: Add support for deferred hardware breakpoint
+ and watchpoint insertion/deletion. This gets around gdb problem where
+ gdb tries accessing watched memory before removing watchpoint.
+ * src/generic-stub.c (__process_packet): Ditto.
+ * include/hal_stub.h: Ditto.
+
2002-05-23 Jesper Skov <jskov@redhat.com>
* cdl/hal.cdl: Don't build tests that are not applicable with the
current configuration.
Added CYGINT_HAL_TESTS_NO_CACHES which allows cache tests to be
Index: hal/common/current/include/generic-stub.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/common/current/include/generic-stub.h,v
retrieving revision 1.13
diff -u -p -5 -r1.13 generic-stub.h
--- hal/common/current/include/generic-stub.h 23 May 2002 23:02:47 -0000 1.13
+++ hal/common/current/include/generic-stub.h 29 Aug 2002 16:14:03 -0000
@@ -345,10 +345,17 @@ extern int __is_bsp_syscall(void);
extern void __install_breakpoint_list (void);
extern void __clear_breakpoint_list (void);
extern int __display_breakpoint_list (void (*print_func)(target_register_t));
+/* 'Z' packet types */
+#define ZTYPE_SW_BREAKPOINT 0
+#define ZTYPE_HW_BREAKPOINT 1
+#define ZTYPE_HW_WATCHPOINT_WRITE 2
+#define ZTYPE_HW_WATCHPOINT_READ 3
+#define ZTYPE_HW_WATCHPOINT_ACCESS 4
+
#endif /* ASM */
#ifdef __cplusplus
} /* extern "C" */
#endif
Index: hal/common/current/include/hal_stub.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/common/current/include/hal_stub.h,v
retrieving revision 1.22
diff -u -p -5 -r1.22 hal_stub.h
--- hal/common/current/include/hal_stub.h 23 May 2002 23:02:47 -0000 1.22
+++ hal/common/current/include/hal_stub.h 29 Aug 2002 16:14:03 -0000
@@ -210,10 +210,22 @@ extern void __reset (void);
extern int __set_breakpoint (target_register_t addr, target_register_t len);
#endif
#ifndef __remove_breakpoint
extern int __remove_breakpoint (target_register_t addr, target_register_t len);
#endif
+#ifndef __set_hw_breakpoint
+extern int __set_hw_breakpoint (target_register_t addr, target_register_t len);
+#endif
+#ifndef __remove_hw_breakpoint
+extern int __remove_hw_breakpoint (target_register_t addr, target_register_t len);
+#endif
+#ifndef __set_hw_watchpoint
+extern int __set_hw_watchpoint (target_register_t addr, target_register_t len, int ztype);
+#endif
+#ifndef __remove_hw_watchpoint
+extern int __remove_hw_watchpoint (target_register_t addr, target_register_t len, int ztype);
+#endif
/* Install the standard set of trap handlers for the stub. */
extern void __install_traps (void);
/* Address in text section of a breakpoint instruction. */
Index: hal/common/current/src/bplist-dynamic.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/common/current/src/bplist-dynamic.c,v
retrieving revision 1.8
diff -u -p -5 -r1.8 bplist-dynamic.c
--- hal/common/current/src/bplist-dynamic.c 23 May 2002 23:02:48 -0000 1.8
+++ hal/common/current/src/bplist-dynamic.c 29 Aug 2002 16:14:03 -0000
@@ -165,10 +165,180 @@ __remove_breakpoint (target_register_t a
free_bp_list = l;
return 0;
}
+#if defined(HAL_STUB_HW_BREAKPOINT_LIST_SIZE) && (HAL_STUB_HW_BREAKPOINT_LIST_SIZE > 0)
+#ifndef HAL_STUB_HW_BREAKPOINT
+#error "Must define HAL_STUB_HW_BREAKPOINT"
+#endif
+struct hw_breakpoint_list {
+ target_register_t addr;
+ target_register_t len;
+ char used;
+ char installed;
+};
+static struct hw_breakpoint_list hw_bp_list [HAL_STUB_HW_BREAKPOINT_LIST_SIZE];
+
+int
+__set_hw_breakpoint (target_register_t addr, target_register_t len)
+{
+ int i;
+
+ for (i = 0; i < HAL_STUB_HW_BREAKPOINT_LIST_SIZE; i++)
+ {
+ if (hw_bp_list[i].used == 0)
+ {
+ hw_bp_list[i].addr = addr;
+ hw_bp_list[i].len = len;
+ hw_bp_list[i].used = 1;
+ hw_bp_list[i].installed = 0;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int
+__remove_hw_breakpoint (target_register_t addr, target_register_t len)
+{
+ int i;
+
+ for (i = 0; i < HAL_STUB_HW_BREAKPOINT_LIST_SIZE; i++)
+ {
+ if (hw_bp_list[i].used && hw_bp_list[i].addr == addr
+ && hw_bp_list[i].len == len)
+ {
+ if (hw_bp_list[i].installed)
+ HAL_STUB_HW_BREAKPOINT(0, (void *)addr, (int)len);
+ hw_bp_list[i].used = 0;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+static void
+__install_hw_breakpoint_list (void)
+{
+ int i;
+
+ for (i = 0; i < HAL_STUB_HW_BREAKPOINT_LIST_SIZE; i++)
+ {
+ if (hw_bp_list[i].used && hw_bp_list[i].installed == 0)
+ {
+ HAL_STUB_HW_BREAKPOINT(1, (void *)hw_bp_list[i].addr,
+ (int)hw_bp_list[i].len);
+ hw_bp_list[i].installed = 1;
+ }
+ }
+}
+
+static void
+__clear_hw_breakpoint_list (void)
+{
+ int i;
+
+ for (i = 0; i < HAL_STUB_HW_BREAKPOINT_LIST_SIZE; i++)
+ {
+ if (hw_bp_list[i].used && hw_bp_list[i].installed)
+ {
+ HAL_STUB_HW_BREAKPOINT(0, (void *)hw_bp_list[i].addr,
+ (int)hw_bp_list[i].len);
+ hw_bp_list[i].installed = 0;
+ }
+ }
+}
+#endif // HAL_STUB_HW_BREAKPOINT_LIST_SIZE
+
+#if defined(HAL_STUB_HW_WATCHPOINT_LIST_SIZE) && (HAL_STUB_HW_WATCHPOINT_LIST_SIZE > 0)
+#ifndef HAL_STUB_HW_WATCHPOINT
+#error "Must define HAL_STUB_HW_WATCHPOINT"
+#endif
+struct hw_watchpoint_list {
+ target_register_t addr;
+ target_register_t len;
+ int ztype;
+ char used;
+ char installed;
+};
+static struct hw_watchpoint_list hw_wp_list [HAL_STUB_HW_WATCHPOINT_LIST_SIZE];
+
+int
+__set_hw_watchpoint (target_register_t addr, target_register_t len, int ztype)
+{
+ int i;
+
+ for (i = 0; i < HAL_STUB_HW_WATCHPOINT_LIST_SIZE; i++)
+ {
+ if (hw_wp_list[i].used == 0)
+ {
+ hw_wp_list[i].addr = addr;
+ hw_wp_list[i].len = len;
+ hw_wp_list[i].ztype = ztype;
+ hw_wp_list[i].used = 1;
+ hw_wp_list[i].installed = 0;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int
+__remove_hw_watchpoint (target_register_t addr, target_register_t len, int ztype)
+{
+ int i;
+
+ for (i = 0; i < HAL_STUB_HW_WATCHPOINT_LIST_SIZE; i++)
+ {
+ if (hw_wp_list[i].used && hw_wp_list[i].addr == addr
+ && hw_wp_list[i].len == len && hw_wp_list[i].ztype == ztype )
+ {
+ if (hw_wp_list[i].installed)
+ HAL_STUB_HW_WATCHPOINT(0, (void *)addr, (int)len, ztype);
+ hw_wp_list[i].used = 0;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+static void
+__install_hw_watchpoint_list (void)
+{
+ int i;
+
+ for (i = 0; i < HAL_STUB_HW_WATCHPOINT_LIST_SIZE; i++)
+ {
+ if (hw_wp_list[i].used && hw_wp_list[i].installed == 0)
+ {
+ HAL_STUB_HW_WATCHPOINT(1, (void *)hw_wp_list[i].addr,
+ (int)hw_wp_list[i].len, hw_wp_list[i].ztype);
+ hw_wp_list[i].installed = 1;
+ }
+ }
+}
+
+static void
+__clear_hw_watchpoint_list (void)
+{
+ int i;
+
+ for (i = 0; i < HAL_STUB_HW_WATCHPOINT_LIST_SIZE; i++)
+ {
+ if (hw_wp_list[i].used && hw_wp_list[i].installed)
+ {
+ HAL_STUB_HW_WATCHPOINT(0, (void *)hw_wp_list[i].addr,
+ (int)hw_wp_list[i].len, hw_wp_list[i].ztype);
+ hw_wp_list[i].installed = 0;
+ }
+ }
+}
+#endif // HAL_STUB_HW_WATCHPOINT_LIST_SIZE
+
+
+
void
__install_breakpoint_list (void)
{
struct breakpoint_list *l = breakpoint_list;
@@ -186,10 +356,16 @@ __install_breakpoint_list (void)
}
}
}
l = l->next;
}
+#if defined(HAL_STUB_HW_BREAKPOINT_LIST_SIZE) && (HAL_STUB_HW_BREAKPOINT_LIST_SIZE > 0)
+ __install_hw_breakpoint_list();
+#endif
+#if defined(HAL_STUB_HW_WATCHPOINT_LIST_SIZE) && (HAL_STUB_HW_WATCHPOINT_LIST_SIZE > 0)
+ __install_hw_watchpoint_list();
+#endif
HAL_ICACHE_SYNC();
}
void
__clear_breakpoint_list (void)
@@ -206,10 +382,16 @@ __clear_breakpoint_list (void)
l->in_memory = 0;
}
}
l = l->next;
}
+#if defined(HAL_STUB_HW_BREAKPOINT_LIST_SIZE) && (HAL_STUB_HW_BREAKPOINT_LIST_SIZE > 0)
+ __clear_hw_breakpoint_list();
+#endif
+#if defined(HAL_STUB_HW_WATCHPOINT_LIST_SIZE) && (HAL_STUB_HW_WATCHPOINT_LIST_SIZE > 0)
+ __clear_hw_watchpoint_list();
+#endif
HAL_ICACHE_INVALIDATE_ALL();
}
int
__display_breakpoint_list (void (*print_func)(target_register_t))
@@ -222,11 +404,10 @@ __display_breakpoint_list (void (*print_
l = l->next;
}
return 0;
}
-
#else // (CYGNUM_HAL_BREAKPOINT_LIST_SIZE == 0) or UNDEFINED
#include <cyg/hal/hal_stub.h> // Our header
#ifndef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
Index: hal/common/current/src/generic-stub.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/common/current/src/generic-stub.c,v
retrieving revision 1.28
diff -u -p -5 -r1.28 generic-stub.c
--- hal/common/current/src/generic-stub.c 20 May 2002 22:22:32 -0000 1.28
+++ hal/common/current/src/generic-stub.c 29 Aug 2002 16:14:05 -0000
@@ -1521,36 +1521,42 @@ __process_packet (char *packet)
addr = (target_register_t)TARGET_ADDR_TO_PTR(taddr);
switch (ztype)
{
- case 0:
+ case ZTYPE_SW_BREAKPOINT:
/* sw breakpoint */
if (is_Z)
err = __set_breakpoint(addr,length);
else
err = __remove_breakpoint(addr,length);
if (!err)
strcpy (__remcomOutBuffer, "OK");
else
strcpy (__remcomOutBuffer, "E02");
break;
- case 1:
- /* hw breakpoint */
-#ifdef HAL_STUB_HW_BREAKPOINT
- if (!HAL_STUB_HW_BREAKPOINT(is_Z, (void *)addr, length))
+ case ZTYPE_HW_BREAKPOINT:
+#if defined(HAL_STUB_HW_BREAKPOINT_LIST_SIZE) && (HAL_STUB_HW_BREAKPOINT_LIST_SIZE > 0)
+ if (is_Z)
+ err = __set_hw_breakpoint(addr, length);
+ else
+ err = __remove_hw_breakpoint(addr, length);
+ if (!err)
strcpy (__remcomOutBuffer, "OK");
else
#endif
strcpy (__remcomOutBuffer, "E02");
break;
- case 2:
- case 3:
- case 4:
- /* hw watchpoint */
-#ifdef HAL_STUB_HW_WATCHPOINT
- if (!HAL_STUB_HW_WATCHPOINT(is_Z, (void *)addr, length, ztype))
+ case ZTYPE_HW_WATCHPOINT_WRITE:
+ case ZTYPE_HW_WATCHPOINT_READ:
+ case ZTYPE_HW_WATCHPOINT_ACCESS:
+#if defined(HAL_STUB_HW_WATCHPOINT_LIST_SIZE) && (HAL_STUB_HW_WATCHPOINT_LIST_SIZE > 0)
+ if (is_Z)
+ err = __set_hw_watchpoint(addr, length, ztype);
+ else
+ err = __remove_hw_watchpoint(addr, length, ztype);
+ if (!err)
strcpy (__remcomOutBuffer, "OK");
else
#endif
strcpy (__remcomOutBuffer, "E02");
break;
Index: hal/frv/frv400/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/frv/frv400/current/ChangeLog,v
retrieving revision 1.2
diff -u -p -5 -r1.2 ChangeLog
--- hal/frv/frv400/current/ChangeLog 23 May 2002 23:02:53 -0000 1.2
+++ hal/frv/frv400/current/ChangeLog 29 Aug 2002 16:14:05 -0000
@@ -1,5 +1,10 @@
+2002-08-29 Mark Salter <msalter@redhat.com>
+
+ * include/plf_stub.h: Add HAL_STUB_HW_BREAKPOINT_LIST_SIZE and
+ HAL_STUB_HW_WATCHPOINT_LIST_SIZE.
+
2002-05-07 Gary Thomas <gthomas@redhat.com>
* cdl/hal_frv_frv400.cdl:
Make CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT more standard.
Index: hal/frv/frv400/current/include/plf_stub.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/frv/frv400/current/include/plf_stub.h,v
retrieving revision 1.2
diff -u -p -5 -r1.2 plf_stub.h
--- hal/frv/frv400/current/include/plf_stub.h 23 May 2002 23:02:54 -0000 1.2
+++ hal/frv/frv400/current/include/plf_stub.h 29 Aug 2002 16:14:05 -0000
@@ -80,10 +80,13 @@ externC void cyg_hal_plf_comms_init(void
// Hardware breakpoint/watchpoint support
extern int cyg_hal_plf_hw_breakpoint(int setflag, void *addr, int len);
extern int cyg_hal_plf_hw_watchpoint(int setflag, void *addr, int len, int type);
extern int cyg_hal_plf_is_stopped_by_hardware(void **paddr);
+#define HAL_STUB_HW_BREAKPOINT_LIST_SIZE 4
+#define HAL_STUB_HW_WATCHPOINT_LIST_SIZE 2
+
#define HAL_STUB_HW_BREAKPOINT(f,a,l) cyg_hal_plf_hw_breakpoint((f),(a),(l))
#define HAL_STUB_HW_WATCHPOINT(f,a,l,t) cyg_hal_plf_hw_watchpoint((f),(a),(l),(t))
#define HAL_STUB_IS_STOPPED_BY_HARDWARE(p) cyg_hal_plf_is_stopped_by_hardware(&(p))
#endif // ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS