From d0f76dfa1398e37c33f0ae4d48b3398422cac1c2 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 9 Jun 2002 16:28:19 +0000 Subject: [PATCH] dump function and field defs --- tools/qfprogs/include/globals.h | 2 ++ tools/qfprogs/source/globals.c | 47 +++++++++++++++++++++++++++++++++ tools/qfprogs/source/qfprogs.c | 10 ++++++- 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/tools/qfprogs/include/globals.h b/tools/qfprogs/include/globals.h index 9425e9bd0..c859a6969 100644 --- a/tools/qfprogs/include/globals.h +++ b/tools/qfprogs/include/globals.h @@ -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 diff --git a/tools/qfprogs/source/globals.c b/tools/qfprogs/source/globals.c index 9830b7950..a9121e3a1 100644 --- a/tools/qfprogs/source/globals.c +++ b/tools/qfprogs/source/globals.c @@ -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); + } +} diff --git a/tools/qfprogs/source/qfprogs.c b/tools/qfprogs/source/qfprogs.c index 8a3b44eba..38a3659ca 100644 --- a/tools/qfprogs/source/qfprogs.c +++ b/tools/qfprogs/source/qfprogs.c @@ -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; }