]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Better coverage output.
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 7 Jan 2014 16:29:29 +0000 (16:29 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Thu, 9 Jan 2014 14:17:31 +0000 (15:17 +0100)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12043 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=15f3ecf8b59f74d65d3382c729034790650f6264

progsvm.h
prvm_cmds.c
prvm_exec.c
prvm_execprogram.h

index fb40545e8fbca2bbdd4097d2c919e613253bff9e..02cb4beadab9ba924ebba202b7a7c58984ac7cc5 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -897,6 +897,6 @@ void VM_FrameBlendFromFrameGroupBlend(frameblend_t *frameblend, const framegroup
 void VM_UpdateEdictSkeleton(prvm_prog_t *prog, prvm_edict_t *ed, const dp_model_t *edmodel, const frameblend_t *frameblend);
 void VM_RemoveEdictSkeleton(prvm_prog_t *prog, prvm_edict_t *ed);
 
-void PRVM_ExplicitCoverageEvent(prvm_prog_t *prog, int statement);
+void PRVM_ExplicitCoverageEvent(prvm_prog_t *prog, mfunction_t *func, int statement);
 
 #endif
index e375a50da8a205f0d1b9c1d567171fcbab788c76..3b8a629d40067aa1380f593c6884a442548cca11 100644 (file)
@@ -7346,5 +7346,5 @@ void VM_coverage(prvm_prog_t *prog)
 {
        VM_SAFEPARMCOUNT(0, VM_coverage);
        if (prog->explicit_profile[prog->xstatement]++ == 0 && (prvm_coverage.integer & 2))
-               PRVM_ExplicitCoverageEvent(prog, prog->xstatement);
+               PRVM_ExplicitCoverageEvent(prog, prog->xfunction, prog->xstatement);
 }
index 1be07894330e569c26fc0e40c6cb274218a7d9a1..b926f26c4590fe8282bbc149c870dfc12a902124 100644 (file)
@@ -685,20 +685,35 @@ void PRVM_Init_Exec(prvm_prog_t *prog)
 Coverage
 ==================
 */
+// Note: in these two calls, prog->xfunction is assumed to be sane.
+static const char *PRVM_WhereAmI(char *buf, size_t bufsize, prvm_prog_t *prog, mfunction_t *func, int statement)
+{
+       if (prog->statement_linenums)
+       {
+               if (prog->statement_columnnums)
+                       return va(buf, bufsize, "%s:%i:%i(%s, %i)", PRVM_GetString(prog, func->s_file), prog->statement_linenums[statement], prog->statement_columnnums[statement], PRVM_GetString(prog, func->s_name), statement - func->first_statement);
+               else
+                       return va(buf, bufsize, "%s:%i(%s, %i)", PRVM_GetString(prog, func->s_file), prog->statement_linenums[statement], PRVM_GetString(prog, func->s_name), statement - func->first_statement);
+       }
+       else
+               return va(buf, bufsize, "%s(%s, %i)", PRVM_GetString(prog, func->s_file), PRVM_GetString(prog, func->s_name), statement - func->first_statement);
+}
 static void PRVM_FunctionCoverageEvent(prvm_prog_t *prog, mfunction_t *func)
 {
        ++prog->functions_covered;
        Con_Printf("prvm_coverage: %s just called %s for the first time. Coverage: %.2f%%.\n", prog->name, PRVM_GetString(prog, func->s_name), prog->functions_covered * 100.0 / prog->numfunctions);
 }
-void PRVM_ExplicitCoverageEvent(prvm_prog_t *prog, int statement)
+void PRVM_ExplicitCoverageEvent(prvm_prog_t *prog, mfunction_t *func, int statement)
 {
+       char vabuf[128];
        ++prog->explicit_covered;
-       Con_Printf("prvm_coverage: %s just executed a coverage() statement for the first time. Coverage: %.2f%%.\n", prog->name, prog->explicit_covered * 100.0 / prog->numexplicitcoveragestatements);
+       Con_Printf("prvm_coverage: %s just executed a coverage() statement at %s for the first time. Coverage: %.2f%%.\n", prog->name, PRVM_WhereAmI(vabuf, sizeof(vabuf), prog, func, statement), prog->explicit_covered * 100.0 / prog->numexplicitcoveragestatements);
 }
-static void PRVM_StatementCoverageEvent(prvm_prog_t *prog, int statement)
+static void PRVM_StatementCoverageEvent(prvm_prog_t *prog, mfunction_t *func, int statement)
 {
+       char vabuf[128];
        ++prog->statements_covered;
-       Con_Printf("prvm_coverage: %s just executed a statement for the first time. Coverage: %.2f%%.\n", prog->name, prog->statements_covered * 100.0 / prog->numstatements);
+       Con_Printf("prvm_coverage: %s just executed a statement at %s for the first time. Coverage: %.2f%%.\n", prog->name, PRVM_WhereAmI(vabuf, sizeof(vabuf), prog, func, statement), prog->statements_covered * 100.0 / prog->numstatements);
 }
 
 
index ea2ba3749fa85b2351ffaa5e9dc562b75ddef845..d7182fc7f2fe620b617b4256cde8fdd9d56e1e10 100644 (file)
@@ -37,7 +37,7 @@
                        if (prog->trace)
                                PRVM_PrintStatement(prog, st);
                        if (prog->statement_profile[st - cached_statements]++ == 0 && (prvm_coverage.integer & 4))
-                               PRVM_StatementCoverageEvent(prog, st - cached_statements);
+                               PRVM_StatementCoverageEvent(prog, prog->xfunction, st - cached_statements);
                        if (prog->break_statement >= 0)
                                if ((st - cached_statements) == prog->break_statement)
                                {