فهرست منبع

add uncaught exception printing in debugger

Nicolas Cannasse 7 سال پیش
والد
کامیت
8452371631
2فایلهای تغییر یافته به همراه6 افزوده شده و 0 حذف شده
  1. 3 0
      src/debugger.c
  2. 3 0
      src/std/error.c

+ 3 - 0
src/debugger.c

@@ -34,6 +34,7 @@ HL_API int hl_socket_send( hl_socket *s, vbyte *buf, int pos, int len );
 HL_API int hl_socket_recv( hl_socket *s, vbyte *buf, int pos, int len );
 HL_API int hl_socket_recv( hl_socket *s, vbyte *buf, int pos, int len );
 HL_API void hl_sys_sleep( double t );
 HL_API void hl_sys_sleep( double t );
 HL_API int hl_thread_id();
 HL_API int hl_thread_id();
+HL_API vdynamic **hl_debug_exc;
 
 
 static hl_socket *debug_socket = NULL;
 static hl_socket *debug_socket = NULL;
 static hl_socket *client_socket = NULL;
 static hl_socket *client_socket = NULL;
@@ -47,6 +48,7 @@ static void send( void *ptr, int size ) {
 
 
 static void hl_debug_loop( hl_module *m ) {
 static void hl_debug_loop( hl_module *m ) {
 	void *stack_top = hl_module_stack_top();
 	void *stack_top = hl_module_stack_top();
+	void *dbg_addr = &hl_debug_exc;
 	int flags = 0;
 	int flags = 0;
 #	ifdef HL_64
 #	ifdef HL_64
 	flags |= 1;
 	flags |= 1;
@@ -61,6 +63,7 @@ static void hl_debug_loop( hl_module *m ) {
 		send(&flags,4);
 		send(&flags,4);
 		send(&main_thread_id,4);
 		send(&main_thread_id,4);
 		send(&m->globals_data,sizeof(void*));
 		send(&m->globals_data,sizeof(void*));
+		send(&dbg_addr,sizeof(void*));
 		send(&stack_top,sizeof(void*));
 		send(&stack_top,sizeof(void*));
 		send(&m->jit_code,sizeof(void*));
 		send(&m->jit_code,sizeof(void*));
 		send(&m->codesize,4);
 		send(&m->codesize,4);

+ 3 - 0
src/std/error.c

@@ -25,6 +25,7 @@
 
 
 HL_PRIM hl_trap_ctx *hl_current_trap = NULL;
 HL_PRIM hl_trap_ctx *hl_current_trap = NULL;
 HL_PRIM vdynamic *hl_current_exc = NULL;
 HL_PRIM vdynamic *hl_current_exc = NULL;
+HL_PRIM vdynamic **hl_debug_exc = NULL;
 
 
 static void *stack_trace[0x1000];
 static void *stack_trace[0x1000];
 static int stack_count = 0;
 static int stack_count = 0;
@@ -90,7 +91,9 @@ HL_PRIM void hl_throw( vdynamic *v ) {
 	hl_current_exc = v;
 	hl_current_exc = v;
 	hl_current_trap = t->prev;
 	hl_current_trap = t->prev;
 	if( hl_current_trap == NULL ) {
 	if( hl_current_trap == NULL ) {
+		hl_debug_exc = &v;
 		hl_debug_break();
 		hl_debug_break();
+		hl_debug_exc = NULL;
 		if( hl_error_handler ) hl_dyn_call(hl_error_handler,&v,1);
 		if( hl_error_handler ) hl_dyn_call(hl_error_handler,&v,1);
 	}
 	}
 	if( throw_jump == NULL ) throw_jump = longjmp;
 	if( throw_jump == NULL ) throw_jump = longjmp;