Fixes for random Qemu crashes
RFC 1/1 Fixes for random Qemu crashes
Following the discussion about the inlining problems encountered while compiling gcc, I tried another set of patches to address those issues.
I first moved all common definitions to osdep.h, changed the always_inline definition into:
#define always_inline __attribute__ (( always_inline )) __inline__ (as suggested by Ben Pfaff) and added:
#define inline always_inline
It then appeared that translate-op.c did not include osdep.h. As it seems not great that inlining would not be done in this part of the code, I did add the include.
This patch also triggered that there are some recursive functions declared as inline in thunk.h / thunk.c. Defining inline as always_inline makes gcc emit an error as those functions can obviously not be inlined.
Here are the 3 diffs, which are not too invasive. Even if gcc still emit inlining warnings (when setting the -Winline flag), then not inlining some functions declared as always_inline, this patch seems to allow the PowerPC 64 target not to crash.
Please comment.
Signature · 2 lines
J. Mayer <[email protected]> Never organized
Index: exec-all.h
===================================================================
RCS file: /sources/qemu/qemu/exec-all.h,v
retrieving revision 1.70
exec-all.h +0 -30
@@ -21,36 +21,6 @@/* allow to see translation results - the slowdown should be negligible, so we leave it */ #define DEBUG_DISAS -#ifndef glue -#define xglue (x, y) x ## y -#define glue (x, y) xglue(x, y) -#define stringify (s) tostring(s) -#define tostring (s) #s -#endif - -#ifndef likely -#if __GNUC__ <3 -#define __builtin_expect (x, n) (x) -#endif - -#define likely (x) __builtin_expect(!!(x), 1) -#define unlikely (x) __builtin_expect(!!(x), 0) -#endif - -#ifndef always_inline -#if (__GNUC__ <3 ) || defined(__APPLE__) -#define always_inline inline -#else -#define always_inline __attribute__ (( always_inline )) inline -#endif -#endif - -#ifdef __i386__ -#define REGPARM (n) __attribute((regparm(n))) -#else -#define REGPARM (n) -#endif -/* is_jmp field values */ #define DISAS_NEXT 0/* next instruction can be analyzed */ #define DISAS_JUMP 1/* only pc was modified dynamically */
Index: osdep.h
===================================================================
RCS file: /sources/qemu/qemu/osdep.h,v
retrieving revision 1.10
osdep.h +38 -0
@@ -3,6 +3,44 @@#include <stdarg.h> +#ifndef glue +#define xglue (x, y) x ## y +#define glue (x, y) xglue(x, y) +#define stringify (s) tostring(s) +#define tostring (s) #s +#endif + +#ifndef likely +#if __GNUC__ <3 +#define __builtin_expect (x, n) (x) +#endif + +#define likely (x) __builtin_expect(!!(x), 1) +#define unlikely (x) __builtin_expect(!!(x), 0) +#endif + +#ifndef MIN +#define MIN (a, b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef MAX +#define MAX (a, b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef always_inline +#if (__GNUC__ <3 ) || defined(__APPLE__) +#define always_inline inline +#else +#define always_inline __attribute__ (( always_inline )) __inline__ +#endif +#endif +#define inline always_inline + +#ifdef __i386__ +#define REGPARM (n) __attribute((regparm(n))) +#else +#define REGPARM (n) +#endif +#define qemu_printf printfvoid *qemu_malloc (size_t size);
Index: vl.h
===================================================================
RCS file: /sources/qemu/qemu/vl.h,v
retrieving revision 1.296
vl.h +0 -31
@@ -29,37 +29,6 @@/* FIXME: Remove this. */ #include "block.h" -#ifndef glue -#define xglue (x, y) x ## y -#define glue (x, y) xglue(x, y) -#define stringify (s) tostring(s) -#define tostring (s) #s -#endif - -#ifndef likely -#if __GNUC__ <3 -#define __builtin_expect (x, n) (x) -#endif - -#define likely (x) __builtin_expect(!!(x), 1) -#define unlikely (x) __builtin_expect(!!(x), 0) -#endif - -#ifndef MIN -#define MIN (a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX (a, b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef always_inline -#if (__GNUC__ <3 ) || defined(__APPLE__) -#define always_inline inline -#else -#define always_inline __attribute__ (( always_inline )) inline -#endif -#endif -#include "audio/audio.h" /* vl.c */
Index: darwin-user/qemu.h
===================================================================
RCS file: /sources/qemu/qemu/darwin-user/qemu.h,v
retrieving revision 1.1
qemu.h +2 -2
@@ -1,13 +1,13 @@#ifndef GEMU_H #define GEMU_H -#include "thunk.h" -#include <signal.h> #include <string.h> #include "cpu.h" +#include "thunk.h" +#include "gdbstub.h" typedef siginfo_t target_siginfo_t ;
Index: translate-op.c
===================================================================
RCS file: /sources/qemu/qemu/translate-op.c,v
retrieving revision 1.2
translate-op.c +1 -0
@@ -24,6 +24,7 @@#include <inttypes.h> #include "config.h" +#include "osdep.h" enum {#define DEF(s, n, copy_size) INDEX_op_ ## s,
Index: thunk.c
===================================================================
RCS file: /sources/qemu/qemu/thunk.c,v
retrieving revision 1.10
thunk.c +76 -1
86 lines not on this page · raw message
Index: thunk.h
===================================================================
RCS file: /sources/qemu/qemu/thunk.h,v
retrieving revision 1.15
thunk.h +2 -72
80 lines not on this page · raw message