Fix qfo field dumping

This commit is contained in:
Bill Currie 2020-02-23 14:56:50 +09:00
parent 81293d98dd
commit b0157e5095
3 changed files with 37 additions and 1 deletions

View file

@ -55,6 +55,7 @@ struct dfunction_s *func_find (int st_num);
void dump_strings (struct progs_s *pr);
void qfo_globals (struct qfo_s *qfo);
void qfo_fields (struct qfo_s *qfo);
void qfo_functions (struct qfo_s *qfo);
void qfo_lines (struct qfo_s *qfo);
void qfo_relocs (struct qfo_s *qfo);

View file

@ -192,6 +192,41 @@ dump_fields (progs_t *pr)
}
}
void
qfo_fields (qfo_t *qfo)
{
unsigned int i;
const char *name;
const char *typestr;
qfot_type_t *type;
int offset;
const char *comment;
qfo_mspace_t *space = &qfo->spaces[qfo_entity_space];
if (qfo_entity_space >= qfo->num_spaces) {
printf ("no entity space\n");
return;
}
if (!space->num_defs) {
printf ("no fields\n");
return;
}
for (i = 0; i < space->num_defs; i++) {
qfo_def_t *def = space->defs + i;
name = QFO_GETSTR (qfo, def->name);
//FIXME check type
type = QFO_POINTER (qfo, qfo_type_space, qfot_type_t, def->type);
typestr = QFO_GETSTR (qfo, type->encoding);
offset = def->offset;
comment = "";
printf ("%d %s %s%s\n", offset, name, typestr, comment);
}
}
void
dump_functions (progs_t *pr)
{

View file

@ -307,7 +307,7 @@ operation_t operations[] = {
{disassemble_progs, 0}, // disassemble
{dump_globals, qfo_globals}, // globals
{dump_strings, 0}, // strings
{dump_fields, 0}, // fields
{dump_fields, qfo_fields}, // fields
{dump_functions, qfo_functions}, // functions
{dump_lines, qfo_lines}, // lines
{dump_modules, 0}, // modules