diff options
| author | Aníbal Limón <anibal.limon@linux.intel.com> | 2015-08-12 15:38:49 -0500 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-16 09:24:58 +0100 |
| commit | 73a876e4ff04ebbbcd3bde62efe02146ab601e25 (patch) | |
| tree | deaddb90f52c526a94cdec6c6bfaf2f383b224c0 | |
| parent | 6b166891d2452aec95e0757afda734722a318ad3 (diff) | |
| download | poky-73a876e4ff04ebbbcd3bde62efe02146ab601e25.tar.gz | |
qemu-native: Add debugging when qemu fails with qemu_cpu_kick_thread
We are expecting some random failures in QEMU runs one of this is
related to qemu_cpu_kick_thread that ends on exit(1) on qemu.
To improve debug information add patch that prints the backtrace and
the status of qemu cpu.
[YOCTO #8143]
(From OE-Core rev: c9dd8fae8fd799f0f64328606904e047ed8ee9c3)
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/recipes-devtools/qemu/qemu.inc | 1 | ||||
| -rw-r--r-- | meta/recipes-devtools/qemu/qemu/cpus.c-qemu_cpu_kick_thread_debugging.patch | 76 |
2 files changed, 77 insertions, 0 deletions
diff --git a/meta/recipes-devtools/qemu/qemu.inc b/meta/recipes-devtools/qemu/qemu.inc index c3f73d1ec5..8c1e77940e 100644 --- a/meta/recipes-devtools/qemu/qemu.inc +++ b/meta/recipes-devtools/qemu/qemu.inc | |||
| @@ -25,6 +25,7 @@ SRC_URI = "\ | |||
| 25 | 25 | ||
| 26 | SRC_URI_append_class-native = "\ | 26 | SRC_URI_append_class-native = "\ |
| 27 | file://fix-libcap-header-issue-on-some-distro.patch \ | 27 | file://fix-libcap-header-issue-on-some-distro.patch \ |
| 28 | file://cpus.c-qemu_cpu_kick_thread_debugging.patch \ | ||
| 28 | " | 29 | " |
| 29 | 30 | ||
| 30 | EXTRA_OECONF += "--target-list=${@get_qemu_target_list(d)} --disable-werror --disable-bluez --disable-libiscsi --with-system-pixman --extra-cflags='${CFLAGS}'" | 31 | EXTRA_OECONF += "--target-list=${@get_qemu_target_list(d)} --disable-werror --disable-bluez --disable-libiscsi --with-system-pixman --extra-cflags='${CFLAGS}'" |
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 @@ | |||
| 1 | From 697a834c35d19447b7dcdb9e1d9434bc6ce17c21 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: =?UTF-8?q?An=C3=ADbal=20Lim=C3=B3n?= <anibal.limon@linux.intel.com> | ||
| 3 | Date: Wed, 12 Aug 2015 15:11:30 -0500 | ||
| 4 | Subject: [PATCH] cpus.c: Add error messages when qemi_cpu_kick_thread fails. | ||
| 5 | MIME-Version: 1.0 | ||
| 6 | Content-Type: text/plain; charset=UTF-8 | ||
| 7 | Content-Transfer-Encoding: 8bit | ||
| 8 | |||
| 9 | Add custom_debug.h with function for print backtrace information. | ||
| 10 | When pthread_kill fails in qemu_cpu_kick_thread display backtrace and | ||
| 11 | current cpu information. | ||
| 12 | |||
| 13 | Upstream-Status: Inappropriate | ||
| 14 | Signed-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 | |||
| 21 | diff --git a/cpus.c b/cpus.c | ||
| 22 | index 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 */ | ||
| 44 | diff --git a/custom_debug.h b/custom_debug.h | ||
| 45 | new file mode 100644 | ||
| 46 | index 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 | -- | ||
| 75 | 1.9.1 | ||
| 76 | |||
