File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / mpd / src / assert.c
Revision 1.1.1.3 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:39:23 2021 UTC (3 years, 9 months ago) by misho
Branches: mpd, MAIN
CVS tags: v5_9p16, v5_9, HEAD
mpd 5.9


/*
 * assert.c
 *
 * Written by Archie Cobbs <archie@freebsd.org>
 * Copyright (c) 1995-1999 Whistle Communications, Inc. All rights reserved.
 * See ``COPYRIGHT.whistle''
 */

#include "ppp.h"
#include "log.h"
#ifdef USE_BACKTRACE
#include <execinfo.h>
#endif

void
DoAssert(const char *file, int line, const char *failedexpr)
{
#ifdef USE_BACKTRACE
	void *buffer[100];
	char **strings;
	int n, k;

	n = backtrace(buffer, 100);
	strings = backtrace_symbols(buffer, n);
	if (strings == NULL) {
		Log(LG_ERR, ("No backtrace symbols found"));
	} else {
		for (k = 0; k < n; k++) {
			Log(LG_ERR, ("%s", strings[k]));
		}
		free(strings);
	}
#endif
	Log(LG_ERR, ("ASSERT \"%s\" failed: file \"%s\", line %d",
	    failedexpr, file, line));

	DoExit(EX_ERRDEAD);
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>