]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_exec.c
prvm_leaktest - leak detector for QC objects (all but Gecko instances at the moment)
[xonotic/darkplaces.git] / prvm_exec.c
index 95a94196b5f721690d4ef124f0b604c5a22774f1..b866ed27f40e4756d2c61341047f6ca84b8ccffd 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 ()
 {