[Spice-devel] [PATCH 09/11] common/backtrace: for mingw32 no pipe/wait_pid, just disable

Alon Levy alevy at redhat.com
Fri Jan 13 03:35:52 PST 2012


---
 common/backtrace.c |   25 ++++++++++++++++++++++---
 common/backtrace.h |    2 +-
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/common/backtrace.c b/common/backtrace.c
index 650dc1d..6fabdf0 100644
--- a/common/backtrace.c
+++ b/common/backtrace.c
@@ -26,8 +26,12 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
+#include <unistd.h>
 #include <sys/types.h>
+#ifndef __MINGW32__
 #include <sys/wait.h>
+#endif
+
 #include "spice_common.h"
 
 #define GSTACK_PATH "/usr/bin/gstack"
@@ -49,6 +53,10 @@ static void spice_backtrace_backtrace(void)
 }
 #endif
 
+/* XXX perhaps gstack can be available in windows but pipe/waitpid isn't,
+ * so until it is ported properly just compile it out, we lose the
+ * backtrace only. */
+#ifndef __MINGW32__
 static int spice_backtrace_gstack(void)
 {
     pid_t kidpid;
@@ -104,11 +112,22 @@ static int spice_backtrace_gstack(void)
     }
     return 0;
 }
+#else
+static int spice_backtrace_gstack(void)
+{
+    /* empty failing implementation */
+    return -1;
+}
+#endif
+
+void spice_backtrace(void)
+{
+    int ret = -1;
 
-void spice_backtrace() {
     if (!access(GSTACK_PATH, X_OK)) {
-        spice_backtrace_gstack();
-    } else {
+        ret = spice_backtrace_gstack();
+    }
+    if (ret != 0) {
         spice_backtrace_backtrace();
     }
 }
diff --git a/common/backtrace.h b/common/backtrace.h
index 8fcbb78..894c027 100644
--- a/common/backtrace.h
+++ b/common/backtrace.h
@@ -23,7 +23,7 @@
 
 SPICE_BEGIN_DECLS
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(__MINGW32__)
 #define spice_backtrace()
 #else
 void spice_backtrace(void);
-- 
1.7.8.2



More information about the Spice-devel mailing list