diff --git a/include/QF/progs.h b/include/QF/progs.h index 3cd6a5c6c..c393be5a5 100644 --- a/include/QF/progs.h +++ b/include/QF/progs.h @@ -1857,9 +1857,8 @@ struct progs_s { /// \name debugging ///@{ struct prdeb_resources_s *pr_debug_resources; - void (*debug_handler) (prdebug_t event, void *data); + void (*debug_handler) (prdebug_t event, void *param, void *data); void *debug_data; - const char *error_string; pr_type_t *watch; int wp_conditional; pr_type_t wp_val; diff --git a/libs/gamecode/pr_exec.c b/libs/gamecode/pr_exec.c index 43681da79..425ec5f64 100644 --- a/libs/gamecode/pr_exec.c +++ b/libs/gamecode/pr_exec.c @@ -55,7 +55,7 @@ VISIBLE void PR_RunError (progs_t * pr, const char *error, ...) { - dstring_t *string = dstring_new (); + dstring_t *string = dstring_new ();//FIXME leaks when debugging va_list argptr; va_start (argptr, error); @@ -63,8 +63,7 @@ PR_RunError (progs_t * pr, const char *error, ...) va_end (argptr); if (pr->debug_handler) { - pr->error_string = string->str; - pr->debug_handler (prd_runerror, pr->debug_data); + pr->debug_handler (prd_runerror, string->str, pr->debug_data); // not expected to return, but if so, behave as if there was no handler } @@ -486,7 +485,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum) if (pr->pr_trace) { if (pr->debug_handler) { - pr->debug_handler (prd_trace, pr->debug_data); + pr->debug_handler (prd_trace, 0, pr->debug_data); } else { PR_PrintStatement (pr, st, 1); } @@ -494,7 +493,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum) if (st->op & OP_BREAK) { if (pr->debug_handler) { - pr->debug_handler (prd_breakpoint, pr->debug_data); + pr->debug_handler (prd_breakpoint, 0, pr->debug_data); } else { PR_RunError (pr, "breakpoint hit"); } @@ -1714,7 +1713,7 @@ op_call: if (!pr->wp_conditional || pr->watch->integer_var == pr->wp_val.integer_var) { if (pr->debug_handler) { - pr->debug_handler (prd_watchpoint, pr->debug_data); + pr->debug_handler (prd_watchpoint, 0, pr->debug_data); } else { PR_RunError (pr, "watchpoint hit: %d -> %d", old_val.integer_var, pr->watch->integer_var); diff --git a/libs/gamecode/pr_load.c b/libs/gamecode/pr_load.c index 9ea30a037..dd405769a 100644 --- a/libs/gamecode/pr_load.c +++ b/libs/gamecode/pr_load.c @@ -326,7 +326,6 @@ PR_LoadProgsFile (progs_t *pr, QFile *file, int size) def->type_encoding = xdef->type; } } - pr->error_string = 0; pr->pr_trace = 0; pr->pr_trace_depth = 0; pr->pr_xfunction = 0; @@ -483,15 +482,14 @@ VISIBLE void PR_Error (progs_t *pr, const char *error, ...) { va_list argptr; - dstring_t *string = dstring_new (); + dstring_t *string = dstring_new ();//FIXME leaks when debugging va_start (argptr, error); dvsprintf (string, error, argptr); va_end (argptr); if (pr->debug_handler) { - pr->error_string = string->str; - pr->debug_handler (prd_error, pr->debug_data); + pr->debug_handler (prd_error, string->str, pr->debug_data); // not expected to return, but if so, behave as if there was no handler } Sys_Error ("%s: %s", pr->progs_name, string->str); diff --git a/ruamoko/qwaq/main.c b/ruamoko/qwaq/main.c index 46e1d8e4b..8c9650786 100644 --- a/ruamoko/qwaq/main.c +++ b/ruamoko/qwaq/main.c @@ -233,7 +233,7 @@ run_progs (void *data) PR_ExecuteProgram (thread->pr, thread->main_func); PR_PopFrame (thread->pr); if (thread->pr->debug_handler) { - thread->pr->debug_handler (prd_exit, thread->pr->debug_data); + thread->pr->debug_handler (prd_exit, 0, thread->pr->debug_data); } thread->return_code = R_INT (thread->pr); return thread; diff --git a/ruamoko/qwaq/qwaq-debug.c b/ruamoko/qwaq/qwaq-debug.c index 40effa817..b7fcab168 100644 --- a/ruamoko/qwaq/qwaq-debug.c +++ b/ruamoko/qwaq/qwaq-debug.c @@ -109,7 +109,7 @@ get_target (qwaq_debug_t *debug, const char *name, int handle) } static void -qwaq_debug_handler (prdebug_t debug_event, void *data) +qwaq_debug_handler (prdebug_t debug_event, void *param, void *data) { __auto_type target = (qwaq_target_t *) data; qwaq_debug_t *debug = target->debugger; @@ -130,7 +130,7 @@ qwaq_debug_handler (prdebug_t debug_event, void *data) pthread_cond_wait (&target->run_cond.rcond, &target->run_cond.mut); pthread_mutex_unlock (&target->run_cond.mut); if (debug_event == prd_runerror || debug_event == prd_error) { - pthread_exit ((void *) target->pr->error_string); + pthread_exit (param); } }