From a5fd7448ae1542bda55e593e120dd6b3f7920dd4 Mon Sep 17 00:00:00 2001 From: Florian Obser Date: Tue, 7 Jan 2020 19:11:19 +0000 Subject: Remove backtrace support. Minus 800 lines. OK millert --- usr.sbin/bind/Makefile.bsd-wrapper | 3 +- usr.sbin/bind/bin/dig/Makefile.in | 3 +- usr.sbin/bind/configure | 96 -------- usr.sbin/bind/configure.in | 66 ------ usr.sbin/bind/lib/isc/Makefile.in | 27 +-- usr.sbin/bind/lib/isc/assertions.c | 40 +--- usr.sbin/bind/lib/isc/backtrace-emptytbl.c | 35 --- usr.sbin/bind/lib/isc/backtrace.c | 296 ------------------------ usr.sbin/bind/lib/isc/include/isc/Makefile.in | 2 +- usr.sbin/bind/lib/isc/include/isc/backtrace.h | 132 ----------- usr.sbin/bind/lib/isc/include/isc/platform.h.in | 5 - usr.sbin/bind/lib/isc/include/isc/types.h | 3 +- usr.sbin/bind/make/rules.in | 52 +---- usr.sbin/bind/util/mksymtbl.pl | 127 ---------- 14 files changed, 17 insertions(+), 870 deletions(-) delete mode 100644 usr.sbin/bind/lib/isc/backtrace-emptytbl.c delete mode 100644 usr.sbin/bind/lib/isc/backtrace.c delete mode 100644 usr.sbin/bind/lib/isc/include/isc/backtrace.h delete mode 100644 usr.sbin/bind/util/mksymtbl.pl (limited to 'usr.sbin') diff --git a/usr.sbin/bind/Makefile.bsd-wrapper b/usr.sbin/bind/Makefile.bsd-wrapper index 0775f46ce6b..58db7fd1e05 100644 --- a/usr.sbin/bind/Makefile.bsd-wrapper +++ b/usr.sbin/bind/Makefile.bsd-wrapper @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.bsd-wrapper,v 1.22 2020/01/07 19:08:09 florian Exp $ +# $OpenBSD: Makefile.bsd-wrapper,v 1.23 2020/01/07 19:11:17 florian Exp $ .include @@ -6,7 +6,6 @@ XCFLAGS= CC="${CC}" CFLAGS="${CFLAGS} ${COPTS}" LDFLAGS="${LDFLAGS}" CONFIGURE_OPTS= --prefix=/usr \ --localstatedir=/var \ --sysconfdir=/etc \ - --disable-backtrace \ --disable-isc-spnego \ --without-readline \ --with-python=no \ diff --git a/usr.sbin/bind/bin/dig/Makefile.in b/usr.sbin/bind/bin/dig/Makefile.in index 17ee0389d4b..7c25a935d8d 100644 --- a/usr.sbin/bind/bin/dig/Makefile.in +++ b/usr.sbin/bind/bin/dig/Makefile.in @@ -12,7 +12,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# $Id: Makefile.in,v 1.10 2020/01/06 17:46:59 florian Exp $ +# $Id: Makefile.in,v 1.11 2020/01/07 19:11:17 florian Exp $ srcdir = @srcdir@ VPATH = @srcdir@ @@ -34,7 +34,6 @@ CWARNINGS = ISCCFGLIBS = ../../lib/isccfg/libisccfg.@A@ DNSLIBS = ../../lib/dns/libdns.@A@ @DNS_CRYPTO_LIBS@ ISCLIBS = ../../lib/isc/libisc.@A@ -ISCNOSYMLIBS = ../../lib/isc/libisc-nosymtbl.@A@ LWRESLIBS = ../../lib/lwres/liblwres.@A@ ISCCFGDEPLIBS = ../../lib/isccfg/libisccfg.@A@ diff --git a/usr.sbin/bind/configure b/usr.sbin/bind/configure index 47d0fcf9129..8dbef4996be 100644 --- a/usr.sbin/bind/configure +++ b/usr.sbin/bind/configure @@ -781,9 +781,6 @@ LIBTOOL_MKDEP_SED SA A O -ALWAYS_MAKE_SYMTABLE -MKSYMTBL_PROGRAM -ISC_PLATFORM_USEBACKTRACE PURIFY purify_path IRIX_DNSSEC_WARNINGS_HACK @@ -994,8 +991,6 @@ with_libjson enable_largefile with_purify with_gperftools_profiler -enable_backtrace -enable_symtable enable_ipv6 with_kame enable_getifaddrs @@ -1665,9 +1660,6 @@ Optional Features: --enable-openssl-hash use OpenSSL for hash functions [default=no] --enable-sit enable source identity token [default=no] --enable-largefile 64-bit file support - --enable-backtrace log stack backtrace on abort [default=yes] - --enable-symtable use internal symbol table for backtrace - [all|minimal(default)|none] --enable-ipv6 use IPv6 [default=autodetect] --enable-getifaddrs enable the use of getifaddrs() [yes|no]. --disable-isc-spnego use SPNEGO from GSSAPI library @@ -11412,7 +11404,6 @@ yes) test "${with_atf+set}" = set || with_atf=yes test "${enable_filter_aaaa+set}" = set || enable_filter_aaaa=yes test "${with_dlz_filesystem+set}" = set || with_dlz_filesystem=yes - test "${enable_symtable+set}" = set || enable_symtable=all test "${enable_sit+set}" = set || enable_sit=yes test "${enable_fetchlimit+set}" = set || enable_fetchlimit=yes test "${enable_warn_error+set}" = set || enable_warn_error=yes @@ -16368,89 +16359,6 @@ $as_echo "no" >&6; } ;; esac -# -# enable/disable dumping stack backtrace. Also check if the system supports -# glibc-compatible backtrace() function. -# -# Check whether --enable-backtrace was given. -if test "${enable_backtrace+set}" = set; then : - enableval=$enable_backtrace; want_backtrace="$enableval" -else - want_backtrace="yes" -fi - -case $want_backtrace in -yes) - ISC_PLATFORM_USEBACKTRACE="#define ISC_PLATFORM_USEBACKTRACE 1" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -return (backtrace((void **)0, 0)); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - -$as_echo "#define HAVE_LIBCTRACE /**/" >>confdefs.h - -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - ;; -*) - ISC_PLATFORM_USEBACKTRACE="#undef ISC_PLATFORM_USEBACKTRACE" - ;; -esac - - -# Check whether --enable-symtable was given. -if test "${enable_symtable+set}" = set; then : - enableval=$enable_symtable; want_symtable="$enableval" -else - want_symtable="minimal" -fi - -case $want_symtable in -yes|all|minimal) # "yes" is a hidden value equivalent to "minimal" - if test "" = "$PERL" - then - as_fn_error $? "Internal symbol table requires perl but no perl is found. -Install perl or explicitly disable the feature by --disable-symtable." "$LINENO" 5 - fi - if test "yes" = "$use_libtool"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Internal symbol table does not work with libtool. Disabling symbol table." >&5 -$as_echo "$as_me: WARNING: Internal symbol table does not work with libtool. Disabling symbol table." >&2;} - else - # we generate the internal symbol table only for those systems - # known to work to avoid unexpected build failure. Also, warn - # about unsupported systems when the feature is enabled - # manually. - case $host_os in - freebsd*|netbsd*|openbsd*|linux*|solaris*|darwin*) - MKSYMTBL_PROGRAM="$PERL" - if test "all" = "$want_symtable"; then - ALWAYS_MAKE_SYMTABLE="yes" - fi - ;; - *) - if test "yes" = "$want_symtable" -o "all" = "$want_symtable" - then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: this system is not known to generate internal symbol table safely; disabling it" >&5 -$as_echo "$as_me: WARNING: this system is not known to generate internal symbol table safely; disabling it" >&2;} - fi - esac - fi - ;; -*) - ;; -esac - - - # # File name extension for static archive files, for those few places # where they are treated differently from dynamic ones. @@ -22863,10 +22771,6 @@ report() { echo " Use libseccomp system call filtering (--enable-seccomp)" test "yes" = "$want_backtrace" && \ echo " Print backtrace on crash (--enable-backtrace)" - test "minimal" = "$want_symtable" && \ - echo " Use symbol table for backtrace, named only (--enable-symtable)" - test "yes" = "$want_symtable" -o "all" = "$want_symtable" && \ - echo " Use symbol table for backtrace, all binaries (--enable-symtable=all)" test "no" = "$use_libtool" || echo " Use GNU libtool (--with-libtool)" test "yes" = "$want_querytrace" && \ echo " Very verbose query trace logging (--enable-querytrace)" diff --git a/usr.sbin/bind/configure.in b/usr.sbin/bind/configure.in index 3da6b8b82e0..26dee767d6b 100644 --- a/usr.sbin/bind/configure.in +++ b/usr.sbin/bind/configure.in @@ -96,7 +96,6 @@ yes) test "${with_atf+set}" = set || with_atf=yes test "${enable_filter_aaaa+set}" = set || enable_filter_aaaa=yes test "${with_dlz_filesystem+set}" = set || with_dlz_filesystem=yes - test "${enable_symtable+set}" = set || enable_symtable=all test "${enable_sit+set}" = set || enable_sit=yes test "${enable_fetchlimit+set}" = set || enable_fetchlimit=yes test "${enable_warn_error+set}" = set || enable_warn_error=yes @@ -2489,67 +2488,6 @@ case $use_profiler in ;; esac -# -# enable/disable dumping stack backtrace. Also check if the system supports -# glibc-compatible backtrace() function. -# -AC_ARG_ENABLE(backtrace, - AS_HELP_STRING([--enable-backtrace], - [log stack backtrace on abort [default=yes]]), - want_backtrace="$enableval", want_backtrace="yes") -case $want_backtrace in -yes) - ISC_PLATFORM_USEBACKTRACE="#define ISC_PLATFORM_USEBACKTRACE 1" - AC_TRY_LINK([#include ], - [return (backtrace((void **)0, 0));], - [AC_DEFINE([HAVE_LIBCTRACE], [], [if system have backtrace function])],) - ;; -*) - ISC_PLATFORM_USEBACKTRACE="#undef ISC_PLATFORM_USEBACKTRACE" - ;; -esac -AC_SUBST(ISC_PLATFORM_USEBACKTRACE) - -AC_ARG_ENABLE(symtable, - AS_HELP_STRING([--enable-symtable], - [use internal symbol table for backtrace - [all|minimal(default)|none]]), - want_symtable="$enableval", want_symtable="minimal") -case $want_symtable in -yes|all|minimal) # "yes" is a hidden value equivalent to "minimal" - if test "" = "$PERL" - then - AC_MSG_ERROR([Internal symbol table requires perl but no perl is found. -Install perl or explicitly disable the feature by --disable-symtable.]) - fi - if test "yes" = "$use_libtool"; then - AC_MSG_WARN([Internal symbol table does not work with libtool. Disabling symbol table.]) - else - # we generate the internal symbol table only for those systems - # known to work to avoid unexpected build failure. Also, warn - # about unsupported systems when the feature is enabled - # manually. - case $host_os in - freebsd*|netbsd*|openbsd*|linux*|solaris*|darwin*) - MKSYMTBL_PROGRAM="$PERL" - if test "all" = "$want_symtable"; then - ALWAYS_MAKE_SYMTABLE="yes" - fi - ;; - *) - if test "yes" = "$want_symtable" -o "all" = "$want_symtable" - then - AC_MSG_WARN([this system is not known to generate internal symbol table safely; disabling it]) - fi - esac - fi - ;; -*) - ;; -esac -AC_SUBST(MKSYMTBL_PROGRAM) -AC_SUBST(ALWAYS_MAKE_SYMTABLE) - # # File name extension for static archive files, for those few places # where they are treated differently from dynamic ones. @@ -4751,10 +4689,6 @@ report() { echo " Use libseccomp system call filtering (--enable-seccomp)" test "yes" = "$want_backtrace" && \ echo " Print backtrace on crash (--enable-backtrace)" - test "minimal" = "$want_symtable" && \ - echo " Use symbol table for backtrace, named only (--enable-symtable)" - test "yes" = "$want_symtable" -o "all" = "$want_symtable" && \ - echo " Use symbol table for backtrace, all binaries (--enable-symtable=all)" test "no" = "$use_libtool" || echo " Use GNU libtool (--with-libtool)" test "yes" = "$want_querytrace" && \ echo " Very verbose query trace logging (--enable-querytrace)" diff --git a/usr.sbin/bind/lib/isc/Makefile.in b/usr.sbin/bind/lib/isc/Makefile.in index 4ac3e23202d..b941b14e801 100644 --- a/usr.sbin/bind/lib/isc/Makefile.in +++ b/usr.sbin/bind/lib/isc/Makefile.in @@ -48,7 +48,7 @@ THREADOBJS = nothreads/thread.@O@ # Alphabetically OBJS = @ISC_EXTRA_OBJS@ @ISC_PK11_O@ @ISC_PK11_RESULT_O@ \ - aes.@O@ assertions.@O@ backtrace.@O@ base32.@O@ base64.@O@ \ + aes.@O@ assertions.@O@ base32.@O@ base64.@O@ \ bind9.@O@ buffer.@O@ bufferlist.@O@ \ commandline.@O@ counter.@O@ crc64.@O@ error.@O@ event.@O@ \ hash.@O@ heap.@O@ hex.@O@ hmacmd5.@O@ hmacsha.@O@ \ @@ -63,11 +63,10 @@ OBJS = @ISC_EXTRA_OBJS@ @ISC_PK11_O@ @ISC_PK11_RESULT_O@ \ string.@O@ strtoul.@O@ symtab.@O@ task.@O@ taskpool.@O@ \ tm.@O@ timer.@O@ version.@O@ \ ${UNIXOBJS} ${NLSOBJS} ${THREADOBJS} -SYMTBLOBJS = backtrace-emptytbl.@O@ # Alphabetically SRCS = @ISC_EXTRA_SRCS@ @ISC_PK11_C@ @ISC_PK11_RESULT_C@ \ - aes.c assertions.c backtrace.c base32.c base64.c bind9.c \ + aes.c assertions.c base32.c base64.c bind9.c \ buffer.c bufferlist.c commandline.c counter.c crc64.c \ error.c event.c heap.c hex.c hmacmd5.c hmacsha.c \ httpd.c inet_aton.c iterated_hash.c \ @@ -104,30 +103,20 @@ version.@O@: version.c -DLIBAGE=${LIBAGE} \ -c ${srcdir}/version.c -libisc.@SA@: ${OBJS} ${SYMTBLOBJS} - ${AR} ${ARFLAGS} $@ ${OBJS} ${SYMTBLOBJS} - ${RANLIB} $@ - -libisc-nosymtbl.@SA@: ${OBJS} +libisc.@SA@: ${OBJS} ${AR} ${ARFLAGS} $@ ${OBJS} ${RANLIB} $@ -libisc.la: ${OBJS} ${SYMTBLOBJS} +libisc.la: ${OBJS} ${LIBTOOL_MODE_LINK} \ ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libisc.la -rpath ${libdir} \ -version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \ - ${OBJS} ${SYMTBLOBJS} ${LIBS} - -libisc-nosymtbl.la: ${OBJS} - ${LIBTOOL_MODE_LINK} \ - ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libisc-nosymtbl.la -rpath ${libdir} \ - -version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \ ${OBJS} ${LIBS} -timestamp: libisc.@A@ libisc-nosymtbl.@A@ +timestamp: libisc.@A@ touch timestamp -testdirs: libisc.@A@ libisc-nosymtbl.@A@ +testdirs: libisc.@A@ installdirs: $(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${libdir} @@ -139,5 +128,5 @@ uninstall:: ${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${libdir}/libisc.@A@ clean distclean:: - rm -f libisc.@A@ libisc-nosymtbl.@A@ libisc.la \ - libisc-nosymtbl.la timestamp + rm -f libisc.@A@ libisc.la \ + timestamp diff --git a/usr.sbin/bind/lib/isc/assertions.c b/usr.sbin/bind/lib/isc/assertions.c index d7a8db140cc..1ef05e2ef4d 100644 --- a/usr.sbin/bind/lib/isc/assertions.c +++ b/usr.sbin/bind/lib/isc/assertions.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: assertions.c,v 1.3 2019/12/17 01:46:34 sthen Exp $ */ +/* $Id: assertions.c,v 1.4 2020/01/07 19:11:17 florian Exp $ */ /*! \file */ @@ -24,18 +24,10 @@ #include #include -#include #include #include #include -/* - * The maximum number of stack frames to dump on assertion failure. - */ -#ifndef BACKTRACE_MAXFRAME -#define BACKTRACE_MAXFRAME 128 -#endif - /*% * Forward. */ @@ -105,35 +97,9 @@ static void default_callback(const char *file, int line, isc_assertiontype_t type, const char *cond) { - void *tracebuf[BACKTRACE_MAXFRAME]; - int i, nframes; - const char *logsuffix = "."; - const char *fname; - isc_result_t result; - - result = isc_backtrace_gettrace(tracebuf, BACKTRACE_MAXFRAME, &nframes); - if (result == ISC_R_SUCCESS && nframes > 0) - logsuffix = ", back trace"; - - fprintf(stderr, "%s:%d: %s(%s) %s%s\n", + fprintf(stderr, "%s:%d: %s(%s) %s\n", file, line, isc_assertion_typetotext(type), cond, isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), logsuffix); - if (result == ISC_R_SUCCESS) { - for (i = 0; i < nframes; i++) { - unsigned long offset; - - fname = NULL; - result = isc_backtrace_getsymbol(tracebuf[i], &fname, - &offset); - if (result == ISC_R_SUCCESS) { - fprintf(stderr, "#%d %p in %s()+0x%lx\n", i, - tracebuf[i], fname, offset); - } else { - fprintf(stderr, "#%d %p in ??\n", i, - tracebuf[i]); - } - } - } + ISC_MSG_FAILED, "failed")); fflush(stderr); } diff --git a/usr.sbin/bind/lib/isc/backtrace-emptytbl.c b/usr.sbin/bind/lib/isc/backtrace-emptytbl.c deleted file mode 100644 index 827ef3b253a..00000000000 --- a/usr.sbin/bind/lib/isc/backtrace-emptytbl.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: backtrace-emptytbl.c,v 1.2 2019/12/17 01:46:34 sthen Exp $ */ - -/*! \file */ - -/* - * This file defines an empty (default) symbol table used in backtrace.c - * If the application wants to have a complete symbol table, it should redefine - * isc__backtrace_symtable with the complete table in some way, and link the - * version of the library not including this definition - * (e.g. libisc-nosymbol.a). - */ - -#include - -#include - -LIBISC_EXTERNAL_DATA const int isc__backtrace_nsymbols = 0; -LIBISC_EXTERNAL_DATA const - isc_backtrace_symmap_t isc__backtrace_symtable[] = { { NULL, "" } }; diff --git a/usr.sbin/bind/lib/isc/backtrace.c b/usr.sbin/bind/lib/isc/backtrace.c deleted file mode 100644 index 2116e4f6d03..00000000000 --- a/usr.sbin/bind/lib/isc/backtrace.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: backtrace.c,v 1.2 2019/12/17 01:46:34 sthen Exp $ */ - -/*! \file */ - -#include "config.h" - -#include -#include -#ifdef HAVE_LIBCTRACE -#include -#endif - -#include -#include -#include - -#ifdef ISC_PLATFORM_USEBACKTRACE -/* - * Getting a back trace of a running process is tricky and highly platform - * dependent. Our current approach is as follows: - * 1. If the system library supports the "backtrace()" function, use it. - * 2. Otherwise, if the compiler is gcc and the architecture is x86_64 or IA64, - * then use gcc's (hidden) Unwind_Backtrace() function. Note that this - * function doesn't work for C programs on many other architectures. - * 3. Otherwise, if the architecture x86 or x86_64, try to unwind the stack - * frame following frame pointers. This assumes the executable binary - * compiled with frame pointers; this is not always true for x86_64 (rather, - * compiler optimizations often disable frame pointers). The validation - * checks in getnextframeptr() hopefully rejects bogus values stored in - * the RBP register in such a case. If the backtrace function itself crashes - * due to this problem, the whole package should be rebuilt with - * --disable-backtrace. - */ -#ifdef HAVE_LIBCTRACE -#define BACKTRACE_LIBC -#elif defined(__GNUC__) && (defined(__x86_64__) || defined(__ia64__)) -#define BACKTRACE_GCC -#elif defined(WIN32) -#define BACKTRACE_WIN32 -#elif defined(__x86_64__) || defined(__i386__) -#define BACKTRACE_X86STACK -#else -#define BACKTRACE_DISABLED -#endif /* HAVE_LIBCTRACE */ -#else /* !ISC_PLATFORM_USEBACKTRACE */ -#define BACKTRACE_DISABLED -#endif /* ISC_PLATFORM_USEBACKTRACE */ - -#ifdef BACKTRACE_LIBC -isc_result_t -isc_backtrace_gettrace(void **addrs, int maxaddrs, int *nframes) { - int n; - - /* - * Validate the arguments: intentionally avoid using REQUIRE(). - * See notes in backtrace.h. - */ - if (addrs == NULL || nframes == NULL) - return (ISC_R_FAILURE); - - /* - * backtrace(3) includes this function itself in the address array, - * which should be eliminated from the returned sequence. - */ - n = backtrace(addrs, maxaddrs); - if (n < 2) - return (ISC_R_NOTFOUND); - n--; - memmove(addrs, &addrs[1], sizeof(void *) * n); - *nframes = n; - return (ISC_R_SUCCESS); -} -#elif defined(BACKTRACE_GCC) -extern int _Unwind_Backtrace(void* fn, void* a); -extern void* _Unwind_GetIP(void* ctx); - -typedef struct { - void **result; - int max_depth; - int skip_count; - int count; -} trace_arg_t; - -static int -btcallback(void *uc, void *opq) { - trace_arg_t *arg = (trace_arg_t *)opq; - - if (arg->skip_count > 0) - arg->skip_count--; - else - arg->result[arg->count++] = (void *)_Unwind_GetIP(uc); - if (arg->count == arg->max_depth) - return (5); /* _URC_END_OF_STACK */ - - return (0); /* _URC_NO_REASON */ -} - -isc_result_t -isc_backtrace_gettrace(void **addrs, int maxaddrs, int *nframes) { - trace_arg_t arg; - - /* Argument validation: see above. */ - if (addrs == NULL || nframes == NULL) - return (ISC_R_FAILURE); - - arg.skip_count = 1; - arg.result = addrs; - arg.max_depth = maxaddrs; - arg.count = 0; - _Unwind_Backtrace(btcallback, &arg); - - *nframes = arg.count; - - return (ISC_R_SUCCESS); -} -#elif defined(BACKTRACE_WIN32) -isc_result_t -isc_backtrace_gettrace(void **addrs, int maxaddrs, int *nframes) { - unsigned long ftc = (unsigned long)maxaddrs; - - *nframes = (int)CaptureStackBackTrace(1, ftc, addrs, NULL); - return ISC_R_SUCCESS; -} -#elif defined(BACKTRACE_X86STACK) -#ifdef __x86_64__ -static unsigned long -getrbp(void) { - __asm("movq %rbp, %rax\n"); -} -#endif - -static void ** -getnextframeptr(void **sp) { - void **newsp = (void **)*sp; - - /* - * Perform sanity check for the new frame pointer, derived from - * google glog. This can actually be bogus depending on compiler. - */ - - /* prohibit the stack frames from growing downwards */ - if (newsp <= sp) - return (NULL); - - /* A heuristics to reject "too large" frame: this actually happened. */ - if ((char *)newsp - (char *)sp > 100000) - return (NULL); - - /* - * Not sure if other checks used in glog are needed at this moment. - * For our purposes we don't have to consider non-contiguous frames, - * for example. - */ - - return (newsp); -} - -isc_result_t -isc_backtrace_gettrace(void **addrs, int maxaddrs, int *nframes) { - int i = 0; - void **sp; - - /* Argument validation: see above. */ - if (addrs == NULL || nframes == NULL) - return (ISC_R_FAILURE); - -#ifdef __x86_64__ - sp = (void **)getrbp(); - if (sp == NULL) - return (ISC_R_NOTFOUND); - /* - * sp is the frame ptr of this function itself due to the call to - * getrbp(), so need to unwind one frame for consistency. - */ - sp = getnextframeptr(sp); -#else - /* - * i386: the frame pointer is stored 2 words below the address for the - * first argument. Note that the body of this function cannot be - * inlined since it depends on the address of the function argument. - */ - sp = (void **)&addrs - 2; -#endif - - while (sp != NULL && i < maxaddrs) { - addrs[i++] = *(sp + 1); - sp = getnextframeptr(sp); - } - - *nframes = i; - - return (ISC_R_SUCCESS); -} -#elif defined(BACKTRACE_DISABLED) -isc_result_t -isc_backtrace_gettrace(void **addrs, int maxaddrs, int *nframes) { - /* Argument validation: see above. */ - if (addrs == NULL || nframes == NULL) - return (ISC_R_FAILURE); - - UNUSED(maxaddrs); - - return (ISC_R_NOTIMPLEMENTED); -} -#endif - -isc_result_t -isc_backtrace_getsymbolfromindex(int idx, const void **addrp, - const char **symbolp) -{ - REQUIRE(addrp != NULL && *addrp == NULL); - REQUIRE(symbolp != NULL && *symbolp == NULL); - - if (idx < 0 || idx >= isc__backtrace_nsymbols) - return (ISC_R_RANGE); - - *addrp = isc__backtrace_symtable[idx].addr; - *symbolp = isc__backtrace_symtable[idx].symbol; - return (ISC_R_SUCCESS); -} - -static int -symtbl_compare(const void *addr, const void *entryarg) { - const isc_backtrace_symmap_t *entry = entryarg; - const isc_backtrace_symmap_t *end = - &isc__backtrace_symtable[isc__backtrace_nsymbols - 1]; - - if (isc__backtrace_nsymbols == 1 || entry == end) { - if (addr >= entry->addr) { - /* - * If addr is equal to or larger than that of the last - * entry of the table, we cannot be sure if this is - * within a valid range so we consider it valid. - */ - return (0); - } - return (-1); - } - - /* entry + 1 is a valid entry from now on. */ - if (addr < entry->addr) - return (-1); - else if (addr >= (entry + 1)->addr) - return (1); - return (0); -} - -isc_result_t -isc_backtrace_getsymbol(const void *addr, const char **symbolp, - unsigned long *offsetp) -{ - isc_result_t result = ISC_R_SUCCESS; - isc_backtrace_symmap_t *found; - - /* - * Validate the arguments: intentionally avoid using REQUIRE(). - * See notes in backtrace.h. - */ - if (symbolp == NULL || *symbolp != NULL || offsetp == NULL) - return (ISC_R_FAILURE); - - if (isc__backtrace_nsymbols < 1) - return (ISC_R_NOTFOUND); - - /* - * Search the table for the entry that meets: - * entry.addr <= addr < next_entry.addr. - */ - found = bsearch(addr, isc__backtrace_symtable, isc__backtrace_nsymbols, - sizeof(isc__backtrace_symtable[0]), symtbl_compare); - if (found == NULL) - result = ISC_R_NOTFOUND; - else { - *symbolp = found->symbol; - *offsetp = (unsigned long) ((const char *)addr - - (char *)found->addr); - } - - return (result); -} diff --git a/usr.sbin/bind/lib/isc/include/isc/Makefile.in b/usr.sbin/bind/lib/isc/include/isc/Makefile.in index 80f0e078a82..5d69055e660 100644 --- a/usr.sbin/bind/lib/isc/include/isc/Makefile.in +++ b/usr.sbin/bind/lib/isc/include/isc/Makefile.in @@ -23,7 +23,7 @@ VERSION=@BIND9_VERSION@ # machine generated. The latter are handled specially in the # install target below. # -HEADERS = aes.h app.h assertions.h backtrace.h base32.h base64.h \ +HEADERS = aes.h app.h assertions.h base32.h base64.h \ bind9.h boolean.h buffer.h bufferlist.h \ commandline.h counter.h crc64.h entropy.h errno.h error.h \ event.h eventclass.h file.h formatcheck.h fsaccess.h \ diff --git a/usr.sbin/bind/lib/isc/include/isc/backtrace.h b/usr.sbin/bind/lib/isc/include/isc/backtrace.h deleted file mode 100644 index 00c71f8fc73..00000000000 --- a/usr.sbin/bind/lib/isc/include/isc/backtrace.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: backtrace.h,v 1.2 2019/12/17 01:46:35 sthen Exp $ */ - -/*! \file isc/backtrace.h - * \brief provide a back trace of the running process to help debug problems. - * - * This module tries to get a back trace of the process using some platform - * dependent way when available. It also manages an internal symbol table - * that maps function addresses used in the process to their textual symbols. - * This module is expected to be used to help debug when some fatal error - * happens. - * - * IMPORTANT NOTE: since the (major) intended use case of this module is - * dumping a back trace on a fatal error, normally followed by self termination, - * functions defined in this module generally doesn't employ assertion checks - * (if it did, a program bug could cause infinite recursive calls to a - * backtrace function). These functions still perform minimal checks and return - * ISC_R_FAILURE if they detect an error, but the caller should therefore be - * very careful about the use of these functions, and generally discouraged to - * use them except in an exit path. The exception is - * isc_backtrace_getsymbolfromindex(), which is expected to be used in a - * non-error-handling context and validates arguments with assertion checks. - */ - -#ifndef ISC_BACKTRACE_H -#define ISC_BACKTRACE_H 1 - -/*** - *** Imports - ***/ - -#include - -/*** - *** Types - ***/ -struct isc_backtrace_symmap { - void *addr; - const char *symbol; -}; - -LIBISC_EXTERNAL_DATA extern const int isc__backtrace_nsymbols; -LIBISC_EXTERNAL_DATA extern const - isc_backtrace_symmap_t isc__backtrace_symtable[]; - -/*** - *** Functions - ***/ - -ISC_LANG_BEGINDECLS -isc_result_t -isc_backtrace_gettrace(void **addrs, int maxaddrs, int *nframes); -/*%< - * Get a back trace of the running process above this function itself. On - * success, addrs[i] will store the address of the call point of the i-th - * stack frame (addrs[0] is the caller of this function). *nframes will store - * the total number of frames. - * - * Requires (note that these are not ensured by assertion checks, see above): - * - *\li 'addrs' is a valid array containing at least 'maxaddrs' void * entries. - * - *\li 'nframes' must be non NULL. - * - * Returns: - * - *\li #ISC_R_SUCCESS - *\li #ISC_R_FAILURE - *\li #ISC_R_NOTFOUND - *\li #ISC_R_NOTIMPLEMENTED - */ - -isc_result_t -isc_backtrace_getsymbolfromindex(int index, const void **addrp, - const char **symbolp); -/*%< - * Returns the content of the internal symbol table of the given index. - * On success, *addrsp and *symbolp point to the address and the symbol of - * the 'index'th entry of the table, respectively. If 'index' is not in the - * range of the symbol table, ISC_R_RANGE will be returned. - * - * Requires - * - *\li 'addrp' must be non NULL && '*addrp' == NULL. - * - *\li 'symbolp' must be non NULL && '*symbolp' == NULL. - * - * Returns: - * - *\li #ISC_R_SUCCESS - *\li #ISC_R_RANGE - */ - -isc_result_t -isc_backtrace_getsymbol(const void *addr, const char **symbolp, - unsigned long *offsetp); -/*%< - * Searches the internal symbol table for the symbol that most matches the - * given 'addr'. On success, '*symbolp' will point to the name of function - * to which the address 'addr' belong, and '*offsetp' will store the offset - * from the function's entry address to 'addr'. - * - * Requires (note that these are not ensured by assertion checks, see above): - * - *\li 'symbolp' must be non NULL && '*symbolp' == NULL. - * - *\li 'offsetp' must be non NULL. - * - * Returns: - * - *\li #ISC_R_SUCCESS - *\li #ISC_R_FAILURE - *\li #ISC_R_NOTFOUND - */ -ISC_LANG_ENDDECLS - -#endif /* ISC_BACKTRACE_H */ diff --git a/usr.sbin/bind/lib/isc/include/isc/platform.h.in b/usr.sbin/bind/lib/isc/include/isc/platform.h.in index ac47dbdfad8..c1bbd006e53 100644 --- a/usr.sbin/bind/lib/isc/include/isc/platform.h.in +++ b/usr.sbin/bind/lib/isc/include/isc/platform.h.in @@ -148,11 +148,6 @@ */ @ISC_PLATFORM_HAVEDEVPOLL@ -/*! \brief - * Define if we want to log backtrace - */ -@ISC_PLATFORM_USEBACKTRACE@ - /* *** Printing. ***/ diff --git a/usr.sbin/bind/lib/isc/include/isc/types.h b/usr.sbin/bind/lib/isc/include/isc/types.h index dfeddc24a13..54ddb07574c 100644 --- a/usr.sbin/bind/lib/isc/include/isc/types.h +++ b/usr.sbin/bind/lib/isc/include/isc/types.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: types.h,v 1.6 2019/12/17 01:46:35 sthen Exp $ */ +/* $Id: types.h,v 1.7 2020/01/07 19:11:17 florian Exp $ */ #ifndef ISC_TYPES_H #define ISC_TYPES_H 1 @@ -42,7 +42,6 @@ /* Core Types. Alphabetized by defined type. */ typedef struct isc_appctx isc_appctx_t; /*%< Application context */ -typedef struct isc_backtrace_symmap isc_backtrace_symmap_t; /*%< Symbol Table Entry */ typedef struct isc_buffer isc_buffer_t; /*%< Buffer */ typedef ISC_LIST(isc_buffer_t) isc_bufferlist_t; /*%< Buffer List */ typedef struct isc_constregion isc_constregion_t; /*%< Const region */ diff --git a/usr.sbin/bind/make/rules.in b/usr.sbin/bind/make/rules.in index 6768294652e..e8d8bff1933 100644 --- a/usr.sbin/bind/make/rules.in +++ b/usr.sbin/bind/make/rules.in @@ -190,46 +190,8 @@ MKDEP = ${SHELL} ${top_builddir}/make/mkdep ### ${FINALBUILDCMD} ### See bin/check/Makefile.in for a complete example of the use of LIBS0. ### -FINALBUILDCMD = if [ X"${MKSYMTBL_PROGRAM}" = X -o X"$${MAKE_SYMTABLE:-${ALWAYS_MAKE_SYMTABLE}}" = X ] ; then \ - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} ${LDFLAGS} \ - -o $@ $${BASEOBJS} $${LIBS0} ${LIBS}; \ - else \ - rm -f $@tmp0; \ - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} ${LDFLAGS} \ - -o $@tmp0 $${BASEOBJS} $${LIBS0} ${LIBS} || exit 1; \ - rm -f $@-symtbl.c $@-symtbl.@O@; \ - ${MKSYMTBL_PROGRAM} ${top_srcdir}/util/mksymtbl.pl \ - -o $@-symtbl.c $@tmp0 || exit 1; \ - $(MAKE) $@-symtbl.@O@ || exit 1; \ - rm -f $@tmp1; \ - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} ${LDFLAGS} \ - -o $@tmp1 $${BASEOBJS} $@-symtbl.@O@ $${LIBS0} ${NOSYMLIBS} || exit 1; \ - rm -f $@-symtbl.c $@-symtbl.@O@; \ - ${MKSYMTBL_PROGRAM} ${top_srcdir}/util/mksymtbl.pl \ - -o $@-symtbl.c $@tmp1 || exit 1; \ - $(MAKE) $@-symtbl.@O@ || exit 1; \ - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} ${LDFLAGS} \ - -o $@tmp2 $${BASEOBJS} $@-symtbl.@O@ $${LIBS0} ${NOSYMLIBS}; \ - ${MKSYMTBL_PROGRAM} ${top_srcdir}/util/mksymtbl.pl \ - -o $@-symtbl2.c $@tmp2; \ - count=0; \ - until diff $@-symtbl.c $@-symtbl2.c > /dev/null ; \ - do \ - count=`expr $$count + 1` ; \ - test $$count = 42 && exit 1 ; \ - rm -f $@-symtbl.c $@-symtbl.@O@; \ - ${MKSYMTBL_PROGRAM} ${top_srcdir}/util/mksymtbl.pl \ - -o $@-symtbl.c $@tmp2 || exit 1; \ - $(MAKE) $@-symtbl.@O@ || exit 1; \ - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} \ - ${LDFLAGS} -o $@tmp2 $${BASEOBJS} $@-symtbl.@O@ \ - $${LIBS0} ${NOSYMLIBS}; \ - ${MKSYMTBL_PROGRAM} ${top_srcdir}/util/mksymtbl.pl \ - -o $@-symtbl2.c $@tmp2; \ - done ; \ - mv $@tmp2 $@; \ - rm -f $@tmp0 $@tmp1 $@tmp2 $@-symtbl2.c; \ - fi +FINALBUILDCMD = ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} ${LDFLAGS} \ + -o $@ $${BASEOBJS} $${LIBS0} ${LIBS}; cleandir: distclean superclean: maintainer-clean @@ -317,16 +279,6 @@ DBLATEX = @DBLATEX@ W3M = @W3M@ PANDOC = @PANDOC@ -### -### Script language program used to create internal symbol tables -### -MKSYMTBL_PROGRAM = @MKSYMTBL_PROGRAM@ - -### -### Switch to create internal symbol table selectively -### -ALWAYS_MAKE_SYMTABLE = @ALWAYS_MAKE_SYMTABLE@ - ### ### DocBook -> HTML ### DocBook -> man page diff --git a/usr.sbin/bind/util/mksymtbl.pl b/usr.sbin/bind/util/mksymtbl.pl deleted file mode 100644 index 25d05a5af49..00000000000 --- a/usr.sbin/bind/util/mksymtbl.pl +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env perl -# -# Copyright (C) 2009, 2012 Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: mksymtbl.pl,v 1.1 2019/12/16 16:31:37 deraadt Exp $ - -use strict; -use diagnostics; -$^W = 1; - -my $rev = '$Id: mksymtbl.pl,v 1.1 2019/12/16 16:31:37 deraadt Exp $'; -$rev =~ s/\$//g; -$rev =~ s/,v//g; -$rev =~ s/Id: //; - -use Getopt::Std; -my %options; -getopts('i:o:', \%options); - -my ($binname, $need_uscorefix, $outputfile, $nsyms, $ostype, $nm_prog); -my %symmap; - -$binname = $ARGV[0]; -$need_uscorefix = 0; -if ($options{'o'}) { - $outputfile = $options{'o'}; -} else { - $outputfile = "symtbl.c"; -} - -# OS-depending configuration -$nm_prog = "nm"; -$ostype = `uname -s`; -chop($ostype); -if ($ostype eq "SunOS" || $ostype eq "HP-UX") { - $nm_prog = "/usr/ccs/bin/nm -x" -} - -if ($options{'i'}) { - open(SYMBOLS, $options{'i'}) || die "failed to open $options{'i'}"; -} else { - open(SYMBOLS, "$nm_prog $binname |") || - die "failed to invoke utility to get symbols"; -} -open(TBLFILE, ">$outputfile") || die "failed to open output file: $outputfile"; - -$nsyms = 0; -while () { - my ($addr, $symbol) = (0, ""); - if ($ostype eq "SunOS") { - if (/\[\d*\]\s*\|\s*0x([0-9a-f]*)\|\s*0x[0-9a-f]*\|FUNC\s*(.*)\|([^|]+)$/) { - next if ($2 =~ /UNDEF/); # skip undefined symbols - $addr = $1; - $symbol = $3; - chop($symbol); - } - } elsif ($ostype eq "HP-UX") { - if (/(\S*)\s*\|0x([0-9a-f]*)\|([^|]*\|entry|extern\|code)/) { - $addr = $2; - $symbol = $1; - # this filter catches a massive number of awkward - # symbols such as "$START$". we are not interested in - # those and ignore them. - next if ($symbol =~ /\$/); - } - } else { - # *BSDs, Linux, etc. - if (/([0-9a-f]*)\s[tT]\s(.*)/) { - ($addr, $symbol) = ($1, $2); - # heuristics: some compilers add a "_" to all program - # defined symbols. Detect and fix it for a well known - # symbol of "main". - $need_uscorefix = 1 if ($symbol eq "_main"); - } - } - if ($symbol ne "") { - # XXX: HP-UX's nm can produce a duplicate entry for the same - # address. Ignore duplicate entries except the first one. - next if ($symmap{$addr}); - - $symmap{$addr} = $symbol; - $nsyms++; - } -} - -sub lhex { - my $la = substr($a, -8); - my $lb = substr($b, -8); - my $ha = substr($a, 0, length($a) - length($la)); - my $hb = substr($b, 0, length($b) - length($lb)); - $ha = "0" if ($ha eq ""); - $ha = "0" if ($hb eq ""); - if (hex($ha) != hex($hb)) { - $la = $ha; - $lb = $hb; - } - hex($la) <=> hex($lb) -} - -print TBLFILE "/*\n * Generated by $rev \n */\n"; -print TBLFILE "#include \n"; -print TBLFILE "const int isc__backtrace_nsymbols = $nsyms;\n"; -print TBLFILE "const isc_backtrace_symmap_t isc__backtrace_symtable[] = {\n"; -foreach (sort lhex keys(%symmap)) { - my ($addr, $symbol) = ($_, $symmap{$_}); - if ($need_uscorefix && $symbol =~ /^_(.*)/) { - $symbol = $1; - } - print TBLFILE "\t{ (void *)0x$addr, \"$symbol\" },\n"; -} -print TBLFILE "\t{ (void *)0x0, \"\" },\n"; -print TBLFILE "};\n"; - -close(TBLFILE); -close(SYMBOLS); -- cgit v1.2.3