From 15e19273b2a6ebda3b2d55b28d693e7b8a0740b2 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 21 Nov 2017 11:29:01 +0100 Subject: sapi: New implementation of rtems_panic() The previous rtems_panic() implementation was quite heavy weight. It depended on _exit() which calls the global destructors. It used fprintf(stderr, ...) for output which depends on an initialized console device and the complex fprintf(). Introduce a new fatal source RTEMS_FATAL_SOURCE_PANIC for rtems_panic() and output via vprintk(). Update #3244. --- cpukit/sapi/Makefile.am | 1 + cpukit/sapi/include/rtems/fatal.h | 12 ++++++++++++ cpukit/sapi/src/panic.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 cpukit/sapi/src/panic.c (limited to 'cpukit/sapi') diff --git a/cpukit/sapi/Makefile.am b/cpukit/sapi/Makefile.am index 85d89ef494..326d67f193 100644 --- a/cpukit/sapi/Makefile.am +++ b/cpukit/sapi/Makefile.am @@ -43,6 +43,7 @@ libsapi_a_SOURCES += src/delaynano.c libsapi_a_SOURCES += src/rbtree.c libsapi_a_SOURCES += src/rbtreefind.c libsapi_a_SOURCES += src/rbtreeinsert.c +libsapi_a_SOURCES += src/panic.c libsapi_a_SOURCES += src/profilingiterate.c libsapi_a_SOURCES += src/profilingreportxml.c libsapi_a_SOURCES += src/tcsimpleinstall.c diff --git a/cpukit/sapi/include/rtems/fatal.h b/cpukit/sapi/include/rtems/fatal.h index 80929cd274..291af42c6e 100644 --- a/cpukit/sapi/include/rtems/fatal.h +++ b/cpukit/sapi/include/rtems/fatal.h @@ -88,6 +88,18 @@ RTEMS_NO_RETURN RTEMS_INLINE_ROUTINE void rtems_fatal( _Terminate( fatal_source, error_code ); } +/** + * @brief Prints the specified message via printk() and terminates the system. + * + * @param[in] fmt The message format. + * @param[in] ... The message parameters. + * + * @see _Terminate(). + */ +RTEMS_NO_RETURN void rtems_panic( + const char *fmt, ... +) RTEMS_PRINTFLIKE( 1, 2 ); + /** * @brief Returns a text for a fatal source. * diff --git a/cpukit/sapi/src/panic.c b/cpukit/sapi/src/panic.c new file mode 100644 index 0000000000..34b6f75213 --- /dev/null +++ b/cpukit/sapi/src/panic.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2017 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include + +void rtems_panic( const char *fmt, ... ) +{ + va_list ap; + + va_start( ap, fmt ); + vprintk( fmt, ap ); + va_end( ap); + + _Terminate( RTEMS_FATAL_SOURCE_PANIC, (Internal_errors_t) fmt ); +} -- cgit v1.2.3