351 opname = valuebuf,
dpsnprintf(valuebuf,
sizeof(valuebuf),
"OPCODE_%u", (
unsigned)s->
op);
376 int i, firststatement, endstatement;
385 if (firststatement < 0)
387 Con_Printf(
"%s progs: function %s is builtin #%i\n", prog->
name,
name, -firststatement);
400 for (
i = firststatement;
i < endstatement;
i++)
407 Con_Printf(
"Collecting statement coverage, not flushing statement profile.\n");
421 Con_Printf(
"usage: prvm_printfunction <program name> <function name>\n");
494 if (p ==
buf + bufsize)
506 double newprofiletime;
534 Con_Printf(
" - used by QC code of this VM: %9.4f\n", sum);
549 Con_Printf(
"%s Profile:\n[CallCount] [Time] [BuiltinTm] [Statement] [BuiltinCt] [TimeTotal] [StmtTotal] [BltnTotal] [self]\n", prog->
name );
552 Con_Printf(
"%s Profile:\n[CallCount] [Statement] [BuiltinCt] [StmtTotal] [BltnTotal] [self]\n", prog->
name );
567 if(
f->first_statement < 0)
579 max =
f->tprofile_total;
588 max =
f->tprofile +
f->tbprofile;
597 if (
max < f->profile_total +
f->builtinsprofile_total +
f->callcount)
599 max =
f->profile_total +
f->builtinsprofile_total +
f->callcount;
605 if (
max < f->profile +
f->builtinsprofile +
f->callcount)
607 max =
f->profile +
f->builtinsprofile +
f->callcount;
615 if (num < maxfunctions && max > mintime)
623 Con_Printf(
"%11.0f %11.6f %11.6f %11.0f %11.0f %11.6f %11.0f %11.0f %6.2f%% %s\n", best->
callcount, best->
tprofile, best->
tbprofile, best->
profile, best->
builtinsprofile, best->
tprofile_total, best->
profile_total, best->
builtinsprofile_total, (best->
tprofile_total > 0) ? ((best->
tprofile) * 100.0 / (best->
tprofile_total)) : -99.99,
PRVM_GetString(prog, best->
s_name));
658 Con_Print(
"prvm_callprofile <program name>\n");
681 Con_Printf(
"Collecting function coverage, cannot profile - sorry!\n");
690 Con_Print(
"prvm_profile <program name>\n");
707 Con_Printf(
"Collecting function coverage, cannot profile - sorry!\n");
716 Con_Print(
"prvm_childprofile <program name>\n");
731 if (stack_index > 0 && stack_index <= prog->
depth)
742 for (
i = -7;
i <= 0;
i++)
804 prog->
error_cmd(
"PRVM_EnterFunction: NULL function in %s", prog->
name);
818 prog->
error_cmd(
"PRVM_ExecuteProgram: locals stack overflow in %s", prog->
name);
820 for (
i=0 ;
i < c ;
i++)
826 for (
i=0 ;
i<
f->numparms ;
i++)
828 for (j=0 ; j<
f->parm_size[
i] ; j++)
837 return f->first_statement - 1;
850 if (prog->
depth <= 0)
854 prog->
error_cmd(
"PR_LeaveFunction: NULL function in %s", prog->
name);
859 prog->
error_cmd(
"PRVM_ExecuteProgram: locals stack underflow in %s", prog->
name);
861 for (
i=0 ;
i < c ;
i++)
912 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);
937#if defined (__GNUC__) || (__clang__) || (__TINYC__)
938# ifndef CONFIG_PEDANTIC
939# define HAVE_COMPUTED_GOTOS 1
943#define OPA ((prvm_eval_t *)&globals[st->operand[0]])
944#define OPB ((prvm_eval_t *)&globals[st->operand[1]])
945#define OPC ((prvm_eval_t *)&globals[st->operand[2]])
951#define PRVM_GLOBALSBASE 0x80000000
954#define CACHE_UNCHANGING() \
955 mstatement_t *cached_statements = prog->statements; \
956 qbool cached_allowworldwrites = prog->allowworldwrites; \
957 unsigned int cached_flag = prog->flag; \
958 unsigned int cached_vmglobals = prog->numglobals; \
959 unsigned int cached_vmglobals_1 = prog->numglobals - 1; \
960 unsigned int cached_vmglobals_2 = prog->numglobals - 2; \
961 unsigned int cached_vmglobals_3 = prog->numglobals - 3; \
962 unsigned int cached_vmglobal1 = PRVM_GLOBALSBASE + 1; \
963 unsigned int cached_vmentity0start = PRVM_GLOBALSBASE + prog->numglobals; \
964 unsigned int cached_vmentity1start = cached_vmentity0start + prog->entityfields; \
965 unsigned int cached_entityfields = prog->entityfields; \
966 unsigned int cached_entityfields_2 = prog->entityfields - 2; \
967 prvm_vec_t *globals = prog->globals.fp; \
968 prvm_vec_t *global1 = prog->globals.fp + 1
971#define CACHE_CHANGING(DECLARE) \
972 DECLARE(prvm_vec_t *) cached_edictsfields = prog->edictsfields.fp; \
973 DECLARE(prvm_vec_t *) cached_edictsfields_entity1 = cached_edictsfields + prog->entityfields; \
974 DECLARE(unsigned int) cached_entityfieldsarea = prog->entityfieldsarea; \
975 DECLARE(unsigned int) cached_entityfieldsarea_2 = prog->entityfieldsarea - 2; \
976 DECLARE(unsigned int) cached_entityfieldsarea_entityfields = prog->entityfieldsarea - prog->entityfields; \
977 DECLARE(unsigned int) cached_entityfieldsarea_entityfields_2 = prog->entityfieldsarea - prog->entityfields - 2; \
978 DECLARE(unsigned int) cached_max_edicts = prog->max_edicts
980#define DO_DECLARE(t) t
990void MVM_ExecuteProgram (
prvm_prog_t *prog,
func_t fnum,
const char *errormessage)
996 int jumpcount, cachedpr_trace, exitdepth;
997 int restorevm_tempstringsbuf_cursize;
1010 prog->
error_cmd(
"MVM_ExecuteProgram: %s", errormessage);
1021 exitdepth = prog->
depth;
1037 cachedpr_trace = prog->
trace;
1040#define PRVMSLOWINTERPRETER 1
1043#define PRVMTIMEPROFILING 1
1045#undef PRVMTIMEPROFILING
1051#undef PRVMSLOWINTERPRETER
1057#define PRVMTIMEPROFILING 1
1059#undef PRVMTIMEPROFILING
1073 tm =
Sys_DirtyTime() - calltime;
if (tm < 0 || tm >= 1800) tm = 0;
1092 int jumpcount, cachedpr_trace, exitdepth;
1093 int restorevm_tempstringsbuf_cursize;
1106 prog->
error_cmd(
"CLVM_ExecuteProgram: %s", errormessage);
1117 exitdepth = prog->
depth;
1133 cachedpr_trace = prog->
trace;
1136#define PRVMSLOWINTERPRETER 1
1139#define PRVMTIMEPROFILING 1
1141#undef PRVMTIMEPROFILING
1147#undef PRVMSLOWINTERPRETER
1153#define PRVMTIMEPROFILING 1
1155#undef PRVMTIMEPROFILING
1169 tm =
Sys_DirtyTime() - calltime;
if (tm < 0 || tm >= 1800) tm = 0;
1185void PRVM_ExecuteProgram (
prvm_prog_t *prog,
func_t fnum,
const char *errormessage)
1192 int jumpcount, cachedpr_trace, exitdepth;
1193 int restorevm_tempstringsbuf_cursize;
1206 prog->
error_cmd(
"SVVM_ExecuteProgram: %s", errormessage);
1217 exitdepth = prog->
depth;
1233 cachedpr_trace = prog->
trace;
1236#define PRVMSLOWINTERPRETER 1
1239#define PRVMTIMEPROFILING 1
1241#undef PRVMTIMEPROFILING
1247#undef PRVMSLOWINTERPRETER
1253#define PRVMTIMEPROFILING 1
1255#undef PRVMTIMEPROFILING
1269 tm =
Sys_DirtyTime() - calltime;
if (tm < 0 || tm >= 1800) tm = 0;
static int Cmd_Argc(cmd_state_t *cmd)
static const char * Cmd_Argv(cmd_state_t *cmd, int arg)
Cmd_Argv(cmd, ) will return an empty string (not a NULL) if arg > argc, so string operations are alwa...
char * va(char *buf, size_t buflen, const char *format,...)
char * dp_stpecpy(char *dst, char *end, const char *src)
Chain-copies a string with truncation and efficiency (compared to strlcat()).
int dpsnprintf(char *buffer, size_t buffersize, const char *format,...)
Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't ...
#define dp_strlcpy(dst, src, dsize)
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
static int(ZEXPORT *qz_inflate)(z_stream *strm
GLint GLenum GLsizei GLsizei GLsizei depth
GLenum GLuint GLenum GLsizei const GLchar * buf
#define PRVM_clientfunction(funcname)
mfunction_t * PRVM_ED_FindFunction(prvm_prog_t *prog, const char *name)
const char * PRVM_GetString(prvm_prog_t *prog, int num)
void PRVM_Prog_Reset(prvm_prog_t *prog)
#define PRVM_MAX_STACK_DEPTH
prvm_prog_t * PRVM_FriendlyProgFromString(const char *str)
for console commands (prints error if name unknown and returns NULL, prints error if prog not loaded ...
#define PRVM_PROG_TO_EDICT(n)
char * PRVM_GlobalString(prvm_prog_t *prog, int ofs, char *line, size_t linelength)
#define PRVM_LOCALSTACK_SIZE
#define PRVM_serverfunction(funcname)
#define PRVM_allglobaledict(fieldname)
void PRVM_ED_Print(prvm_prog_t *prog, prvm_edict_t *ed, const char *wildcard_fieldname)
static void PRVM_StatementCoverageEvent(prvm_prog_t *prog, mfunction_t *func, int statement)
cvar_t prvm_gameplayfix_div0is0
void PRVM_ChildProfile_f(cmd_state_t *cmd)
void PRVM_Init_Exec(prvm_prog_t *prog)
#define CACHE_UNCHANGING()
cvar_t prvm_timeprofiling
static const char * PRVM_WhereAmI(char *buf, size_t bufsize, prvm_prog_t *prog, mfunction_t *func, int statement)
#define CACHE_CHANGING(DECLARE)
static void PRVM_FunctionCoverageEvent(prvm_prog_t *prog, mfunction_t *func)
void PRVM_PrintFunction_f(cmd_state_t *cmd)
void SVVM_ExecuteProgram(prvm_prog_t *prog, func_t fnum, const char *errormessage)
cvar_t prvm_statementprofiling
static int PRVM_EnterFunction(prvm_prog_t *prog, mfunction_t *f)
static void PRVM_CallProfile(prvm_prog_t *prog)
void PRVM_ExplicitCoverageEvent(prvm_prog_t *prog, mfunction_t *func, int statement)
void PRVM_Profile_f(cmd_state_t *cmd)
void CLVM_ExecuteProgram(prvm_prog_t *prog, func_t fnum, const char *errormessage)
void PRVM_Profile(prvm_prog_t *prog, int maxfunctions, double mintime, int sortby)
void PRVM_PrintFunctionStatements(prvm_prog_t *prog, const char *name)
void PRVM_CallProfile_f(cmd_state_t *cmd)
static int PRVM_LeaveFunction(prvm_prog_t *prog)
void PRVM_StackTrace(prvm_prog_t *prog)
void PRVM_PrintState(prvm_prog_t *prog, int stack_index)
static const char * prvm_opnames[]
void PRVM_ShortStackTrace(prvm_prog_t *prog, char *buf, size_t bufsize)
static void PRVM_PrintStatement(prvm_prog_t *prog, mstatement_t *s)
#define MAX_INPUTLINE
maximum size of console commandline, QuakeC strings, and many other text processing buffers
void SV_FlushBroadcastMessages(void)
void SV_Savegame_to(prvm_prog_t *prog, const char *name)
command interpreter state - the tokenizing and execution of commands, as well as pointers to which cv...
double builtinsprofile_total
const char * statestring
printed together with backtraces
int * statement_linenums
NULL if not available.
const char * name
name of the prog, e.g. "Server", "Client" or "Menu" (used for text output)
void(* error_cmd)(const char *format,...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN
[INIT]
prvm_stack_t stack[PRVM_MAX_STACK_DEPTH+1]
stacktrace writes into stack[MAX_STACK_DEPTH] thus increase the array, so depth wont be overwritten
prvm_int_t localstack[PRVM_LOCALSTACK_SIZE]
double * statement_profile
only incremented if prvm_statementprofiling is on
etype_t watch_global_type
mstatement_t * statements
sizebuf_t tempstringsbuf
buffer for storing all tempstrings created during one invocation of ExecuteProgram
int numexplicitcoveragestatements
union prvm_prog_t::@31 globals
double profiletime
system time when last PRVM_CallProfile was called (or PRVM_Prog_Load initially)
int * statement_columnnums
NULL if not available.
double builtinsprofile_acc
double Sys_DirtyTime(void)