mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-20 01:11:18 +00:00
dump function and field defs
This commit is contained in:
parent
e3055837fa
commit
d0f76dfa13
3 changed files with 58 additions and 1 deletions
|
@ -4,5 +4,7 @@
|
|||
struct progs_s;
|
||||
|
||||
void dump_globals (struct progs_s *pr);
|
||||
void dump_fields (struct progs_s *pr);
|
||||
void dump_functions (struct progs_s *pr);
|
||||
|
||||
#endif//__globals_h
|
||||
|
|
|
@ -77,3 +77,50 @@ dump_globals (progs_t *pr)
|
|||
printf ("%s %d %d %s%s\n", type, saveglobal, offset, name, comment);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
dump_fields (progs_t *pr)
|
||||
{
|
||||
int i;
|
||||
const char *name;
|
||||
const char *type;
|
||||
int offset;
|
||||
char *comment;
|
||||
|
||||
for (i = 0; i < pr->progs->numfielddefs; i++) {
|
||||
ddef_t *def = &pr->pr_fielddefs[i];
|
||||
|
||||
name = PR_GetString (pr, def->s_name);
|
||||
type = pr_type_name[def->type & ~DEF_SAVEGLOBAL];
|
||||
offset = def->ofs;
|
||||
|
||||
comment = " ";
|
||||
|
||||
printf ("%s %d %s%s\n", type, offset, name, comment);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
dump_functions (progs_t *pr)
|
||||
{
|
||||
int i;
|
||||
const char *name;
|
||||
int start;
|
||||
char *comment;
|
||||
|
||||
for (i = 0; i < pr->progs->numfunctions; i++) {
|
||||
dfunction_t *func = &pr->pr_functions[i];
|
||||
|
||||
name = PR_GetString (pr, func->s_name);
|
||||
|
||||
comment = " ";
|
||||
|
||||
start = func->first_statement;
|
||||
if (start > 0)
|
||||
comment = va (" @ %d", start);
|
||||
else
|
||||
comment = va (" = #%d", -start);
|
||||
|
||||
printf ("%s%s\n", name, comment);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,8 @@ static const struct option long_options[] = {
|
|||
{"disassemble", no_argument, 0, 'd'},
|
||||
{"globals", no_argument, 0, 'g'},
|
||||
{"strings", no_argument, 0, 's'},
|
||||
{"fields", no_argument, 0, 'f'},
|
||||
{"functions", no_argument, 0, 'F'},
|
||||
{NULL, 0, NULL, 0},
|
||||
};
|
||||
|
||||
|
@ -199,7 +201,7 @@ main (int argc, char **argv)
|
|||
void (*func)(progs_t *pr) = dump_globals;
|
||||
|
||||
init_qf ();
|
||||
while ((c = getopt_long (argc, argv, "dgs", long_options, 0)) != EOF) {
|
||||
while ((c = getopt_long (argc, argv, "dgsfF", long_options, 0)) != EOF) {
|
||||
switch (c) {
|
||||
case 'd':
|
||||
func = disassemble_progs;
|
||||
|
@ -210,6 +212,12 @@ main (int argc, char **argv)
|
|||
case 's':
|
||||
func = dump_strings;
|
||||
break;
|
||||
case 'f':
|
||||
func = dump_fields;
|
||||
break;
|
||||
case 'F':
|
||||
func = dump_functions;
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue