]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
print out profile report above runaway loop counter error
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 25 Jul 2006 10:38:17 +0000 (10:38 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 25 Jul 2006 10:38:17 +0000 (10:38 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6526 d7cf8633-e32d-0410-b094-e92efae38249

progsvm.h
prvm_exec.c
prvm_execprogram.h

index 8270615d4fd830aa5256302a42364b9a99e63997..77cf410949b26c829e91aa2eb1c44fe262979f53 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -429,6 +429,7 @@ void *_PRVM_Alloc (size_t buffersize, const char *filename, int fileline);
 void _PRVM_Free (void *buffer, const char *filename, int fileline);
 void _PRVM_FreeAll (const char *filename, int fileline);
 
+void PRVM_Profile (int maxfunctions, int mininstructions);
 void PRVM_Profile_f (void);
 void PRVM_PrintFunction_f (void);
 
index e7fb591a04550789d74c5e709c6d699aa842d70b..eab6a2fdf2e51d2d9851dafd376d47b96bd6f926 100644 (file)
@@ -266,31 +266,12 @@ void PRVM_StackTrace (void)
 }
 
 
-/*
-============
-PRVM_Profile_f
-
-============
-*/
-void PRVM_Profile_f (void)
+void PRVM_Profile (int maxfunctions, int mininstructions)
 {
        mfunction_t *f, *best;
-       int i, num, howmany;
+       int i, num;
        double max;
 
-       howmany = 1<<30;
-       if (Cmd_Argc() == 3)
-               howmany = atoi(Cmd_Argv(2));
-       else if (Cmd_Argc() != 2)
-       {
-               Con_Print("prvm_profile <program name>\n");
-               return;
-       }
-
-       PRVM_Begin;
-       if(!PRVM_SetProgFromString(Cmd_Argv(1)))
-               return;
-
        Con_Printf( "%s Profile:\n[CallCount] [Statements] [BuiltinCost]\n", PRVM_NAME );
 
        num = 0;
@@ -309,7 +290,7 @@ void PRVM_Profile_f (void)
                }
                if (best)
                {
-                       if (num < howmany)
+                       if (num < maxfunctions && max >= mininstructions)
                        {
                                if (best->first_statement < 0)
                                        Con_Printf("%9.0f ----- builtin ----- %s\n", best->callcount, PRVM_GetString(best->s_name));
@@ -322,6 +303,32 @@ void PRVM_Profile_f (void)
                        best->callcount = 0;
                }
        } while (best);
+}
+
+/*
+============
+PRVM_Profile_f
+
+============
+*/
+void PRVM_Profile_f (void)
+{
+       int howmany;
+
+       howmany = 1<<30;
+       if (Cmd_Argc() == 3)
+               howmany = atoi(Cmd_Argv(2));
+       else if (Cmd_Argc() != 2)
+       {
+               Con_Print("prvm_profile <program name>\n");
+               return;
+       }
+
+       PRVM_Begin;
+       if(!PRVM_SetProgFromString(Cmd_Argv(1)))
+               return;
+
+       PRVM_Profile(howmany, 1);
 
        PRVM_End;
 }
index aa72801c45bca0f9c714d7c71f1218053f38da55..b9504c84e493a06c1c63b8bb9a826cd3d1ff8926 100644 (file)
                                        if (++jumpcount == 10000000)
                                        {
                                                prog->xstatement = st - prog->statements;
-                                               PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: if having trouble identifying the problem, try typing profile now in %s", jumpcount, PRVM_NAME);
+                                               PRVM_Profile(1<<30, 1000000);
+                                               PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", jumpcount, PRVM_NAME);
                                        }
                                }
                                break;
                                        if (++jumpcount == 10000000)
                                        {
                                                prog->xstatement = st - prog->statements;
-                                               PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: if having trouble identifying the problem, try typing profile now in %s", jumpcount, PRVM_NAME);
+                                               PRVM_Profile(1<<30, 1000000);
+                                               PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", jumpcount, PRVM_NAME);
                                        }
                                }
                                break;
                                if (++jumpcount == 10000000)
                                {
                                        prog->xstatement = st - prog->statements;
-                                       PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: if having trouble identifying the problem, try typing profile now in %s", jumpcount, PRVM_NAME);
+                                       PRVM_Profile(1<<30, 1000000);
+                                       PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", jumpcount, PRVM_NAME);
                                }
                                break;