mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Make exit behaviour of jerry_fatal flag-dependent
* Added new flag `JERRY_FLAG_ABORT_ON_FAIL`. * Added new internal api function `jerry_is_abort_on_fail` to check the status of the flag. * Changed `jerry_fatal` bail-out function to call `abort` when the flag is set and exit code is non-zero (i.e., not only for assertion failures). * Added `--abort-on-fail` command line option to linux and nuttx apps to set the flag. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
parent
4c10a6d057
commit
9d423d9901
@ -34,4 +34,7 @@ extern void
|
||||
jerry_dispatch_object_free_callback (ecma_external_pointer_t freecb_p,
|
||||
ecma_external_pointer_t native_p);
|
||||
|
||||
extern bool
|
||||
jerry_is_abort_on_fail (void);
|
||||
|
||||
#endif /* !JERRY_INTERNAL_H */
|
||||
|
||||
@ -1185,6 +1185,18 @@ jerry_get_memory_limits (size_t *out_data_bss_brk_limit_p, /**< out: Jerry's max
|
||||
*out_stack_limit_p = CONFIG_MEM_STACK_LIMIT;
|
||||
} /* jerry_get_memory_limits */
|
||||
|
||||
/**
|
||||
* Check whether 'abort' should be called instead of 'exit' upon exiting with non-zero exit code.
|
||||
*
|
||||
* @return true - if 'abort on fail' flag is set,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
jerry_is_abort_on_fail (void)
|
||||
{
|
||||
return ((jerry_flags & JERRY_FLAG_ABORT_ON_FAIL) != 0);
|
||||
} /* jerry_is_abort_on_fail */
|
||||
|
||||
/**
|
||||
* Register Jerry's fatal error callback
|
||||
*/
|
||||
|
||||
@ -40,6 +40,7 @@ typedef uint32_t jerry_flag_t;
|
||||
#define JERRY_FLAG_PARSE_ONLY (1u << 4) /**< parse only, prevents script execution (only for testing)
|
||||
* FIXME: Remove. */
|
||||
#define JERRY_FLAG_ENABLE_LOG (1u << 5) /**< enable logging */
|
||||
#define JERRY_FLAG_ABORT_ON_FAIL (1u << 6) /**< abort instead of exit in case of failure */
|
||||
|
||||
/**
|
||||
* Error codes
|
||||
|
||||
@ -20,6 +20,9 @@
|
||||
#include "jrt.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
#define JERRY_INTERNAL
|
||||
#include "jerry-internal.h"
|
||||
|
||||
/*
|
||||
* Exit with specified status code.
|
||||
*
|
||||
@ -62,7 +65,7 @@ jerry_fatal (jerry_fatal_code_t code) /**< status code */
|
||||
}
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
if (code == ERR_FAILED_INTERNAL_ASSERTION)
|
||||
if (code != 0 && jerry_is_abort_on_fail ())
|
||||
{
|
||||
abort ();
|
||||
}
|
||||
|
||||
@ -193,6 +193,10 @@ main (int argc,
|
||||
return JERRY_STANDALONE_EXIT_CODE_FAIL;
|
||||
}
|
||||
}
|
||||
else if (!strcmp ("--abort-on-fail", argv[i]))
|
||||
{
|
||||
flags |= JERRY_FLAG_ABORT_ON_FAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
file_names[files_counter++] = argv[i];
|
||||
|
||||
@ -166,6 +166,10 @@ int jerry_main (int argc, char *argv[])
|
||||
{
|
||||
flags |= JERRY_FLAG_SHOW_OPCODES;
|
||||
}
|
||||
else if (!strcmp ("--abort-on-fail", argv[i]))
|
||||
{
|
||||
flags |= JERRY_FLAG_ABORT_ON_FAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
file_names[files_counter++] = argv[i];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user