#include "prvm_cmds.h"
#include <time.h>
+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;
+ }
}
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;
Cvar_RegisterVariable (&prvm_boundscheck);
Cvar_RegisterVariable (&prvm_traceqc);
Cvar_RegisterVariable (&prvm_statementprofiling);
+ Cvar_RegisterVariable (&prvm_backtraceforwarnings);
//VM_Cmd_Init();
}
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 "";
}
}
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 "";
}
}
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 "";
}
}