Adding jerry_unreachable and jerry_unimplemented routines that print file name and line for corresponding unreachable, unimplemented marks.
This commit is contained in:
+5
-5
@@ -98,6 +98,8 @@ typedef enum
|
||||
extern uint32_t jerry_unreferenced_expression;
|
||||
|
||||
extern void __noreturn jerry_assert_fail (const char *assertion, const char *file, const uint32_t line);
|
||||
extern void __noreturn jerry_unreachable (const char *comment, const char *file, const uint32_t line);
|
||||
extern void __noreturn jerry_unimplemented (const char *comment, const char *file, const uint32_t line);
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
#define JERRY_ASSERT(x) do { if (__builtin_expect (!(x), 0)) { jerry_assert_fail (#x, __FILE__, __LINE__); } } while (0)
|
||||
@@ -112,21 +114,19 @@ extern void jerry_ref_unused_variables (int unused_variables_follow, ...);
|
||||
#define JERRY_UNREACHABLE() \
|
||||
do \
|
||||
{ \
|
||||
JERRY_ASSERT (false); \
|
||||
jerry_exit (ERR_FAILED_INTERNAL_ASSERTION); \
|
||||
jerry_unreachable (NULL, __FILE__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
#define JERRY_UNIMPLEMENTED() \
|
||||
do \
|
||||
{ \
|
||||
JERRY_ASSERT (false); \
|
||||
jerry_exit (ERR_UNIMPLEMENTED_CASE); \
|
||||
jerry_unimplemented (NULL, __FILE__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
#define JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(...) \
|
||||
do \
|
||||
{ \
|
||||
JERRY_UNIMPLEMENTED (); \
|
||||
jerry_unimplemented (NULL, __FILE__, __LINE__); \
|
||||
if (false) \
|
||||
{ \
|
||||
jerry_ref_unused_variables (0, __VA_ARGS__); \
|
||||
|
||||
@@ -24,9 +24,46 @@ jerry_assert_fail (const char *assertion, /**< assertion condition string */
|
||||
const char *file, /**< file name */
|
||||
const uint32_t line) /** line */
|
||||
{
|
||||
__printf ("Assertion '%s' failed at %s:%u\n",
|
||||
__printf ("Assertion '%s' failed at %s:%u.\n",
|
||||
assertion, file, line);
|
||||
|
||||
__exit (-ERR_FAILED_INTERNAL_ASSERTION);
|
||||
} /* jerry_assert_fail */
|
||||
|
||||
/**
|
||||
* Handle execution of control path that should be unreachable
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_unreachable (const char *comment, /**< comment to unreachable mark if exists,
|
||||
NULL - otherwise */
|
||||
const char *file, /**< file name */
|
||||
const uint32_t line) /**< line */
|
||||
{
|
||||
__printf ("Unreachable control path at %s:%u was executed", file, line);
|
||||
if (comment != NULL)
|
||||
{
|
||||
__printf ("(%s)", comment);
|
||||
}
|
||||
__printf (".\n");
|
||||
|
||||
__exit (-ERR_FAILED_INTERNAL_ASSERTION);
|
||||
} /* jerry_unreachable */
|
||||
|
||||
/**
|
||||
* Handle unimplemented case execution
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_unimplemented (const char *comment, /**< comment to unimplemented mark if exists,
|
||||
NULL - otherwise */
|
||||
const char *file, /**< file name */
|
||||
const uint32_t line) /**< line */
|
||||
{
|
||||
__printf ("Unimplemented case at %s:%u was executed", file, line);
|
||||
if (comment != NULL)
|
||||
{
|
||||
__printf ("(%s)", comment);
|
||||
}
|
||||
__printf (".\n");
|
||||
|
||||
__exit (-ERR_UNIMPLEMENTED_CASE);
|
||||
} /* jerry_unimplemented */
|
||||
|
||||
@@ -385,11 +385,18 @@ __putchar (int c)
|
||||
return putchar (c);
|
||||
} /* __putchar */
|
||||
|
||||
/** exit - cause normal process termination */
|
||||
/**
|
||||
* Exit - cause normal process termination with specified status code
|
||||
*/
|
||||
void __noreturn
|
||||
__exit (int status)
|
||||
__exit (int status) /**< status code */
|
||||
{
|
||||
exit (status);
|
||||
|
||||
while (true)
|
||||
{
|
||||
/* unreachable */
|
||||
}
|
||||
} /* __exit */
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,8 +21,32 @@
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_assert_fail (const char *assertion __unused, /**< assertion condition string */
|
||||
const char *file __unused, /**< file name */
|
||||
const uint32_t line __unused) /** line */
|
||||
const char *file __unused, /**< file name */
|
||||
const uint32_t line __unused) /** line */
|
||||
{
|
||||
__exit (-ERR_FAILED_INTERNAL_ASSERTION);
|
||||
} /* jerry_assert_fail */
|
||||
|
||||
/**
|
||||
* Handle execution of control path that should be unreachable
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_unreachable (const char *comment __unused, /**< comment to unreachable mark if exists,
|
||||
NULL - otherwise */
|
||||
const char *file __unused, /**< file name */
|
||||
const uint32_t line __unused) /**< line */
|
||||
{
|
||||
__exit (-ERR_FAILED_INTERNAL_ASSERTION);
|
||||
} /* jerry_unreachable */
|
||||
|
||||
/**
|
||||
* Handle unimplemented case execution
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_unimplemented (const char *comment __unused, /**< comment to unimplemented mark if exists,
|
||||
NULL - otherwise */
|
||||
const char *file __unused, /**< file name */
|
||||
const uint32_t line __unused) /**< line */
|
||||
{
|
||||
__exit (-ERR_UNIMPLEMENTED_CASE);
|
||||
} /* jerry_unimplemented */
|
||||
|
||||
Reference in New Issue
Block a user