mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-09 22:17:33 +02:00
Adding exception stack to thread data
This commit is contained in:
parent
42ec26f7b1
commit
87c266a44a
5 changed files with 14 additions and 6 deletions
1
gc.c
1
gc.c
|
@ -1200,6 +1200,7 @@ void gc_thread_data_init(gc_thread_data *thd, int mut_num, char *stack_base, lon
|
||||||
thd->stack_trace_idx = 0;
|
thd->stack_trace_idx = 0;
|
||||||
thd->stack_prev_frame = NULL;
|
thd->stack_prev_frame = NULL;
|
||||||
thd->mutations = NULL;
|
thd->mutations = NULL;
|
||||||
|
thd->exception_handler_stack = NULL;
|
||||||
// thd->thread = NULL;
|
// thd->thread = NULL;
|
||||||
thd->thread_state = CYC_THREAD_STATE_NEW;
|
thd->thread_state = CYC_THREAD_STATE_NEW;
|
||||||
//thd->mutator_num = mut_num;
|
//thd->mutator_num = mut_num;
|
||||||
|
|
|
@ -369,6 +369,7 @@ extern object Cyc_exception_handler_stack;
|
||||||
|
|
||||||
object Cyc_default_exception_handler(void *data, int argc, closure _, object err);
|
object Cyc_default_exception_handler(void *data, int argc, closure _, object err);
|
||||||
object Cyc_current_exception_handler();
|
object Cyc_current_exception_handler();
|
||||||
|
object Cyc_current_exception_handler2(void *data); // TODO: this is temporary, will consolidate with above function
|
||||||
void Cyc_rt_raise(void *data, object err);
|
void Cyc_rt_raise(void *data, object err);
|
||||||
void Cyc_rt_raise2(void *data, const char *msg, object err);
|
void Cyc_rt_raise2(void *data, const char *msg, object err);
|
||||||
void Cyc_rt_raise_msg(void *data, const char *err);
|
void Cyc_rt_raise_msg(void *data, const char *err);
|
||||||
|
|
|
@ -91,6 +91,8 @@ struct gc_thread_data_t {
|
||||||
char **stack_traces;
|
char **stack_traces;
|
||||||
int stack_trace_idx;
|
int stack_trace_idx;
|
||||||
char *stack_prev_frame;
|
char *stack_prev_frame;
|
||||||
|
// Exception handler stack
|
||||||
|
object exception_handler_stack;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* GC data structures */
|
/* GC data structures */
|
||||||
|
|
11
runtime.c
11
runtime.c
|
@ -371,6 +371,9 @@ object Cyc_default_exception_handler(void *data, int argc, closure _, object err
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object Cyc_current_exception_handler2(void *data) {
|
||||||
|
return Cyc_current_exception_handler();
|
||||||
|
}
|
||||||
object Cyc_current_exception_handler() {
|
object Cyc_current_exception_handler() {
|
||||||
if (nullp(Cyc_exception_handler_stack)) {
|
if (nullp(Cyc_exception_handler_stack)) {
|
||||||
return primitive_Cyc_91default_91exception_91handler;
|
return primitive_Cyc_91default_91exception_91handler;
|
||||||
|
@ -384,7 +387,7 @@ void Cyc_rt_raise(void *data, object err) {
|
||||||
make_cons(c2, err, nil);
|
make_cons(c2, err, nil);
|
||||||
make_cons(c1, boolean_f, &c2);
|
make_cons(c1, boolean_f, &c2);
|
||||||
make_cons(c0, &c1, nil);
|
make_cons(c0, &c1, nil);
|
||||||
apply(data, nil, Cyc_current_exception_handler(), &c0);
|
apply(data, nil, Cyc_current_exception_handler2(data), &c0);
|
||||||
// Should never get here
|
// Should never get here
|
||||||
fprintf(stderr, "Internal error in Cyc_rt_raise\n");
|
fprintf(stderr, "Internal error in Cyc_rt_raise\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -395,7 +398,7 @@ void Cyc_rt_raise2(void *data, const char *msg, object err) {
|
||||||
make_cons(c2, &s, &c3);
|
make_cons(c2, &s, &c3);
|
||||||
make_cons(c1, boolean_f, &c2);
|
make_cons(c1, boolean_f, &c2);
|
||||||
make_cons(c0, &c1, nil);
|
make_cons(c0, &c1, nil);
|
||||||
apply(data, nil, Cyc_current_exception_handler(), &c0);
|
apply(data, nil, Cyc_current_exception_handler2(data), &c0);
|
||||||
// Should never get here
|
// Should never get here
|
||||||
fprintf(stderr, "Internal error in Cyc_rt_raise2\n");
|
fprintf(stderr, "Internal error in Cyc_rt_raise2\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -1958,7 +1961,7 @@ void _cyc_system(void *data, object cont, object args) {
|
||||||
// integer_type argc = Cyc_length(args);
|
// integer_type argc = Cyc_length(args);
|
||||||
// dispatch_va(data, argc.value, dispatch_error, cont, cont, args); }
|
// dispatch_va(data, argc.value, dispatch_error, cont, cont, args); }
|
||||||
void _Cyc_91current_91exception_91handler(void *data, object cont, object args) {
|
void _Cyc_91current_91exception_91handler(void *data, object cont, object args) {
|
||||||
object handler = Cyc_current_exception_handler();
|
object handler = Cyc_current_exception_handler2(data);
|
||||||
return_closcall1(data, cont, handler); }
|
return_closcall1(data, cont, handler); }
|
||||||
void _Cyc_91default_91exception_91handler(void *data, object cont, object args) {
|
void _Cyc_91default_91exception_91handler(void *data, object cont, object args) {
|
||||||
// TODO: this is a quick-and-dirty implementation, may be a better way to write this
|
// TODO: this is a quick-and-dirty implementation, may be a better way to write this
|
||||||
|
@ -2627,7 +2630,7 @@ static primitive_type _121_123_primitive = {{0}, primitive_tag, "<=", &__121_123
|
||||||
static primitive_type apply_primitive = {{0}, primitive_tag, "apply", &_apply};
|
static primitive_type apply_primitive = {{0}, primitive_tag, "apply", &_apply};
|
||||||
static primitive_type _75halt_primitive = {{0}, primitive_tag, "%halt", &__75halt};
|
static primitive_type _75halt_primitive = {{0}, primitive_tag, "%halt", &__75halt};
|
||||||
static primitive_type exit_primitive = {{0}, primitive_tag, "exit", &_cyc_exit};
|
static primitive_type exit_primitive = {{0}, primitive_tag, "exit", &_cyc_exit};
|
||||||
static primitive_type Cyc_91current_91exception_91handler_primitive = {{0}, primitive_tag, "Cyc_current_exception_handler", &_Cyc_91current_91exception_91handler};
|
static primitive_type Cyc_91current_91exception_91handler_primitive = {{0}, primitive_tag, "Cyc_current_exception_handler2", &_Cyc_91current_91exception_91handler};
|
||||||
static primitive_type Cyc_91default_91exception_91handler_primitive = {{0}, primitive_tag, "Cyc_default_exception_handler", &_Cyc_91default_91exception_91handler};
|
static primitive_type Cyc_91default_91exception_91handler_primitive = {{0}, primitive_tag, "Cyc_default_exception_handler", &_Cyc_91default_91exception_91handler};
|
||||||
static primitive_type cons_primitive = {{0}, primitive_tag, "cons", &_cons};
|
static primitive_type cons_primitive = {{0}, primitive_tag, "cons", &_cons};
|
||||||
static primitive_type cell_91get_primitive = {{0}, primitive_tag, "cell-get", &_cell_91get};
|
static primitive_type cell_91get_primitive = {{0}, primitive_tag, "cell-get", &_cell_91get};
|
||||||
|
|
|
@ -472,7 +472,7 @@
|
||||||
((eq? p '%halt) "__halt")
|
((eq? p '%halt) "__halt")
|
||||||
((eq? p 'exit) "__halt")
|
((eq? p 'exit) "__halt")
|
||||||
((eq? p 'Cyc-default-exception-handler) "Cyc_default_exception_handler")
|
((eq? p 'Cyc-default-exception-handler) "Cyc_default_exception_handler")
|
||||||
((eq? p 'Cyc-current-exception-handler) "Cyc_current_exception_handler")
|
((eq? p 'Cyc-current-exception-handler) "Cyc_current_exception_handler2")
|
||||||
((eq? p 'open-input-file) "Cyc_io_open_input_file")
|
((eq? p 'open-input-file) "Cyc_io_open_input_file")
|
||||||
((eq? p 'open-output-file) "Cyc_io_open_output_file")
|
((eq? p 'open-output-file) "Cyc_io_open_output_file")
|
||||||
((eq? p 'close-port) "Cyc_io_close_port")
|
((eq? p 'close-port) "Cyc_io_close_port")
|
||||||
|
@ -591,6 +591,7 @@
|
||||||
<=
|
<=
|
||||||
apply
|
apply
|
||||||
Cyc-default-exception-handler
|
Cyc-default-exception-handler
|
||||||
|
Cyc-current-exception-handler
|
||||||
Cyc-end-thread!
|
Cyc-end-thread!
|
||||||
thread-sleep!
|
thread-sleep!
|
||||||
open-input-file
|
open-input-file
|
||||||
|
@ -716,7 +717,7 @@
|
||||||
;; Primitive functions that pass a continuation or thread data but have no other arguments
|
;; Primitive functions that pass a continuation or thread data but have no other arguments
|
||||||
(define (prim:cont/no-args? exp)
|
(define (prim:cont/no-args? exp)
|
||||||
(and (prim? exp)
|
(and (prim? exp)
|
||||||
(member exp '(command-line-arguments make-mutex Cyc-minor-gc))))
|
(member exp '(command-line-arguments make-mutex Cyc-minor-gc Cyc-current-exception-handler))))
|
||||||
|
|
||||||
;; Pass an integer arg count as the function's first parameter?
|
;; Pass an integer arg count as the function's first parameter?
|
||||||
(define (prim:arg-count? exp)
|
(define (prim:arg-count? exp)
|
||||||
|
|
Loading…
Add table
Reference in a new issue