mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
[gamecode] Add a param pointer to debug_handler
I decided I want events for VM enter/exit but enter needs to somehow pass the function which will be executed (even if a builtin). A generic void * param seemed the best idea, which meant the error string could be passed via the param instead of a "global" string in the progs struct.
This commit is contained in:
parent
35bb3a3854
commit
1bd8e2ee85
5 changed files with 11 additions and 15 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue