Stop stack unfolding on exception only up to an event raise now.
[INTERPRETER] * NEW: Stop stack unfolding on exception only up to an event raise now.
This commit is contained in:
parent
62c9205762
commit
38604fd11b
@ -792,6 +792,7 @@ static bool raise_event(OBJECT *observer, void *object, int func_id, int nparam)
|
||||
CLASS_DESC_METHOD *desc;
|
||||
void *old_last;
|
||||
bool result;
|
||||
uint stack_barrier;
|
||||
|
||||
func_id--;
|
||||
|
||||
@ -823,6 +824,8 @@ static bool raise_event(OBJECT *observer, void *object, int func_id, int nparam)
|
||||
stop_event = GAMBAS_StopEvent;
|
||||
GAMBAS_StopEvent = FALSE;
|
||||
|
||||
stack_barrier = STACK_push_barrier();
|
||||
|
||||
TRY
|
||||
{
|
||||
EXEC_public_desc(class, observer, desc, nparam);
|
||||
@ -845,10 +848,15 @@ static bool raise_event(OBJECT *observer, void *object, int func_id, int nparam)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EVENT_Last = old_last;
|
||||
GAMBAS_StopEvent = stop_event;
|
||||
STACK_pop_barrier(stack_barrier);
|
||||
PROPAGATE();
|
||||
}
|
||||
}
|
||||
END_TRY
|
||||
|
||||
|
||||
if (RP->type == T_VOID)
|
||||
result = FALSE;
|
||||
else
|
||||
@ -857,10 +865,9 @@ static bool raise_event(OBJECT *observer, void *object, int func_id, int nparam)
|
||||
if (GAMBAS_StopEvent)
|
||||
result = TRUE;
|
||||
|
||||
GAMBAS_StopEvent = stop_event;
|
||||
|
||||
//OBJECT_UNREF(object, "raise_event");
|
||||
EVENT_Last = old_last;
|
||||
GAMBAS_StopEvent = stop_event;
|
||||
STACK_pop_barrier(stack_barrier);
|
||||
|
||||
EXEC_release_return_value();
|
||||
|
||||
|
@ -922,7 +922,7 @@ void EXEC_function_loop()
|
||||
PROPAGATE();
|
||||
}
|
||||
|
||||
if (EXEC_break_on_error)
|
||||
if (EXEC_break_on_error && EXEC_debug)
|
||||
DEBUG.Main(TRUE);
|
||||
|
||||
if (ERROR->info.code == E_ASSERT)
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
gbx_stack.c
|
||||
|
||||
(c) 2000-2017 Benoît Minisini <g4mba5@gmail.com>
|
||||
(c) Benoît Minisini <g4mba5@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -38,7 +38,8 @@ char *STACK_base = NULL;
|
||||
size_t STACK_size;
|
||||
char *STACK_limit = NULL;
|
||||
STACK_CONTEXT *STACK_frame;
|
||||
int STACK_frame_count;
|
||||
uint STACK_frame_count;
|
||||
uint STACK_frame_barrier;
|
||||
|
||||
uintptr_t STACK_process_stack_limit;
|
||||
|
||||
@ -71,6 +72,7 @@ void STACK_init(void)
|
||||
STACK_limit = STACK_base + STACK_size;
|
||||
STACK_frame = (STACK_CONTEXT *)STACK_limit;
|
||||
STACK_frame_count = 0;
|
||||
STACK_frame_barrier = 0;
|
||||
STACK_limit -= STACK_FOR_EVAL * sizeof(VALUE);
|
||||
|
||||
SP = (VALUE *)STACK_base;
|
||||
@ -111,22 +113,21 @@ bool STACK_check(int need)
|
||||
|
||||
bool STACK_has_error_handler(void)
|
||||
{
|
||||
int i;
|
||||
uint i;
|
||||
STACK_CONTEXT *sc;
|
||||
uint b = STACK_frame_count - STACK_frame_barrier;
|
||||
|
||||
for (i = 0; i < STACK_frame_count; i++)
|
||||
for (i = 0; i < b; i++)
|
||||
{
|
||||
sc = &STACK_frame[i];
|
||||
if (sc->ec || sc->ep)
|
||||
return TRUE;
|
||||
if (!sc->pc)
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STACK_CONTEXT *STACK_get_frame(int frame)
|
||||
STACK_CONTEXT *STACK_get_frame(uint frame)
|
||||
{
|
||||
if (frame >= 0 && frame < STACK_frame_count)
|
||||
return &STACK_frame[frame];
|
||||
@ -137,7 +138,7 @@ STACK_CONTEXT *STACK_get_frame(int frame)
|
||||
STACK_BACKTRACE *STACK_get_backtrace(void)
|
||||
{
|
||||
STACK_BACKTRACE *bt, *pbt;
|
||||
int i;
|
||||
uint i;
|
||||
|
||||
if (STACK_frame_count == 0)
|
||||
return NULL;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
gbx_stack.h
|
||||
|
||||
(c) 2000-2017 Benoît Minisini <g4mba5@gmail.com>
|
||||
(c) Benoît Minisini <g4mba5@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -60,11 +60,13 @@ EXTERN size_t STACK_size;
|
||||
EXTERN char *STACK_limit;
|
||||
//EXTERN size_t STACK_relocate;
|
||||
|
||||
EXTERN int STACK_frame_count;
|
||||
EXTERN uint STACK_frame_count;
|
||||
EXTERN STACK_CONTEXT *STACK_frame;
|
||||
|
||||
EXTERN uintptr_t STACK_process_stack_limit;
|
||||
|
||||
EXTERN uint STACK_frame_barrier;
|
||||
|
||||
#endif
|
||||
|
||||
#define STACK_FOR_EVAL 16
|
||||
@ -95,9 +97,9 @@ STACK_BACKTRACE *STACK_copy_backtrace(STACK_BACKTRACE *bt);
|
||||
#define STACK_backtrace_clear_end(_bt) ((_bt)->cp = (void *)(((intptr_t)((_bt)->cp)) & ~1))
|
||||
|
||||
|
||||
STACK_CONTEXT *STACK_get_frame(int frame);
|
||||
STACK_CONTEXT *STACK_get_frame(uint frame);
|
||||
|
||||
#define STACK_get_previous_pc() ((STACK_frame_count <= 0) ? NULL : STACK_frame->pc)
|
||||
#define STACK_get_previous_pc() ((STACK_frame_count == 0) ? NULL : STACK_frame->pc)
|
||||
|
||||
#define STACK_get_current() ((STACK_frame_count > 0) ? STACK_frame : NULL)
|
||||
|
||||
@ -130,4 +132,13 @@ STACK_CONTEXT *STACK_get_frame(int frame);
|
||||
#define STACK_enable_for_eval() STACK_limit += STACK_FOR_EVAL * sizeof(VALUE)
|
||||
#define STACK_disable_for_eval() STACK_limit -= STACK_FOR_EVAL * sizeof(VALUE)
|
||||
|
||||
#define STACK_push_barrier() \
|
||||
({ \
|
||||
int old = STACK_frame_barrier; \
|
||||
STACK_frame_barrier = STACK_frame_count + 1; \
|
||||
old; \
|
||||
})
|
||||
|
||||
#define STACK_pop_barrier(_old) (STACK_frame_barrier = (_old))
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user