Support for bi-endian remote breakpoints.
authorStan Shebs <shebs@codesourcery.com>
Sun, 28 Apr 1996 23:43:05 +0000 (23:43 +0000)
committerStan Shebs <shebs@codesourcery.com>
Sun, 28 Apr 1996 23:43:05 +0000 (23:43 +0000)
* remote.c (big_break_insn, little_break_insn): New globals.
(break_insn): Remove.
(remote_insert_breakpoint, remote_remove_breakpoint): Use own
code if REMOTE_BREAKPOINT defined, otherwise call memory
breakpoint functions.
* config/sh/tm-sh.h (REMOTE_BREAKPOINT): Remove.
(BIG_REMOTE_BREAKPOINT, LITTLE_REMOTE_BREAKPOINT): Define.

gdb/ChangeLog
gdb/config/sh/tm-sh.h
gdb/remote.c

index b3682927b64ca5c69d9381cedfedbbc986df5d0a..b15eb394f19fd322d75b36b1614e3424a9d480ad 100644 (file)
@@ -1,5 +1,14 @@
 Sun Apr 28 15:08:05 1996  Stan Shebs  <shebs@andros.cygnus.com>
 
+       Support for bi-endian remote breakpoints.
+       * remote.c (big_break_insn, little_break_insn): New globals.
+       (break_insn): Remove.
+       (remote_insert_breakpoint, remote_remove_breakpoint): Use own
+       code if REMOTE_BREAKPOINT defined, otherwise call memory
+       breakpoint functions.
+       * config/sh/tm-sh.h (REMOTE_BREAKPOINT): Remove.
+       (BIG_REMOTE_BREAKPOINT, LITTLE_REMOTE_BREAKPOINT): Define.
+
        * mon960-rom.c (mon960_cmds): Remove forward decl.
        (mon960_load): Use current_monitor instead of mon960_cmds.
        (mon960_regnames): Remove backslashes from line ends.
index 0a57192bec98970d3d58605dff570af2db1ac0aa..9152625381c8cdb122fae9b8c6913bcc189259f1 100644 (file)
@@ -60,7 +60,9 @@ extern CORE_ADDR sh_skip_prologue ();
 
 #define BREAKPOINT {0xc3, 0xc3}  /* 0xc3c3 is trapa #c3, and it works in big 
                                    and little endian modes  */
-#define REMOTE_BREAKPOINT { 0xc3, 0x20}
+
+#define BIG_REMOTE_BREAKPOINT    { 0xc3, 0x20 }
+#define LITTLE_REMOTE_BREAKPOINT { 0x20, 0xc3 }
 
 /* If your kernel resets the pc after the trap happens you may need to
    define this before including this file.  */
index 5356e5e459b6a716997f0346a3b6ee35482d7626..25c873427c9f37cc640fb09fc61c2579186bc8f1 100644 (file)
@@ -308,6 +308,13 @@ serial_t remote_desc = NULL;
 #define        PBUFSIZ (REGISTER_BYTES * 2 + 32)
 #endif
 
+/* This variable sets the number of bytes to be written to the target
+   in a single packet.  Normally PBUFSIZ is satisfactory, but some
+   targets need smaller values (perhaps because the receiving end
+   is slow).  */
+
+static int remote_write_size = PBUFSIZ;
+
 /* Should we try the 'P' request?  If this is set to one when the stub
    doesn't support 'P', the only consequence is some unnecessary traffic.  */
 static int stub_supports_P = 1;
@@ -1071,7 +1078,8 @@ remote_write_bytes (memaddr, myaddr, len)
   while (done < len)
     {
       int todo = len - done;
-      int cando = PBUFSIZ /2 - 32; /* number of bytes that will fit. */
+      int cando = min(remote_write_size, PBUFSIZ) / 2 - 32; /* num bytes that will fit */
+
       if (todo > cando)
        todo = cando;
 
@@ -1684,19 +1692,33 @@ extended_remote_create_inferior (exec_file, args, env)
 }
 
 \f
-#ifdef REMOTE_BREAKPOINT
-
 /* On some machines, e.g. 68k, we may use a different breakpoint instruction
-   than other targets.  */
-static unsigned char break_insn[] = REMOTE_BREAKPOINT;
+   than other targets; in those use REMOTE_BREAKPOINT instead of just
+   BREAKPOINT.  Also, bi-endian targets may define LITTLE_REMOTE_BREAKPOINT
+   and BIG_REMOTE_BREAKPOINT.  If none of these are defined, we just call
+   the standard routines that are in mem-break.c.  */
+
+/* FIXME, these ought to be done in a more dynamic fashion.  For instance,
+   the choice of breakpoint instruction affects target program design and
+   vice versa, and by making it user-tweakable, the special code here
+   goes away and we need fewer special GDB configurations.  */
+
+#if defined (LITTLE_REMOTE_BREAKPOINT) && defined (BIG_REMOTE_BREAKPOINT) && !defined(REMOTE_BREAKPOINT)
+#define REMOTE_BREAKPOINT
+#endif
+
+#ifdef REMOTE_BREAKPOINT
 
-#else /* No REMOTE_BREAKPOINT.  */
+/* If the target isn't bi-endian, just pretend it is.  */
+#if !defined (LITTLE_REMOTE_BREAKPOINT) && !defined (BIG_REMOTE_BREAKPOINT)
+#define LITTLE_REMOTE_BREAKPOINT REMOTE_BREAKPOINT
+#define BIG_REMOTE_BREAKPOINT REMOTE_BREAKPOINT
+#endif
 
-/* Same old breakpoint instruction.  This code does nothing different
-   than mem-break.c.  */
-static unsigned char break_insn[] = BREAKPOINT;
+static unsigned char big_break_insn[] = BIG_REMOTE_BREAKPOINT;
+static unsigned char little_break_insn[] = LITTLE_REMOTE_BREAKPOINT;
 
-#endif /* No REMOTE_BREAKPOINT.  */
+#endif /* REMOTE_BREAKPOINT */
 
 /* Insert a breakpoint on targets that don't have any better breakpoint
    support.  We read the contents of the target location and stash it,
@@ -1711,14 +1733,25 @@ remote_insert_breakpoint (addr, contents_cache)
      CORE_ADDR addr;
      char *contents_cache;
 {
+#ifdef REMOTE_BREAKPOINT
   int val;
 
-  val = target_read_memory (addr, contents_cache, sizeof break_insn);
+  val = target_read_memory (addr, contents_cache, sizeof big_break_insn);
 
   if (val == 0)
-    val = target_write_memory (addr, (char *)break_insn, sizeof break_insn);
+    {
+      if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+       val = target_write_memory (addr, (char *) big_break_insn,
+                                  sizeof big_break_insn);
+      else
+       val = target_write_memory (addr, (char *) little_break_insn,
+                                  sizeof little_break_insn);
+    }
 
   return val;
+#else
+  return memory_insert_breakpoint (addr, contents_cache);
+#endif /* REMOTE_BREAKPOINT */
 }
 
 static int
@@ -1726,7 +1759,11 @@ remote_remove_breakpoint (addr, contents_cache)
      CORE_ADDR addr;
      char *contents_cache;
 {
-  return target_write_memory (addr, contents_cache, sizeof break_insn);
+#ifdef REMOTE_BREAKPOINT
+  return target_write_memory (addr, contents_cache, sizeof big_break_insn);
+#else
+  return memory_remove_breakpoint (addr, contents_cache);
+#endif /* REMOTE_BREAKPOINT */
 }
 \f
 /* Define the target subroutine names */
@@ -1836,4 +1873,9 @@ _initialize_remote ()
                                  var_integer, (char *)&remote_break,
                                  "Set whether to send break if interrupted.\n", &setlist),
                     &showlist);
+
+  add_show_from_set (add_set_cmd ("remotewritesize", no_class,
+                                 var_integer, (char *)&remote_write_size,
+                                 "Set the maximum number of bytes in each memory write packet.\n", &setlist),
+                    &showlist);
 }