qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [4483] Support signal reception in user-mode.
@ 2008-05-17 22:20 Edgar E. Iglesias
  0 siblings, 0 replies; only message in thread
From: Edgar E. Iglesias @ 2008-05-17 22:20 UTC (permalink / raw)
  To: qemu-devel

Revision: 4483
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4483
Author:   edgar_igl
Date:     2008-05-17 22:20:53 +0000 (Sat, 17 May 2008)

Log Message:
-----------
Support signal reception in user-mode. Handle when the peer terminates or aborts the connection.

Modified Paths:
--------------
    trunk/gdbstub.c

Modified: trunk/gdbstub.c
===================================================================
--- trunk/gdbstub.c	2008-05-17 19:55:28 UTC (rev 4482)
+++ trunk/gdbstub.c	2008-05-17 22:20:53 UTC (rev 4483)
@@ -65,6 +65,7 @@
     int line_csum;
     uint8_t last_packet[4100];
     int last_packet_len;
+    int signal;
 #ifdef CONFIG_USER_ONLY
     int fd;
     int running_state;
@@ -93,9 +94,13 @@
     for(;;) {
         ret = recv(s->fd, &ch, 1, 0);
         if (ret < 0) {
+            if (errno == ECONNRESET)
+                s->fd = -1;
             if (errno != EINTR && errno != EAGAIN)
                 return -1;
         } else if (ret == 0) {
+            close(s->fd);
+            s->fd = -1;
             return -1;
         } else {
             break;
@@ -991,6 +996,10 @@
         }
         gdb_continue(s);
 	return RS_IDLE;
+    case 'C':
+        s->signal = strtoul(p, (char **)&p, 16);
+        gdb_continue(s);
+        return RS_IDLE;
     case 'k':
         /* Kill the target */
         fprintf(stderr, "\nQEMU: Terminated via GDBstub\n");
@@ -1364,11 +1373,10 @@
   char buf[256];
   int n;
 
-  if (gdbserver_fd < 0)
+  s = &gdbserver_state;
+  if (gdbserver_fd < 0 || s->fd < 0)
     return sig;
 
-  s = &gdbserver_state;
-
   /* disable single step if it was enabled */
   cpu_single_step(env, 0);
   tb_flush(env);
@@ -1378,6 +1386,10 @@
       snprintf(buf, sizeof(buf), "S%02x", sig);
       put_packet(s, buf);
     }
+  /* put_packet() might have detected that the peer terminated the 
+     connection.  */
+  if (s->fd < 0)
+      return sig;
 
   sig = 0;
   s->state = RS_IDLE;
@@ -1398,6 +1410,8 @@
           return sig;
         }
   }
+  sig = s->signal;
+  s->signal = 0;
   return sig;
 }
 
@@ -1407,11 +1421,10 @@
   GDBState *s;
   char buf[4];
 
-  if (gdbserver_fd < 0)
+  s = &gdbserver_state;
+  if (gdbserver_fd < 0 || s->fd < 0)
     return;
 
-  s = &gdbserver_state;
-
   snprintf(buf, sizeof(buf), "W%02x", code);
   put_packet(s, buf);
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-05-17 22:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-17 22:20 [Qemu-devel] [4483] Support signal reception in user-mode Edgar E. Iglesias

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).