Adding jerry_unreachable and jerry_unimplemented routines that print file name and line for corresponding unreachable, unimplemented marks.

This commit is contained in:
Ruben Ayrapetyan
2014-09-18 17:08:32 +04:00
parent 55d9b12176
commit d9e0f2936d
4 changed files with 78 additions and 10 deletions
+38 -1
View File
@@ -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 */
+9 -2
View File
@@ -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 */
/**
+26 -2
View File
@@ -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 */