fix building on Cygwin

Cygwin still doesn't support any of the backtrace functions. Also, remove a
spurious newline from a debug message.

Fixes #2993
This commit is contained in:
Kurtis Rader 2016-05-19 19:27:22 -07:00
parent 46be5ac468
commit 7c24369454
5 changed files with 12 additions and 21 deletions

View file

@ -217,7 +217,6 @@ CXXFLAGS="$CXXFLAGS -Wall -Wno-sign-compare"
#
# This is needed in order to get the really cool backtraces on Linux
#
AC_MSG_CHECKING([for -rdynamic linker flag])
prev_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -rdynamic"
@ -268,7 +267,6 @@ AC_SEARCH_LIBS( shm_open, rt, , [AC_MSG_ERROR([Cannot find the rt library, neede
AC_SEARCH_LIBS( pthread_create, pthread, , [AC_MSG_ERROR([Cannot find the pthread library, needed to build this package.] )] )
AC_SEARCH_LIBS( setupterm, [ncurses tinfo curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish. If this is Linux, try running 'sudo apt-get install libncurses5-dev' or 'sudo yum install ncurses-devel'])] )
AC_SEARCH_LIBS( [nan], [m], [AC_DEFINE( [HAVE_NAN], [1], [Define to 1 if you have the nan function])] )
AC_SEARCH_LIBS( [backtrace_symbols_fd], [execinfo] )
AC_SEARCH_LIBS( [dladdr], [dl] )
if test x$local_gettext != xno; then
@ -313,7 +311,7 @@ AC_STRUCT_DIRENT_D_TYPE
AC_CHECK_FUNCS( wcsndup )
AC_CHECK_FUNCS( futimes )
AC_CHECK_FUNCS( wcslcat wcslcpy lrand48_r killpg )
AC_CHECK_FUNCS( backtrace backtrace_symbols_fd getifaddrs )
AC_CHECK_FUNCS( backtrace_symbols getifaddrs )
AC_CHECK_FUNCS( futimens clock_gettime )
AC_CHECK_DECL( [mkostemp], [ AC_CHECK_FUNCS([mkostemp]) ] )

View file

@ -70,7 +70,9 @@ static volatile bool termsize_valid;
static rwlock_t termsize_rwlock;
static char *wcs2str_internal(const wchar_t *in, char *out);
static void debug_shared(const wchar_t msg_level, const wcstring &msg);
#ifdef HAVE_BACKTRACE_SYMBOLS
// This function produces a stack backtrace with demangled function & method names. It is based on
// https://gist.github.com/fmela/591333 but adapted to the style of the fish project.
static const wcstring_list_t __attribute__((noinline))
@ -104,7 +106,6 @@ demangled_backtrace(int max_frames, int skip_levels) {
return backtrace_text;
}
static void debug_shared(const wchar_t msg_level, const wcstring &msg);
void __attribute__((noinline)) show_stackframe(const wchar_t msg_level, int frame_count,
int skip_levels) {
ASSERT_IS_NOT_FORKED_CHILD();
@ -124,6 +125,14 @@ void __attribute__((noinline)) show_stackframe(const wchar_t msg_level, int fram
}
}
#else // HAVE_BACKTRACE_SYMBOLS
void __attribute__((noinline)) show_stackframe(const wchar_t msg_level, int frame_count,
int skip_levels) {
debug_shared(msg_level, L"Sorry, but your system does not support backtraces");
}
#endif // HAVE_BACKTRACE_SYMBOLS
int fgetws2(wcstring *s, FILE *f) {
int i = 0;
wint_t c;

View file

@ -1058,7 +1058,7 @@ void exec_job(parser_t &parser, job_t *j) {
// A 0 pid means we failed to posix_spawn. Since we have no pid, we'll never get
// told when it's exited, so we have to mark the process as failed.
debug(2, L"Fork #%d, pid %d: spawn external command '%s' from '%ls'\n",
debug(2, L"Fork #%d, pid %d: spawn external command '%s' from '%ls'",
g_fork_count, pid, actual_cmd, file ? file : L"<no file>");
if (pid == 0) {
job_mark_process_as_failed(j, p);

View file

@ -332,14 +332,6 @@ int killpg(int pgr, int sig) {
}
#endif
#ifndef HAVE_BACKTRACE
int backtrace(void **buffer, int size) { return 0; }
#endif
#ifndef HAVE_BACKTRACE_SYMBOLS_FD
char **backtrace_symbols_fd(void *const *buffer, int size, int fd) { return 0; }
#endif
#ifndef HAVE_NAN
double nan(char *tagp) { return 0.0 / 0.0; }
#endif

View file

@ -149,12 +149,4 @@ int killpg(int pgr, int sig);
double nan(char *tagp);
#endif
#ifndef HAVE_BACKTRACE
int backtrace(void **buffer, int size);
#endif
#ifndef HAVE_BACKTRACE_SYMBOLS_FD
char **backtrace_symbols_fd(void *const *buffer, int size, int fd);
#endif
#endif