int within_function;
+#if 0
+/* The type of the function we are currently reading in. This is
+ used by define_symbol to record the type of arguments to a function. */
+
+static struct type *in_function_type;
+#endif
+
/* List of blocks already made (lexical contexts already closed).
This is used at the end to make the blockvector. */
{"bad string table offset in symbol %d", 0, 0};
struct complaint unknown_symtype_complaint =
- {"unknown symbol type 0x%x", 0, 0};
+ {"unknown symbol type %s", 0, 0};
struct complaint lbrac_rbrac_complaint =
{"block start larger than block end", 0, 0};
for (subfile = subfiles; subfile; subfile = nextsub)
{
- symtab = (struct symtab *) xmalloc (sizeof (struct symtab));
+ symtab = allocate_symtab (subfile->name);
/* Fill in its components. */
symtab->blockvector = blockvector;
type_vector->length = type_vector_length;
symtab->typevector = type_vector;
- symtab->filename = subfile->name;
symtab->dirname = subfile->dirname;
symtab->free_code = free_linetable;
if (subfile->next == 0)
symtab->free_ptr = (char *) type_vector;
- symtab->nlines = 0;
- symtab->line_charpos = 0;
-
- symtab->language = language_unknown;
- symtab->fullname = NULL;
-
/* There should never already be a symtab for this name, since
any prev dups have been removed when the psymtab was read in.
FIXME, there ought to be a way to check this here. */
CORE_ADDR address;
int type;
{
- enum misc_function_type misc_type =
- (type == (N_TEXT | N_EXT) ? mf_text :
- (type == (N_DATA | N_EXT)
- || type == (N_DATA)
- || type == (N_SETV | N_EXT)
- ) ? mf_data :
- type == (N_BSS | N_EXT) ? mf_bss :
- type == (N_ABS | N_EXT) ? mf_abs : mf_unknown);
+ enum misc_function_type misc_type;
+
+ switch (type &~ N_EXT) {
+ case N_TEXT: misc_type = mf_text; break;
+ case N_DATA: misc_type = mf_data; break;
+ case N_BSS: misc_type = mf_bss; break;
+ case N_ABS: misc_type = mf_abs; break;
+#ifdef N_SETV
+ case N_SETV: misc_type = mf_data; break;
+#endif
+ default: misc_type = mf_unknown; break;
+ }
prim_record_misc_function (obsavestring (name, strlen (name)),
address, misc_type);
namestring, valu,
first_symnum * sizeof (struct nlist),
global_psymbols.next, static_psymbols.next);
-
continue;
}
case N_LBRAC:
case N_RBRAC:
case N_NSYMS: /* Ultrix 4.0: symbol count */
+ case N_DEFD: /* GNU Modula-2 */
/* These symbols aren't interesting; don't worry about them */
continue;
default:
/* If we haven't found it yet, ignore it. It's probably some
new type we don't know about yet. */
- complain (&unknown_symtype_complaint, bufp->n_type);
+ complain (&unknown_symtype_complaint, local_hex_string(bufp->n_type));
continue;
}
}
*st1 = SYMBOL_NAME (s1),
*st2 = SYMBOL_NAME (s2);
- return (st1[0] - st2[0] ? st1[0] - st2[0] :
- strcmp (st1 + 1, st2 + 1));
+ if (st1[0] - st2[0])
+ return st1[0] - st2[0];
+ if (st1[1] - st2[1])
+ return st1[1] - st2[1];
+ return strcmp (st1 + 1, st2 + 1);
}
}
/* Process a pair of symbols. Currently they must both be N_SO's. */
+/* ARGSUSED */
static void
process_symbol_pair (type1, desc1, value1, name1,
type2, desc2, value2, name2)
processing_gcc_compilation = 1;
else if (type & N_EXT || type == (unsigned char)N_TEXT
|| type == (unsigned char)N_NBTEXT
- )
+ ) {
/* Global symbol: see if we came across a dbx defintion for
a corresponding symbol. If so, store the value. Remove
syms from the chain when their values are stored, but
be satisfied in each file as it appears. So we skip this
section. */
;
+ }
}
return end_symtab (text_offset + text_size);
case N_ECOML:
case N_LENG:
+ case N_DEFD: /* GNU Modula-2 symbol */
break;
default:
get this name). */
static char *type_synonym_name;
+/* ARGSUSED */
static struct symbol *
define_symbol (valu, string, desc, type)
unsigned int valu;
if ((deftype == 'F' || deftype == 'f')
&& TYPE_CODE (type_read) != TYPE_CODE_FUNC)
+ {
+#if 0
+/* This code doesn't work -- it needs to realloc and can't. */
+ struct type *new = (struct type *)
+ obstack_alloc (symbol_obstack, sizeof (struct type));
+
+ /* Generate a template for the type of this function. The
+ types of the arguments will be added as we read the symbol
+ table. */
+ *new = *lookup_function_type (type_read);
+ SYMBOL_TYPE(sym) = new;
+ in_function_type = new;
+#else
SYMBOL_TYPE (sym) = lookup_function_type (type_read);
+#endif
+ }
else
SYMBOL_TYPE (sym) = type_read;
}
SYMBOL_CLASS (sym) = DBX_PARM_SYMBOL_CLASS (type);
SYMBOL_VALUE (sym) = valu;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+#if 0
+ /* This doesn't work yet. */
+ add_param_to_type (&in_function_type, sym);
+#endif
add_symbol_to_list (sym, &local_symbols);
/* If it's gcc-compiled, if it says `short', believe it. */
|| TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
&& TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)))
{
- int i;
- for (i = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; i >= 0; i--)
- if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), i) == 0)
- TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), i) =
- type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), i));
+ int j;
+ for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--)
+ if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0)
+ TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) =
+ type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), j));
}
add_symbol_to_list (sym, &file_symbols);
j = o_nsyms;
for (; j < syms->nsyms; j++,n++)
{
- struct symbol *sym = syms->symbol[j];
- SYMBOL_TYPE (sym) = type;
- TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (sym);
+ struct symbol *xsym = syms->symbol[j];
+ SYMBOL_TYPE (xsym) = type;
+ TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
TYPE_FIELD_VALUE (type, n) = 0;
- TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (sym);
+ TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
TYPE_FIELD_BITSIZE (type, n) = 0;
}
if (syms == osyms)
break;
}
+ /* Is this Modula-2's BOOLEAN type? Flag it as such if so. */
+ if(TYPE_NFIELDS(type) == 2 &&
+ ((!strcmp(TYPE_FIELD_NAME(type,0),"TRUE") &&
+ !strcmp(TYPE_FIELD_NAME(type,1),"FALSE")) ||
+ (!strcmp(TYPE_FIELD_NAME(type,1),"TRUE") &&
+ !strcmp(TYPE_FIELD_NAME(type,0),"FALSE"))))
+ TYPE_CODE(type) = TYPE_CODE_BOOL;
+
return type;
}
}
}
-#define MAX_OF_TYPE(t) ((1 << (sizeof (t)*8 - 1)) - 1)
-#define MIN_OF_TYPE(t) (-(1 << (sizeof (t)*8 - 1)))
+#define MAX_OF_C_TYPE(t) ((1 << (sizeof (t)*8 - 1)) - 1)
+#define MIN_OF_C_TYPE(t) (-(1 << (sizeof (t)*8 - 1)))
static struct type *
read_range_type (pp, typenums)
sizeof (struct type));
bzero (result_type, sizeof (struct type));
- TYPE_TARGET_TYPE (result_type) = (self_subrange ?
- builtin_type_int :
- *dbx_lookup_type(rangenums));
+ TYPE_CODE (result_type) = TYPE_CODE_RANGE;
+
+ TYPE_TARGET_TYPE (result_type) = *dbx_lookup_type(rangenums);
+
+ TYPE_NFIELDS (result_type) = 2;
+ TYPE_FIELDS (result_type) =
+ (struct field *) obstack_alloc (symbol_obstack,
+ 2 * sizeof (struct field));
+ bzero (TYPE_FIELDS (result_type), 2 * sizeof (struct field));
+ TYPE_FIELD_BITPOS (result_type, 0) = n2;
+ TYPE_FIELD_BITPOS (result_type, 1) = n3;
+#if 0
+/* Note that TYPE_LENGTH (result_type) is just overridden a few
+ statements down. What do we really need here? */
/* We have to figure out how many bytes it takes to hold this
range type. I'm going to assume that anything that is pushing
the bounds of a long was taken care of above. */
- if (n2 >= MIN_OF_TYPE(char) && n3 <= MAX_OF_TYPE(char))
+ if (n2 >= MIN_OF_C_TYPE(char) && n3 <= MAX_OF_C_TYPE(char))
TYPE_LENGTH (result_type) = 1;
- else if (n2 >= MIN_OF_TYPE(short) && n3 <= MAX_OF_TYPE(short))
+ else if (n2 >= MIN_OF_C_TYPE(short) && n3 <= MAX_OF_C_TYPE(short))
TYPE_LENGTH (result_type) = sizeof (short);
- else if (n2 >= MIN_OF_TYPE(int) && n3 <= MAX_OF_TYPE(int))
+ else if (n2 >= MIN_OF_C_TYPE(int) && n3 <= MAX_OF_C_TYPE(int))
TYPE_LENGTH (result_type) = sizeof (int);
- else if (n2 >= MIN_OF_TYPE(long) && n3 <= MAX_OF_TYPE(long))
+ else if (n2 >= MIN_OF_C_TYPE(long) && n3 <= MAX_OF_C_TYPE(long))
TYPE_LENGTH (result_type) = sizeof (long);
else
/* Ranged type doesn't fit within known sizes. */
+ /* FIXME -- use "long long" here. */
return error_type (pp);
+#endif
TYPE_LENGTH (result_type) = TYPE_LENGTH (TYPE_TARGET_TYPE (result_type));
- TYPE_CODE (result_type) = TYPE_CODE_RANGE;
- TYPE_NFIELDS (result_type) = 2;
- TYPE_FIELDS (result_type) =
- (struct field *) obstack_alloc (symbol_obstack,
- 2 * sizeof (struct field));
- bzero (TYPE_FIELDS (result_type), 2 * sizeof (struct field));
- TYPE_FIELD_BITPOS (result_type, 0) = n2;
- TYPE_FIELD_BITPOS (result_type, 1) = n3;
return result_type;
}
/* Exported procedure: Allocate zeroed memory */
-char *xzalloc(size)
+char *
+xzalloc(size)
{
char *p = xmalloc(size);
SYMBOL_VALUE(s) = sh->value;
SYMBOL_TYPE(s) = parse_type(ax + sh->index, sh, 0);
add_symbol(s, top_stack->cur_block);
+#if 0
+ /* FIXME: This has not been tested. See dbxread.c */
+ /* Add the type of this parameter to the function/procedure
+ type of this block. */
+ add_param_to_type(&top_stack->cur_block->function->type,s);
+#endif
break;
case stLabel: /* label, goes into current block */
add_symbol(s, top_stack->cur_block);
break;
- case stProc: /* Procedure, goes into current block? FIXME */
+ case stProc: /* Procedure, usually goes into global block */
case stStaticProc: /* Static procedure, goes into current block */
s = new_symbol(sh->iss);
SYMBOL_NAMESPACE(s) = VAR_NAMESPACE;
t = builtin_type_int;
else
t = parse_type(ax + sh->index, sh, 0);
- add_symbol(s, top_stack->cur_block);
+ b = top_stack->cur_block;
+ if (sh->st == stProc) {
+ struct blockvector *bv = BLOCKVECTOR(top_stack->cur_st);
+ /* The next test should normally be true,
+ but provides a hook for nested functions
+ (which we don't want to make global). */
+ if (b == BLOCKVECTOR_BLOCK(bv, STATIC_BLOCK))
+ b = BLOCKVECTOR_BLOCK(bv, GLOBAL_BLOCK);
+ }
+ add_symbol(s, b);
/* Make a type for the procedure itself */
+#if 0
+ /* FIXME: This has not been tested yet! See dbxread.c */
+ /* Generate a template for the type of this function. The
+ types of the arguments will be added as we read the symbol
+ table. */
+ bcopy(SYMBOL_TYPE(s),lookup_function_type(t),sizeof(struct type));
+#else
SYMBOL_TYPE(s) = lookup_function_type (t);
+#endif
/* Create and enter a new lexical context */
b = new_block(top_stack->maxsyms);
*
* Only parse the Local and External symbols, and the Relative FDR.
* Fixup enough of the loader symtab to be able to use it.
- * Allocate space only for the file`s portions we need to
+ * Allocate space only for the file's portions we need to
* look at. (XXX)
*/
new_symtab(name, maxsyms, maxlines)
char *name;
{
- struct symtab *s = (struct symtab *) xzalloc(sizeof(struct symtab));
- int i;
+ struct symtab *s = allocate_symtab (name);
LINETABLE(s) = new_linetable(maxlines);
- s->filename = name;
-
/* All symtabs must have at least two blocks */
BLOCKVECTOR(s) = new_bvect(2);
BLOCKVECTOR_BLOCK(BLOCKVECTOR(s), GLOBAL_BLOCK) = new_block(maxsyms);
pst->next = partial_symtab_list;
partial_symtab_list = pst;
- /* Keep a backpointer to the file`s symbols */
+ /* Keep a backpointer to the file's symbols */
/* FIXME, we should use private data that is a proper pointer. */
pst->ldsymlen = (int)cur_hdr;