qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [4483] Support signal reception in user-mode.
Date: Sat, 17 May 2008 22:20:54 +0000	[thread overview]
Message-ID: <E1JxUlq-0003PC-8j@cvs.savannah.gnu.org> (raw)

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);
 }

                 reply	other threads:[~2008-05-17 22:20 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=E1JxUlq-0003PC-8j@cvs.savannah.gnu.org \
    --to=edgar.iglesias@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).