Use libbfd as a fallback for backtrace symbol lookup on MinGW.

This will try to demangle.
If bfd_find_nearest_line returns a file name but nothing else
(debugging info is turned off), scan the symbol table for the previous
symbol and use it if it looks OKish.
This commit is contained in:
Jonathan G Rennison
2015-09-09 02:14:06 +01:00
parent 99d8d1afa6
commit 3a093c4b63
6 changed files with 196 additions and 84 deletions

View File

@@ -1571,22 +1571,6 @@ EOL
fi
rm tmp.config.libdl
"$cc_host" $CFLAGS $LDFLAGS -o tmp.config.demangle -x c++ - -lstdc++ 2> /dev/null << EOL
#include <cxxabi.h>
int main() {
int status = -1;
char *demangled = abi::__cxa_demangle("test", 0, 0, &status);
return 0;
}
EOL
if [ $? -ne 0 ]; then
log 1 "checking abi::__cxa_demangle... no"
else
log 1 "checking abi::__cxa_demangle... found"
CFLAGS="$CFLAGS -DWITH_DEMANGLE"
fi
rm tmp.config.demangle
"$cc_host" $CFLAGS $LDFLAGS -o tmp.config.bfd -x c++ - -lbfd 2> /dev/null << EOL
#define PACKAGE 1
#define PACKAGE_VERSION 1
@@ -1629,10 +1613,53 @@ EOL
else
log 1 "checking dbghelp... found"
CFLAGS="$CFLAGS -DWITH_DBGHELP"
"$cc_host" $CFLAGS $LDFLAGS -o tmp.config.bfd -x c++ - -lbfd -liberty -lintl 2> /dev/null << EOL
#define PACKAGE 1
#define PACKAGE_VERSION 1
#include <bfd.h>
int main() {
bfd_init();
unsigned int size;
asymbol *syms = 0;
long symcount = bfd_read_minisymbols((bfd *) 0, false, (void**) &syms, &size);
return 0;
}
EOL
if [ $? -ne 0 ]; then
log 1 "checking libbfd... no"
else
log 1 "checking libbfd... found"
LIBS="$LIBS -lbfd -liberty -lintl"
CFLAGS="$CFLAGS -DWITH_BFD"
if [ $enable_debug -lt 1 ]; then
CFLAGS="$CFLAGS -g1"
fi
fi
rm -f tmp.config.bfd
fi
rm -f tmp.config.dbghelp
fi
if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
"$cc_host" $CFLAGS $LDFLAGS -o tmp.config.demangle -x c++ - -lstdc++ 2> /dev/null << EOL
#include <cxxabi.h>
int main() {
int status = -1;
char *demangled = abi::__cxa_demangle("test", 0, 0, &status);
return 0;
}
EOL
if [ $? -ne 0 ]; then
log 1 "checking abi::__cxa_demangle... no"
else
log 1 "checking abi::__cxa_demangle... found"
CFLAGS="$CFLAGS -DWITH_DEMANGLE"
fi
rm tmp.config.demangle
fi
if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ]; then
LIBS="$LIBS -lc"
fi