backtrace: Only define print_sourceline() and esc() if actually used

This commit is contained in:
Tobias Brunner
2022-10-03 17:36:17 +02:00
parent 3cc5a670b5
commit 27da024a5d
+10 -1
View File
@@ -97,6 +97,9 @@ static void println(FILE *file, char *format, ...)
va_end(args);
}
#if ((defined(HAVE_BACKTRACE) || defined(HAVE_LIBUNWIND_H)) && \
defined(HAVE_DLADDR)) || defined(WIN32)
/**
* Same as tty_escape_get(), but for a potentially NULL FILE*
*/
@@ -109,6 +112,8 @@ static inline char* esc(FILE *file, tty_escape_t escape)
return "";
}
#endif /* HAVE_BACKTRACE/HAVE_LIBUNWIND_H/WIN32 */
#ifdef HAVE_DBGHELP
#include <dbghelp.h>
@@ -408,6 +413,8 @@ static void print_sourceline(FILE *file, char *filename, void *ptr, void *base)
void backtrace_init() {}
void backtrace_deinit() {}
#if defined(HAVE_BACKTRACE) || defined(HAVE_LIBUNWIND_H) || defined(WIN32)
/**
* Print the source file with line number to file, slow addr2line variant
*/
@@ -444,6 +451,8 @@ static void print_sourceline(FILE *file, char *filename, void *ptr, void* base)
}
}
#endif /* HAVE_BACKTRACE/HAVE_LIBUNWIND_H/WIN32 */
#endif /* HAVE_BFD_H */
#else /* !HAVE_DLADDR && !HAVE_DBGHELP */
@@ -572,7 +581,7 @@ METHOD(backtrace_t, log_, void,
#endif /* HAVE_BFD_H */
}
else
#endif /* HAVE_DLADDR/HAVE_DBGHELP */
#endif /* HAVE_DLADDR/HAVE_DBGHELP/WIN32 */
{
#ifdef HAVE_BACKTRACE
if (!strings)