]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_exec.c
patch from esteel making the findkeysforcommand builtin available in
[xonotic/darkplaces.git] / prvm_exec.c
index 95a94196b5f721690d4ef124f0b604c5a22774f1..8adee10ff3fc3a8b654513711b74c7e817a1dcf0 100644 (file)
@@ -265,6 +265,37 @@ void PRVM_StackTrace (void)
        }
 }
 
+void PRVM_ShortStackTrace(char *buf, size_t bufsize)
+{
+       mfunction_t     *f;
+       int                     i;
+
+       if(prog)
+       {
+               dpsnprintf(buf, bufsize, "(%s) ", prog->name);
+       }
+       else
+       {
+               strlcpy(buf, "<NO PROG>", sizeof(buf));
+               return;
+       }
+
+       prog->stack[prog->depth].s = prog->xstatement;
+       prog->stack[prog->depth].f = prog->xfunction;
+       for (i = prog->depth;i > 0;i--)
+       {
+               f = prog->stack[i].f;
+
+               if(strlcat(buf,
+                       f
+                               ? va("%s:%s(%i) ", PRVM_GetString(f->s_file), PRVM_GetString(f->s_name), prog->stack[i].s - f->first_statement)
+                               : "<NULL> ",
+                       bufsize
+               ) >= bufsize)
+                       break;
+       }
+}
+
 
 void PRVM_CallProfile ()
 {
@@ -424,6 +455,8 @@ void PRVM_PrintState(void)
 }
 
 extern sizebuf_t vm_tempstringsbuf;
+extern cvar_t prvm_errordump;
+void Host_Savegame_to (const char *name);
 void PRVM_Crash(void)
 {
        if (prog == NULL)
@@ -437,6 +470,12 @@ void PRVM_Crash(void)
                PRVM_PrintState();
        }
 
+       if(prvm_errordump.integer)
+       {
+               // make a savegame
+               Host_Savegame_to(va("crash-%s.dmp", PRVM_NAME));
+       }
+
        // dump the stack so host_error can shutdown functions
        prog->depth = 0;
        prog->localstack_used = 0;