Implement jerry_get_backtrace_from API function (#4454)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -59,15 +59,45 @@ vm_is_direct_eval_form_call (void)
|
||||
* @return array ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
vm_get_backtrace (uint32_t max_depth) /**< maximum backtrace depth, 0 = unlimited */
|
||||
vm_get_backtrace (uint32_t max_depth, /**< maximum backtrace depth, 0 = unlimited */
|
||||
ecma_object_t *ignored_function_p) /**< ignore functions up to this function */
|
||||
{
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
vm_frame_ctx_t *context_p = JERRY_CONTEXT (vm_top_context_p);
|
||||
|
||||
if (ignored_function_p != NULL)
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_type (ignored_function_p) == ECMA_OBJECT_TYPE_FUNCTION
|
||||
|| ecma_get_object_type (ignored_function_p) == ECMA_OBJECT_TYPE_NATIVE_FUNCTION);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (context_p == NULL)
|
||||
{
|
||||
context_p = JERRY_CONTEXT (vm_top_context_p);
|
||||
break;
|
||||
}
|
||||
|
||||
if (context_p->shared_p->status_flags & VM_FRAME_CTX_SHARED_HAS_ARG_LIST)
|
||||
{
|
||||
vm_frame_ctx_shared_args_t *shared_args_p = (vm_frame_ctx_shared_args_t *) context_p->shared_p;
|
||||
|
||||
if (shared_args_p->function_object_p == ignored_function_p)
|
||||
{
|
||||
context_p = context_p->prev_context_p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
context_p = context_p->prev_context_p;
|
||||
}
|
||||
}
|
||||
|
||||
if (max_depth == 0)
|
||||
{
|
||||
max_depth = UINT32_MAX;
|
||||
}
|
||||
|
||||
vm_frame_ctx_t *context_p = JERRY_CONTEXT (vm_top_context_p);
|
||||
ecma_object_t *array_p = ecma_op_new_array_object (0);
|
||||
JERRY_ASSERT (ecma_op_object_is_fast_array (array_p));
|
||||
uint32_t index = 0;
|
||||
@@ -108,6 +138,7 @@ vm_get_backtrace (uint32_t max_depth) /**< maximum backtrace depth, 0 = unlimite
|
||||
return ecma_make_object_value (array_p);
|
||||
#else /* !ENABLED (JERRY_LINE_INFO) */
|
||||
JERRY_UNUSED (max_depth);
|
||||
JERRY_UNUSED (ignored_function_p);
|
||||
|
||||
return ecma_make_object_value (ecma_op_new_array_object (0));
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) */
|
||||
|
||||
+1
-1
@@ -490,7 +490,7 @@ ecma_value_t vm_execute (vm_frame_ctx_t *frame_ctx_p);
|
||||
bool vm_is_strict_mode (void);
|
||||
bool vm_is_direct_eval_form_call (void);
|
||||
|
||||
ecma_value_t vm_get_backtrace (uint32_t max_depth);
|
||||
ecma_value_t vm_get_backtrace (uint32_t max_depth, ecma_object_t *ignored_function_p);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
Reference in New Issue
Block a user