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:
parent
91c46d4399
commit
e7b451941b
|
@ -85,9 +85,6 @@
|
||||||
#include <sys/brt_impl.h>
|
#include <sys/brt_impl.h>
|
||||||
#include <zfs_comutil.h>
|
#include <zfs_comutil.h>
|
||||||
#include <sys/zstd/zstd.h>
|
#include <sys/zstd/zstd.h>
|
||||||
#if (__GLIBC__ && !__UCLIBC__)
|
|
||||||
#include <execinfo.h> /* for backtrace() */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <libnvpair.h>
|
#include <libnvpair.h>
|
||||||
#include <libzutil.h>
|
#include <libzutil.h>
|
||||||
|
@ -843,18 +840,11 @@ dump_debug_buffer(void)
|
||||||
zfs_dbgmsg_print("zdb");
|
zfs_dbgmsg_print("zdb");
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BACKTRACE_SZ 100
|
|
||||||
|
|
||||||
static void sig_handler(int signo)
|
static void sig_handler(int signo)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
#if (__GLIBC__ && !__UCLIBC__) /* backtrace() is a GNU extension */
|
|
||||||
int nptrs;
|
|
||||||
void *buffer[BACKTRACE_SZ];
|
|
||||||
|
|
||||||
nptrs = backtrace(buffer, BACKTRACE_SZ);
|
libspl_dump_backtrace();
|
||||||
backtrace_symbols_fd(buffer, nptrs, STDERR_FILENO);
|
|
||||||
#endif
|
|
||||||
dump_debug_buffer();
|
dump_debug_buffer();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
12
cmd/ztest.c
12
cmd/ztest.c
|
@ -136,9 +136,6 @@
|
||||||
#include <libzutil.h>
|
#include <libzutil.h>
|
||||||
#include <sys/crypto/icp.h>
|
#include <sys/crypto/icp.h>
|
||||||
#include <sys/zfs_impl.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_data = -1;
|
||||||
static int ztest_fd_rand = -1;
|
static int ztest_fd_rand = -1;
|
||||||
|
@ -621,18 +618,11 @@ dump_debug_buffer(void)
|
||||||
zfs_dbgmsg_print("ztest");
|
zfs_dbgmsg_print("ztest");
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BACKTRACE_SZ 100
|
|
||||||
|
|
||||||
static void sig_handler(int signo)
|
static void sig_handler(int signo)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
#if (__GLIBC__ && !__UCLIBC__) /* backtrace() is a GNU extension */
|
|
||||||
int nptrs;
|
|
||||||
void *buffer[BACKTRACE_SZ];
|
|
||||||
|
|
||||||
nptrs = backtrace(buffer, BACKTRACE_SZ);
|
libspl_dump_backtrace();
|
||||||
backtrace_symbols_fd(buffer, nptrs, STDERR_FILENO);
|
|
||||||
#endif
|
|
||||||
dump_debug_buffer();
|
dump_debug_buffer();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
#define UNW_LOCAL_ONLY
|
#define UNW_LOCAL_ONLY
|
||||||
#include <libunwind.h>
|
#include <libunwind.h>
|
||||||
|
|
||||||
static inline void
|
void
|
||||||
libspl_dump_backtrace(void)
|
libspl_dump_backtrace(void)
|
||||||
{
|
{
|
||||||
unw_context_t uc;
|
unw_context_t uc;
|
||||||
|
@ -85,7 +85,7 @@ libspl_dump_backtrace(void)
|
||||||
#elif defined(HAVE_BACKTRACE)
|
#elif defined(HAVE_BACKTRACE)
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
|
|
||||||
static inline void
|
void
|
||||||
libspl_dump_backtrace(void)
|
libspl_dump_backtrace(void)
|
||||||
{
|
{
|
||||||
void *btptrs[100];
|
void *btptrs[100];
|
||||||
|
@ -97,7 +97,10 @@ libspl_dump_backtrace(void)
|
||||||
free(bt);
|
free(bt);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define libspl_dump_backtrace()
|
void
|
||||||
|
libspl_dump_backtrace(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
|
|
@ -60,6 +60,8 @@ libspl_assert(const char *buf, const char *file, const char *func, int line)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern void libspl_dump_backtrace(void);
|
||||||
|
|
||||||
#ifdef verify
|
#ifdef verify
|
||||||
#undef verify
|
#undef verify
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue