mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-30 12:40:42 +00:00
provide a way to dump module information
This commit is contained in:
parent
e429195f91
commit
76a7637b5e
5 changed files with 138 additions and 3 deletions
|
@ -1,3 +1,3 @@
|
||||||
AUTOMAKE_OPTIONS= foreign
|
AUTOMAKE_OPTIONS= foreign
|
||||||
|
|
||||||
EXTRA_DIST= disassemble.h globals.h qfprogs.h strings.h
|
EXTRA_DIST= disassemble.h globals.h modules.h qfprogs.h strings.h
|
||||||
|
|
8
tools/qfprogs/include/modules.h
Normal file
8
tools/qfprogs/include/modules.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef __modules_h
|
||||||
|
#define __modules_h
|
||||||
|
|
||||||
|
struct progs_s;
|
||||||
|
|
||||||
|
void dump_modules (struct progs_s *pr);
|
||||||
|
|
||||||
|
#endif//__modules_h
|
|
@ -10,6 +10,6 @@ bin_PROGRAMS= qfprogs
|
||||||
|
|
||||||
#man_MANS= qfprogs.1
|
#man_MANS= qfprogs.1
|
||||||
|
|
||||||
qfprogs_SOURCES= disassemble.c globals.c qfprogs.c strings.c
|
qfprogs_SOURCES= disassemble.c globals.c modules.c qfprogs.c strings.c
|
||||||
qfprogs_LDADD= $(QFPROGS_LIBS)
|
qfprogs_LDADD= $(QFPROGS_LIBS)
|
||||||
qfprogs_DEPENDENCIES= $(QFPROGS_DEPS)
|
qfprogs_DEPENDENCIES= $(QFPROGS_DEPS)
|
||||||
|
|
122
tools/qfprogs/source/modules.c
Normal file
122
tools/qfprogs/source/modules.c
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
/*
|
||||||
|
#FILENAME#
|
||||||
|
|
||||||
|
#DESCRIPTION#
|
||||||
|
|
||||||
|
Copyright (C) 2001 #AUTHOR#
|
||||||
|
|
||||||
|
Author: #AUTHOR#
|
||||||
|
Date: #DATE#
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
static const char rcsid[] =
|
||||||
|
"$Id$";
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "QF/pr_obj.h"
|
||||||
|
#include "QF/progs.h"
|
||||||
|
#include "QF/va.h"
|
||||||
|
|
||||||
|
#include "qfprogs.h"
|
||||||
|
#include "modules.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
dump_methods (progs_t *pr, pr_method_list_t *methods, int class)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char mark = class ? '+' : '-';
|
||||||
|
|
||||||
|
while (methods) {
|
||||||
|
pr_method_t *method = methods->method_list;
|
||||||
|
for (i = 0; i < methods->method_count; i++) {
|
||||||
|
printf (" %c%s %d @ %d\n", mark,
|
||||||
|
PR_GetString (pr, method->method_name.sel_id),
|
||||||
|
method->method_imp, POINTER_TO_PROG (pr, method));
|
||||||
|
method++;
|
||||||
|
}
|
||||||
|
methods = &G_STRUCT (pr, pr_method_list_t, methods->method_next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dump_class (progs_t *pr, pr_class_t *class)
|
||||||
|
{
|
||||||
|
pr_class_t *meta = &G_STRUCT (pr, pr_class_t, class->class_pointer);
|
||||||
|
|
||||||
|
if (class->super_class) {
|
||||||
|
printf (" %s @ %d : %s\n", PR_GetString (pr, class->name),
|
||||||
|
POINTER_TO_PROG (pr, class), PR_GetString (pr,
|
||||||
|
class->super_class));
|
||||||
|
} else {
|
||||||
|
printf (" %s @ %d\n", PR_GetString (pr, class->name),
|
||||||
|
POINTER_TO_PROG (pr, class));
|
||||||
|
}
|
||||||
|
printf (" %d %d %d %d\n", class->class_pointer, class->version,
|
||||||
|
class->info, class->instance_size);
|
||||||
|
dump_methods (pr, &G_STRUCT (pr, pr_method_list_t, class->methods), 0);
|
||||||
|
dump_methods (pr, &G_STRUCT (pr, pr_method_list_t, meta->methods), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dump_category (progs_t *pr, pr_category_t *category)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dump_module (progs_t *pr, pr_module_t *module)
|
||||||
|
{
|
||||||
|
pr_symtab_t *symtab = &G_STRUCT (pr, pr_symtab_t, module->symtab);
|
||||||
|
pointer_t *ptr = symtab->defs;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
printf ("%d %d %s\n", module->version, module->size,
|
||||||
|
PR_GetString (pr, module->name));
|
||||||
|
if (!symtab) {
|
||||||
|
printf (" No symtab!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf (" %d %d %d\n", symtab->sel_ref_cnt, symtab->cls_def_cnt,
|
||||||
|
symtab->cat_def_cnt);
|
||||||
|
for (i = 0; i < symtab->cls_def_cnt; i++)
|
||||||
|
dump_class (pr, &G_STRUCT (pr, pr_class_t, *ptr++));
|
||||||
|
for (i = 0; i < symtab->cls_def_cnt; i++)
|
||||||
|
dump_category (pr, &G_STRUCT (pr, pr_category_t, *ptr++));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dump_modules (progs_t *pr)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
for (i = 0; i < pr->progs->numglobaldefs; i++) {
|
||||||
|
ddef_t *def = &pr->pr_globaldefs[i];
|
||||||
|
|
||||||
|
name = PR_GetString (pr, def->s_name);
|
||||||
|
if (strcmp (name, "_OBJ_MODULE") == 0)
|
||||||
|
dump_module (pr, &G_STRUCT (pr, pr_module_t, def->ofs));
|
||||||
|
}
|
||||||
|
}
|
|
@ -60,6 +60,7 @@ static const char rcsid[] =
|
||||||
|
|
||||||
#include "disassemble.h"
|
#include "disassemble.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
#include "modules.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
|
|
||||||
static const struct option long_options[] = {
|
static const struct option long_options[] = {
|
||||||
|
@ -68,6 +69,7 @@ static const struct option long_options[] = {
|
||||||
{"strings", no_argument, 0, 's'},
|
{"strings", no_argument, 0, 's'},
|
||||||
{"fields", no_argument, 0, 'f'},
|
{"fields", no_argument, 0, 'f'},
|
||||||
{"functions", no_argument, 0, 'F'},
|
{"functions", no_argument, 0, 'F'},
|
||||||
|
{"modules", no_argument, 0, 'M'},
|
||||||
{NULL, 0, NULL, 0},
|
{NULL, 0, NULL, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -221,7 +223,7 @@ main (int argc, char **argv)
|
||||||
void (*func)(progs_t *pr) = dump_globals;
|
void (*func)(progs_t *pr) = dump_globals;
|
||||||
|
|
||||||
init_qf ();
|
init_qf ();
|
||||||
while ((c = getopt_long (argc, argv, "dgsfF", long_options, 0)) != EOF) {
|
while ((c = getopt_long (argc, argv, "dgsfFM", long_options, 0)) != EOF) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'd':
|
case 'd':
|
||||||
func = disassemble_progs;
|
func = disassemble_progs;
|
||||||
|
@ -238,6 +240,9 @@ main (int argc, char **argv)
|
||||||
case 'F':
|
case 'F':
|
||||||
func = dump_functions;
|
func = dump_functions;
|
||||||
break;
|
break;
|
||||||
|
case 'M':
|
||||||
|
func = dump_modules;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue