aboutsummaryrefslogtreecommitdiff
path: root/gdb/stabsread.c
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2009-06-29 13:18:37 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2009-06-29 13:18:37 +0000
commit46bf50512ce837bbc53e8704dd5117db3273099b (patch)
tree46832d44f1d266f8be7f9786c64080e6f85e410f /gdb/stabsread.c
parentb08f1e8d6d0c824023e04fa0f379026fd4d56c72 (diff)
downloadgdb-46bf50512ce837bbc53e8704dd5117db3273099b.zip
gdb-46bf50512ce837bbc53e8704dd5117db3273099b.tar.gz
gdb-46bf50512ce837bbc53e8704dd5117db3273099b.tar.bz2
* gdbtypes.h (struct builtin_type): Remove builtin_core_addr,
nodebug_text_symbol, nodebug_data_symbol, nodebug_unknown_symbol, and nodebug_tls_symbol members. (struct objfile_type): New data structure. (objfile_type): Add prototype. * gdbtypes.c (gdbtypes_post_init): Remove initialization code for types no longer in struct builtin_type. (objfile_type_data): New static variable. (_initialize_gdbtypes): Initialize it. (objfile_type): New function. * gdbtypes.h (builtin_type_error): Remove. * gdbtypes.c (build_complex): Do not use builtin_type_error. * symtab.c (builtin_type_error): Remove. (_initialize_symtab): Remove initialization. * stabsread.c (dbx_lookup_type, define_symbol, error_type, rs6000_builtin_type, read_range_type): Use per-objfile types instead of global or per-architecture builtin types. * coffread.c (decode_type): Likewise. * dwarf2read.c (read_array_type, read_tag_string_type, new_symbol, die_type): Likewise. * mdebugread.c (parse_symbol, basic_type, upgrade_type, parse_procedure, psymtab_to_symtab_1): Likewise. * xcoffread.c (process_xcoff_symbol): Likewise. * parse.c (write_exp_msymbol): Likewise. * stabsread.c (rs6000_builtin_type_data): New static variable. (_initialize_stabsread): Initialize it. (rs6000_builtin_type): Add OBJFILE argument. Allocate builtin types per-objfile instead of globally. * stabsread.c (dbx_lookup_type): Add OBJFILE argument. Use it instead of current_objfile; pass it to rs6000_builtin_type. (dbx_alloc_type, read_type, read_range_type): Update calls. (cleanup_undefined_types_noname): Add OBJFILE argument and pass it to dbx_lookup_type. (cleanup_undefined_types): Add OBJFILE argument and pass it to cleanup_undefined_types_noname. * stabsread.h (cleanup_undefined_types): Add OBJFILE argument. * buildsym.c (end_symtab): Update call.
Diffstat (limited to 'gdb/stabsread.c')
-rw-r--r--gdb/stabsread.c164
1 files changed, 89 insertions, 75 deletions
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index ed67096..624a4c0 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -114,7 +114,7 @@ static struct type *read_sun_floating_type (char **, int[2],
static struct type *read_enum_type (char **, struct type *, struct objfile *);
-static struct type *rs6000_builtin_type (int);
+static struct type *rs6000_builtin_type (int, struct objfile *);
static int
read_member_functions (struct field_info *, char **, struct type *,
@@ -218,7 +218,7 @@ static int noname_undefs_length;
or for associating a new type with the pair. */
static struct type **
-dbx_lookup_type (int typenums[2])
+dbx_lookup_type (int typenums[2], struct objfile *objfile)
{
int filenum = typenums[0];
int index = typenums[1];
@@ -249,7 +249,7 @@ dbx_lookup_type (int typenums[2])
this will do the right thing. */
static struct type *temp_type;
- temp_type = rs6000_builtin_type (index);
+ temp_type = rs6000_builtin_type (index, objfile);
return &temp_type;
}
@@ -280,18 +280,18 @@ dbx_lookup_type (int typenums[2])
{
real_filenum = this_object_header_files[filenum];
- if (real_filenum >= N_HEADER_FILES (current_objfile))
+ if (real_filenum >= N_HEADER_FILES (objfile))
{
- static struct type **temp_type_p;
+ static struct type *temp_type;
warning (_("GDB internal error: bad real_filenum"));
error_return:
- temp_type_p = &builtin_type_error;
- return temp_type_p;
+ temp_type = objfile_type (objfile)->builtin_error;
+ return &temp_type;
}
- f = HEADER_FILES (current_objfile) + real_filenum;
+ f = HEADER_FILES (objfile) + real_filenum;
f_orig_length = f->length;
if (index >= f_orig_length)
@@ -325,7 +325,7 @@ dbx_alloc_type (int typenums[2], struct objfile *objfile)
return (alloc_type (objfile));
}
- type_addr = dbx_lookup_type (typenums);
+ type_addr = dbx_lookup_type (typenums, objfile);
/* If we are referring to a type not known at all yet,
allocate an empty type for it.
@@ -772,7 +772,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
target arithmetic to get the value. real.c in GCC
probably has the necessary code. */
- dbl_type = builtin_type (gdbarch)->builtin_double;
+ dbl_type = objfile_type (objfile)->builtin_double;
dbl_valu =
obstack_alloc (&objfile->objfile_obstack,
TYPE_LENGTH (dbl_type));
@@ -792,7 +792,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
types; other languages probably should have at least
unsigned as well as signed constants. */
- SYMBOL_TYPE (sym) = builtin_type (gdbarch)->builtin_long;
+ SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_long;
SYMBOL_VALUE (sym) = atoi (p);
SYMBOL_CLASS (sym) = LOC_CONST;
}
@@ -903,7 +903,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
it back into builtin_int here.
FIXME: Do we need a new builtin_promoted_int_arg ? */
if (TYPE_CODE (ptype) == TYPE_CODE_VOID)
- ptype = builtin_type (gdbarch)->builtin_int;
+ ptype = objfile_type (objfile)->builtin_int;
TYPE_FIELD_TYPE (ftype, nparams) = ptype;
TYPE_FIELD_ARTIFICIAL (ftype, nparams++) = 0;
}
@@ -995,8 +995,8 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
{
SYMBOL_TYPE (sym) =
TYPE_UNSIGNED (SYMBOL_TYPE (sym))
- ? builtin_type (gdbarch)->builtin_unsigned_int
- : builtin_type (gdbarch)->builtin_int;
+ ? objfile_type (objfile)->builtin_unsigned_int
+ : objfile_type (objfile)->builtin_int;
}
break;
}
@@ -1401,7 +1401,7 @@ error_type (char **pp, struct objfile *objfile)
break;
}
}
- return (builtin_type_error);
+ return objfile_type (objfile)->builtin_error;
}
@@ -1577,7 +1577,7 @@ again:
obstack_free (&objfile->objfile_obstack, type_name);
type = SYMBOL_TYPE (sym);
if (typenums[0] != -1)
- *dbx_lookup_type (typenums) = type;
+ *dbx_lookup_type (typenums, objfile) = type;
return type;
}
}
@@ -1672,17 +1672,18 @@ again:
case '*': /* Pointer to another type */
type1 = read_type (pp, objfile);
- type = make_pointer_type (type1, dbx_lookup_type (typenums));
+ type = make_pointer_type (type1, dbx_lookup_type (typenums, objfile));
break;
case '&': /* Reference to another type */
type1 = read_type (pp, objfile);
- type = make_reference_type (type1, dbx_lookup_type (typenums));
+ type = make_reference_type (type1, dbx_lookup_type (typenums, objfile));
break;
case 'f': /* Function returning another type */
type1 = read_type (pp, objfile);
- type = make_function_type (type1, dbx_lookup_type (typenums), objfile);
+ type = make_function_type (type1, dbx_lookup_type (typenums, objfile),
+ objfile);
break;
case 'g': /* Prototyped function. (Sun) */
@@ -1705,8 +1706,8 @@ again:
const char *type_start = (*pp) - 1;
struct type *return_type = read_type (pp, objfile);
struct type *func_type
- = make_function_type (return_type, dbx_lookup_type (typenums),
- objfile);
+ = make_function_type (return_type,
+ dbx_lookup_type (typenums, objfile), objfile);
struct type_list {
struct type *type;
struct type_list *next;
@@ -1762,13 +1763,13 @@ again:
case 'k': /* Const qualifier on some type (Sun) */
type = read_type (pp, objfile);
type = make_cv_type (1, TYPE_VOLATILE (type), type,
- dbx_lookup_type (typenums));
+ dbx_lookup_type (typenums, objfile));
break;
case 'B': /* Volatile qual on some type (Sun) */
type = read_type (pp, objfile);
type = make_cv_type (TYPE_CONST (type), 1, type,
- dbx_lookup_type (typenums));
+ dbx_lookup_type (typenums, objfile));
break;
case '@':
@@ -1842,7 +1843,7 @@ again:
symnum);
type = allocate_stub_method (return_type);
if (typenums[0] != -1)
- *dbx_lookup_type (typenums) = type;
+ *dbx_lookup_type (typenums, objfile) = type;
}
else
{
@@ -1870,7 +1871,7 @@ again:
case 'r': /* Range type */
type = read_range_type (pp, typenums, type_size, objfile);
if (typenums[0] != -1)
- *dbx_lookup_type (typenums) = type;
+ *dbx_lookup_type (typenums, objfile) = type;
break;
case 'b':
@@ -1878,21 +1879,21 @@ again:
/* Sun ACC builtin int type */
type = read_sun_builtin_type (pp, typenums, objfile);
if (typenums[0] != -1)
- *dbx_lookup_type (typenums) = type;
+ *dbx_lookup_type (typenums, objfile) = type;
}
break;
case 'R': /* Sun ACC builtin float type */
type = read_sun_floating_type (pp, typenums, objfile);
if (typenums[0] != -1)
- *dbx_lookup_type (typenums) = type;
+ *dbx_lookup_type (typenums, objfile) = type;
break;
case 'e': /* Enumeration type */
type = dbx_alloc_type (typenums, objfile);
type = read_enum_type (pp, type, objfile);
if (typenums[0] != -1)
- *dbx_lookup_type (typenums) = type;
+ *dbx_lookup_type (typenums, objfile) = type;
break;
case 's': /* Struct type */
@@ -1932,7 +1933,7 @@ again:
if (is_string)
TYPE_CODE (type) = TYPE_CODE_BITSTRING;
if (typenums[0] != -1)
- *dbx_lookup_type (typenums) = type;
+ *dbx_lookup_type (typenums, objfile) = type;
break;
default:
@@ -1957,20 +1958,31 @@ again:
/* RS/6000 xlc/dbx combination uses a set of builtin types, starting from -1.
Return the proper type node for a given builtin type number. */
+static const struct objfile_data *rs6000_builtin_type_data;
+
static struct type *
-rs6000_builtin_type (int typenum)
+rs6000_builtin_type (int typenum, struct objfile *objfile)
{
+ struct type **negative_types = objfile_data (objfile, rs6000_builtin_type_data);
+
/* We recognize types numbered from -NUMBER_RECOGNIZED to -1. */
#define NUMBER_RECOGNIZED 34
- /* This includes an empty slot for type number -0. */
- static struct type *negative_types[NUMBER_RECOGNIZED + 1];
struct type *rettype = NULL;
if (typenum >= 0 || typenum < -NUMBER_RECOGNIZED)
{
complaint (&symfile_complaints, _("Unknown builtin type %d"), typenum);
- return builtin_type_error;
+ return objfile_type (objfile)->builtin_error;
}
+
+ if (!negative_types)
+ {
+ /* This includes an empty slot for type number -0. */
+ negative_types = OBSTACK_CALLOC (&objfile->objfile_obstack,
+ NUMBER_RECOGNIZED + 1, struct type *);
+ set_objfile_data (objfile, rs6000_builtin_type_data, negative_types);
+ }
+
if (negative_types[-typenum] != NULL)
return negative_types[-typenum];
@@ -1990,129 +2002,129 @@ rs6000_builtin_type (int typenum)
is other than 32 bits, then it should use a new negative type
number (or avoid negative type numbers for that case).
See stabs.texinfo. */
- rettype = init_type (TYPE_CODE_INT, 4, 0, "int", NULL);
+ rettype = init_type (TYPE_CODE_INT, 4, 0, "int", objfile);
break;
case 2:
- rettype = init_type (TYPE_CODE_INT, 1, 0, "char", NULL);
+ rettype = init_type (TYPE_CODE_INT, 1, 0, "char", objfile);
break;
case 3:
- rettype = init_type (TYPE_CODE_INT, 2, 0, "short", NULL);
+ rettype = init_type (TYPE_CODE_INT, 2, 0, "short", objfile);
break;
case 4:
- rettype = init_type (TYPE_CODE_INT, 4, 0, "long", NULL);
+ rettype = init_type (TYPE_CODE_INT, 4, 0, "long", objfile);
break;
case 5:
rettype = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED,
- "unsigned char", NULL);
+ "unsigned char", objfile);
break;
case 6:
- rettype = init_type (TYPE_CODE_INT, 1, 0, "signed char", NULL);
+ rettype = init_type (TYPE_CODE_INT, 1, 0, "signed char", objfile);
break;
case 7:
rettype = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED,
- "unsigned short", NULL);
+ "unsigned short", objfile);
break;
case 8:
rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
- "unsigned int", NULL);
+ "unsigned int", objfile);
break;
case 9:
rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
- "unsigned", NULL);
+ "unsigned", objfile);
case 10:
rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
- "unsigned long", NULL);
+ "unsigned long", objfile);
break;
case 11:
- rettype = init_type (TYPE_CODE_VOID, 1, 0, "void", NULL);
+ rettype = init_type (TYPE_CODE_VOID, 1, 0, "void", objfile);
break;
case 12:
/* IEEE single precision (32 bit). */
- rettype = init_type (TYPE_CODE_FLT, 4, 0, "float", NULL);
+ rettype = init_type (TYPE_CODE_FLT, 4, 0, "float", objfile);
break;
case 13:
/* IEEE double precision (64 bit). */
- rettype = init_type (TYPE_CODE_FLT, 8, 0, "double", NULL);
+ rettype = init_type (TYPE_CODE_FLT, 8, 0, "double", objfile);
break;
case 14:
/* This is an IEEE double on the RS/6000, and different machines with
different sizes for "long double" should use different negative
type numbers. See stabs.texinfo. */
- rettype = init_type (TYPE_CODE_FLT, 8, 0, "long double", NULL);
+ rettype = init_type (TYPE_CODE_FLT, 8, 0, "long double", objfile);
break;
case 15:
- rettype = init_type (TYPE_CODE_INT, 4, 0, "integer", NULL);
+ rettype = init_type (TYPE_CODE_INT, 4, 0, "integer", objfile);
break;
case 16:
rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
- "boolean", NULL);
+ "boolean", objfile);
break;
case 17:
- rettype = init_type (TYPE_CODE_FLT, 4, 0, "short real", NULL);
+ rettype = init_type (TYPE_CODE_FLT, 4, 0, "short real", objfile);
break;
case 18:
- rettype = init_type (TYPE_CODE_FLT, 8, 0, "real", NULL);
+ rettype = init_type (TYPE_CODE_FLT, 8, 0, "real", objfile);
break;
case 19:
- rettype = init_type (TYPE_CODE_ERROR, 0, 0, "stringptr", NULL);
+ rettype = init_type (TYPE_CODE_ERROR, 0, 0, "stringptr", objfile);
break;
case 20:
rettype = init_type (TYPE_CODE_CHAR, 1, TYPE_FLAG_UNSIGNED,
- "character", NULL);
+ "character", objfile);
break;
case 21:
rettype = init_type (TYPE_CODE_BOOL, 1, TYPE_FLAG_UNSIGNED,
- "logical*1", NULL);
+ "logical*1", objfile);
break;
case 22:
rettype = init_type (TYPE_CODE_BOOL, 2, TYPE_FLAG_UNSIGNED,
- "logical*2", NULL);
+ "logical*2", objfile);
break;
case 23:
rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
- "logical*4", NULL);
+ "logical*4", objfile);
break;
case 24:
rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
- "logical", NULL);
+ "logical", objfile);
break;
case 25:
/* Complex type consisting of two IEEE single precision values. */
- rettype = init_type (TYPE_CODE_COMPLEX, 8, 0, "complex", NULL);
+ rettype = init_type (TYPE_CODE_COMPLEX, 8, 0, "complex", objfile);
TYPE_TARGET_TYPE (rettype) = init_type (TYPE_CODE_FLT, 4, 0, "float",
- NULL);
+ objfile);
break;
case 26:
/* Complex type consisting of two IEEE double precision values. */
rettype = init_type (TYPE_CODE_COMPLEX, 16, 0, "double complex", NULL);
TYPE_TARGET_TYPE (rettype) = init_type (TYPE_CODE_FLT, 8, 0, "double",
- NULL);
+ objfile);
break;
case 27:
- rettype = init_type (TYPE_CODE_INT, 1, 0, "integer*1", NULL);
+ rettype = init_type (TYPE_CODE_INT, 1, 0, "integer*1", objfile);
break;
case 28:
- rettype = init_type (TYPE_CODE_INT, 2, 0, "integer*2", NULL);
+ rettype = init_type (TYPE_CODE_INT, 2, 0, "integer*2", objfile);
break;
case 29:
- rettype = init_type (TYPE_CODE_INT, 4, 0, "integer*4", NULL);
+ rettype = init_type (TYPE_CODE_INT, 4, 0, "integer*4", objfile);
break;
case 30:
- rettype = init_type (TYPE_CODE_CHAR, 2, 0, "wchar", NULL);
+ rettype = init_type (TYPE_CODE_CHAR, 2, 0, "wchar", objfile);
break;
case 31:
- rettype = init_type (TYPE_CODE_INT, 8, 0, "long long", NULL);
+ rettype = init_type (TYPE_CODE_INT, 8, 0, "long long", objfile);
break;
case 32:
rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
- "unsigned long long", NULL);
+ "unsigned long long", objfile);
break;
case 33:
rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
- "logical*8", NULL);
+ "logical*8", objfile);
break;
case 34:
- rettype = init_type (TYPE_CODE_INT, 8, 0, "integer*8", NULL);
+ rettype = init_type (TYPE_CODE_INT, 8, 0, "integer*8", objfile);
break;
}
negative_types[-typenum] = rettype;
@@ -4062,9 +4074,9 @@ read_range_type (char **pp, int typenums[2], int type_size,
handle_true_range:
if (self_subrange)
- index_type = builtin_type (gdbarch)->builtin_int;
+ index_type = objfile_type (objfile)->builtin_int;
else
- index_type = *dbx_lookup_type (rangenums);
+ index_type = *dbx_lookup_type (rangenums, objfile);
if (index_type == NULL)
{
/* Does this actually ever happen? Is that why we are worrying
@@ -4073,7 +4085,7 @@ handle_true_range:
complaint (&symfile_complaints,
_("base type %d of range type is not defined"), rangenums[1]);
- index_type = builtin_type (gdbarch)->builtin_int;
+ index_type = objfile_type (objfile)->builtin_int;
}
result_type = create_range_type ((struct type *) NULL, index_type, n2, n3);
@@ -4293,7 +4305,7 @@ add_undefined_type (struct type *type, int typenums[2])
/* Try to fix all undefined types pushed on the UNDEF_TYPES vector. */
static void
-cleanup_undefined_types_noname (void)
+cleanup_undefined_types_noname (struct objfile *objfile)
{
int i;
@@ -4302,7 +4314,7 @@ cleanup_undefined_types_noname (void)
struct nat nat = noname_undefs[i];
struct type **type;
- type = dbx_lookup_type (nat.typenums);
+ type = dbx_lookup_type (nat.typenums, objfile);
if (nat.type != *type && TYPE_CODE (*type) != TYPE_CODE_UNDEF)
{
/* The instance flags of the undefined type are still unset,
@@ -4415,10 +4427,10 @@ cleanup_undefined_types_1 (void)
this unit. */
void
-cleanup_undefined_types (void)
+cleanup_undefined_types (struct objfile *objfile)
{
cleanup_undefined_types_1 ();
- cleanup_undefined_types_noname ();
+ cleanup_undefined_types_noname (objfile);
}
/* Scan through all of the global symbols defined in the object file,
@@ -4650,6 +4662,8 @@ find_name_end (char *name)
void
_initialize_stabsread (void)
{
+ rs6000_builtin_type_data = register_objfile_data ();
+
undef_types_allocated = 20;
undef_types_length = 0;
undef_types = (struct type **)