From 48dd658f8bbfa60efbd5f56d1c208727c4418078 Mon Sep 17 00:00:00 2001 From: divverent Date: Mon, 6 Jan 2014 10:00:04 +0000 Subject: [PATCH] Patch by graphitemaster to support column number enhanced lno format. From: Dale Weiler git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12040 d7cf8633-e32d-0410-b094-e92efae38249 --- progsvm.h | 1 + prvm_edict.c | 9 ++++++++- prvm_exec.c | 14 ++++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/progsvm.h b/progsvm.h index acaf6df0..e1fd5055 100644 --- a/progsvm.h +++ b/progsvm.h @@ -562,6 +562,7 @@ typedef struct prvm_prog_s int numglobals; int *statement_linenums; // NULL if not available + int *statement_columnnums; // NULL if not available double *statement_profile; // only incremented if prvm_statementprofiling is on diff --git a/prvm_edict.c b/prvm_edict.c index 12781fdc..882a558a 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -1887,7 +1887,14 @@ static void PRVM_LoadLNO( prvm_prog_t *prog, const char *progname ) { (unsigned int)LittleLong( header[ 5 ] ) == (unsigned int)prog->progs_numstatements ) { prog->statement_linenums = (int *)Mem_Alloc(prog->progs_mempool, prog->progs_numstatements * sizeof( int ) ); - memcpy( prog->statement_linenums, (int *) lno + 6, prog->progs_numstatements * sizeof( int ) ); + memcpy( prog->statement_linenums, header + 6, prog->progs_numstatements * sizeof( int ) ); + + /* gmqcc suports columnums */ + if ((unsigned int)filesize > ((6 + 2 * prog->progs_numstatements) * sizeof( int ))) + { + prog->statement_columnnums = (int *)Mem_Alloc(prog->progs_mempool, prog->progs_numstatements * sizeof( int ) ); + memcpy( prog->statement_columnnums, header + 6 + prog->progs_numstatements, prog->progs_numstatements * sizeof( int ) ); + } } Mem_Free( lno ); } diff --git a/prvm_exec.c b/prvm_exec.c index fee9d829..40b19d44 100644 --- a/prvm_exec.c +++ b/prvm_exec.c @@ -129,7 +129,12 @@ static void PRVM_PrintStatement(prvm_prog_t *prog, mstatement_t *s) Con_Printf("s%i: ", opnum); if( prog->statement_linenums ) - Con_Printf( "%s:%i: ", PRVM_GetString( prog, prog->xfunction->s_file ), prog->statement_linenums[ opnum ] ); + { + if ( prog->statement_columnnums ) + Con_Printf( "%s:%i:%i: ", PRVM_GetString( prog, prog->xfunction->s_file ), prog->statement_linenums[ opnum ], prog->statement_columnnums[ opnum ] ); + else + Con_Printf( "%s:%i: ", PRVM_GetString( prog, prog->xfunction->s_file ), prog->statement_linenums[ opnum ] ); + } if (prvm_statementprofiling.integer) Con_Printf("%7.0f ", prog->statement_profile[s - prog->statements]); @@ -226,7 +231,12 @@ void PRVM_StackTrace (prvm_prog_t *prog) else { if (prog->statement_linenums) - Con_Printf("%12s:%i : %s : statement %i\n", PRVM_GetString(prog, f->s_file), prog->statement_linenums[prog->stack[i].s], PRVM_GetString(prog, f->s_name), prog->stack[i].s - f->first_statement); + { + if (prog->statement_columnnums) + Con_Printf("%12s:%i:%i : %s : statement %i\n", PRVM_GetString(prog, f->s_file), prog->statement_linenums[prog->stack[i].s], prog->statement_columnnums[prog->stack[i].s], PRVM_GetString(prog, f->s_name), prog->stack[i].s - f->first_statement); + else + Con_Printf("%12s:%i : %s : statement %i\n", PRVM_GetString(prog, f->s_file), prog->statement_linenums[prog->stack[i].s], PRVM_GetString(prog, f->s_name), prog->stack[i].s - f->first_statement); + } else Con_Printf("%12s : %s : statement %i\n", PRVM_GetString(prog, f->s_file), PRVM_GetString(prog, f->s_name), prog->stack[i].s - f->first_statement); } -- 2.39.2