Implement debugging of WOW64 processes in gdbserver
[deliverable/binutils-gdb.git] / gdbserver / remote-utils.cc
index 6b547493a71a91ab02318fa8ad475c0387a26d04..67c560d1c87bbdd5d42b8b9448bd8b5b9091affb 100644 (file)
@@ -78,12 +78,6 @@ typedef int socklen_t;
 
 #ifndef IN_PROCESS_AGENT
 
-#if USE_WIN32API
-# define INVALID_DESCRIPTOR INVALID_SOCKET
-#else
-# define INVALID_DESCRIPTOR -1
-#endif
-
 /* Extra value for readchar_callback.  */
 enum {
   /* The callback is currently not scheduled.  */
@@ -108,8 +102,8 @@ struct sym_cache
 
 static int remote_is_stdio = 0;
 
-static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR;
-static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR;
+static int remote_desc = -1;
+static int listen_desc = -1;
 
 #ifdef USE_WIN32API
 # define read(fd, buf, len) recv (fd, (char *) buf, len, 0)
@@ -119,7 +113,7 @@ static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR;
 int
 gdb_connected (void)
 {
-  return remote_desc != INVALID_DESCRIPTOR;
+  return remote_desc != -1;
 }
 
 /* Return true if the remote connection is over stdio.  */
@@ -144,7 +138,7 @@ enable_async_notification (int fd)
 #endif
 }
 
-static int
+static void
 handle_accept_event (int err, gdb_client_data client_data)
 {
   struct sockaddr_storage sockaddr;
@@ -213,8 +207,6 @@ handle_accept_event (int err, gdb_client_data client_data)
      until GDB as selected all-stop/non-stop, and has queried the
      threads' status ('?').  */
   target_async (0);
-
-  return 0;
 }
 
 /* Prepare for a later connection to a remote debugger.
@@ -427,7 +419,7 @@ remote_close (void)
   if (! remote_connection_is_stdio ())
     close (remote_desc);
 #endif
-  remote_desc = INVALID_DESCRIPTOR;
+  remote_desc = -1;
 
   reset_readchar ();
 }
@@ -790,7 +782,7 @@ check_remote_input_interrupt_request (void)
   /* This function may be called before establishing communications,
      therefore we need to validate the remote descriptor.  */
 
-  if (remote_desc == INVALID_DESCRIPTOR)
+  if (remote_desc == -1)
     return;
 
   input_interrupt (0);
@@ -930,27 +922,21 @@ reset_readchar (void)
   readchar_bufcnt = 0;
   if (readchar_callback != NOT_SCHEDULED)
     {
-      delete_callback_event (readchar_callback);
+      delete_timer (readchar_callback);
       readchar_callback = NOT_SCHEDULED;
     }
 }
 
 /* Process remaining data in readchar_buf.  */
 
-static int
+static void
 process_remaining (void *context)
 {
-  int res;
-
   /* This is a one-shot event.  */
   readchar_callback = NOT_SCHEDULED;
 
   if (readchar_bufcnt > 0)
-    res = handle_serial_event (0, NULL);
-  else
-    res = 0;
-
-  return res;
+    handle_serial_event (0, NULL);
 }
 
 /* If there is still data in the buffer, queue another event to process it,
@@ -960,7 +946,7 @@ static void
 reschedule (void)
 {
   if (readchar_bufcnt > 0 && readchar_callback == NOT_SCHEDULED)
-    readchar_callback = append_callback_event (process_remaining, NULL);
+    readchar_callback = create_timer (0, process_remaining, NULL);
 }
 
 /* Read a packet from the remote machine, with error checking,
@@ -1204,6 +1190,26 @@ prepare_resume_reply (char *buf, ptid_t ptid,
        else
          sprintf (buf, "T%02x", status->value.sig);
 
+       if (disable_packet_T)
+         {
+           /* This is a bit (OK, a lot) of a kludge, however, this isn't
+              really a user feature, but exists only so GDB can use the
+              gdbserver to test handling of the 'S' stop reply packet, so
+              we would rather this code be as simple as possible.
+
+              By this point we've started to build the 'T' stop packet,
+              and it should look like 'Txx....' where 'x' is a hex digit.
+              An 'S' stop packet always looks like 'Sxx', so all we do
+              here is convert the buffer from a T packet to an S packet
+              and the avoid adding any extra content by breaking out.  */
+           gdb_assert (*buf == 'T');
+           gdb_assert (isxdigit (*(buf + 1)));
+           gdb_assert (isxdigit (*(buf + 2)));
+           *buf = 'S';
+           *(buf + 3) = '\0';
+           break;
+         }
+
        buf += strlen (buf);
 
        saved_thread = current_thread;
This page took 0.03715 seconds and 4 git commands to generate.