Commit 5346f1b9 by Richard Kenner

(enum st): Define st_Struct, st_Union, and st_Enum.

(st_to_string): Handle them.
(type_to_string): Add fdp argument; pass it to emit_aggregate.
(print_symbol): Add fdp argument; pass it to type_to_string.
Handle st_Struct, st_Union, and st_Enum.
(emit_aggregate): Add fdp argument.  Handle opaque types.  Map through
RFD entries.
(print_file_desc): Pass FDR to print_symbol.
(main): Pass null FDR to type_to_string.

From-SVN: r10516
parent 94f3f2cb
/* Read and manage MIPS symbol tables from object modules. /* Read and manage MIPS symbol tables from object modules.
Copyright (C) 1991, 1994 Free Software Foundation, Inc. Copyright (C) 1991, 1994, 1995 Free Software Foundation, Inc.
Contributed by hartzell@boulder.colorado.edu, Contributed by hartzell@boulder.colorado.edu,
Rewritten by meissner@osf.org. Rewritten by meissner@osf.org.
...@@ -144,6 +144,11 @@ typedef enum st { ...@@ -144,6 +144,11 @@ typedef enum st {
st_StaticProc = stStaticProc, /* load time only static procs */ st_StaticProc = stStaticProc, /* load time only static procs */
st_StaParam = stStaParam, /* Fortran static parameters */ st_StaParam = stStaParam, /* Fortran static parameters */
st_Constant = stConstant, /* const */ st_Constant = stConstant, /* const */
#ifdef stStruct
st_Struct = stStruct, /* struct */
st_Union = stUnion, /* union */
st_Enum = stEnum, /* enum */
#endif
st_Str = stStr, /* string */ st_Str = stStr, /* string */
st_Number = stNumber, /* pure number (ie. 4 NOR 2+2) */ st_Number = stNumber, /* pure number (ie. 4 NOR 2+2) */
st_Expr = stExpr, /* 2+2 vs. 4 */ st_Expr = stExpr, /* 2+2 vs. 4 */
...@@ -260,14 +265,14 @@ void read_tfile __proto((void)); ...@@ -260,14 +265,14 @@ void read_tfile __proto((void));
void print_global_hdr __proto((struct filehdr *)); void print_global_hdr __proto((struct filehdr *));
void print_sym_hdr __proto((HDRR *)); void print_sym_hdr __proto((HDRR *));
void print_file_desc __proto((FDR *, int)); void print_file_desc __proto((FDR *, int));
void print_symbol __proto((SYMR *, int, char *, AUXU *, int)); void print_symbol __proto((SYMR *, int, char *, AUXU *, int, FDR *));
void print_aux __proto((AUXU, int, int)); void print_aux __proto((AUXU, int, int));
void emit_aggregate __proto((char *, AUXU, AUXU, const char *)); void emit_aggregate __proto((char *, AUXU, AUXU, const char *, FDR *));
char *st_to_string __proto((st_t)); char *st_to_string __proto((st_t));
char *sc_to_string __proto((sc_t)); char *sc_to_string __proto((sc_t));
char *glevel_to_string __proto((glevel_t)); char *glevel_to_string __proto((glevel_t));
char *lang_to_string __proto((lang_t)); char *lang_to_string __proto((lang_t));
char *type_to_string __proto((AUXU *, int)); char *type_to_string __proto((AUXU *, int, FDR *));
#ifndef __alpha #ifndef __alpha
extern PTR_T malloc __proto((size_t)); extern PTR_T malloc __proto((size_t));
...@@ -409,6 +414,11 @@ st_to_string(symbol_type) ...@@ -409,6 +414,11 @@ st_to_string(symbol_type)
case st_StaticProc: return "StaticProc"; case st_StaticProc: return "StaticProc";
case st_Constant: return "Constant"; case st_Constant: return "Constant";
case st_StaParam: return "StaticParam"; case st_StaParam: return "StaticParam";
#ifdef stStruct
case st_Struct: return "Struct";
case st_Union: return "Union";
case st_Enum: return "Enum";
#endif
case st_Str: return "String"; case st_Str: return "String";
case st_Number: return "Number"; case st_Number: return "Number";
case st_Expr: return "Expr"; case st_Expr: return "Expr";
...@@ -441,9 +451,10 @@ glevel_to_string (g_level) ...@@ -441,9 +451,10 @@ glevel_to_string (g_level)
/* Convert the type information to string format. */ /* Convert the type information to string format. */
char * char *
type_to_string (aux_ptr, index) type_to_string (aux_ptr, index, fdp)
AUXU *aux_ptr; AUXU *aux_ptr;
int index; int index;
FDR *fdp;
{ {
AUXU u; AUXU u;
struct qual { struct qual {
...@@ -540,7 +551,7 @@ type_to_string (aux_ptr, index) ...@@ -540,7 +551,7 @@ type_to_string (aux_ptr, index)
2nd word is file index if 1st word rfd is ST_RFDESCAPE. */ 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
case bt_Struct: /* Structure (Record) */ case bt_Struct: /* Structure (Record) */
emit_aggregate (p1, aux_ptr[index], aux_ptr[index+1], "struct"); emit_aggregate (p1, aux_ptr[index], aux_ptr[index+1], "struct", fdp);
used_ptr[index] = 1; used_ptr[index] = 1;
if (aux_ptr[index].rndx.rfd == ST_RFDESCAPE) if (aux_ptr[index].rndx.rfd == ST_RFDESCAPE)
used_ptr[++index] = 1; used_ptr[++index] = 1;
...@@ -553,7 +564,7 @@ type_to_string (aux_ptr, index) ...@@ -553,7 +564,7 @@ type_to_string (aux_ptr, index)
2nd word is file index if 1st word rfd is ST_RFDESCAPE. */ 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
case bt_Union: /* Union */ case bt_Union: /* Union */
emit_aggregate (p1, aux_ptr[index], aux_ptr[index+1], "union"); emit_aggregate (p1, aux_ptr[index], aux_ptr[index+1], "union", fdp);
used_ptr[index] = 1; used_ptr[index] = 1;
if (aux_ptr[index].rndx.rfd == ST_RFDESCAPE) if (aux_ptr[index].rndx.rfd == ST_RFDESCAPE)
used_ptr[++index] = 1; used_ptr[++index] = 1;
...@@ -566,7 +577,7 @@ type_to_string (aux_ptr, index) ...@@ -566,7 +577,7 @@ type_to_string (aux_ptr, index)
2nd word is file index if 1st word rfd is ST_RFDESCAPE. */ 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
case bt_Enum: /* Enumeration */ case bt_Enum: /* Enumeration */
emit_aggregate (p1, aux_ptr[index], aux_ptr[index+1], "enum"); emit_aggregate (p1, aux_ptr[index], aux_ptr[index+1], "enum", fdp);
used_ptr[index] = 1; used_ptr[index] = 1;
if (aux_ptr[index].rndx.rfd == ST_RFDESCAPE) if (aux_ptr[index].rndx.rfd == ST_RFDESCAPE)
used_ptr[++index] = 1; used_ptr[++index] = 1;
...@@ -882,12 +893,13 @@ print_sym_hdr (sym_ptr) ...@@ -882,12 +893,13 @@ print_sym_hdr (sym_ptr)
/* Print out a symbol. */ /* Print out a symbol. */
void void
print_symbol (sym_ptr, number, strbase, aux_base, ifd) print_symbol (sym_ptr, number, strbase, aux_base, ifd, fdp)
SYMR *sym_ptr; SYMR *sym_ptr;
int number; int number;
char *strbase; char *strbase;
AUXU *aux_base; AUXU *aux_base;
int ifd; int ifd;
FDR *fdp;
{ {
sc_t storage_class = (sc_t) sym_ptr->sc; sc_t storage_class = (sc_t) sym_ptr->sc;
st_t symbol_type = (st_t) sym_ptr->st; st_t symbol_type = (st_t) sym_ptr->st;
...@@ -955,7 +967,8 @@ print_symbol (sym_ptr, number, strbase, aux_base, ifd) ...@@ -955,7 +967,8 @@ print_symbol (sym_ptr, number, strbase, aux_base, ifd)
{ {
used_ptr[index] = used_ptr[index+1] = 1; used_ptr[index] = used_ptr[index+1] = 1;
printf (" End+1 symbol: %-7ld Type: %s\n", printf (" End+1 symbol: %-7ld Type: %s\n",
aux_base[index].isym, type_to_string (aux_base, index+1)); aux_base[index].isym,
type_to_string (aux_base, index+1, fdp));
} }
else /* global symbol */ else /* global symbol */
printf (" Local symbol: %ld\n", index); printf (" Local symbol: %ld\n", index);
...@@ -977,12 +990,20 @@ print_symbol (sym_ptr, number, strbase, aux_base, ifd) ...@@ -977,12 +990,20 @@ print_symbol (sym_ptr, number, strbase, aux_base, ifd)
} }
break; break;
#ifdef stStruct
case st_Struct:
case st_Union:
case st_Enum:
printf (" End+1 symbol: %lu\n", index);
break;
#endif
default: default:
if (!MIPS_IS_STAB (sym_ptr)) if (!MIPS_IS_STAB (sym_ptr))
{ {
used_ptr[index] = 1; used_ptr[index] = 1;
printf (" Type: %s\n", printf (" Type: %s\n",
type_to_string (aux_base, index)); type_to_string (aux_base, index, fdp));
} }
break; break;
} }
...@@ -1077,30 +1098,39 @@ print_aux (u, auxi, used) ...@@ -1077,30 +1098,39 @@ print_aux (u, auxi, used)
/* Write aggregate information to a string. */ /* Write aggregate information to a string. */
void void
emit_aggregate (string, u, u2, which) emit_aggregate (string, u, u2, which, fdp)
char *string; char *string;
AUXU u; AUXU u;
AUXU u2; AUXU u2;
const char *which; const char *which;
FDR *fdp;
{ {
int ifd = u.rndx.rfd; unsigned int ifd = u.rndx.rfd;
int index = u.rndx.index; unsigned int index = u.rndx.index;
int sym_base, ss_base; const char *name;
int name;
if (ifd == ST_RFDESCAPE) if (ifd == ST_RFDESCAPE)
ifd = u2.isym; ifd = u2.isym;
sym_base = file_desc[ifd].isymBase;
ss_base = file_desc[ifd].issBase;
name = (index == indexNil) ? 0 : l_symbols[index + sym_base].iss; /* An ifd of -1 is an opaque type. An escaped index of 0 is a
struct return type of a procedure compiled without -g. */
if (ifd == 0xffffffff
|| (u.rndx.rfd == ST_RFDESCAPE && index == 0))
name = "<undefined>";
else if (index == indexNil)
name = "<no name>";
else
{
if (fdp == 0 || sym_hdr.crfd == 0)
fdp = &file_desc[ifd];
else
fdp = &file_desc[rfile_desc[fdp->rfdBase + ifd]];
name = &l_strings[fdp->issBase + l_symbols[index + fdp->isymBase].iss];
}
sprintf (string, sprintf (string,
"%s %s { ifd = %d, index = %d }", "%s %s { ifd = %u, index = %u }",
which, which, name, ifd, index);
(name == 0) ? "/* no name */" : &l_strings[ ss_base + name ],
ifd,
index);
} }
...@@ -1205,7 +1235,8 @@ print_file_desc (fdp, number) ...@@ -1205,7 +1235,8 @@ print_file_desc (fdp, number)
symi - fdp->isymBase, symi - fdp->isymBase,
str_base, str_base,
aux_base, aux_base,
-1); -1,
fdp);
if (want_scope && cur_scope != (scope_t *)0) if (want_scope && cur_scope != (scope_t *)0)
printf ("\n Warning scope does not end at 0!\n"); printf ("\n Warning scope does not end at 0!\n");
...@@ -1524,7 +1555,8 @@ main (argc, argv) ...@@ -1524,7 +1555,8 @@ main (argc, argv)
for(i = 0; i < sym_hdr.iextMax; i++) for(i = 0; i < sym_hdr.iextMax; i++)
print_symbol (&e_symbols[i].asym, i, e_strings, print_symbol (&e_symbols[i].asym, i, e_strings,
aux_symbols + file_desc[e_symbols[i].ifd].iauxBase, aux_symbols + file_desc[e_symbols[i].ifd].iauxBase,
e_symbols[i].ifd); e_symbols[i].ifd,
&file_desc[e_symbols[i].ifd]);
/* /*
* Print unused aux symbols now. * Print unused aux symbols now.
...@@ -1548,7 +1580,7 @@ main (argc, argv) ...@@ -1548,7 +1580,7 @@ main (argc, argv)
i, i,
(long) aux_symbols[i].isym, (long) aux_symbols[i].isym,
(long) aux_symbols[i].isym, (long) aux_symbols[i].isym,
type_to_string (aux_symbols, i)); type_to_string (aux_symbols, i, (FDR *) 0));
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment