From d538f3efbbcb958222e4c97aa4c5fca00d392bb5 Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 1 Jan 2008 14:19:44 +0000 Subject: [PATCH] add cvar prvm_backtraceforwarning git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7887 d7cf8633-e32d-0410-b094-e92efae38249 --- prvm_cmds.c | 13 +++++++++++-- prvm_edict.c | 12 +++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/prvm_cmds.c b/prvm_cmds.c index 7f099c46..b7cae0d2 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -9,19 +9,28 @@ #include "prvm_cmds.h" #include +extern cvar_t prvm_backtraceforwarnings; + // LordHavoc: changed this to NOT use a return statement, so that it can be used in functions that must return a value void VM_Warning(const char *fmt, ...) { va_list argptr; char msg[MAX_INPUTLINE]; + static double recursive = -1; va_start(argptr,fmt); dpvsnprintf(msg,sizeof(msg),fmt,argptr); va_end(argptr); - Con_Print(msg); + Con_Printf(msg); + // TODO: either add a cvar/cmd to control the state dumping or replace some of the calls with Con_Printf [9/13/2006 Black] - //PRVM_PrintState(); + if(prvm_backtraceforwarnings.integer && recursive != realtime) // NOTE: this compares to the time, just in case if PRVM_PrintState causes a Host_Error and keeps recursive set + { + recursive = realtime; + PRVM_PrintState(); + recursive = -1; + } } diff --git a/prvm_edict.c b/prvm_edict.c index 64fae58b..f752f9e7 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -37,6 +37,7 @@ cvar_t prvm_boundscheck = {0, "prvm_boundscheck", "1", "enables detection of out cvar_t prvm_traceqc = {0, "prvm_traceqc", "0", "prints every QuakeC statement as it is executed (only for really thorough debugging!)"}; // LordHavoc: counts usage of each QuakeC statement cvar_t prvm_statementprofiling = {0, "prvm_statementprofiling", "0", "counts how many times each QuakeC statement has been executed, these counts are displayed in prvm_printfunction output (if enabled)"}; +cvar_t prvm_backtraceforwarnings = {0, "prvm_backtraceforwarnings", "0", "print a backtrace for warnings too"}; extern sizebuf_t vm_tempstringsbuf; @@ -2042,6 +2043,7 @@ void PRVM_Init (void) Cvar_RegisterVariable (&prvm_boundscheck); Cvar_RegisterVariable (&prvm_traceqc); Cvar_RegisterVariable (&prvm_statementprofiling); + Cvar_RegisterVariable (&prvm_backtraceforwarnings); //VM_Cmd_Init(); } @@ -2156,14 +2158,14 @@ const char *PRVM_GetString(int num) return (char *)vm_tempstringsbuf.data + num; else { - VM_Warning("PRVM_GetString: Invalid temp-string offset (%i >= %i vm_tempstringsbuf.cursize)", num, vm_tempstringsbuf.cursize); + VM_Warning("PRVM_GetString: Invalid temp-string offset (%i >= %i vm_tempstringsbuf.cursize)\n", num, vm_tempstringsbuf.cursize); return ""; } } else #endif { - VM_Warning("PRVM_GetString: Invalid constant-string offset (%i >= %i prog->stringssize)", num, prog->stringssize); + VM_Warning("PRVM_GetString: Invalid constant-string offset (%i >= %i prog->stringssize)\n", num, prog->stringssize); return ""; } } @@ -2179,7 +2181,7 @@ const char *PRVM_GetString(int num) return (char *)vm_tempstringsbuf.data + num; else { - VM_Warning("PRVM_GetString: Invalid temp-string offset (%i >= %i vm_tempstringsbuf.cursize)", num, vm_tempstringsbuf.cursize); + VM_Warning("PRVM_GetString: Invalid temp-string offset (%i >= %i vm_tempstringsbuf.cursize)\n", num, vm_tempstringsbuf.cursize); return ""; } } @@ -2188,12 +2190,12 @@ const char *PRVM_GetString(int num) if (num < prog->numknownstrings) { if (!prog->knownstrings[num]) - VM_Warning("PRVM_GetString: Invalid zone-string offset (%i has been freed)", num); + VM_Warning("PRVM_GetString: Invalid zone-string offset (%i has been freed)\n", num); return prog->knownstrings[num]; } else { - VM_Warning("PRVM_GetString: Invalid zone-string offset (%i >= %i)", num, prog->numknownstrings); + VM_Warning("PRVM_GetString: Invalid zone-string offset (%i >= %i)\n", num, prog->numknownstrings); return ""; } } -- 2.39.2