mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-19 07:20:50 +00:00
[gamecode] Be more informative with function calls
PR_EnterFunction and PR_LeaveFunction now print the entered/left/returned function when tracing. Makes debugging obj code much easier.
This commit is contained in:
parent
30519e93fb
commit
753d183d82
1 changed files with 19 additions and 2 deletions
|
@ -188,6 +188,11 @@ PR_EnterFunction (progs_t *pr, bfunction_t *f)
|
|||
pr_type_t *dstParams[MAX_PARMS];
|
||||
pointer_t paramofs = 0;
|
||||
|
||||
if (pr->pr_trace) {
|
||||
Sys_Printf ("Entering function %s\n",
|
||||
PR_GetString (pr, f->descriptor->s_name));
|
||||
}
|
||||
|
||||
PR_PushFrame (pr);
|
||||
|
||||
if (f->numparms > 0) {
|
||||
|
@ -268,12 +273,24 @@ PR_EnterFunction (progs_t *pr, bfunction_t *f)
|
|||
}
|
||||
|
||||
static void
|
||||
PR_LeaveFunction (progs_t *pr)
|
||||
PR_LeaveFunction (progs_t *pr, int to_engine)
|
||||
{
|
||||
bfunction_t *f = pr->pr_xfunction;
|
||||
|
||||
PR_PopFrame (pr);
|
||||
|
||||
if (pr->pr_trace) {
|
||||
Sys_Printf ("Leaving function %s\n",
|
||||
PR_GetString (pr, f->descriptor->s_name));
|
||||
if (to_engine) {
|
||||
Sys_Printf ("Returning to engine\n");
|
||||
} else {
|
||||
bfunction_t *rf = pr->pr_xfunction;
|
||||
Sys_Printf ("Returning to function %s\n",
|
||||
PR_GetString (pr, rf->descriptor->s_name));
|
||||
}
|
||||
}
|
||||
|
||||
// restore locals from the stack
|
||||
pr->localstack_used -= f->locals;
|
||||
if (pr->localstack_used < 0)
|
||||
|
@ -1443,7 +1460,7 @@ op_call:
|
|||
case OP_RETURN_V:
|
||||
pr->pr_xfunction->profile += profile - startprofile;
|
||||
startprofile = profile;
|
||||
PR_LeaveFunction (pr);
|
||||
PR_LeaveFunction (pr, pr->pr_depth == exitdepth);
|
||||
st = pr->pr_statements + pr->pr_xstatement;
|
||||
if (pr->pr_depth == exitdepth) {
|
||||
if (pr->pr_trace && pr->pr_depth <= pr->pr_trace_depth)
|
||||
|
|
Loading…
Reference in a new issue