ryu: Use brief assertion failure message

Currently, when an assertion fails, the error message is like:

  ASSERTION FAILURE '1 + 1 == 3' in command_apreset() at common/chipset.c:24

To save flash space, let's add an option to remove the failed
expression and function name. The error message becomes:

  ASSERTION FAILURE at common/chipset.c:24

BUG=chrome-os-partner:32203
TEST=make buildall
TEST=Add an assertion and triggers it. Check error message.
BRANCH=None

Change-Id: Ie323d5b43cbff2cd8f6cd5bb46c1f34ecd16bd5e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219670
Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Vic Yang
2014-09-24 11:46:24 +08:00
committed by chrome-internal-fetch
parent 28891eaaab
commit baf3bac6d8
5 changed files with 31 additions and 0 deletions

View File

@@ -36,6 +36,7 @@
#undef CONFIG_CONSOLE_CMDHELP
#define CONFIG_INDUCTIVE_CHARGING
#undef CONFIG_HIBERNATE
#define CONFIG_DEBUG_ASSERT_BRIEF
/* Disable unused console command to save flash space */
#undef CONFIG_CMD_POWERINDEBUG

View File

@@ -78,6 +78,14 @@ void panic_reboot(void)
}
#ifdef CONFIG_DEBUG_ASSERT_REBOOTS
#ifdef CONFIG_DEBUG_ASSERT_BRIEF
void panic_assert_fail(const char *fname, int linenum)
{
panic_printf("\nASSERTION FAILURE at %s:%d\n", fname, linenum);
panic_reboot();
}
#else
void panic_assert_fail(const char *msg, const char *func, const char *fname,
int linenum)
{
@@ -87,6 +95,7 @@ void panic_assert_fail(const char *msg, const char *func, const char *fname,
panic_reboot();
}
#endif
#endif
void panic(const char *msg)
{

View File

@@ -413,6 +413,15 @@
*/
#define CONFIG_DEBUG_ASSERT_REBOOTS
/*
* On assertion failure, prints only the file name and the line number.
*
* Ignored if CONFIG_DEBUG_ASSERT_REBOOTS is not defined.
*
* Boards may define this to reduce image size.
*/
#undef CONFIG_DEBUG_ASSERT_BRIEF
/*
* Disable the write buffer used for default memory map accesses.
* This turns "Imprecise data bus errors" into "Precise" errors

View File

@@ -101,8 +101,12 @@ void panic_data_print(const struct panic_data *pdata);
* @param fname File name where assertion happened
* @param linenum Line number where assertion happened
*/
#ifdef CONFIG_DEBUG_ASSERT_BRIEF
void panic_assert_fail(const char *fname, int linenum);
#else
void panic_assert_fail(const char *msg, const char *func, const char *fname,
int linenum);
#endif
/**
* Display a custom panic message and reset

View File

@@ -18,11 +18,19 @@
*/
#ifdef CONFIG_DEBUG_ASSERT
#ifdef CONFIG_DEBUG_ASSERT_REBOOTS
#ifdef CONFIG_DEBUG_ASSERT_BRIEF
#define ASSERT(cond) do { \
if (!(cond)) \
panic_assert_fail(__FILE__, __LINE__); \
} while (0)
#else
#define ASSERT(cond) do { \
if (!(cond)) \
panic_assert_fail(#cond, __func__, __FILE__, \
__LINE__); \
} while (0)
#endif
#else
#define ASSERT(cond) do { \
if (!(cond)) \