qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vl.c: Implement SIGILL signal handler for triggering SIGSEGV
@ 2013-09-05 12:19 Michal Novotny
  2013-09-05 13:26 ` Paolo Bonzini
  2013-09-05 22:50 ` Anthony Liguori
  0 siblings, 2 replies; 6+ messages in thread
From: Michal Novotny @ 2013-09-05 12:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: minovotn

This is the patch to introduce SIGILL handler to be able to trigger
SIGSEGV signal in qemu. This has been written to help debugging
state when qemu crashes by SIGSEGV as a simple reproducer to
emulate such situation in case of need.

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 vl.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/vl.c b/vl.c
index 7e04641..3966271 100644
--- a/vl.c
+++ b/vl.c
@@ -2897,6 +2897,26 @@ static int object_create(QemuOpts *opts, void *opaque)
     return 0;
 }
 
+#ifdef CONFIG_POSIX
+static void signal_handler(int signal)
+{
+    int *p = NULL;
+
+    *p = 0xDEADBEEF;
+}
+
+static void setup_signal_handlers(void)
+{
+    struct sigaction action;
+
+    memset(&action, 0, sizeof(action));
+    sigfillset(&action.sa_mask);
+    action.sa_handler = signal_handler;
+    action.sa_flags = 0;
+    sigaction(SIGILL, &action, NULL);
+}
+#endif
+
 int main(int argc, char **argv, char **envp)
 {
     int i;
@@ -2945,6 +2965,10 @@ int main(int argc, char **argv, char **envp)
 #endif
     }
 
+#ifdef CONFIG_POSIX
+    setup_signal_handlers();
+#endif
+
     module_call_init(MODULE_INIT_QOM);
 
     qemu_add_opts(&qemu_drive_opts);
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-09-06 13:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-05 12:19 [Qemu-devel] [PATCH] vl.c: Implement SIGILL signal handler for triggering SIGSEGV Michal Novotny
2013-09-05 13:26 ` Paolo Bonzini
2013-09-05 22:37   ` Laszlo Ersek
2013-09-05 22:50 ` Anthony Liguori
2013-09-05 23:06   ` Eric Blake
2013-09-06 13:24   ` Michal Novotny

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).