common/backtrace: for mingw32 no pipe/wait_pid, just disable

This commit is contained in:
Alon Levy 2012-01-13 12:56:59 +02:00
parent a9bf749779
commit c7f4e52000
2 changed files with 23 additions and 4 deletions

View File

@ -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();
}
}

View File

@ -23,7 +23,7 @@
SPICE_BEGIN_DECLS
#ifdef WIN32
#if defined(WIN32) && !defined(__MINGW32__)
#define spice_backtrace()
#else
void spice_backtrace(void);