forked from Imagelibrary/rtems
sapi: Add rtems_fatal_source_description()
This commit is contained in:
@@ -38,7 +38,7 @@ libsapi_a_SOURCES = src/debug.c src/extension.c src/extensioncreate.c \
|
||||
src/rtemsapi.c src/extensiondata.c src/getversionstring.c \
|
||||
src/chainappendnotify.c src/chaingetnotify.c src/chaingetwait.c \
|
||||
src/chainprependnotify.c src/rbheap.c src/interrdesc.c \
|
||||
src/fatal2.c
|
||||
src/fatal2.c src/fatalsrcdesc.c
|
||||
libsapi_a_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
include $(srcdir)/preinstall.am
|
||||
|
||||
@@ -82,6 +82,16 @@ void rtems_fatal(
|
||||
rtems_fatal_code error
|
||||
) RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
* @brief Returns a description for a fatal source.
|
||||
*
|
||||
* @param[in] source The fatal source.
|
||||
*
|
||||
* @return The fatal source description or "?" in case the passed fatal source
|
||||
* is invalid.
|
||||
*/
|
||||
const char *rtems_fatal_source_description( rtems_fatal_source source );
|
||||
|
||||
/**
|
||||
* @brief Returns a description for an internal error code.
|
||||
*
|
||||
|
||||
53
cpukit/sapi/src/fatalsrcdesc.c
Normal file
53
cpukit/sapi/src/fatalsrcdesc.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief Implementation of rtems_fatal_source_description()
|
||||
*
|
||||
* @ingroup ClassicFatal
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Obere Lagerstr. 30
|
||||
* 82178 Puchheim
|
||||
* Germany
|
||||
* <rtems@embedded-brains.de>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/fatal.h>
|
||||
|
||||
static const char *const fatal_source_desc [] = {
|
||||
"INTERNAL_ERROR_CORE",
|
||||
"INTERNAL_ERROR_RTEMS_API",
|
||||
"INTERNAL_ERROR_POSIX_API",
|
||||
"RTEMS_FATAL_SOURCE_BDBUF",
|
||||
"RTEMS_FATAL_SOURCE_APPLICATION",
|
||||
"RTEMS_FATAL_SOURCE_EXIT",
|
||||
"RTEMS_FATAL_SOURCE_BSP_GENERIC",
|
||||
"RTEMS_FATAL_SOURCE_BSP_SPECIFIC",
|
||||
"RTEMS_FATAL_SOURCE_ASSERT",
|
||||
"RTEMS_FATAL_SOURCE_STACK_CHECKER",
|
||||
"RTEMS_FATAL_SOURCE_EXCEPTION"
|
||||
};
|
||||
|
||||
const char *rtems_fatal_source_description( rtems_fatal_source source )
|
||||
{
|
||||
size_t i = source;
|
||||
const char *desc = "?";
|
||||
|
||||
if ( i < RTEMS_ARRAY_SIZE( fatal_source_desc ) ) {
|
||||
desc = fatal_source_desc [i];
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
@@ -226,6 +226,33 @@ NONE
|
||||
|
||||
Prints the exception frame via printk().
|
||||
|
||||
@c
|
||||
@c
|
||||
@c
|
||||
@page
|
||||
@subsection FATAL_SOURCE_DESCRIPTION - Returns a description for a fatal source
|
||||
|
||||
@cindex fatal error
|
||||
|
||||
@subheading CALLING SEQUENCE:
|
||||
|
||||
@ifset is-C
|
||||
@findex rtems_fatal_source_description
|
||||
@example
|
||||
const char *rtems_fatal_source_description(
|
||||
rtems_fatal_source source
|
||||
);
|
||||
@end example
|
||||
@end ifset
|
||||
|
||||
@subheading DIRECTIVE STATUS CODES
|
||||
|
||||
The fatal source description or "?" in case the passed fatal source is invalid.
|
||||
|
||||
@subheading DESCRIPTION:
|
||||
|
||||
Returns a description for a fatal source.
|
||||
|
||||
@c
|
||||
@c
|
||||
@c
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
static void test(void)
|
||||
static void test_internal_error_description(void)
|
||||
{
|
||||
rtems_fatal_code error = 0;
|
||||
const char *desc_last = NULL;
|
||||
@@ -36,11 +36,28 @@ static void test(void)
|
||||
rtems_test_assert( error - 3 == INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR );
|
||||
}
|
||||
|
||||
static void test_fatal_source_description(void)
|
||||
{
|
||||
rtems_fatal_source source = 0;
|
||||
const char *desc_last = NULL;
|
||||
const char *desc;
|
||||
|
||||
do {
|
||||
desc_last = desc;
|
||||
desc = rtems_fatal_source_description( source );
|
||||
++source;
|
||||
puts( desc );
|
||||
} while ( desc != desc_last );
|
||||
|
||||
rtems_test_assert( source - 3 == RTEMS_FATAL_SOURCE_EXCEPTION );
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
{
|
||||
puts("\n\n*** TEST SPINTERNALERROR 2 ***");
|
||||
|
||||
test();
|
||||
test_internal_error_description();
|
||||
test_fatal_source_description();
|
||||
|
||||
puts("*** END OF TEST SPINTERNALERROR 2 ***");
|
||||
|
||||
|
||||
@@ -26,4 +26,17 @@ INTERNAL_ERROR_NO_MEMORY_FOR_HEAP
|
||||
INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR
|
||||
?
|
||||
?
|
||||
INTERNAL_ERROR_CORE
|
||||
INTERNAL_ERROR_RTEMS_API
|
||||
INTERNAL_ERROR_POSIX_API
|
||||
RTEMS_FATAL_SOURCE_BDBUF
|
||||
RTEMS_FATAL_SOURCE_APPLICATION
|
||||
RTEMS_FATAL_SOURCE_EXIT
|
||||
RTEMS_FATAL_SOURCE_BSP_GENERIC
|
||||
RTEMS_FATAL_SOURCE_BSP_SPECIFIC
|
||||
RTEMS_FATAL_SOURCE_ASSERT
|
||||
RTEMS_FATAL_SOURCE_STACK_CHECKER
|
||||
RTEMS_FATAL_SOURCE_EXCEPTION
|
||||
?
|
||||
?
|
||||
*** END OF TEST SPINTERNALERROR 2 ***
|
||||
|
||||
Reference in New Issue
Block a user