mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-09-10 14:59:31 +08:00
* gdbtypes.c (make_{reference,pointer,function}_type): New
functions which handle overwriting of forward-referenced types for stabs file reading. (lookup_{reference,pointer,function}_type): These just call the make_*_type functions with a null storage alloc parameter. * gdbtypes.h (make_{reference,pointer,function}_type): Declare. * xcoffread.c (smash_to_pointer_type): Remove, no longer used. * buildsym.c (dbx_lookup_type): Zero result for (-1,-1) arg. (dbx_alloc_type): Make it easier to understand. No funct change. (define_symbol: 't'): Don't put the typedef name into the name of the struct, union, or enum. Bugfix. (read_type: '*', '&', 'f'): Add comments. Use make_XXX_type routines to properly handle overwriting preallocated types so that forward references will work. (read_enum_type): Force enum values to file scope, due to bug in Sun compiler output. FIXME, fix later. Remove unused header_file_prev_index mechanism. It was already obsolete in gdb-3.5. These comments appeared in 3.5: /* This code was used before I knew about the instance codes. My first hypothesis is that it is not necessary now that instance codes are handled. */ * dbxread.c (add_new_header_file): Remove header_file_prev_index. * buildsym.h: Remove it and prev_index that saves it. * buildsym.c (push_subfile, pop_subfile, start_symtab): Remove it. * solib.c (special_symbol_handling): When called from core files, must set up debug_addr. Don't print error messages, just return. * symmisc.c (print_symbol): Less ascii diarrhea for enums, please.
This commit is contained in:
@ -1,3 +1,36 @@
|
|||||||
|
Fri May 1 01:53:26 1992 John Gilmore (gnu at cygnus.com)
|
||||||
|
|
||||||
|
* gdbtypes.c (make_{reference,pointer,function}_type): New
|
||||||
|
functions which handle overwriting of forward-referenced types
|
||||||
|
for stabs file reading.
|
||||||
|
(lookup_{reference,pointer,function}_type): These just call
|
||||||
|
the make_*_type functions with a null storage alloc parameter.
|
||||||
|
* gdbtypes.h (make_{reference,pointer,function}_type): Declare.
|
||||||
|
* xcoffread.c (smash_to_pointer_type): Remove, no longer used.
|
||||||
|
|
||||||
|
* buildsym.c (dbx_lookup_type): Zero result for (-1,-1) arg.
|
||||||
|
(dbx_alloc_type): Make it easier to understand. No funct change.
|
||||||
|
(define_symbol: 't'): Don't put the typedef name into the name of
|
||||||
|
the struct, union, or enum. Bugfix.
|
||||||
|
(read_type: '*', '&', 'f'): Add comments. Use make_XXX_type
|
||||||
|
routines to properly handle overwriting preallocated types so that
|
||||||
|
forward references will work.
|
||||||
|
(read_enum_type): Force enum values to file scope, due to bug in
|
||||||
|
Sun compiler output. FIXME, fix later.
|
||||||
|
|
||||||
|
Remove unused header_file_prev_index mechanism. It was already
|
||||||
|
obsolete in gdb-3.5. These comments appeared in 3.5:
|
||||||
|
/* This code was used before I knew about the instance codes.
|
||||||
|
My first hypothesis is that it is not necessary now
|
||||||
|
that instance codes are handled. */
|
||||||
|
* dbxread.c (add_new_header_file): Remove header_file_prev_index.
|
||||||
|
* buildsym.h: Remove it and prev_index that saves it.
|
||||||
|
* buildsym.c (push_subfile, pop_subfile, start_symtab): Remove it.
|
||||||
|
|
||||||
|
* solib.c (special_symbol_handling): When called from core files,
|
||||||
|
must set up debug_addr. Don't print error messages, just return.
|
||||||
|
* symmisc.c (print_symbol): Less ascii diarrhea for enums, please.
|
||||||
|
|
||||||
Wed Apr 29 15:26:51 1992 Per Bothner (bothner@rtl.cygnus.com)
|
Wed Apr 29 15:26:51 1992 Per Bothner (bothner@rtl.cygnus.com)
|
||||||
|
|
||||||
* cplus-dem.c: Allow nested class names (as in
|
* cplus-dem.c: Allow nested class names (as in
|
||||||
|
126
gdb/buildsym.c
126
gdb/buildsym.c
@ -189,6 +189,9 @@ dbx_lookup_type (typenums)
|
|||||||
register int filenum = typenums[0], index = typenums[1];
|
register int filenum = typenums[0], index = typenums[1];
|
||||||
unsigned old_len;
|
unsigned old_len;
|
||||||
|
|
||||||
|
if (filenum == -1) /* -1,-1 is for temporary types. */
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (filenum < 0 || filenum >= n_this_object_header_files)
|
if (filenum < 0 || filenum >= n_this_object_header_files)
|
||||||
error ("Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
|
error ("Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
|
||||||
filenum, index, symnum);
|
filenum, index, symnum);
|
||||||
@ -252,30 +255,19 @@ dbx_alloc_type (typenums, objfile)
|
|||||||
struct objfile *objfile;
|
struct objfile *objfile;
|
||||||
{
|
{
|
||||||
register struct type **type_addr;
|
register struct type **type_addr;
|
||||||
register struct type *type;
|
|
||||||
|
|
||||||
if (typenums[0] != -1)
|
if (typenums[0] == -1)
|
||||||
{
|
return alloc_type (objfile);
|
||||||
type_addr = dbx_lookup_type (typenums);
|
|
||||||
type = *type_addr;
|
type_addr = dbx_lookup_type (typenums);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
type_addr = 0;
|
|
||||||
type = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we are referring to a type not known at all yet,
|
/* If we are referring to a type not known at all yet,
|
||||||
allocate an empty type for it.
|
allocate an empty type for it.
|
||||||
We will fill it in later if we find out how. */
|
We will fill it in later if we find out how. */
|
||||||
if (type == 0)
|
if (*type_addr == 0)
|
||||||
{
|
*type_addr = alloc_type (objfile);
|
||||||
type = alloc_type (objfile);
|
|
||||||
if (type_addr)
|
return *type_addr;
|
||||||
*type_addr = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
return type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* maintain the lists of symbols and blocks */
|
/* maintain the lists of symbols and blocks */
|
||||||
@ -595,7 +587,6 @@ push_subfile ()
|
|||||||
if (current_subfile == 0 || current_subfile->name == 0)
|
if (current_subfile == 0 || current_subfile->name == 0)
|
||||||
abort ();
|
abort ();
|
||||||
tem->name = current_subfile->name;
|
tem->name = current_subfile->name;
|
||||||
tem->prev_index = header_file_prev_index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@ -609,7 +600,6 @@ pop_subfile ()
|
|||||||
|
|
||||||
name = link->name;
|
name = link->name;
|
||||||
subfile_stack = link->next;
|
subfile_stack = link->next;
|
||||||
header_file_prev_index = link->prev_index;
|
|
||||||
free ((PTR)link);
|
free ((PTR)link);
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
@ -692,7 +682,6 @@ start_symtab (name, dirname, start_addr)
|
|||||||
|
|
||||||
/* Leave FILENUM of 0 free for builtin types and this file's types. */
|
/* Leave FILENUM of 0 free for builtin types and this file's types. */
|
||||||
n_this_object_header_files = 1;
|
n_this_object_header_files = 1;
|
||||||
header_file_prev_index = -1;
|
|
||||||
|
|
||||||
type_vector_length = 0;
|
type_vector_length = 0;
|
||||||
type_vector = (struct type **) 0;
|
type_vector = (struct type **) 0;
|
||||||
@ -1277,6 +1266,7 @@ define_symbol (valu, string, desc, type, objfile)
|
|||||||
save away the name so that far away from here in read_range_type,
|
save away the name so that far away from here in read_range_type,
|
||||||
we can examine it to decide between "int" and "long". FIXME. */
|
we can examine it to decide between "int" and "long". FIXME. */
|
||||||
long_kludge_name = SYMBOL_NAME (sym);
|
long_kludge_name = SYMBOL_NAME (sym);
|
||||||
|
|
||||||
type_read = read_type (&p, objfile);
|
type_read = read_type (&p, objfile);
|
||||||
|
|
||||||
if ((deftype == 'F' || deftype == 'f')
|
if ((deftype == 'F' || deftype == 'f')
|
||||||
@ -1475,16 +1465,12 @@ define_symbol (valu, string, desc, type, objfile)
|
|||||||
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
|
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
|
||||||
SYMBOL_VALUE (sym) = valu;
|
SYMBOL_VALUE (sym) = valu;
|
||||||
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
||||||
if (TYPE_NAME (SYMBOL_TYPE (sym)) == NULL)
|
/* C++ vagaries: we may have a type which is derived from
|
||||||
TYPE_NAME (SYMBOL_TYPE (sym)) =
|
a base type which did not have its name defined when the
|
||||||
obsavestring (SYMBOL_NAME (sym),
|
derived class was output. We fill in the derived class's
|
||||||
strlen (SYMBOL_NAME (sym)),
|
base part member's name here in that case. */
|
||||||
&objfile -> symbol_obstack);
|
if (TYPE_NAME (SYMBOL_TYPE (sym)) != NULL)
|
||||||
/* C++ vagaries: we may have a type which is derived from
|
if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
|
||||||
a base type which did not have its name defined when the
|
|
||||||
derived class was output. We fill in the derived class's
|
|
||||||
base part member's name here in that case. */
|
|
||||||
else if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
|
|
||||||
|| TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
|
|| TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
|
||||||
&& TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)))
|
&& TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)))
|
||||||
{
|
{
|
||||||
@ -1917,23 +1903,30 @@ read_type (pp, objfile)
|
|||||||
*dbx_lookup_type (typenums) = type;
|
*dbx_lookup_type (typenums) = type;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* In the following types, we must be sure to overwrite any existing
|
||||||
|
type that the typenums refer to, rather than allocating a new one
|
||||||
|
and making the typenums point to the new one. This is because there
|
||||||
|
may already be pointers to the existing type (if it had been
|
||||||
|
forward-referenced), and we must change it to a pointer, function,
|
||||||
|
reference, or whatever, *in-place*. */
|
||||||
|
|
||||||
case '*':
|
case '*':
|
||||||
type1 = read_type (pp, objfile);
|
type1 = read_type (pp, objfile);
|
||||||
/* FIXME -- we should be doing smash_to_XXX types here. */
|
type = make_pointer_type (type1, dbx_lookup_type (typenums));
|
||||||
#ifdef IBM6000_TARGET
|
|
||||||
/* postponed type decoration should be allowed. */
|
|
||||||
if (typenums[1] > 0 && typenums[1] < type_vector_length &&
|
|
||||||
(type = type_vector[typenums[1]])) {
|
|
||||||
smash_to_pointer_type (type, type1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
type = lookup_pointer_type (type1);
|
|
||||||
if (typenums[0] != -1)
|
|
||||||
*dbx_lookup_type (typenums) = type;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '@':
|
case '&': /* Reference to another type */
|
||||||
|
type1 = read_type (pp, objfile);
|
||||||
|
type = make_reference_type (type1, dbx_lookup_type (typenums));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'f': /* Function returning another type */
|
||||||
|
type1 = read_type (pp, objfile);
|
||||||
|
type = make_function_type (type1, dbx_lookup_type (typenums));
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* FIXME -- we should be doing smash_to_XXX types here. */
|
||||||
|
case '@': /* Member (class & variable) type */
|
||||||
{
|
{
|
||||||
struct type *domain = read_type (pp, objfile);
|
struct type *domain = read_type (pp, objfile);
|
||||||
struct type *memtype;
|
struct type *memtype;
|
||||||
@ -1949,7 +1942,7 @@ read_type (pp, objfile)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '#':
|
case '#': /* Method (class & fn) type */
|
||||||
if ((*pp)[0] == '#')
|
if ((*pp)[0] == '#')
|
||||||
{
|
{
|
||||||
/* We'll get the parameter types from the name. */
|
/* We'll get the parameter types from the name. */
|
||||||
@ -1980,33 +1973,19 @@ read_type (pp, objfile)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '&':
|
case 'r': /* Range type */
|
||||||
type1 = read_type (pp, objfile);
|
|
||||||
type = lookup_reference_type (type1);
|
|
||||||
if (typenums[0] != -1)
|
|
||||||
*dbx_lookup_type (typenums) = type;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'f':
|
|
||||||
type1 = read_type (pp, objfile);
|
|
||||||
type = lookup_function_type (type1);
|
|
||||||
if (typenums[0] != -1)
|
|
||||||
*dbx_lookup_type (typenums) = type;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'r':
|
|
||||||
type = read_range_type (pp, typenums, objfile);
|
type = read_range_type (pp, typenums, objfile);
|
||||||
if (typenums[0] != -1)
|
if (typenums[0] != -1)
|
||||||
*dbx_lookup_type (typenums) = type;
|
*dbx_lookup_type (typenums) = type;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'e':
|
case 'e': /* Enumeration type */
|
||||||
type = dbx_alloc_type (typenums, objfile);
|
type = dbx_alloc_type (typenums, objfile);
|
||||||
type = read_enum_type (pp, type, objfile);
|
type = read_enum_type (pp, type, objfile);
|
||||||
*dbx_lookup_type (typenums) = type;
|
*dbx_lookup_type (typenums) = type;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's': /* Struct type */
|
||||||
type = dbx_alloc_type (typenums, objfile);
|
type = dbx_alloc_type (typenums, objfile);
|
||||||
if (!TYPE_NAME (type))
|
if (!TYPE_NAME (type))
|
||||||
TYPE_NAME (type) = type_synonym_name;
|
TYPE_NAME (type) = type_synonym_name;
|
||||||
@ -2014,7 +1993,7 @@ read_type (pp, objfile)
|
|||||||
type = read_struct_type (pp, type, objfile);
|
type = read_struct_type (pp, type, objfile);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'u':
|
case 'u': /* Union type */
|
||||||
type = dbx_alloc_type (typenums, objfile);
|
type = dbx_alloc_type (typenums, objfile);
|
||||||
if (!TYPE_NAME (type))
|
if (!TYPE_NAME (type))
|
||||||
TYPE_NAME (type) = type_synonym_name;
|
TYPE_NAME (type) = type_synonym_name;
|
||||||
@ -2023,7 +2002,7 @@ read_type (pp, objfile)
|
|||||||
TYPE_CODE (type) = TYPE_CODE_UNION;
|
TYPE_CODE (type) = TYPE_CODE_UNION;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a':
|
case 'a': /* Array type */
|
||||||
if (**pp != 'r')
|
if (**pp != 'r')
|
||||||
return error_type (pp);
|
return error_type (pp);
|
||||||
++*pp;
|
++*pp;
|
||||||
@ -2041,18 +2020,6 @@ read_type (pp, objfile)
|
|||||||
if (type == 0)
|
if (type == 0)
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* If this is an overriding temporary alteration for a header file's
|
|
||||||
contents, and this type number is unknown in the global definition,
|
|
||||||
put this type into the global definition at this type number. */
|
|
||||||
if (header_file_prev_index >= 0)
|
|
||||||
{
|
|
||||||
register struct type **tp
|
|
||||||
= explicit_lookup_type (header_file_prev_index, typenums[1]);
|
|
||||||
if (*tp == 0)
|
|
||||||
*tp = type;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2874,9 +2841,14 @@ read_enum_type (pp, type, objfile)
|
|||||||
struct pending *osyms, *syms;
|
struct pending *osyms, *syms;
|
||||||
int o_nsyms;
|
int o_nsyms;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* FIXME! The stabs produced by Sun CC merrily define things that ought
|
||||||
|
to be file-scope, between N_FN entries, using N_LSYM. What's a mother
|
||||||
|
to do? For now, force all enum values to file scope. */
|
||||||
if (within_function)
|
if (within_function)
|
||||||
symlist = &local_symbols;
|
symlist = &local_symbols;
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
symlist = &file_symbols;
|
symlist = &file_symbols;
|
||||||
osyms = *symlist;
|
osyms = *symlist;
|
||||||
o_nsyms = osyms ? osyms->nsyms : 0;
|
o_nsyms = osyms ? osyms->nsyms : 0;
|
||||||
|
@ -256,18 +256,10 @@ EXTERN int n_this_object_header_files;
|
|||||||
|
|
||||||
EXTERN int n_allocated_this_object_header_files;
|
EXTERN int n_allocated_this_object_header_files;
|
||||||
|
|
||||||
/* When a header file is getting special overriding definitions
|
|
||||||
for one source file, record here the header_files index
|
|
||||||
of its normal definition vector.
|
|
||||||
At other times, this is -1. */
|
|
||||||
|
|
||||||
EXTERN int header_file_prev_index;
|
|
||||||
|
|
||||||
struct subfile_stack
|
struct subfile_stack
|
||||||
{
|
{
|
||||||
struct subfile_stack *next;
|
struct subfile_stack *next;
|
||||||
char *name;
|
char *name;
|
||||||
int prev_index;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EXTERN struct subfile_stack *subfile_stack;
|
EXTERN struct subfile_stack *subfile_stack;
|
||||||
|
217
gdb/gdbtypes.c
217
gdb/gdbtypes.c
@ -62,6 +62,61 @@ alloc_type (objfile)
|
|||||||
return (type);
|
return (type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points
|
||||||
|
to a pointer to memory where the pointer type should be stored.
|
||||||
|
If *TYPEPTR is zero, update it to point to the pointer type we return.
|
||||||
|
We allocate new memory if needed. */
|
||||||
|
|
||||||
|
struct type *
|
||||||
|
make_pointer_type (type, typeptr)
|
||||||
|
struct type *type;
|
||||||
|
struct type **typeptr;
|
||||||
|
{
|
||||||
|
register struct type *ntype; /* New type */
|
||||||
|
struct objfile *objfile;
|
||||||
|
|
||||||
|
ntype = TYPE_POINTER_TYPE (type);
|
||||||
|
|
||||||
|
if (ntype)
|
||||||
|
if (typeptr == 0)
|
||||||
|
return ntype; /* Don't care about alloc, and have new type. */
|
||||||
|
else if (*typeptr == 0)
|
||||||
|
{
|
||||||
|
*typeptr = ntype; /* Tracking alloc, and we have new type. */
|
||||||
|
return ntype;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
|
||||||
|
{
|
||||||
|
ntype = alloc_type (TYPE_OBJFILE (type));
|
||||||
|
if (typeptr)
|
||||||
|
*typeptr = ntype;
|
||||||
|
}
|
||||||
|
else /* We have storage, but need to reset it. */
|
||||||
|
{
|
||||||
|
ntype = *typeptr;
|
||||||
|
objfile = TYPE_OBJFILE (ntype);
|
||||||
|
memset ((char *)ntype, 0, sizeof (struct type));
|
||||||
|
TYPE_OBJFILE (ntype) = objfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
TYPE_TARGET_TYPE (ntype) = type;
|
||||||
|
TYPE_POINTER_TYPE (type) = ntype;
|
||||||
|
|
||||||
|
/* FIXME! Assume the machine has only one representation for pointers! */
|
||||||
|
|
||||||
|
TYPE_LENGTH (ntype) = TARGET_PTR_BIT / TARGET_CHAR_BIT;
|
||||||
|
TYPE_CODE (ntype) = TYPE_CODE_PTR;
|
||||||
|
|
||||||
|
/* pointers are unsigned */
|
||||||
|
TYPE_FLAGS (ntype) |= TYPE_FLAG_UNSIGNED;
|
||||||
|
|
||||||
|
if (!TYPE_POINTER_TYPE (type)) /* Remember it, if don't have one. */
|
||||||
|
TYPE_POINTER_TYPE (type) = ntype;
|
||||||
|
|
||||||
|
return ntype;
|
||||||
|
}
|
||||||
|
|
||||||
/* Given a type TYPE, return a type of pointers to that type.
|
/* Given a type TYPE, return a type of pointers to that type.
|
||||||
May need to construct such a type if this is the first use. */
|
May need to construct such a type if this is the first use. */
|
||||||
|
|
||||||
@ -69,53 +124,122 @@ struct type *
|
|||||||
lookup_pointer_type (type)
|
lookup_pointer_type (type)
|
||||||
struct type *type;
|
struct type *type;
|
||||||
{
|
{
|
||||||
register struct type *ptype;
|
return make_pointer_type (type, (struct type **)0);
|
||||||
|
|
||||||
if ((ptype = TYPE_POINTER_TYPE (type)) == NULL)
|
|
||||||
{
|
|
||||||
/* This is the first time anyone wanted a pointer to a TYPE. */
|
|
||||||
|
|
||||||
ptype = alloc_type (TYPE_OBJFILE (type));
|
|
||||||
TYPE_TARGET_TYPE (ptype) = type;
|
|
||||||
TYPE_POINTER_TYPE (type) = ptype;
|
|
||||||
|
|
||||||
/* FIXME, assume machine has only one representation for pointers! */
|
|
||||||
|
|
||||||
TYPE_LENGTH (ptype) = TARGET_PTR_BIT / TARGET_CHAR_BIT;
|
|
||||||
TYPE_CODE (ptype) = TYPE_CODE_PTR;
|
|
||||||
|
|
||||||
/* pointers are unsigned */
|
|
||||||
TYPE_FLAGS(ptype) |= TYPE_FLAG_UNSIGNED;
|
|
||||||
|
|
||||||
}
|
|
||||||
return (ptype);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, points
|
||||||
|
to a pointer to memory where the reference type should be stored.
|
||||||
|
If *TYPEPTR is zero, update it to point to the reference type we return.
|
||||||
|
We allocate new memory if needed. */
|
||||||
|
|
||||||
|
struct type *
|
||||||
|
make_reference_type (type, typeptr)
|
||||||
|
struct type *type;
|
||||||
|
struct type **typeptr;
|
||||||
|
{
|
||||||
|
register struct type *ntype; /* New type */
|
||||||
|
struct objfile *objfile;
|
||||||
|
|
||||||
|
ntype = TYPE_REFERENCE_TYPE (type);
|
||||||
|
|
||||||
|
if (ntype)
|
||||||
|
if (typeptr == 0)
|
||||||
|
return ntype; /* Don't care about alloc, and have new type. */
|
||||||
|
else if (*typeptr == 0)
|
||||||
|
{
|
||||||
|
*typeptr = ntype; /* Tracking alloc, and we have new type. */
|
||||||
|
return ntype;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
|
||||||
|
{
|
||||||
|
ntype = alloc_type (TYPE_OBJFILE (type));
|
||||||
|
if (typeptr)
|
||||||
|
*typeptr = ntype;
|
||||||
|
}
|
||||||
|
else /* We have storage, but need to reset it. */
|
||||||
|
{
|
||||||
|
ntype = *typeptr;
|
||||||
|
objfile = TYPE_OBJFILE (ntype);
|
||||||
|
memset ((char *)ntype, 0, sizeof (struct type));
|
||||||
|
TYPE_OBJFILE (ntype) = objfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
TYPE_TARGET_TYPE (ntype) = type;
|
||||||
|
TYPE_REFERENCE_TYPE (type) = ntype;
|
||||||
|
|
||||||
|
/* FIXME! Assume the machine has only one representation for references,
|
||||||
|
and that it matches the (only) representation for pointers! */
|
||||||
|
|
||||||
|
TYPE_LENGTH (ntype) = TARGET_PTR_BIT / TARGET_CHAR_BIT;
|
||||||
|
TYPE_CODE (ntype) = TYPE_CODE_REF;
|
||||||
|
|
||||||
|
if (!TYPE_REFERENCE_TYPE (type)) /* Remember it, if don't have one. */
|
||||||
|
TYPE_REFERENCE_TYPE (type) = ntype;
|
||||||
|
|
||||||
|
return ntype;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Same as above, but caller doesn't care about memory allocation details. */
|
||||||
|
|
||||||
struct type *
|
struct type *
|
||||||
lookup_reference_type (type)
|
lookup_reference_type (type)
|
||||||
struct type *type;
|
struct type *type;
|
||||||
{
|
{
|
||||||
register struct type *rtype;
|
return make_reference_type (type, (struct type **)0);
|
||||||
|
|
||||||
if ((rtype = TYPE_REFERENCE_TYPE (type)) == NULL)
|
|
||||||
{
|
|
||||||
/* This is the first time anyone wanted a pointer to a TYPE. */
|
|
||||||
|
|
||||||
rtype = alloc_type (TYPE_OBJFILE (type));
|
|
||||||
TYPE_TARGET_TYPE (rtype) = type;
|
|
||||||
TYPE_REFERENCE_TYPE (type) = rtype;
|
|
||||||
|
|
||||||
/* We assume the machine has only one representation for pointers! */
|
|
||||||
/* FIXME: This confuses host<->target data representations, and is a
|
|
||||||
poor assumption besides. */
|
|
||||||
|
|
||||||
TYPE_LENGTH (rtype) = sizeof (char *);
|
|
||||||
TYPE_CODE (rtype) = TYPE_CODE_REF;
|
|
||||||
|
|
||||||
}
|
|
||||||
return (rtype);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Lookup a function type that returns type TYPE. TYPEPTR, if nonzero, points
|
||||||
|
to a pointer to memory where the function type should be stored.
|
||||||
|
If *TYPEPTR is zero, update it to point to the function type we return.
|
||||||
|
We allocate new memory if needed. */
|
||||||
|
|
||||||
|
struct type *
|
||||||
|
make_function_type (type, typeptr)
|
||||||
|
struct type *type;
|
||||||
|
struct type **typeptr;
|
||||||
|
{
|
||||||
|
register struct type *ntype; /* New type */
|
||||||
|
struct objfile *objfile;
|
||||||
|
|
||||||
|
ntype = TYPE_FUNCTION_TYPE (type);
|
||||||
|
|
||||||
|
if (ntype)
|
||||||
|
if (typeptr == 0)
|
||||||
|
return ntype; /* Don't care about alloc, and have new type. */
|
||||||
|
else if (*typeptr == 0)
|
||||||
|
{
|
||||||
|
*typeptr = ntype; /* Tracking alloc, and we have new type. */
|
||||||
|
return ntype;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
|
||||||
|
{
|
||||||
|
ntype = alloc_type (TYPE_OBJFILE (type));
|
||||||
|
if (typeptr)
|
||||||
|
*typeptr = ntype;
|
||||||
|
}
|
||||||
|
else /* We have storage, but need to reset it. */
|
||||||
|
{
|
||||||
|
ntype = *typeptr;
|
||||||
|
objfile = TYPE_OBJFILE (ntype);
|
||||||
|
memset ((char *)ntype, 0, sizeof (struct type));
|
||||||
|
TYPE_OBJFILE (ntype) = objfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
TYPE_TARGET_TYPE (ntype) = type;
|
||||||
|
TYPE_FUNCTION_TYPE (type) = ntype;
|
||||||
|
|
||||||
|
TYPE_LENGTH (ntype) = 1;
|
||||||
|
TYPE_CODE (ntype) = TYPE_CODE_FUNC;
|
||||||
|
|
||||||
|
if (!TYPE_FUNCTION_TYPE (type)) /* Remember it, if don't have one. */
|
||||||
|
TYPE_FUNCTION_TYPE (type) = ntype;
|
||||||
|
|
||||||
|
return ntype;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Given a type TYPE, return a type of functions that return that type.
|
/* Given a type TYPE, return a type of functions that return that type.
|
||||||
May need to construct such a type if this is the first use. */
|
May need to construct such a type if this is the first use. */
|
||||||
|
|
||||||
@ -123,20 +247,7 @@ struct type *
|
|||||||
lookup_function_type (type)
|
lookup_function_type (type)
|
||||||
struct type *type;
|
struct type *type;
|
||||||
{
|
{
|
||||||
register struct type *ptype;
|
return make_function_type (type, (struct type **)0);
|
||||||
|
|
||||||
if ((ptype = TYPE_FUNCTION_TYPE (type)) == NULL)
|
|
||||||
{
|
|
||||||
/* This is the first time anyone wanted a function returning a TYPE. */
|
|
||||||
|
|
||||||
ptype = alloc_type (TYPE_OBJFILE (type));
|
|
||||||
TYPE_TARGET_TYPE (ptype) = type;
|
|
||||||
TYPE_FUNCTION_TYPE (type) = ptype;
|
|
||||||
|
|
||||||
TYPE_LENGTH (ptype) = 1;
|
|
||||||
TYPE_CODE (ptype) = TYPE_CODE_FUNC;
|
|
||||||
}
|
|
||||||
return (ptype);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implement direct support for MEMBER_TYPE in GNU C++.
|
/* Implement direct support for MEMBER_TYPE in GNU C++.
|
||||||
|
@ -485,6 +485,9 @@ init_type PARAMS ((enum type_code, int, int, char *, struct objfile *));
|
|||||||
extern struct type *
|
extern struct type *
|
||||||
lookup_reference_type PARAMS ((struct type *));
|
lookup_reference_type PARAMS ((struct type *));
|
||||||
|
|
||||||
|
extern struct type *
|
||||||
|
make_reference_type PARAMS ((struct type *, struct type **));
|
||||||
|
|
||||||
extern struct type *
|
extern struct type *
|
||||||
lookup_member_type PARAMS ((struct type *, struct type *));
|
lookup_member_type PARAMS ((struct type *, struct type *));
|
||||||
|
|
||||||
@ -504,9 +507,15 @@ type_name_no_tag PARAMS ((const struct type *));
|
|||||||
extern struct type *
|
extern struct type *
|
||||||
lookup_struct_elt_type PARAMS ((struct type *, char *, int));
|
lookup_struct_elt_type PARAMS ((struct type *, char *, int));
|
||||||
|
|
||||||
|
extern struct type *
|
||||||
|
make_pointer_type PARAMS ((struct type *, struct type **));
|
||||||
|
|
||||||
extern struct type *
|
extern struct type *
|
||||||
lookup_pointer_type PARAMS ((struct type *));
|
lookup_pointer_type PARAMS ((struct type *));
|
||||||
|
|
||||||
|
extern struct type *
|
||||||
|
make_function_type PARAMS ((struct type *, struct type **));
|
||||||
|
|
||||||
extern struct type *
|
extern struct type *
|
||||||
lookup_function_type PARAMS ((struct type *));
|
lookup_function_type PARAMS ((struct type *));
|
||||||
|
|
||||||
|
@ -2333,52 +2333,6 @@ _initialize_xcoffread ()
|
|||||||
add_symtab_fns(&aixcoff_sym_fns);
|
add_symtab_fns(&aixcoff_sym_fns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* In order to handle forward type references, we needed to have this old
|
|
||||||
routine. Try printing the type of member `p' in the following structure
|
|
||||||
in a dbx environment.
|
|
||||||
|
|
||||||
struct s {
|
|
||||||
...
|
|
||||||
struct s *p;
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Smash TYPE to be a type of pointers to TO_TYPE.
|
|
||||||
If TO_TYPE is not permanent and has no pointer-type yet,
|
|
||||||
record TYPE as its pointer-type. */
|
|
||||||
|
|
||||||
void
|
|
||||||
smash_to_pointer_type (type, to_type)
|
|
||||||
struct type *type, *to_type;
|
|
||||||
{
|
|
||||||
/* int type_permanent = (TYPE_FLAGS (type) & TYPE_FLAG_PERM); */
|
|
||||||
|
|
||||||
bzero (type, sizeof (struct type));
|
|
||||||
TYPE_TARGET_TYPE (type) = to_type;
|
|
||||||
/* We assume the machine has only one representation for pointers! */
|
|
||||||
TYPE_LENGTH (type) = sizeof (char *);
|
|
||||||
TYPE_CODE (type) = TYPE_CODE_PTR;
|
|
||||||
|
|
||||||
/* ??? TYPE_TARGET_TYPE and TYPE_MAIN_VARIANT are the same. You can't do
|
|
||||||
this. It will break the target type!!!
|
|
||||||
TYPE_MAIN_VARIANT (type) = type;
|
|
||||||
|
|
||||||
if (type_permanent)
|
|
||||||
TYPE_FLAGS (type) |= TYPE_FLAG_PERM;
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (TYPE_POINTER_TYPE (to_type) == 0)
|
|
||||||
#if 0
|
|
||||||
&& (!(TYPE_FLAGS (to_type) & TYPE_FLAG_PERM)
|
|
||||||
|| type_permanent))
|
|
||||||
#endif /* 0 */
|
|
||||||
{
|
|
||||||
TYPE_POINTER_TYPE (to_type) = type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* IBM6000_HOST */
|
#else /* IBM6000_HOST */
|
||||||
struct type *
|
struct type *
|
||||||
builtin_type (ignore)
|
builtin_type (ignore)
|
||||||
|
Reference in New Issue
Block a user