mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-06-01 17:12:15 +00:00
debug info for local variables is now used. only works when tracing atm:/
This commit is contained in:
parent
b23786880a
commit
edcc313501
5 changed files with 66 additions and 20 deletions
|
@ -176,6 +176,7 @@ unsigned long PR_Get_Lineno_Line (progs_t *pr, pr_lineno_t *lineno);
|
||||||
pr_lineno_t *PR_Find_Lineno (progs_t *pr, unsigned long addr);
|
pr_lineno_t *PR_Find_Lineno (progs_t *pr, unsigned long addr);
|
||||||
const char *PR_Get_Source_File (progs_t *pr, pr_lineno_t *lineno);
|
const char *PR_Get_Source_File (progs_t *pr, pr_lineno_t *lineno);
|
||||||
const char *PR_Get_Source_Line (progs_t *pr, unsigned long addr);
|
const char *PR_Get_Source_Line (progs_t *pr, unsigned long addr);
|
||||||
|
ddef_t *PR_Get_Local_Def (progs_t *pr, int offs);
|
||||||
|
|
||||||
extern struct cvar_s *pr_debug;
|
extern struct cvar_s *pr_debug;
|
||||||
|
|
||||||
|
@ -256,6 +257,7 @@ struct progs_s {
|
||||||
char *debugfile;
|
char *debugfile;
|
||||||
struct pr_debug_header_s *debug;
|
struct pr_debug_header_s *debug;
|
||||||
struct pr_auxfunction_s *auxfunctions;
|
struct pr_auxfunction_s *auxfunctions;
|
||||||
|
struct pr_auxfunction_s **auxfunction_map;
|
||||||
struct pr_lineno_s *linenos;
|
struct pr_lineno_s *linenos;
|
||||||
ddef_t *local_defs;
|
ddef_t *local_defs;
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,15 @@ PR_LoadDebug (progs_t *pr)
|
||||||
char *sym_path;
|
char *sym_path;
|
||||||
ddef_t *def;
|
ddef_t *def;
|
||||||
|
|
||||||
|
pr->debug = 0;
|
||||||
|
pr->auxfunctions = 0;
|
||||||
|
pr->auxfunction_map = 0;
|
||||||
|
pr->linenos = 0;
|
||||||
|
pr->local_defs = 0;
|
||||||
|
|
||||||
|
if (!pr_debug->int_val)
|
||||||
|
return;
|
||||||
|
|
||||||
def = PR_FindGlobal (pr, ".debug_file");
|
def = PR_FindGlobal (pr, ".debug_file");
|
||||||
if (def)
|
if (def)
|
||||||
str = &pr->pr_globals[def->ofs];
|
str = &pr->pr_globals[def->ofs];
|
||||||
|
@ -150,9 +159,6 @@ PR_LoadDebug (progs_t *pr)
|
||||||
pr->debug->version & 0xfff);
|
pr->debug->version & 0xfff);
|
||||||
Hunk_FreeToLowMark (start);
|
Hunk_FreeToLowMark (start);
|
||||||
pr->debug = 0;
|
pr->debug = 0;
|
||||||
pr->auxfunctions = 0;
|
|
||||||
pr->linenos = 0;
|
|
||||||
pr->local_defs = 0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pr->debug->crc = LittleShort (pr->debug->crc);
|
pr->debug->crc = LittleShort (pr->debug->crc);
|
||||||
|
@ -164,9 +170,6 @@ PR_LoadDebug (progs_t *pr)
|
||||||
pr->crc);
|
pr->crc);
|
||||||
Hunk_FreeToLowMark (start);
|
Hunk_FreeToLowMark (start);
|
||||||
pr->debug = 0;
|
pr->debug = 0;
|
||||||
pr->auxfunctions = 0;
|
|
||||||
pr->linenos = 0;
|
|
||||||
pr->local_defs = 0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pr->debug->you_tell_me_and_we_will_both_know = LittleShort (pr->debug->you_tell_me_and_we_will_both_know);
|
pr->debug->you_tell_me_and_we_will_both_know = LittleShort (pr->debug->you_tell_me_and_we_will_both_know);
|
||||||
|
@ -181,12 +184,17 @@ PR_LoadDebug (progs_t *pr)
|
||||||
pr->linenos = (pr_lineno_t*)((char*)pr->debug + pr->debug->linenos);
|
pr->linenos = (pr_lineno_t*)((char*)pr->debug + pr->debug->linenos);
|
||||||
pr->local_defs = (ddef_t*)((char*)pr->debug + pr->debug->locals);
|
pr->local_defs = (ddef_t*)((char*)pr->debug + pr->debug->locals);
|
||||||
|
|
||||||
|
pr->auxfunction_map = Hunk_Alloc (pr->progs->numfunctions
|
||||||
|
* sizeof (pr_auxfunction_t*));
|
||||||
|
|
||||||
for (i = 0; i < pr->debug->num_auxfunctions; i++) {
|
for (i = 0; i < pr->debug->num_auxfunctions; i++) {
|
||||||
pr->auxfunctions[i].function = LittleLong (pr->auxfunctions[i].function);
|
pr->auxfunctions[i].function = LittleLong (pr->auxfunctions[i].function);
|
||||||
pr->auxfunctions[i].source_line = LittleLong (pr->auxfunctions[i].source_line);
|
pr->auxfunctions[i].source_line = LittleLong (pr->auxfunctions[i].source_line);
|
||||||
pr->auxfunctions[i].line_info = LittleLong (pr->auxfunctions[i].line_info);
|
pr->auxfunctions[i].line_info = LittleLong (pr->auxfunctions[i].line_info);
|
||||||
pr->auxfunctions[i].local_defs = LittleLong (pr->auxfunctions[i].local_defs);
|
pr->auxfunctions[i].local_defs = LittleLong (pr->auxfunctions[i].local_defs);
|
||||||
pr->auxfunctions[i].num_locals = LittleLong (pr->auxfunctions[i].num_locals);
|
pr->auxfunctions[i].num_locals = LittleLong (pr->auxfunctions[i].num_locals);
|
||||||
|
|
||||||
|
pr->auxfunction_map[pr->auxfunctions[i].function] = &pr->auxfunctions[i];
|
||||||
}
|
}
|
||||||
for (i = 0; i < pr->debug->num_linenos; i++) {
|
for (i = 0; i < pr->debug->num_linenos; i++) {
|
||||||
pr->linenos[i].fa.func = LittleLong (pr->linenos[i].fa.func);
|
pr->linenos[i].fa.func = LittleLong (pr->linenos[i].fa.func);
|
||||||
|
@ -292,6 +300,27 @@ PR_Get_Source_Line (progs_t *pr, unsigned long addr)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ddef_t *
|
||||||
|
PR_Get_Local_Def (progs_t *pr, int offs)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
dfunction_t *func = pr->pr_xfunction;
|
||||||
|
pr_auxfunction_t *aux_func;
|
||||||
|
|
||||||
|
if (!func)
|
||||||
|
return 0;
|
||||||
|
aux_func = pr->auxfunction_map[func - pr->pr_functions];
|
||||||
|
if (!aux_func)
|
||||||
|
return 0;
|
||||||
|
offs -= func->parm_start;
|
||||||
|
if (offs < 0 || offs >= func->locals)
|
||||||
|
return 0;
|
||||||
|
for (i = 0; i < aux_func->num_locals; i++)
|
||||||
|
if (pr->local_defs[aux_func->local_defs + i].ofs == offs)
|
||||||
|
return &pr->local_defs[aux_func->local_defs + i];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
file_get_key (void *_f, void *unused)
|
file_get_key (void *_f, void *unused)
|
||||||
{
|
{
|
||||||
|
|
|
@ -451,12 +451,15 @@ PR_GlobalString (progs_t * pr, int ofs)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
int i;
|
int i;
|
||||||
ddef_t *def;
|
ddef_t *def = 0;
|
||||||
void *val;
|
void *val;
|
||||||
static char line[128];
|
static char line[128];
|
||||||
|
|
||||||
|
if (pr_debug->int_val && pr->debug)
|
||||||
|
def = PR_Get_Local_Def (pr, ofs);
|
||||||
val = (void *) &pr->pr_globals[ofs];
|
val = (void *) &pr->pr_globals[ofs];
|
||||||
def = ED_GlobalAtOfs (pr, ofs);
|
if (!def)
|
||||||
|
def = ED_GlobalAtOfs (pr, ofs);
|
||||||
if (!def)
|
if (!def)
|
||||||
snprintf (line, sizeof (line), "%i(?)", ofs);
|
snprintf (line, sizeof (line), "%i(?)", ofs);
|
||||||
else {
|
else {
|
||||||
|
@ -477,10 +480,13 @@ char *
|
||||||
PR_GlobalStringNoContents (progs_t * pr, int ofs)
|
PR_GlobalStringNoContents (progs_t * pr, int ofs)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
ddef_t *def;
|
ddef_t *def = 0;
|
||||||
static char line[128];
|
static char line[128];
|
||||||
|
|
||||||
def = ED_GlobalAtOfs (pr, ofs);
|
if (pr_debug->int_val && pr->debug)
|
||||||
|
def = PR_Get_Local_Def (pr, ofs);
|
||||||
|
if (!def)
|
||||||
|
def = ED_GlobalAtOfs (pr, ofs);
|
||||||
if (!def)
|
if (!def)
|
||||||
snprintf (line, sizeof (line), "%i(?)", ofs);
|
snprintf (line, sizeof (line), "%i(?)", ofs);
|
||||||
else
|
else
|
||||||
|
@ -1160,7 +1166,9 @@ PR_LoadProgs (progs_t * pr, const char *progsname)
|
||||||
PR_LoadDebug (pr);
|
PR_LoadDebug (pr);
|
||||||
|
|
||||||
// LordHavoc: bounds check anything static
|
// LordHavoc: bounds check anything static
|
||||||
for (i = 0, st = pr->pr_statements; i < pr->progs->numstatements; i++, st++) {
|
for (i = 0, st = pr->pr_statements;
|
||||||
|
i < pr->progs->numstatements;
|
||||||
|
i++, st++) {
|
||||||
switch (st->op) {
|
switch (st->op) {
|
||||||
case OP_IF:
|
case OP_IF:
|
||||||
case OP_IFNOT:
|
case OP_IFNOT:
|
||||||
|
|
|
@ -58,7 +58,7 @@ PR_PrintStatement (progs_t * pr, dstatement_t *s)
|
||||||
int addr = s - pr->pr_statements;
|
int addr = s - pr->pr_statements;
|
||||||
opcode_t *op;
|
opcode_t *op;
|
||||||
|
|
||||||
if (pr_debug->int_val) {
|
if (pr_debug->int_val && pr->debug) {
|
||||||
const char *source_line = PR_Get_Source_Line (pr, addr);
|
const char *source_line = PR_Get_Source_Line (pr, addr);
|
||||||
|
|
||||||
if (source_line)
|
if (source_line)
|
||||||
|
@ -169,7 +169,7 @@ PR_RunError (progs_t * pr, const char *error, ...)
|
||||||
vsnprintf (string, sizeof (string), error, argptr);
|
vsnprintf (string, sizeof (string), error, argptr);
|
||||||
va_end (argptr);
|
va_end (argptr);
|
||||||
|
|
||||||
if (pr_debug->int_val) {
|
if (pr_debug->int_val && pr->debug) {
|
||||||
int addr = pr->pr_xstatement;
|
int addr = pr->pr_xstatement;
|
||||||
|
|
||||||
while (!PR_Get_Source_Line (pr, addr))
|
while (!PR_Get_Source_Line (pr, addr))
|
||||||
|
@ -187,12 +187,6 @@ PR_RunError (progs_t * pr, const char *error, ...)
|
||||||
PR_Error (pr, "Program error");
|
PR_Error (pr, "Program error");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
PR_ExecuteProgram
|
|
||||||
|
|
||||||
The interpretation main loop
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PR_EnterFunction
|
PR_EnterFunction
|
||||||
|
|
||||||
|
@ -265,6 +259,8 @@ PR_LeaveFunction (progs_t * pr)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PR_ExecuteProgram
|
PR_ExecuteProgram
|
||||||
|
|
||||||
|
The interpretation main loop
|
||||||
*/
|
*/
|
||||||
#define OPA (pr->pr_globals[(unsigned short) st->a])
|
#define OPA (pr->pr_globals[(unsigned short) st->a])
|
||||||
#define OPB (pr->pr_globals[(unsigned short) st->b])
|
#define OPB (pr->pr_globals[(unsigned short) st->b])
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
#define NIT_TESLA 32768 //The *real* bug zapper!
|
||||||
|
#define NIT_SECURITY_CAMERA 65536 //CH Security Camera
|
||||||
|
#define NIT_TELEPORTER 131072 //CH Teleporter
|
||||||
|
#define PC_ENGINEER_TF_ITEMS NIT_TESLA | NIT_SECURITY_CAMERA | NIT_TELEPORTER
|
||||||
|
|
||||||
|
//float messed_or = PC_ENGINEER_TF_ITEMS;
|
||||||
float foo = 1;
|
float foo = 1;
|
||||||
float bar = 1;
|
float bar = 1;
|
||||||
float snafu = 2;
|
float snafu = 2;
|
||||||
|
@ -7,9 +13,12 @@ void () eek;
|
||||||
|
|
||||||
float () main =
|
float () main =
|
||||||
{
|
{
|
||||||
|
local float messed_or;
|
||||||
local float handle;
|
local float handle;
|
||||||
local string buffer;
|
local string buffer;
|
||||||
|
|
||||||
|
traceon();
|
||||||
|
messed_or = PC_ENGINEER_TF_ITEMS;
|
||||||
handle = open ("main.qc", 0);
|
handle = open ("main.qc", 0);
|
||||||
if (handle == -1) {
|
if (handle == -1) {
|
||||||
print (strerror (errno ()) + "\n");
|
print (strerror (errno ()) + "\n");
|
||||||
|
@ -59,10 +68,12 @@ void () blarg =
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
.entity owner;
|
||||||
|
entity sent;
|
||||||
void () eek =
|
void () eek =
|
||||||
{
|
{
|
||||||
traceon();
|
traceon();
|
||||||
if (self && self.origin)
|
if (sent && sent.owner != self )
|
||||||
self.origin = '0 0 0';
|
self.origin = '0 0 0';
|
||||||
self.origin = self.origin + '1 2 3';
|
self.origin = self.origin + '1 2 3';
|
||||||
traceoff();
|
traceoff();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue