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 (4 years ago) by misho
Branches: mpd, MAIN
CVS tags: v5_9p16, v5_9, HEAD
mpd 5.9

    1: 
    2: /*
    3:  * assert.c
    4:  *
    5:  * Written by Archie Cobbs <archie@freebsd.org>
    6:  * Copyright (c) 1995-1999 Whistle Communications, Inc. All rights reserved.
    7:  * See ``COPYRIGHT.whistle''
    8:  */
    9: 
   10: #include "ppp.h"
   11: #include "log.h"
   12: #ifdef USE_BACKTRACE
   13: #include <execinfo.h>
   14: #endif
   15: 
   16: void
   17: DoAssert(const char *file, int line, const char *failedexpr)
   18: {
   19: #ifdef USE_BACKTRACE
   20: 	void *buffer[100];
   21: 	char **strings;
   22: 	int n, k;
   23: 
   24: 	n = backtrace(buffer, 100);
   25: 	strings = backtrace_symbols(buffer, n);
   26: 	if (strings == NULL) {
   27: 		Log(LG_ERR, ("No backtrace symbols found"));
   28: 	} else {
   29: 		for (k = 0; k < n; k++) {
   30: 			Log(LG_ERR, ("%s", strings[k]));
   31: 		}
   32: 		free(strings);
   33: 	}
   34: #endif
   35: 	Log(LG_ERR, ("ASSERT \"%s\" failed: file \"%s\", line %d",
   36: 	    failedexpr, file, line));
   37: 
   38: 	DoExit(EX_ERRDEAD);
   39: }

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