Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Jon Beniston" <jbeniston@compxs.com>
To: <gdb-patches@sources.redhat.com>
Subject: Falling back to h/w breakpoints on ROM targets
Date: Tue, 13 Jan 2004 13:43:00 -0000	[thread overview]
Message-ID: <002601c3d9db$35a050f0$06bda8c0@Kindrogan> (raw)


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




                 reply	other threads:[~2004-01-13 13:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='002601c3d9db$35a050f0$06bda8c0@Kindrogan' \
    --to=jbeniston@compxs.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox