This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Falling back to h/w breakpoints on ROM targets
- From: "Jon Beniston" <jbeniston at compxs dot com>
- To: <gdb-patches at sources dot redhat dot com>
- Date: Tue, 13 Jan 2004 13:43:16 -0000
- Subject: Falling back to h/w breakpoints on ROM targets
- Organization: CompXs
- Reply-to: <jbeniston at compxs dot com>
I've been working on a remote target where the code runs from ROM.
Obviously, trying to set s/w breakpoints always fails. The following
patch therefore trys inserting h/w breakpoints when s/w breakpoints
fail.
Cheers,
Jon
Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.5195
diff -c -p -r1.5195 ChangeLog
*** ChangeLog 12 Jan 2004 20:33:21 -0000 1.5195
--- ChangeLog 13 Jan 2004 13:36:08 -0000
***************
*** 1,3 ****
--- 1,9 ----
+ 2004-01-13 Jon Beniston <jon@beniston.com>
+
+ * remote.c (remote_insert/remove_breakpoint): Try using
+ h/w breakpoints when s/w breakpoints fail for targets
+ running from ROM.
+
2004-01-12 Andrew Cagney <cagney@redhat.com>
* exec.h (exec_ops): Make "extern".
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.124
diff -c -p -r1.124 remote.c
*** remote.c 8 Dec 2003 17:00:06 -0000 1.124
--- remote.c 13 Jan 2004 13:36:20 -0000
*************** static int remote_insert_breakpoint (COR
*** 145,150 ****
--- 145,154 ----
static int remote_remove_breakpoint (CORE_ADDR, char *);
+ static int remote_insert_hw_breakpoint (CORE_ADDR, char *);
+
+ static int remote_remove_hw_breakpoint (CORE_ADDR, char *);
+
static int hexnumlen (ULONGEST num);
static void init_remote_ops (void);
*************** static int
*** 4679,4687 ****
remote_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
{
struct remote_state *rs = get_remote_state ();
- #ifdef DEPRECATED_REMOTE_BREAKPOINT
int val;
- #endif
int bp_size;
/* Try the "Z" s/w breakpoint packet if it is not already disabled.
--- 4683,4689 ----
*************** remote_insert_breakpoint (CORE_ADDR addr
*** 4708,4714 ****
switch (packet_ok (buf,
&remote_protocol_Z[Z_PACKET_SOFTWARE_BP]))
{
case PACKET_ERROR:
! return -1;
case PACKET_OK:
return 0;
case PACKET_UNKNOWN:
--- 4710,4719 ----
switch (packet_ok (buf,
&remote_protocol_Z[Z_PACKET_SOFTWARE_BP]))
{
case PACKET_ERROR:
! if (remote_protocol_Z[Z_PACKET_HARDWARE_BP].support !=
PACKET_DISABLE)
! return remote_insert_hw_breakpoint (addr, contents_cache);
! else
! return -1;
case PACKET_OK:
return 0;
case PACKET_UNKNOWN:
*************** remote_insert_breakpoint (CORE_ADDR addr
*** 4728,4743 ****
val = target_write_memory (addr, (char *) little_break_insn,
sizeof little_break_insn);
}
-
- return val;
#else
! return memory_insert_breakpoint (addr, contents_cache);
#endif /* DEPRECATED_REMOTE_BREAKPOINT */
}
static int
remote_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
{
struct remote_state *rs = get_remote_state ();
int bp_size;
--- 4733,4753 ----
val = target_write_memory (addr, (char *) little_break_insn,
sizeof little_break_insn);
}
#else
! val = memory_insert_breakpoint (addr, contents_cache);
#endif /* DEPRECATED_REMOTE_BREAKPOINT */
+
+ if ((val != 0)
+ && (remote_protocol_Z[Z_PACKET_HARDWARE_BP].support !=
PACKET_DISABLE))
+ val = remote_insert_hw_breakpoint (addr, contents_cache);
+
+ return val;
}
static int
remote_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
{
+ int val;
struct remote_state *rs = get_remote_state ();
int bp_size;
*************** remote_remove_breakpoint (CORE_ADDR addr
*** 4758,4771 ****
putpkt (buf);
getpkt (buf, (rs->remote_packet_size), 0);
! return (buf[0] == 'E');
}
#ifdef DEPRECATED_REMOTE_BREAKPOINT
! return target_write_memory (addr, contents_cache, sizeof
big_break_insn);
#else
! return memory_remove_breakpoint (addr, contents_cache);
#endif /* DEPRECATED_REMOTE_BREAKPOINT */
}
static int
--- 4768,4790 ----
putpkt (buf);
getpkt (buf, (rs->remote_packet_size), 0);
! if (buf[0] == 'E')
! return remote_remove_hw_breakpoint (addr, contents_cache);
! else
! return 0;
}
#ifdef DEPRECATED_REMOTE_BREAKPOINT
! val = target_write_memory (addr, contents_cache, sizeof
big_break_insn);
#else
! val = memory_remove_breakpoint (addr, contents_cache);
#endif /* DEPRECATED_REMOTE_BREAKPOINT */
+
+ if ((val != 0)
+ && (remote_protocol_Z[Z_PACKET_HARDWARE_BP].support !=
PACKET_DISABLE))
+ val = remote_remove_hw_breakpoint (addr, contents_cache);
+
+ return val;
}
static int