Add new devices x1122 x1132 emulation.
[deliverable/binutils-gdb.git] / gdb / remote.c
index 0c3f23a527eb0ad93438507feac6530a95df888c..5edea0102753eee58761fbc90382e809c023b4dc 100644 (file)
@@ -94,9 +94,8 @@ static void remote_async_open (char *name, int from_tty);
 static void extended_remote_open (char *name, int from_tty);
 static void extended_remote_async_open (char *name, int from_tty);
 
-static void remote_open_1 (char *, int, struct target_ops *, int extended_p);
-static void remote_async_open_1 (char *, int, struct target_ops *,
-                                int extended_p);
+static void remote_open_1 (char *, int, struct target_ops *, int extended_p,
+                          int async_p);
 
 static void remote_close (int quitting);
 
@@ -205,10 +204,6 @@ static void show_packet_config_cmd (struct packet_config *config);
 
 static void update_packet_config (struct packet_config *config);
 
-/* Define the target subroutine names */
-
-void open_remote_target (char *, int, struct target_ops *, int);
-
 void _initialize_remote (void);
 
 /* Description of the remote protocol.  Strictly speaking, when the
@@ -2160,14 +2155,14 @@ remote_start_remote (struct ui_out *uiout, void *dummy)
 static void
 remote_open (char *name, int from_tty)
 {
-  remote_open_1 (name, from_tty, &remote_ops, 0);
+  remote_open_1 (name, from_tty, &remote_ops, 0, 0);
 }
 
 /* Just like remote_open, but with asynchronous support. */
 static void
 remote_async_open (char *name, int from_tty)
 {
-  remote_async_open_1 (name, from_tty, &remote_async_ops, 0);
+  remote_open_1 (name, from_tty, &remote_async_ops, 0, 1);
 }
 
 /* Open a connection to a remote debugger using the extended
@@ -2176,14 +2171,16 @@ remote_async_open (char *name, int from_tty)
 static void
 extended_remote_open (char *name, int from_tty)
 {
-  remote_open_1 (name, from_tty, &extended_remote_ops, 1 /*extended_p */ );
+  remote_open_1 (name, from_tty, &extended_remote_ops, 1 /*extended_p */,
+                0 /* async_p */);
 }
 
 /* Just like extended_remote_open, but with asynchronous support. */
 static void
 extended_remote_async_open (char *name, int from_tty)
 {
-  remote_async_open_1 (name, from_tty, &extended_async_remote_ops, 1 /*extended_p */ );
+  remote_open_1 (name, from_tty, &extended_async_remote_ops,
+                1 /*extended_p */, 1 /* async_p */);
 }
 
 /* Generic code for opening a connection to a remote target.  */
@@ -2264,7 +2261,7 @@ remote_serial_open (char *name)
 
 static void
 remote_open_1 (char *name, int from_tty, struct target_ops *target,
-              int extended_p)
+              int extended_p, int async_p)
 {
   int ex;
   struct remote_state *rs = get_remote_state ();
@@ -2274,7 +2271,8 @@ remote_open_1 (char *name, int from_tty, struct target_ops *target,
           "(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).");
 
   /* See FIXME above */
-  wait_forever_enabled_p = 1;
+  if (!async_p)
+    wait_forever_enabled_p = 1;
 
   target_preopen (from_tty);
 
@@ -2324,6 +2322,22 @@ remote_open_1 (char *name, int from_tty, struct target_ops *target,
      someday have a notion of debugging several processes.  */
 
   inferior_ptid = pid_to_ptid (MAGIC_NULL_PID);
+
+  if (async_p)
+    {
+      /* With this target we start out by owning the terminal. */
+      remote_async_terminal_ours_p = 1;
+
+      /* FIXME: cagney/1999-09-23: During the initial connection it is
+        assumed that the target is already ready and able to respond to
+        requests. Unfortunately remote_start_remote() eventually calls
+        wait_for_inferior() with no timeout.  wait_forever_enabled_p gets
+        around this. Eventually a mechanism that allows
+        wait_for_inferior() to expect/get timeouts will be
+        implemented. */
+      wait_forever_enabled_p = 0;
+    }
+
 #ifdef SOLIB_CREATE_INFERIOR_HOOK
   /* First delete any symbols previously loaded from shared libraries. */
   no_shared_libraries (NULL, 0);
@@ -2352,126 +2366,13 @@ remote_open_1 (char *name, int from_tty, struct target_ops *target,
   if (ex < 0)
     {
       pop_target ();
+      if (async_p)
+       wait_forever_enabled_p = 1;
       throw_exception (ex);
     }
 
-  if (extended_p)
-    {
-      /* Tell the remote that we are using the extended protocol.  */
-      char *buf = alloca (rs->remote_packet_size);
-      putpkt ("!");
-      getpkt (buf, (rs->remote_packet_size), 0);
-    }
-#ifdef SOLIB_CREATE_INFERIOR_HOOK
-  /* FIXME: need a master target_open vector from which all 
-     remote_opens can be called, so that stuff like this can 
-     go there.  Failing that, the following code must be copied
-     to the open function for any remote target that wants to 
-     support svr4 shared libraries.  */
-
-  /* Set up to detect and load shared libraries. */
-  if (exec_bfd)        /* No use without an exec file. */
-    {
-      SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
-      remote_check_symbols (symfile_objfile);
-    }
-#endif
-}
-
-/* Just like remote_open but with asynchronous support. */
-static void
-remote_async_open_1 (char *name, int from_tty, struct target_ops *target,
-                    int extended_p)
-{
-  int ex;
-  struct remote_state *rs = get_remote_state ();
-  if (name == 0)
-    error ("To open a remote debug connection, you need to specify what\n"
-          "serial device is attached to the remote system\n"
-          "(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).");
-
-  target_preopen (from_tty);
-
-  unpush_target (target);
-
-  remote_desc = remote_serial_open (name);
-  if (!remote_desc)
-    perror_with_name (name);
-
-  if (baud_rate != -1)
-    {
-      if (serial_setbaudrate (remote_desc, baud_rate))
-       {
-         serial_close (remote_desc);
-         perror_with_name (name);
-       }
-    }
-
-  serial_raw (remote_desc);
-
-  /* If there is something sitting in the buffer we might take it as a
-     response to a command, which would be bad.  */
-  serial_flush_input (remote_desc);
-
-  if (from_tty)
-    {
-      puts_filtered ("Remote debugging using ");
-      puts_filtered (name);
-      puts_filtered ("\n");
-    }
-
-  push_target (target);                /* Switch to using remote target now */
-
-  init_all_packet_configs ();
-
-  general_thread = -2;
-  continue_thread = -2;
-
-  /* Probe for ability to use "ThreadInfo" query, as required.  */
-  use_threadinfo_query = 1;
-  use_threadextra_query = 1;
-
-  /* Without this, some commands which require an active target (such
-     as kill) won't work.  This variable serves (at least) double duty
-     as both the pid of the target process (if it has such), and as a
-     flag indicating that a target is active.  These functions should
-     be split out into seperate variables, especially since GDB will
-     someday have a notion of debugging several processes.  */
-  inferior_ptid = pid_to_ptid (MAGIC_NULL_PID);
-
-  /* With this target we start out by owning the terminal. */
-  remote_async_terminal_ours_p = 1;
-
-  /* FIXME: cagney/1999-09-23: During the initial connection it is
-     assumed that the target is already ready and able to respond to
-     requests. Unfortunately remote_start_remote() eventually calls
-     wait_for_inferior() with no timeout.  wait_forever_enabled_p gets
-     around this. Eventually a mechanism that allows
-     wait_for_inferior() to expect/get timeouts will be
-     implemented. */
-  wait_forever_enabled_p = 0;
-
-#ifdef SOLIB_CREATE_INFERIOR_HOOK
-  /* First delete any symbols previously loaded from shared libraries. */
-  no_shared_libraries (NULL, 0);
-#endif
-
-  /* Start the remote connection; if error, discard this target.  See
-     the comments in remote_open_1() for further details such as the
-     need to re-throw the exception.  */
-  ex = catch_exceptions (uiout,
-                        remote_start_remote, NULL,
-                        "Couldn't establish connection to remote"
-                        " target\n",
-                        RETURN_MASK_ALL);
-  if (ex < 0)
-    {
-      pop_target ();
-      wait_forever_enabled_p = 1;
-      throw_exception (ex);
-    }
-
-  wait_forever_enabled_p = 1;
+  if (async_p)
+    wait_forever_enabled_p = 1;
 
   if (extended_p)
     {
@@ -3627,7 +3528,8 @@ remote_prepare_to_store (void)
       /* NOTE: This isn't rs->sizeof_g_packet because here, we are
          forcing the register cache to read its and not the target
          registers.  */
-      read_register_bytes (0, (char *) NULL, REGISTER_BYTES); /* OK use.  */
+      deprecated_read_register_bytes (0, (char *) NULL,
+                                     REGISTER_BYTES); /* OK use.  */
       break;
     case PACKET_ENABLE:
       break;
@@ -4937,8 +4839,8 @@ remote_remove_watchpoint (CORE_ADDR addr, int len, int type)
 }
 
 
-int remote_hw_watchpoint_limit = 0;
-int remote_hw_breakpoint_limit = 0;
+int remote_hw_watchpoint_limit = -1;
+int remote_hw_breakpoint_limit = -1;
 
 int
 remote_check_watch_resources (int type, int cnt, int ot)
@@ -4947,6 +4849,8 @@ remote_check_watch_resources (int type, int cnt, int ot)
     {
       if (remote_hw_breakpoint_limit == 0)
        return 0;
+      else if (remote_hw_breakpoint_limit < 0)
+       return 1;
       else if (cnt <= remote_hw_breakpoint_limit)
        return 1;
     }
@@ -4954,6 +4858,8 @@ remote_check_watch_resources (int type, int cnt, int ot)
     {
       if (remote_hw_watchpoint_limit == 0)
        return 0;
+      else if (remote_hw_watchpoint_limit < 0)
+       return 1;
       else if (ot)
        return -1;
       else if (cnt <= remote_hw_watchpoint_limit)
@@ -4985,11 +4891,11 @@ remote_insert_hw_breakpoint (CORE_ADDR addr, char *shadow)
   char *buf = alloca (rs->remote_packet_size);
   char *p = buf;
       
-  /* The length field should be set to soething so that the packet is
-     well formed.  */
+  /* The length field should be set to the size of a breakpoint
+     instruction.  */
+
+  BREAKPOINT_FROM_PC (&addr, &len);  
 
-  len = strlen (shadow);
-  len = len ? len : 1;
   if (remote_protocol_Z[Z_PACKET_HARDWARE_BP].support == PACKET_DISABLE)
     error ("Can't set hardware breakpoint without the '%s' (%s) packet\n",
           remote_protocol_Z[Z_PACKET_HARDWARE_BP].name,
@@ -5026,8 +4932,12 @@ remote_remove_hw_breakpoint (CORE_ADDR addr, char *shadow)
   struct remote_state *rs = get_remote_state ();
   char *buf = alloca (rs->remote_packet_size);
   char *p = buf;
-  
-  len = sizeof (shadow);
+
+  /* The length field should be set to the size of a breakpoint
+     instruction.  */
+
+  BREAKPOINT_FROM_PC (&addr, &len);
+
   if (remote_protocol_Z[Z_PACKET_HARDWARE_BP].support == PACKET_DISABLE)
     error ("Can't clear hardware breakpoint without the '%s' (%s) packet\n",
           remote_protocol_Z[Z_PACKET_HARDWARE_BP].name,
@@ -5073,18 +4983,6 @@ push_remote_target (char *name, int from_tty)
   remote_open (name, from_tty);
 }
 
-/* Other targets want to use the entire remote serial module but with
-   certain remote_ops overridden. */
-
-void
-open_remote_target (char *name, int from_tty, struct target_ops *target,
-                   int extended_p)
-{
-  printf_filtered ("Selecting the %sremote protocol\n",
-                  (extended_p ? "extended-" : ""));
-  remote_open_1 (name, from_tty, target, extended_p);
-}
-
 /* Table used by the crc32 function to calcuate the checksum. */
 
 static unsigned long crc32_table[256] =
@@ -6250,6 +6148,19 @@ terminating `#' character and checksum.",
           "Show the maximum number of bytes per memory-read packet.\n",
           &remote_show_cmdlist);
 
+  add_setshow_cmd ("hardware-watchpoint-limit", no_class,
+                  var_zinteger, &remote_hw_watchpoint_limit, "\
+Set the maximum number of target hardware watchpoints.\n\
+Specify a negative limit for unlimited.", "\
+Show the maximum number of target hardware watchpoints.\n",
+                  NULL, NULL, &remote_set_cmdlist, &remote_show_cmdlist);
+  add_setshow_cmd ("hardware-breakpoint-limit", no_class,
+                  var_zinteger, &remote_hw_breakpoint_limit, "\
+Set the maximum number of target hardware breakpoints.\n\
+Specify a negative limit for unlimited.", "\
+Show the maximum number of target hardware breakpoints.\n",
+                  NULL, NULL, &remote_set_cmdlist, &remote_show_cmdlist);
+
   add_show_from_set
     (add_set_cmd ("remoteaddresssize", class_obscure,
                  var_integer, (char *) &remote_address_size,
This page took 0.027437 seconds and 4 git commands to generate.