dump function and field defs

This commit is contained in:
Bill Currie 2002-06-09 16:28:19 +00:00
parent e3055837fa
commit d0f76dfa13
3 changed files with 58 additions and 1 deletions

View file

@ -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

View file

@ -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);
}
}

View file

@ -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;
}