2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-23 18:49:54 +00:00
bind/lib/isc/assertions.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

111 lines
2.4 KiB
C
Raw Normal View History

1998-10-21 01:08:12 +00:00
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
1998-12-12 20:48:14 +00:00
*
1998-10-21 01:08:12 +00:00
* SPDX-License-Identifier: MPL-2.0
*
1998-10-21 01:08:12 +00:00
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
1998-10-21 01:08:12 +00:00
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
1998-10-21 01:08:12 +00:00
*/
/*! \file */
2000-06-22 22:00:42 +00:00
1998-10-21 01:08:12 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <isc/assertions.h>
#include <isc/backtrace.h>
#include <isc/result.h>
#include <isc/strerr.h>
/*
* The maximum number of stack frames to dump on assertion failure.
*/
#ifndef BACKTRACE_MAXFRAME
#define BACKTRACE_MAXFRAME 128
#endif /* ifndef BACKTRACE_MAXFRAME */
1998-10-21 01:08:12 +00:00
/*%
1998-10-21 01:08:12 +00:00
* Forward.
*/
static void
default_callback(const char *, int, isc_assertiontype_t, const char *);
1998-10-21 01:08:12 +00:00
2009-09-29 15:06:07 +00:00
static isc_assertioncallback_t isc_assertion_failed_cb = default_callback;
/*%
1998-10-21 01:08:12 +00:00
* Public.
*/
2009-09-29 15:06:07 +00:00
/*% assertion failed handler */
/* coverity[+kill] */
void
isc_assertion_failed(const char *file, int line, isc_assertiontype_t type,
const char *cond) {
isc_assertion_failed_cb(file, line, type, cond);
abort();
}
1998-10-21 01:08:12 +00:00
/*% Set callback. */
1998-10-21 01:08:12 +00:00
void
isc_assertion_setcallback(isc_assertioncallback_t cb) {
if (cb == NULL) {
2009-09-29 15:06:07 +00:00
isc_assertion_failed_cb = default_callback;
1998-10-21 01:08:12 +00:00
} else {
2009-09-29 15:06:07 +00:00
isc_assertion_failed_cb = cb;
}
1998-10-21 01:08:12 +00:00
}
/*% Type to Text */
const char *
1998-10-21 01:08:12 +00:00
isc_assertion_typetotext(isc_assertiontype_t type) {
const char *result;
1998-10-21 01:08:12 +00:00
/*
* These strings have purposefully not been internationalized
* because they are considered to essentially be keywords of
* the ISC development environment.
*/
1998-10-21 01:08:12 +00:00
switch (type) {
case isc_assertiontype_require:
result = "REQUIRE";
break;
case isc_assertiontype_ensure:
result = "ENSURE";
break;
case isc_assertiontype_insist:
result = "INSIST";
break;
case isc_assertiontype_invariant:
result = "INVARIANT";
break;
default:
result = "UNKNOWN";
1998-10-21 01:08:12 +00:00
}
return result;
}
/*
* Private.
*/
static void
default_callback(const char *file, int line, isc_assertiontype_t type,
const char *cond) {
void *tracebuf[ISC_BACKTRACE_MAXFRAME];
int nframes = isc_backtrace(tracebuf, ISC_BACKTRACE_MAXFRAME);
2018-11-23 21:35:01 +01:00
fprintf(stderr, "%s:%d: %s(%s) failed%s\n", file, line,
Complete rewrite the BIND 9 build system The rewrite of BIND 9 build system is a large work and cannot be reasonable split into separate merge requests. Addition of the automake has a positive effect on the readability and maintainability of the build system as it is more declarative, it allows conditional and we are able to drop all of the custom make code that BIND 9 developed over the years to overcome the deficiencies of autoconf + custom Makefile.in files. This squashed commit contains following changes: - conversion (or rather fresh rewrite) of all Makefile.in files to Makefile.am by using automake - the libtool is now properly integrated with automake (the way we used it was rather hackish as the only official way how to use libtool is via automake - the dynamic module loading was rewritten from a custom patchwork to libtool's libltdl (which includes the patchwork to support module loading on different systems internally) - conversion of the unit test executor from kyua to automake parallel driver - conversion of the system test executor from custom make/shell to automake parallel driver - The GSSAPI has been refactored, the custom SPNEGO on the basis that all major KRB5/GSSAPI (mit-krb5, heimdal and Windows) implementations support SPNEGO mechanism. - The various defunct tests from bin/tests have been removed: bin/tests/optional and bin/tests/pkcs11 - The text files generated from the MD files have been removed, the MarkDown has been designed to be readable by both humans and computers - The xsl header is now generated by a simple sed command instead of perl helper - The <irs/platform.h> header has been removed - cleanups of configure.ac script to make it more simpler, addition of multiple macros (there's still work to be done though) - the tarball can now be prepared with `make dist` - the system tests are partially able to run in oot build Here's a list of unfinished work that needs to be completed in subsequent merge requests: - `make distcheck` doesn't yet work (because of system tests oot run is not yet finished) - documentation is not yet built, there's a different merge request with docbook to sphinx-build rst conversion that needs to be rebased and adapted on top of the automake - msvc build is non functional yet and we need to decide whether we will just cross-compile bind9 using mingw-w64 or fix the msvc build - contributed dlz modules are not included neither in the autoconf nor automake
2018-08-07 16:46:53 +02:00
isc_assertion_typetotext(type), cond,
(nframes > 0) ? ", back trace" : ".");
if (nframes > 0) {
isc_backtrace_symbols_fd(tracebuf, nframes, fileno(stderr));
}
1998-10-21 01:08:12 +00:00
fflush(stderr);
}