summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/qemu/qemu/cpus.c-qemu_cpu_kick_thread_debugging.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/qemu/qemu/cpus.c-qemu_cpu_kick_thread_debugging.patch')
-rw-r--r--meta/recipes-devtools/qemu/qemu/cpus.c-qemu_cpu_kick_thread_debugging.patch76
1 files changed, 76 insertions, 0 deletions
diff --git a/meta/recipes-devtools/qemu/qemu/cpus.c-qemu_cpu_kick_thread_debugging.patch b/meta/recipes-devtools/qemu/qemu/cpus.c-qemu_cpu_kick_thread_debugging.patch
new file mode 100644
index 0000000000..6822132541
--- /dev/null
+++ b/meta/recipes-devtools/qemu/qemu/cpus.c-qemu_cpu_kick_thread_debugging.patch
@@ -0,0 +1,76 @@
1From 697a834c35d19447b7dcdb9e1d9434bc6ce17c21 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?An=C3=ADbal=20Lim=C3=B3n?= <anibal.limon@linux.intel.com>
3Date: Wed, 12 Aug 2015 15:11:30 -0500
4Subject: [PATCH] cpus.c: Add error messages when qemi_cpu_kick_thread fails.
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Add custom_debug.h with function for print backtrace information.
10When pthread_kill fails in qemu_cpu_kick_thread display backtrace and
11current cpu information.
12
13Upstream-Status: Inappropriate
14Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
15---
16 cpus.c | 5 +++++
17 custom_debug.h | 24 ++++++++++++++++++++++++
18 2 files changed, 29 insertions(+)
19 create mode 100644 custom_debug.h
20
21diff --git a/cpus.c b/cpus.c
22index a822ce3..7e4786e 100644
23--- a/cpus.c
24+++ b/cpus.c
25@@ -1080,6 +1080,8 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
26 return NULL;
27 }
28
29+#include "custom_debug.h"
30+
31 static void qemu_cpu_kick_thread(CPUState *cpu)
32 {
33 #ifndef _WIN32
34@@ -1088,6 +1090,9 @@ static void qemu_cpu_kick_thread(CPUState *cpu)
35 err = pthread_kill(cpu->thread->thread, SIG_IPI);
36 if (err) {
37 fprintf(stderr, "qemu:%s: %s", __func__, strerror(err));
38+ fprintf(stderr, "CPU #%d:\n", cpu->cpu_index);
39+ cpu_dump_state(cpu, stderr, fprintf, 0);
40+ backtrace_print();
41 exit(1);
42 }
43 #else /* _WIN32 */
44diff --git a/custom_debug.h b/custom_debug.h
45new file mode 100644
46index 0000000..f029e45
47--- /dev/null
48+++ b/custom_debug.h
49@@ -0,0 +1,24 @@
50+#include <execinfo.h>
51+#include <stdio.h>
52+#define BACKTRACE_MAX 128
53+static void backtrace_print(void)
54+{
55+ int nfuncs = 0;
56+ void *buf[BACKTRACE_MAX];
57+ char **symbols;
58+ int i;
59+
60+ nfuncs = backtrace(buf, BACKTRACE_MAX);
61+
62+ symbols = backtrace_symbols(buf, nfuncs);
63+ if (symbols == NULL) {
64+ fprintf(stderr, "backtrace_print failed to get symbols");
65+ return;
66+ }
67+
68+ fprintf(stderr, "Backtrace ...\n");
69+ for (i = 0; i < nfuncs; i++)
70+ fprintf(stderr, "%s\n", symbols[i]);
71+
72+ free(symbols);
73+}
74--
751.9.1
76