diff options
-rw-r--r-- | cmd/zdb/zdb.c | 12 | ||||
-rw-r--r-- | cmd/ztest.c | 12 | ||||
-rw-r--r-- | lib/libspl/assert.c | 9 | ||||
-rw-r--r-- | lib/libspl/include/assert.h | 2 |
4 files changed, 10 insertions, 25 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index f3274a65d..908e4e0ab 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -85,9 +85,6 @@ #include <sys/brt_impl.h> #include <zfs_comutil.h> #include <sys/zstd/zstd.h> -#if (__GLIBC__ && !__UCLIBC__) -#include <execinfo.h> /* for backtrace() */ -#endif #include <libnvpair.h> #include <libzutil.h> @@ -843,18 +840,11 @@ dump_debug_buffer(void) zfs_dbgmsg_print("zdb"); } -#define BACKTRACE_SZ 100 - static void sig_handler(int signo) { struct sigaction action; -#if (__GLIBC__ && !__UCLIBC__) /* backtrace() is a GNU extension */ - int nptrs; - void *buffer[BACKTRACE_SZ]; - nptrs = backtrace(buffer, BACKTRACE_SZ); - backtrace_symbols_fd(buffer, nptrs, STDERR_FILENO); -#endif + libspl_dump_backtrace(); dump_debug_buffer(); /* diff --git a/cmd/ztest.c b/cmd/ztest.c index 56eb01618..ccfe71c29 100644 --- a/cmd/ztest.c +++ b/cmd/ztest.c @@ -136,9 +136,6 @@ #include <libzutil.h> #include <sys/crypto/icp.h> #include <sys/zfs_impl.h> -#if (__GLIBC__ && !__UCLIBC__) -#include <execinfo.h> /* for backtrace() */ -#endif static int ztest_fd_data = -1; static int ztest_fd_rand = -1; @@ -621,18 +618,11 @@ dump_debug_buffer(void) zfs_dbgmsg_print("ztest"); } -#define BACKTRACE_SZ 100 - static void sig_handler(int signo) { struct sigaction action; -#if (__GLIBC__ && !__UCLIBC__) /* backtrace() is a GNU extension */ - int nptrs; - void *buffer[BACKTRACE_SZ]; - nptrs = backtrace(buffer, BACKTRACE_SZ); - backtrace_symbols_fd(buffer, nptrs, STDERR_FILENO); -#endif + libspl_dump_backtrace(); dump_debug_buffer(); /* diff --git a/lib/libspl/assert.c b/lib/libspl/assert.c index 5b12c14ac..79b640d89 100644 --- a/lib/libspl/assert.c +++ b/lib/libspl/assert.c @@ -55,7 +55,7 @@ #define UNW_LOCAL_ONLY #include <libunwind.h> -static inline void +void libspl_dump_backtrace(void) { unw_context_t uc; @@ -85,7 +85,7 @@ libspl_dump_backtrace(void) #elif defined(HAVE_BACKTRACE) #include <execinfo.h> -static inline void +void libspl_dump_backtrace(void) { void *btptrs[100]; @@ -97,7 +97,10 @@ libspl_dump_backtrace(void) free(bt); } #else -#define libspl_dump_backtrace() +void +libspl_dump_backtrace(void) +{ +} #endif #if defined(__APPLE__) diff --git a/lib/libspl/include/assert.h b/lib/libspl/include/assert.h index 155bbab30..126f2db24 100644 --- a/lib/libspl/include/assert.h +++ b/lib/libspl/include/assert.h @@ -60,6 +60,8 @@ libspl_assert(const char *buf, const char *file, const char *func, int line) return (0); } +extern void libspl_dump_backtrace(void); + #ifdef verify #undef verify #endif |