zdb/ztest: use libspl backtrace for crashes

We can show much nicer backtraces these days, lets use them.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16181
This commit is contained in:
Rob Norris 2024-05-10 10:19:48 +10:00 committed by Brian Behlendorf
parent 91c46d4399
commit e7b451941b
4 changed files with 10 additions and 25 deletions

View File

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

View File

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

View File

@ -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__)

View File

@ -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