From 27202b6a4746af217ab914394a1ab9b111b1db3c Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Sun, 12 Feb 1995 18:46:45 +0000 Subject: * buildsym.c (finish_block): If finishing a function without known parameter type info, set that from parameter symbols. * c-typeprint.c (c_type_print_varspec_suffix): For TYPE_CODE_FUNC, print parameter types, if available. * ch-typeprint.c (chill_type_print_base): Likewise. * gdbtypes.h (struct type): Remove function type field. (TYPE_FUNCTION_TYPE): Remove macro. We can't as simply re-use function types now that we're also storing parameter types. And the payoff is much less. * gdbtypes.c (make_function_type): Don't use/set TYPE_FUNCTION_TYPE. (recursive_dump_type): Don't print TYPE_FUNCTION_TYPE. * dwarfread.c (read_subroutine_type): Don't set TYPE_FUNCTION_TYPE. --- gdb/ChangeLog | 16 ++++++++++++++++ gdb/buildsym.c | 42 ++++++++++++++++++++++++++++++++++++++++++ gdb/c-typeprint.c | 14 +++++++++++++- gdb/ch-typeprint.c | 21 ++++++++++++++++++++- gdb/dwarfread.c | 1 - gdb/gdbtypes.c | 18 ------------------ gdb/gdbtypes.h | 9 +-------- 7 files changed, 92 insertions(+), 29 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9ac6b29..42ea03e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,19 @@ +Sun Feb 12 10:02:16 1995 Per Bothner + + * buildsym.c (finish_block): If finishing a function without known + parameter type info, set that from parameter symbols. + * c-typeprint.c (c_type_print_varspec_suffix): For TYPE_CODE_FUNC, + print parameter types, if available. + * ch-typeprint.c (chill_type_print_base): Likewise. + + * gdbtypes.h (struct type): Remove function type field. + (TYPE_FUNCTION_TYPE): Remove macro. We can't as simply re-use + function types now that we're also storing parameter types. + And the payoff is much less. + * gdbtypes.c (make_function_type): Don't use/set TYPE_FUNCTION_TYPE. + (recursive_dump_type): Don't print TYPE_FUNCTION_TYPE. + * dwarfread.c (read_subroutine_type): Don't set TYPE_FUNCTION_TYPE. + Sun Feb 12 09:03:47 1995 Jim Kingdon (kingdon@lioth.cygnus.com) * buildsym.c (start_subfile): Set language for f2c like for cfront. diff --git a/gdb/buildsym.c b/gdb/buildsym.c index fc03378..45ee77a 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -31,6 +31,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "symtab.h" #include "symfile.h" /* Needed for "struct complaint" */ #include "objfiles.h" +#include "gdbtypes.h" #include "complaints.h" #include @@ -226,8 +227,49 @@ finish_block (symbol, listhead, old_blocks, start, end, objfile) if (symbol) { + struct type *ftype = SYMBOL_TYPE (symbol); SYMBOL_BLOCK_VALUE (symbol) = block; BLOCK_FUNCTION (block) = symbol; + + if (TYPE_NFIELDS (ftype) <= 0) + { + /* No parameter type information is recorded with the function's + type. Set that from the type of the parameter symbols. */ + int nparams = 0, iparams; + struct symbol *sym; + for (i = 0; i < BLOCK_NSYMS (block); i++) + { + sym = BLOCK_SYM (block, i); + switch (SYMBOL_CLASS (sym)) + { + case LOC_ARG: + case LOC_REF_ARG: + case LOC_REGPARM: + case LOC_REGPARM_ADDR: + nparams++; + } + } + if (nparams > 0) + { + TYPE_NFIELDS (ftype) = nparams; + TYPE_FIELDS (ftype) = (struct field *) + TYPE_ALLOC (ftype, nparams * sizeof (struct field)); + + for (i = iparams = 0; iparams < nparams; i++) + { + sym = BLOCK_SYM (block, i); + switch (SYMBOL_CLASS (sym)) + { + case LOC_ARG: + case LOC_REF_ARG: + case LOC_REGPARM: + case LOC_REGPARM_ADDR: + TYPE_FIELD_TYPE (ftype, iparams) = SYMBOL_TYPE (sym); + iparams++; + } + } + } + } } else { diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 306123d..3968737 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -420,7 +420,19 @@ c_type_print_varspec_suffix (type, stream, show, passed_a_ptr, demangled_args) if (passed_a_ptr) fprintf_filtered (stream, ")"); if (!demangled_args) - fprintf_filtered (stream, "()"); + { int i, len = TYPE_NFIELDS (type); + fprintf_filtered (stream, "("); + for (i = 0; i < len; i++) + { + if (i > 0) + { + fputs_filtered (", ", stream); + wrap_here (" "); + } + c_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0); + } + fprintf_filtered (stream, ")"); + } c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, passed_a_ptr, 0); break; diff --git a/gdb/ch-typeprint.c b/gdb/ch-typeprint.c index 8474cce..f06a85c 100644 --- a/gdb/ch-typeprint.c +++ b/gdb/ch-typeprint.c @@ -165,7 +165,26 @@ chill_type_print_base (type, stream, show, level) chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level); break; case TYPE_CODE_FUNC: - fprintf_filtered (stream, "PROC (?)"); + fprintf_filtered (stream, "PROC ("); + len = TYPE_NFIELDS (type); + for (i = 0; i < len; i++) + { + struct type *param_type = TYPE_FIELD_TYPE (type, i); + if (i > 0) + { + fputs_filtered (", ", stream); + wrap_here (" "); + } + if (TYPE_CODE (param_type) == TYPE_CODE_REF) + { + chill_type_print_base (TYPE_TARGET_TYPE (param_type), + stream, show, level); + fputs_filtered (" LOC", stream); + } + else + chill_type_print_base (param_type, stream, show, level); + } + fprintf_filtered (stream, ")"); if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID) { fputs_filtered (" RETURNS (", stream); diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index 5afe795..ec6182d 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -1600,7 +1600,6 @@ read_subroutine_type (dip, thisdie, enddie) /* We have an existing partially constructed type, so bash it into the correct type. */ TYPE_TARGET_TYPE (ftype) = type; - TYPE_FUNCTION_TYPE (type) = ftype; TYPE_LENGTH (ftype) = 1; TYPE_CODE (ftype) = TYPE_CODE_FUNC; } diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 2ccc845..1a281c8 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -226,17 +226,6 @@ make_function_type (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)); @@ -252,14 +241,10 @@ make_function_type (type, typeptr) } 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; } @@ -1444,9 +1429,6 @@ recursive_dump_type (type, spaces) printfi_filtered (spaces, "reference_type "); gdb_print_address (TYPE_REFERENCE_TYPE (type), gdb_stdout); printf_filtered ("\n"); - printfi_filtered (spaces, "function_type "); - gdb_print_address (TYPE_FUNCTION_TYPE (type), gdb_stdout); - printf_filtered ("\n"); printfi_filtered (spaces, "flags 0x%x", TYPE_FLAGS (type)); if (TYPE_FLAGS (type) & TYPE_FLAG_UNSIGNED) { diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 27166c1..c6b9551 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -228,13 +228,6 @@ struct type struct type *reference_type; - /* Type that is a function returning this type. - NULL if no such function type is known here. - The debugger may add the address of such a type - if it has to construct one later. */ - - struct type *function_type; - /* Flags about this type. */ short flags; @@ -249,6 +242,7 @@ struct type For range types, there are two "fields", the minimum and maximum values (both inclusive). For enum types, each possible value is described by one "field". + For a function type, a "field" for each parameter type. For C++ classes, there is one field for each base class (if it is a derived class) plus one field for each class data member. Member functions are recorded elsewhere. @@ -484,7 +478,6 @@ allocate_cplus_struct_type PARAMS ((struct type *)); #define TYPE_TARGET_TYPE(thistype) (thistype)->target_type #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type -#define TYPE_FUNCTION_TYPE(thistype) (thistype)->function_type #define TYPE_LENGTH(thistype) (thistype)->length #define TYPE_OBJFILE(thistype) (thistype)->objfile #define TYPE_FLAGS(thistype) (thistype)->flags -- cgit v1.1