qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Edgar E. Iglesias" <edgar.iglesias@axis.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] gdbstub: Debug user-mode signals
Date: Thu, 28 Feb 2008 20:22:30 +0100	[thread overview]
Message-ID: <20080228192230.GJ7782@edgar.se.axis.com> (raw)

Hello,

This patch makes it possible to debug signal handlers when simulating programs in user-mode. Without it, the session aborts as soon as a signal is delivered.

On CRIS I still cannot get GDB to unwind the stack beyond the signals return trampoline, but I'm pretty sure it's related to some error in the way I setup the trampoline in linux-user/signal.c.

Tested on ARM and CRIS.

Comments?
Ok to check it in?

Best regards
-- 
Edgar E. Iglesias
Axis Communications AB

Index: gdbstub.c
===================================================================
RCS file: /sources/qemu/qemu/gdbstub.c,v
retrieving revision 1.75
diff -u -p -b -u -p -r1.75 gdbstub.c
--- gdbstub.c	28 Feb 2008 08:28:31 -0000	1.75
+++ gdbstub.c	28 Feb 2008 17:15:33 -0000
@@ -65,6 +65,7 @@ typedef struct GDBState {
     int line_csum;
     uint8_t last_packet[4100];
     int last_packet_len;
+    int signal;
 #ifdef CONFIG_USER_ONLY
     int fd;
     int running_state;
@@ -121,6 +122,16 @@ int use_gdb_syscalls(void)
     return gdb_syscall_mode == GDB_SYS_ENABLED;
 }
 
+/* Resume execution.  */
+static inline void gdb_continue(GDBState *s)
+{
+#ifdef CONFIG_USER_ONLY
+        s->running_state = 1;
+#else
+        vm_start();
+#endif	
+}
+
 static void put_buffer(GDBState *s, const uint8_t *buf, int len)
 {
 #ifdef CONFIG_USER_ONLY
@@ -908,11 +919,11 @@ static int gdb_handle_packet(GDBState *s
             env->pc = addr;
 #endif
         }
-#ifdef CONFIG_USER_ONLY
-        s->running_state = 1;
-#else
-        vm_start();
-#endif
+	gdb_continue(s);
+	return RS_IDLE;
+    case 'C':
+        s->signal = strtoul(p, (char **)&p, 16);
+	gdb_continue(s);
 	return RS_IDLE;
     case 's':
         if (*p != '\0') {
@@ -935,11 +946,7 @@ static int gdb_handle_packet(GDBState *s
 #endif
         }
         cpu_single_step(env, 1);
-#ifdef CONFIG_USER_ONLY
-        s->running_state = 1;
-#else
-        vm_start();
-#endif
+	gdb_continue(s);
 	return RS_IDLE;
     case 'F':
         {
@@ -961,11 +968,7 @@ static int gdb_handle_packet(GDBState *s
             if (type == 'C') {
                 put_packet(s, "T02");
             } else {
-#ifdef CONFIG_USER_ONLY
-                s->running_state = 1;
-#else
-                vm_start();
-#endif
+                gdb_continue(s);
             }
         }
         break;
@@ -1294,6 +1297,8 @@ gdb_handlesig (CPUState *env, int sig)
           return sig;
         }
   }
+  sig = s->signal;
+  s->signal = 0;
   return sig;
 }
 

             reply	other threads:[~2008-02-28 17:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-28 19:22 Edgar E. Iglesias [this message]
2008-02-28 19:55 ` [Qemu-devel] [PATCH] gdbstub: Debug user-mode signals Edgar E. Iglesias

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=20080228192230.GJ7782@edgar.se.axis.com \
    --to=edgar.iglesias@axis.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).