+void PRVM_PrintFunctionStatements (const char *name)
+{
+ int i, firststatement, endstatement;
+ mfunction_t *func;
+ func = PRVM_ED_FindFunction (name);
+ if (!func)
+ {
+ Con_Printf("%s progs: no function named %s\n", PRVM_NAME, name);
+ return;
+ }
+ firststatement = func->first_statement;
+ if (firststatement < 0)
+ {
+ Con_Printf("%s progs: function %s is builtin #%i\n", PRVM_NAME, name, -firststatement);
+ return;
+ }
+
+ // find the end statement
+ endstatement = prog->progs->numstatements;
+ for (i = 0;i < prog->progs->numfunctions;i++)
+ if (endstatement > prog->functions[i].first_statement && firststatement < prog->functions[i].first_statement)
+ endstatement = prog->functions[i].first_statement;
+
+ // now print the range of statements
+ Con_Printf("%s progs: disassembly of function %s (statements %i-%i):\n", PRVM_NAME, name, firststatement, endstatement);
+ for (i = firststatement;i < endstatement;i++)
+ {
+ PRVM_PrintStatement(prog->statements + i);
+ prog->statement_profile[i] = 0;
+ }
+}
+
+/*
+============
+PRVM_PrintFunction_f
+
+============
+*/
+void PRVM_PrintFunction_f (void)
+{
+ if (Cmd_Argc() != 3)
+ {
+ Con_Printf("usage: prvm_printfunction <program name> <function name>\n");
+ return;
+ }
+
+ PRVM_Begin;
+ if(!PRVM_SetProgFromString(Cmd_Argv(1)))
+ return;
+
+ PRVM_PrintFunctionStatements(Cmd_Argv(2));
+
+ PRVM_End;
+}
+