From 93297ea028114b30f985e6609a663bc5cbf04010 Mon Sep 17 00:00:00 2001 From: John Gilmore Date: Sat, 13 Jun 1992 02:18:44 +0000 Subject: [PATCH] * buildsym.h: Add processing_acc_compilation flag. * buildsym.c (read_sun_builtin_type, read_sun_floating_type): New. (define_symbol): Skip arg types in function entries. Resolve overloaded 'P' which acc uses for prototypes of functions called by this file. (read_type: 'b', 'r'): Handle Solaris2 builtin types. * minsyms.c (prim_record_minimal_symbol_and_info): Hack to save size of ELF symbols. FIXME. * tm-sun4os5.h: Rename to tm-sun4sol2.h. Update defines for Sol2. * xm-sun4os5.h: Rename to xm-sun4sol2.h. Hack more defines. * config/sun4os5.m[ht]: Rename to config/sun4sol2.m[ht]; new xm, tm. --- gdb/ChangeLog | 14 +++- gdb/buildsym.c | 145 ++++++++++++++++++++++++++++++++++++++++- gdb/buildsym.h | 3 + gdb/config/sun4sol2.mh | 2 +- gdb/config/sun4sol2.mt | 2 +- gdb/minsyms.c | 26 ++++++++ gdb/tm-sun4sol2.h | 68 +++++++++++++++++++ gdb/xm-sun4sol2.h | 64 ++++++++++++++++++ 8 files changed, 320 insertions(+), 4 deletions(-) create mode 100644 gdb/tm-sun4sol2.h create mode 100644 gdb/xm-sun4sol2.h diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9a533cdf186..e9effecccf3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,7 +1,19 @@ Fri Jun 12 18:54:40 1992 John Gilmore (gnu at cygnus.com) + * buildsym.h: Add processing_acc_compilation flag. + * buildsym.c (read_sun_builtin_type, read_sun_floating_type): New. + (define_symbol): Skip arg types in function entries. Resolve + overloaded 'P' which acc uses for prototypes of functions called + by this file. + (read_type: 'b', 'r'): Handle Solaris2 builtin types. + + * minsyms.c (prim_record_minimal_symbol_and_info): Hack to + save size of ELF symbols. FIXME. + * tm-sun4os5.h: Rename to tm-sun4sol2.h. Update defines for Sol2. + * xm-sun4os5.h: Rename to xm-sun4sol2.h. Hack more defines. + * configure.in: Solaris config is sparc-sun-solaris2. - * config/sun4os5.m[ht]: Rename to config/sun4sol2.m[ht]. + * config/sun4os5.m[ht]: Rename to config/sun4sol2.m[ht]; new xm, tm. Fri Jun 12 12:49:43 1992 Fred Fish (fnf@cygnus.com) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 3a82e9a482b..4c9e7b1f0f0 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -1,5 +1,6 @@ /* Build symbol tables in GDB's internal format. - Copyright 1986, 1987, 1988, 1989, 1990, 1991 Free Software Foundation, Inc. + Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992 + Free Software Foundation, Inc. This file is part of GDB. @@ -66,6 +67,12 @@ cleanup_undefined_types PARAMS ((void)); static struct type * read_range_type PARAMS ((char **, int [2], struct objfile *)); +static struct type * +read_sun_builtin_type PARAMS ((char **, int [2], struct objfile *)); + +static struct type * +read_sun_floating_type PARAMS ((char **, int [2], struct objfile *)); + static struct type * read_enum_type PARAMS ((char **, struct type *, struct objfile *)); @@ -1269,11 +1276,24 @@ define_symbol (valu, string, desc, type, objfile) type_read = read_type (&p, objfile); + if ((deftype == 'F' || deftype == 'f') && *p == ';') { + /* Sun acc puts declared types of aguments here. We don't care + about their actual types (FIXME -- we should remember the whole + function prototype), but the list + may define some new types that we have to remember, so we must + scan them now. */ + while (*p == ';') { + p++; + read_type (&p); + } + } + 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. */ +/* Attempt to set up to record a function prototype... */ struct type *new = (struct type *) obstack_alloc (&objfile -> type_obstack, sizeof (struct type)); @@ -1417,6 +1437,13 @@ define_symbol (valu, string, desc, type, objfile) case 'P': /* Parameter which is in a register. */ + + /* acc seems to use P to delare the types of functions that + are called by this file. gdb is not prepared to deal + with this extra information. */ + if (processing_acc_compilation) + break; + SYMBOL_CLASS (sym) = LOC_REGPARM; SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu); if (SYMBOL_VALUE (sym) >= NUM_REGS) @@ -1979,6 +2006,18 @@ read_type (pp, objfile) *dbx_lookup_type (typenums) = type; break; + case 'b': /* Sun ACC builtin int type */ + type = read_sun_builtin_type (pp, typenums, objfile); + if (typenums[0] != -1) + *dbx_lookup_type (typenums) = 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; + break; + case 'e': /* Enumeration type */ type = dbx_alloc_type (typenums, objfile); type = read_enum_type (pp, type, objfile); @@ -2929,6 +2968,110 @@ read_enum_type (pp, type, objfile) return type; } +/* this is for the initial typedefs in every file (for int, long, etc) */ +static struct type * +read_sun_builtin_type (pp, typenums, objfile) + char **pp; + int typenums[2]; + struct objfile *objfile; +{ + int nbits; + int signed_type; + + switch (**pp) { + case 's': + signed_type = 1; + break; + case 'u': + signed_type = 0; + break; + default: + return error_type (pp); + } + (*pp)++; + + /* The first number appears to be the number of bytes occupied + by this type, except that unsigned short is 4 instead of 2. + Since this information is redundant with the third number, + we will ignore it. */ + read_number (pp, ';'); + + /* The second number is always 0, so ignore it too. */ + read_number (pp, ';'); + + /* The third number is the number of bits for this type. */ + nbits = read_number (pp, 0); + + /* FIXME. Here we should just be able to make a type of the right + number of bits and signedness. FIXME. */ + + if (nbits == TARGET_LONG_LONG_BIT) + return (lookup_fundamental_type (objfile, + signed_type? FT_LONG_LONG: FT_UNSIGNED_LONG_LONG)); + + if (nbits == TARGET_INT_BIT) { + /* FIXME -- the only way to distinguish `int' from `long' + is to look at its name! */ + if (signed_type) { + if (long_kludge_name && long_kludge_name[0] == 'l' /* long */) + return lookup_fundamental_type (objfile, FT_LONG); + else + return lookup_fundamental_type (objfile, FT_INTEGER); + } else { + if (long_kludge_name + && ((long_kludge_name[0] == 'u' /* unsigned */ && + long_kludge_name[9] == 'l' /* long */) + || (long_kludge_name[0] == 'l' /* long unsigned */))) + return lookup_fundamental_type (objfile, FT_UNSIGNED_LONG); + else + return lookup_fundamental_type (objfile, FT_UNSIGNED_INTEGER); + } + } + + if (nbits == TARGET_SHORT_BIT) + return (lookup_fundamental_type (objfile, + signed_type? FT_SHORT: FT_UNSIGNED_SHORT)); + + if (nbits == TARGET_CHAR_BIT) + return (lookup_fundamental_type (objfile, + signed_type? FT_CHAR: FT_UNSIGNED_CHAR)); + + if (nbits == 0) + return lookup_fundamental_type (objfile, FT_VOID); + + return error_type (pp); +} + +static struct type * +read_sun_floating_type (pp, typenums, objfile) + char **pp; + int typenums[2]; + struct objfile *objfile; +{ + int nbytes; + + /* The first number has more details about the type, for example + FN_COMPLEX. See the sun stab.h. */ + read_number (pp, ';'); + + /* The second number is the number of bytes occupied by this type */ + nbytes = read_number (pp, ';'); + + if (**pp != 0) + return error_type (pp); + + if (nbytes == TARGET_FLOAT_BIT / TARGET_CHAR_BIT) + return lookup_fundamental_type (objfile, FT_FLOAT); + + if (nbytes == TARGET_DOUBLE_BIT / TARGET_CHAR_BIT) + return lookup_fundamental_type (objfile, FT_DBL_PREC_FLOAT); + + if (nbytes == TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT) + return lookup_fundamental_type (objfile, FT_EXT_PREC_FLOAT); + + return error_type (pp); +} + /* Read a number from the string pointed to by *PP. The value of *PP is advanced over the number. If END is nonzero, the character that ends the diff --git a/gdb/buildsym.h b/gdb/buildsym.h index 8183cfc1c31..8c660f3b9ef 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -74,6 +74,9 @@ EXTERN struct subfile *current_subfile; EXTERN unsigned char processing_gcc_compilation; +/* When set, we are processing a .o file compiled by sun acc */ +EXTERN unsigned char processing_acc_compilation; + /* Count symbols as they are processed, for error messages. */ EXTERN unsigned int symnum; diff --git a/gdb/config/sun4sol2.mh b/gdb/config/sun4sol2.mh index 85de6ba9563..d90e69564af 100644 --- a/gdb/config/sun4sol2.mh +++ b/gdb/config/sun4sol2.mh @@ -1,6 +1,6 @@ # Host: Sun 4 or Sparcstation, running Solaris 2 XDEPFILES= procfs.o -XM_FILE= xm-sun4os5.h +XM_FILE= xm-sun4sol2.h SYSV_DEFINE=-DSYSV REGEX=regex.o REGEX1=regex.o diff --git a/gdb/config/sun4sol2.mt b/gdb/config/sun4sol2.mt index 2a499e0571e..9c42fd50684 100644 --- a/gdb/config/sun4sol2.mt +++ b/gdb/config/sun4sol2.mt @@ -1,3 +1,3 @@ # Target: Sun 4 or Sparcstation, running Solaris 2 TDEPFILES= exec.o sparc-tdep.o sparc-pinsn.o solib.o -TM_FILE= tm-sun4os5.h +TM_FILE= tm-sun4sol2.h diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 6810d9a25c7..164159241b4 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -263,6 +263,32 @@ prim_record_minimal_symbol (name, address, ms_type) msym_count++; } +void +prim_record_minimal_symbol_and_info (name, address, ms_type, info) + const char *name; + CORE_ADDR address; + enum minimal_symbol_type ms_type; + char *info; +{ + register struct msym_bunch *new; + + if (msym_bunch_index == BUNCH_SIZE) + { + new = (struct msym_bunch *) xmalloc (sizeof (struct msym_bunch)); + msym_bunch_index = 0; + new -> next = msym_bunch; + msym_bunch = new; + } + msym_bunch -> contents[msym_bunch_index].name = (char *) name; + msym_bunch -> contents[msym_bunch_index].address = address; + msym_bunch -> contents[msym_bunch_index].info = NULL; + msym_bunch -> contents[msym_bunch_index].type = ms_type; + /* FIXME: This info, if it remains, needs its own field. */ + msym_bunch -> contents[msym_bunch_index].info = info; /* FIXME! */ + msym_bunch_index++; + msym_count++; +} + /* Compare two minimal symbols by address and return a signed result based on unsigned comparisons, so that we sort into unsigned numeric order. */ diff --git a/gdb/tm-sun4sol2.h b/gdb/tm-sun4sol2.h new file mode 100644 index 00000000000..78c7389db02 --- /dev/null +++ b/gdb/tm-sun4sol2.h @@ -0,0 +1,68 @@ +/* Macro definitions for GDB for a Sun 4 running Solaris 2 + Copyright (C) 1989, 1992 Free Software Foundation, Inc. + +This file is part of GDB. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "tm-sparc.h" + +#include "tm-sysv4.h" + +#undef STACK_END_ADDRESS +#define STACK_END_ADDRESS 0xf8000000 + +/* The values of N_SLINE, N_LBRAC, N_RBRAC symbols in .stab sections are + relative to the current function, rather than being absolute or + relative to the current N_SO. */ + +#define BLOCK_ADDRESS_FUNCTION_RELATIVE + +/* Variables in the debug stabs occur after the N_LBRAC, not before it. */ + +#define VARIABLES_INSIDE_BLOCK(desc, gcc_p) (!gcc_p) + +/* May be needed, may be not? From Pace Willisson's port. FIXME. */ +#define PROLOGUE_FIRSTLINE_OVERLAP + + +#if 0 /* Setjmp/longjmp are not as well doc'd in SunOS 5.x yet */ + +/* Offsets into jmp_buf. Not defined by Sun, but at least documented in a + comment in ! */ + +#define JB_ELEMENT_SIZE 4 /* Size of each element in jmp_buf */ + +#define JB_ONSSTACK 0 +#define JB_SIGMASK 1 +#define JB_SP 2 +#define JB_PC 3 +#define JB_NPC 4 +#define JB_PSR 5 +#define JB_G1 6 +#define JB_O0 7 +#define JB_WBCNT 8 + +/* Figure out where the longjmp will land. We expect that we have just entered + longjmp and haven't yet setup the stack frame, so the args are still in the + output regs. %o0 (O0_REGNUM) points at the jmp_buf structure from which we + extract the pc (JB_PC) that we will land at. The pc is copied into ADDR. + This routine returns true on success */ + +extern int +get_longjmp_target PARAMS ((CORE_ADDR *)); + +#define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR) +#endif /* 0 */ diff --git a/gdb/xm-sun4sol2.h b/gdb/xm-sun4sol2.h new file mode 100644 index 00000000000..25013a9c96c --- /dev/null +++ b/gdb/xm-sun4sol2.h @@ -0,0 +1,64 @@ +/* Macro definitions for running gdb on a Sun 4 running Solaris 2. + Copyright 1989, 1992 Free Software Foundation, Inc. + +This file is part of GDB. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Most of what we know is generic to SPARC hosts. */ + +#include "xm-sparc.h" + +/* Pick up more stuff from the generic SVR4 host include file. */ + +#include "xm-sysv4.h" + +/* SVR4's can't seem to agree on what to call the type that contains the + general registers. Kludge around it with a #define. */ + +#define gregset_t prgreg_t +#define fpregset_t prfpregset_t + +/* The native Sun compiler complains about using volatile + to indicate functions that never return. So shut it up by simply + defining away "NORETURN", which is normally defined to "volatile". */ + +#ifndef __GNUC__ +# define NORETURN /**/ +#endif + +/* Large alloca's fail because the attempt to increase the stack limit in + main() fails because shared libraries are allocated just below the initial + stack limit. The SunOS kernel will not allow the stack to grow into + the area occupied by the shared libraries. Sun knows about this bug + but has no obvious fix for it. */ +#define BROKEN_LARGE_ALLOCA + +/* If you expect to use the mmalloc package to obtain mapped symbol files, + for now you have to specify some parameters that determine how gdb places + the mappings in it's address space. See the comments in map_to_address() + for details. This is expected to only be a short term solution. Yes it + is a kludge. + FIXME: Make this more automatic. */ + +#define MMAP_BASE_ADDRESS 0xE0000000 /* First mapping here */ +#define MMAP_INCREMENT 0x01000000 /* Increment to next mapping */ + +/* These are not currently used in SVR4 (but should be, FIXME!). */ +#undef DO_DEFERRED_STORES +#undef CLEAR_DEFERRED_STORES + +/* May be needed, may be not? From Pace Willisson's port. FIXME. */ +#define NEED_POSIX_SETPGID -- 2.30.2