From: havoc Date: Tue, 25 Jul 2006 10:38:17 +0000 (+0000) Subject: print out profile report above runaway loop counter error X-Git-Tag: xonotic-v0.1.0preview~3854 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=bfbb9768c6b272aae8677be8a7b3219d7bcc56e3;p=xonotic%2Fdarkplaces.git print out profile report above runaway loop counter error git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6526 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/progsvm.h b/progsvm.h index 8270615d..77cf4109 100644 --- 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); diff --git a/prvm_exec.c b/prvm_exec.c index e7fb591a..eab6a2fd 100644 --- a/prvm_exec.c +++ b/prvm_exec.c @@ -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 \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 \n"); + return; + } + + PRVM_Begin; + if(!PRVM_SetProgFromString(Cmd_Argv(1))) + return; + + PRVM_Profile(howmany, 1); PRVM_End; } diff --git a/prvm_execprogram.h b/prvm_execprogram.h index aa72801c..b9504c84 100644 --- a/prvm_execprogram.h +++ b/prvm_execprogram.h @@ -232,7 +232,8 @@ 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; @@ -246,7 +247,8 @@ 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; @@ -258,7 +260,8 @@ 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;