Skip to content

Commit

Permalink
fwk/assert: print location of assertion
Browse files Browse the repository at this point in the history
fwk_assert which is called from several framework and module functions,
enters trap loop silently if condition passed to it fails, without
providing any information about the failure in the debug builds. Such
cases will be hard to debug in case of unavailability of a debugger or
textual trace output. Print the file name and line number to know the
location of assertion before entering infinite loop.

Change-Id: I9ff067178373c8c38ecfd25d9efc322b3d393ed3
Signed-off-by: Vijayenthiran Subramaniam <[email protected]>
  • Loading branch information
vijayenthiran-arm authored and mohamedasaker-arm committed Jan 25, 2024
1 parent 70401a1 commit 0fb270a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions framework/src/assert.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
/*
* Arm SCP/MCP Software
* Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2020-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#include <assert.h>
#include <fwk_attributes.h>
#include <fwk_io.h>

#include <assert.h>

#if defined(__ARMCC_VERSION)
void __aeabi_assert(const char *expr, const char *file, int line)
{
(void)fwk_io_printf(
fwk_io_stdout, "Assertion failed at %s:%d\n", file, line);

while (1) {
continue;
}
Expand All @@ -22,6 +27,13 @@ FWK_WEAK void __assert_func(
const char *function,
const char *assertion)
{
(void)fwk_io_printf(
fwk_io_stdout,
"Assertion failed in %s at %s:%d\n",
function,
file,
line);

while (1) {
continue;
}
Expand Down

0 comments on commit 0fb270a

Please sign in to comment.