aboutsummaryrefslogtreecommitdiff
path: root/gdb/stabsread.c
diff options
context:
space:
mode:
authorJim Kingdon <jkingdon@engr.sgi.com>1993-04-22 22:27:25 +0000
committerJim Kingdon <jkingdon@engr.sgi.com>1993-04-22 22:27:25 +0000
commit5afa2040f45d3772e759c2e148ad8bf33115c80a (patch)
tree1daadfad56d3ec827d2fe2e70f97b98abafb2117 /gdb/stabsread.c
parent4365c36c9b87e20565b20c52809c781c50831a18 (diff)
downloadgdb-5afa2040f45d3772e759c2e148ad8bf33115c80a.zip
gdb-5afa2040f45d3772e759c2e148ad8bf33115c80a.tar.gz
gdb-5afa2040f45d3772e759c2e148ad8bf33115c80a.tar.bz2
Thu Apr 22 14:50:05 1993 Jim Kingdon (kingdon@cygnus.com)
* symtab.h: Fix LOC_REF_ARG comment. Wed Apr 22 20:21:30 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) and Jim Kingdon (kingdon@cygnus.com) * stabsread.c (define_symbol): Combine a 'p', 'r' arg pair to a LOC_REGPARM symbol. * config/sparc/tm-sparc.h (REG_STRUCT_HAS_ADDR): Revise comments. symfile.c (compare_symbols): Don't check first character; STRCMP does that. * stabsread.c (define_symbol): Generate a LOC_REGPARM_ADDR for structures that are passed by address in a register. * symtab.h (enum address_class): Add LOC_REGPARM_ADDR. * findvar.c (read_var_value), printcmd.c (address_info, print_frame_args), stack.c (print_frame_arg_vars), symmisc.c (print_{,partial_}symbol), * symtab.c (lookup_block_symbol): Deal with it.
Diffstat (limited to 'gdb/stabsread.c')
-rw-r--r--gdb/stabsread.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 0357259..9b475bd 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -864,7 +864,31 @@ define_symbol (valu, string, desc, type, objfile)
}
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
if (within_function)
- add_symbol_to_list (sym, &local_symbols);
+ {
+ /* Sun cc uses a pair of symbols, one 'p' and one 'r' with the same
+ name to represent an argument passed in a register.
+ GCC uses 'P' for the same case. So if we find such a symbol pair
+ we combine it into one 'P' symbol.
+ Note that this code illegally combines
+ main(argc) int argc; { register int argc = 1; }
+ but this case is considered pathological and causes a warning
+ from a decent compiler. */
+ if (local_symbols
+ && local_symbols->nsyms > 0)
+ {
+ struct symbol *prev_sym;
+ prev_sym = local_symbols->symbol[local_symbols->nsyms - 1];
+ if (SYMBOL_CLASS (prev_sym) == LOC_ARG
+ && STREQ (SYMBOL_NAME (prev_sym), SYMBOL_NAME(sym)))
+ {
+ SYMBOL_CLASS (prev_sym) = LOC_REGPARM;
+ SYMBOL_VALUE (prev_sym) = SYMBOL_VALUE (sym);
+ sym = prev_sym;
+ break;
+ }
+ }
+ add_symbol_to_list (sym, &local_symbols);
+ }
else
add_symbol_to_list (sym, &file_symbols);
break;
@@ -965,6 +989,23 @@ define_symbol (valu, string, desc, type, objfile)
default:
error ("Invalid symbol data: unknown symbol-type code `%c' at symtab pos %d.", deftype, symnum);
}
+
+ /* When passing structures to a function, some systems sometimes pass
+ the address in a register, not the structure itself.
+
+ If REG_STRUCT_HAS_ADDR yields non-zero we have to convert LOC_REGPARM
+ to LOC_REGPARM_ADDR for structures and unions. */
+
+#if !defined (REG_STRUCT_HAS_ADDR)
+#define REG_STRUCT_HAS_ADDR(gcc_p) 0
+#endif
+
+ if (SYMBOL_CLASS (sym) == LOC_REGPARM
+ && REG_STRUCT_HAS_ADDR (processing_gcc_compilation)
+ && ( (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT)
+ || (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)))
+ SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
+
return sym;
}