mirror of
https://github.com/CTCaer/switch-l4t-atf.git
synced 2025-02-22 03:21:19 +00:00
Add ENABLE_ASSERTIONS
build option
Add the new build option `ENABLE_ASSERTIONS` that controls whether or not assert functions are compiled out. It defaults to 1 for debug builds and to 0 for release builds. Additionally, a following patch will be done to allow this build option to hide auxiliary code used for the checks done in an `assert()`. This code is is currently under the DEBUG build flag. Assert messages are now only printed if LOG_LEVEL >= LOG_LEVEL_INFO, which is the default for debug builds. This patch also updates the User Guide. Change-Id: I1401530b56bab25561bb0f274529f1d12c5263bc Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
This commit is contained in:
parent
239b085caa
commit
cc8b56322b
5
Makefile
5
Makefile
@ -52,8 +52,9 @@ include ${MAKE_HELPERS_DIRECTORY}build_env.mk
|
||||
|
||||
include ${MAKE_HELPERS_DIRECTORY}defaults.mk
|
||||
|
||||
# ASM_ASSERTION enabled for DEBUG builds only
|
||||
# Assertions enabled for DEBUG builds by default
|
||||
ASM_ASSERTION := ${DEBUG}
|
||||
ENABLE_ASSERTIONS := ${DEBUG}
|
||||
ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
|
||||
PLAT := ${DEFAULT_PLAT}
|
||||
|
||||
@ -446,6 +447,7 @@ $(eval $(call assert_boolean,CTX_INCLUDE_AARCH32_REGS))
|
||||
$(eval $(call assert_boolean,CTX_INCLUDE_FPREGS))
|
||||
$(eval $(call assert_boolean,DEBUG))
|
||||
$(eval $(call assert_boolean,DISABLE_PEDANTIC))
|
||||
$(eval $(call assert_boolean,ENABLE_ASSERTIONS))
|
||||
$(eval $(call assert_boolean,ENABLE_PLAT_COMPAT))
|
||||
$(eval $(call assert_boolean,ENABLE_PMF))
|
||||
$(eval $(call assert_boolean,ENABLE_PSCI_STAT))
|
||||
@ -482,6 +484,7 @@ $(eval $(call add_define,ASM_ASSERTION))
|
||||
$(eval $(call add_define,COLD_BOOT_SINGLE_CPU))
|
||||
$(eval $(call add_define,CTX_INCLUDE_AARCH32_REGS))
|
||||
$(eval $(call add_define,CTX_INCLUDE_FPREGS))
|
||||
$(eval $(call add_define,ENABLE_ASSERTIONS))
|
||||
$(eval $(call add_define,ENABLE_PLAT_COMPAT))
|
||||
$(eval $(call add_define,ENABLE_PMF))
|
||||
$(eval $(call add_define,ENABLE_PSCI_STAT))
|
||||
|
@ -107,6 +107,11 @@ assert_msg2:
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
func asm_assert
|
||||
#if LOG_LEVEL >= LOG_LEVEL_INFO
|
||||
/*
|
||||
* Only print the output if LOG_LEVEL is higher or equal to
|
||||
* LOG_LEVEL_INFO, which is the default value for builds with DEBUG=1.
|
||||
*/
|
||||
/* Stash the parameters already in r0 and r1 */
|
||||
mov r5, r0
|
||||
mov r6, r1
|
||||
@ -147,6 +152,7 @@ dec_print_loop:
|
||||
bl plat_crash_console_flush
|
||||
|
||||
1:
|
||||
#endif /* LOG_LEVEL >= LOG_LEVEL_INFO */
|
||||
no_ret plat_panic_handler
|
||||
endfunc asm_assert
|
||||
#endif
|
||||
|
@ -78,6 +78,11 @@ dec_print_loop:
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
func asm_assert
|
||||
#if LOG_LEVEL >= LOG_LEVEL_INFO
|
||||
/*
|
||||
* Only print the output if LOG_LEVEL is higher or equal to
|
||||
* LOG_LEVEL_INFO, which is the default value for builds with DEBUG=1.
|
||||
*/
|
||||
mov x5, x0
|
||||
mov x6, x1
|
||||
/* Ensure the console is initialized */
|
||||
@ -98,6 +103,7 @@ func asm_assert
|
||||
asm_print_line_dec
|
||||
bl plat_crash_console_flush
|
||||
_assert_loop:
|
||||
#endif /* LOG_LEVEL >= LOG_LEVEL_INFO */
|
||||
no_ret plat_panic_handler
|
||||
endfunc asm_assert
|
||||
#endif
|
||||
|
@ -286,6 +286,14 @@ performed.
|
||||
payload. Please refer to the "Booting an EL3 payload" section for more
|
||||
details.
|
||||
|
||||
* `ENABLE_ASSERTIONS`: This option controls whether or not calls to `assert()`
|
||||
are compiled out. For debug builds, this option defaults to 1, and calls to
|
||||
`assert()` are left in place. For release builds, this option defaults to 0
|
||||
and calls to `assert()` function are compiled out. This option can be set
|
||||
independently of `DEBUG`. It can also be used to hide any auxiliary code
|
||||
that is only required for the assertion and does not fit in the assertion
|
||||
itself.
|
||||
|
||||
* `ENABLE_PMF`: Boolean option to enable support for optional Performance
|
||||
Measurement Framework(PMF). Default is 0.
|
||||
|
||||
|
@ -34,30 +34,27 @@
|
||||
* @(#)assert.h 8.2 (Berkeley) 1/21/94
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
/*
|
||||
* Unlike other ANSI header files, <assert.h> may usefully be included
|
||||
* multiple times, with and without NDEBUG defined.
|
||||
* Portions copyright (c) 2017, ARM Limited and Contributors.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#undef assert
|
||||
#undef _assert
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define assert(e) ((void)0)
|
||||
#define _assert(e) ((void)0)
|
||||
#else
|
||||
#define _assert(e) assert(e)
|
||||
|
||||
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
|
||||
__LINE__, #e))
|
||||
#endif /* NDEBUG */
|
||||
|
||||
#ifndef _ASSERT_H_
|
||||
#define _ASSERT_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#if ENABLE_ASSERTIONS
|
||||
#define _assert(e) assert(e)
|
||||
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
|
||||
__LINE__, #e))
|
||||
#else
|
||||
#define assert(e) ((void)0)
|
||||
#define _assert(e) ((void)0)
|
||||
#endif /* ENABLE_ASSERTIONS */
|
||||
|
||||
__BEGIN_DECLS
|
||||
void __assert(const char *, const char *, int, const char *) __dead2;
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_ASSERT_H_ */
|
||||
|
@ -32,15 +32,18 @@
|
||||
#include <debug.h>
|
||||
#include <platform.h>
|
||||
|
||||
/*
|
||||
* This is a basic implementation. This could be improved.
|
||||
*/
|
||||
void __assert (const char *function, const char *file, unsigned int line,
|
||||
void __assert(const char *function, const char *file, unsigned int line,
|
||||
const char *assertion)
|
||||
{
|
||||
#if LOG_LEVEL >= LOG_LEVEL_INFO
|
||||
/*
|
||||
* Only print the output if LOG_LEVEL is higher or equal to
|
||||
* LOG_LEVEL_INFO, which is the default value for builds with DEBUG=1.
|
||||
*/
|
||||
tf_printf("ASSERT: %s <%d> : %s\n", function, line, assertion);
|
||||
|
||||
console_flush();
|
||||
#endif
|
||||
|
||||
plat_panic_handler();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user