]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_execprogram.h
Add an in_releaseall command for debugging/working around stuck keys.
[xonotic/darkplaces.git] / prvm_execprogram.h
index b87cfcf91b3fb0e74cb822addd1122754391194b..6578d78902de24c88a91ea591cf09366eaeaa7f6 100644 (file)
@@ -1,6 +1,14 @@
-// NEED to reset startst after calling this!
+// NEED to reset startst after calling this! startst may or may not be clobbered!
 #define ADVANCE_PROFILE_BEFORE_JUMP() \
-       prog->xfunction->profile += (st - startst)
+       prog->xfunction->profile += (st - startst); \
+       if (prvm_statementprofiling.integer || (prvm_coverage.integer & 4)) { \
+               /* All statements from startst+1 to st have been hit. */ \
+               while (++startst <= st) { \
+                       if (prog->statement_profile[startst - cached_statements]++ == 0 && (prvm_coverage.integer & 4)) \
+                               PRVM_StatementCoverageEvent(prog, prog->xfunction, startst - cached_statements); \
+               } \
+               /* Observe: startst now is clobbered (now at st+1)! */ \
+       }
 
 #ifdef PRVMTIMEPROFILING
 #define PRE_ERROR() \
                {
                        if (prog->watch_global_type != ev_void)
                        {
-                               prvm_eval_t *f = PRVM_GLOBALFIELDVALUE(prog->watch_global);
+                               prvm_eval_t *g = PRVM_GLOBALFIELDVALUE(prog->watch_global);
                                prog->xstatement = st + 1 - cached_statements;
-                               PRVM_Watchpoint(prog, 1, "Global watchpoint hit by engine", prog->watch_global_type, &prog->watch_global_value, f);
+                               PRVM_Watchpoint(prog, 1, "Global watchpoint hit by engine", prog->watch_global_type, &prog->watch_global_value, g);
                        }
                        if (prog->watch_field_type != ev_void && prog->watch_edict < prog->max_edicts)
                        {
-                               prvm_eval_t *f = PRVM_EDICTFIELDVALUE(prog->edicts + prog->watch_edict, prog->watch_field);
+                               prvm_eval_t *g = PRVM_EDICTFIELDVALUE(prog->edicts + prog->watch_edict, prog->watch_field);
                                prog->xstatement = st + 1 - cached_statements;
-                               PRVM_Watchpoint(prog, 1, "Entityfield watchpoint hit by engine", prog->watch_field_type, &prog->watch_edictfield_value, f);
+                               PRVM_Watchpoint(prog, 1, "Entityfield watchpoint hit by engine", prog->watch_field_type, &prog->watch_edictfield_value, g);
                        }
                }
 #endif
 #if PRVMSLOWINTERPRETER
                        if (prog->trace)
                                PRVM_PrintStatement(prog, st);
-                       if (prog->statement_profile[st - cached_statements]++ == 0 && (prvm_coverage.integer & 4))
-                               PRVM_StatementCoverageEvent(prog, prog->xfunction, st - cached_statements);
                        if (prog->break_statement >= 0)
                                if ((st - cached_statements) == prog->break_statement)
                                {
                                        goto cleanup;
                                }
 
-                               newf = &prog->functions[OPA->function];
-                               if (newf->callcount++ == 0 && (prvm_coverage.integer & 1))
-                                       PRVM_FunctionCoverageEvent(prog, newf);
+                               enterfunc = &prog->functions[OPA->function];
+                               if (enterfunc->callcount++ == 0 && (prvm_coverage.integer & 1))
+                                       PRVM_FunctionCoverageEvent(prog, enterfunc);
 
-                               if (newf->first_statement < 0)
+                               if (enterfunc->first_statement < 0)
                                {
                                        // negative first_statement values are built in functions
-                                       int builtinnumber = -newf->first_statement;
+                                       int builtinnumber = -enterfunc->first_statement;
                                        prog->xfunction->builtinsprofile++;
                                        if (builtinnumber < prog->numbuiltins && prog->builtins[builtinnumber])
                                        {
                                                prog->builtins[builtinnumber](prog);
 #ifdef PRVMTIMEPROFILING 
                                                tm = Sys_DirtyTime();
-                                               newf->tprofile += (tm - starttm >= 0 && tm - starttm < 1800) ? (tm - starttm) : 0;
+                                               enterfunc->tprofile += (tm - starttm >= 0 && tm - starttm < 1800) ? (tm - starttm) : 0;
                                                prog->xfunction->tbprofile += (tm - starttm >= 0 && tm - starttm < 1800) ? (tm - starttm) : 0;
                                                starttm = tm;
 #endif
                                                prog->error_cmd("No such builtin #%i in %s; most likely cause: outdated engine build. Try updating!", builtinnumber, prog->name);
                                }
                                else
-                                       st = cached_statements + PRVM_EnterFunction(prog, newf);
+                                       st = cached_statements + PRVM_EnterFunction(prog, enterfunc);
                                startst = st;
                                DISPATCH_OPCODE();
 
                        {
                                if (prog->watch_global_type != ev_void)
                                {
-                                       prvm_eval_t *f = PRVM_GLOBALFIELDVALUE(prog->watch_global);
+                                       prvm_eval_t *g = PRVM_GLOBALFIELDVALUE(prog->watch_global);
                                        prog->xstatement = st - cached_statements;
-                                       PRVM_Watchpoint(prog, 0, "Global watchpoint hit", prog->watch_global_type, &prog->watch_global_value, f);
+                                       PRVM_Watchpoint(prog, 0, "Global watchpoint hit", prog->watch_global_type, &prog->watch_global_value, g);
                                }
                                if (prog->watch_field_type != ev_void && prog->watch_edict < prog->max_edicts)
                                {
-                                       prvm_eval_t *f = PRVM_EDICTFIELDVALUE(prog->edicts + prog->watch_edict, prog->watch_field);
+                                       prvm_eval_t *g = PRVM_EDICTFIELDVALUE(prog->edicts + prog->watch_edict, prog->watch_field);
                                        prog->xstatement = st - cached_statements;
-                                       PRVM_Watchpoint(prog, 0, "Entityfield watchpoint hit", prog->watch_field_type, &prog->watch_edictfield_value, f);
+                                       PRVM_Watchpoint(prog, 0, "Entityfield watchpoint hit", prog->watch_field_type, &prog->watch_edictfield_value, g);
                                }
                        }
 #endif