From 65ce5df44f4afe44894bca3064a7aa685b7d6039 Mon Sep 17 00:00:00 2001 From: John Gilmore Date: Thu, 15 Apr 1993 09:41:59 +0000 Subject: [PATCH] * dbxread.c (unknown_symchar_complaint): Add new complaint. * stabsread.c: Declare it. * partial-stab.h: Use it. * utils.c (malloc_botch): Don't forward-declare if NO_MMALLOC. --- gdb/ChangeLog | 8 ++++ gdb/dbxread.c | 76 +++++++++++++++++++++---------- gdb/partial-stab.h | 9 ++-- gdb/utils.c | 111 ++++++++++++++++----------------------------- 4 files changed, 101 insertions(+), 103 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0f611b11c25..86180bf4c7e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +Thu Apr 15 02:37:48 1993 John Gilmore (gnu@cacophony.cygnus.com) + + * dbxread.c (unknown_symchar_complaint): Add new complaint. + * stabsread.c: Declare it. + * partial-stab.h: Use it. + + * utils.c (malloc_botch): Don't forward-declare if NO_MMALLOC. + Wed Apr 14 17:12:51 1993 Jim Kingdon (kingdon@cygnus.com) * stack.c (print_frame_info): Print specially if dummy frame. diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 3f9334b579b..302d9cb0f67 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -1,5 +1,6 @@ /* Read dbx symbol tables and convert to internal format, for GDB. - Copyright 1986, 1987, 1988, 1989, 1990, 1991 Free Software Foundation, Inc. + Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993 + Free Software Foundation, Inc. This file is part of GDB. @@ -165,6 +166,9 @@ struct complaint string_table_offset_complaint = struct complaint unknown_symtype_complaint = {"unknown symbol type %s", 0, 0}; +struct complaint unknown_symchar_complaint = + {"unknown symbol type character `%c'", 0, 0}; + struct complaint lbrac_rbrac_complaint = {"block start larger than block end", 0, 0}; @@ -561,6 +565,9 @@ dbx_symfile_init (objfile) if (STRING_TABLE_OFFSET == 0) { + /* It appears that with the existing bfd code, STRING_TABLE_OFFSET + will never be zero, even when there is no string table. This + would appear to be a bug in bfd. */ DBX_STRINGTAB_SIZE (objfile) = 0; DBX_STRINGTAB (objfile) = NULL; } @@ -573,28 +580,47 @@ dbx_symfile_init (objfile) memset ((PTR) size_temp, 0, sizeof (size_temp)); val = bfd_read ((PTR) size_temp, sizeof (size_temp), 1, sym_bfd); if (val < 0) - perror_with_name (name); - - DBX_STRINGTAB_SIZE (objfile) = bfd_h_get_32 (sym_bfd, size_temp); - - if (DBX_STRINGTAB_SIZE (objfile) < sizeof (size_temp) - || DBX_STRINGTAB_SIZE (objfile) > bfd_get_size (sym_bfd)) - error ("ridiculous string table size (%d bytes).", - DBX_STRINGTAB_SIZE (objfile)); - - DBX_STRINGTAB (objfile) = - (char *) obstack_alloc (&objfile -> psymbol_obstack, - DBX_STRINGTAB_SIZE (objfile)); - - /* Now read in the string table in one big gulp. */ - - val = bfd_seek (sym_bfd, STRING_TABLE_OFFSET, L_SET); - if (val < 0) - perror_with_name (name); - val = bfd_read (DBX_STRINGTAB (objfile), DBX_STRINGTAB_SIZE (objfile), 1, - sym_bfd); - if (val != DBX_STRINGTAB_SIZE (objfile)) - perror_with_name (name); + { + perror_with_name (name); + } + else if (val == 0) + { + /* With the existing bfd code, STRING_TABLE_OFFSET will be set to + EOF if there is no string table, and attempting to read the size + from EOF will read zero bytes. */ + DBX_STRINGTAB_SIZE (objfile) = 0; + DBX_STRINGTAB (objfile) = NULL; + } + else + { + /* Read some data that would appear to be the string table size. + If there really is a string table, then it is probably the right + size. Byteswap if necessary and validate the size. Note that + the minimum is DBX_STRINGTAB_SIZE_SIZE. If we just read some + random data that happened to be at STRING_TABLE_OFFSET, because + bfd can't tell us there is no string table, the sanity checks may + or may not catch this. */ + DBX_STRINGTAB_SIZE (objfile) = bfd_h_get_32 (sym_bfd, size_temp); + + if (DBX_STRINGTAB_SIZE (objfile) < sizeof (size_temp) + || DBX_STRINGTAB_SIZE (objfile) > bfd_get_size (sym_bfd)) + error ("ridiculous string table size (%d bytes).", + DBX_STRINGTAB_SIZE (objfile)); + + DBX_STRINGTAB (objfile) = + (char *) obstack_alloc (&objfile -> psymbol_obstack, + DBX_STRINGTAB_SIZE (objfile)); + + /* Now read in the string table in one big gulp. */ + + val = bfd_seek (sym_bfd, STRING_TABLE_OFFSET, L_SET); + if (val < 0) + perror_with_name (name); + val = bfd_read (DBX_STRINGTAB (objfile), DBX_STRINGTAB_SIZE (objfile), 1, + sym_bfd); + if (val != DBX_STRINGTAB_SIZE (objfile)) + perror_with_name (name); + } } } @@ -1421,7 +1447,7 @@ read_ofile_symtab (objfile, sym_offset, sym_size, text_offset, text_size, if (last_source_start_addr == 0) last_source_start_addr = text_offset; - rtn = end_symtab (text_offset + text_size, 0, 0, objfile); + rtn = end_symtab (text_offset + text_size, 0, 0, objfile, SECT_OFF_TEXT); end_stabs (); return (rtn); } @@ -1668,7 +1694,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) patch_subfile_names (current_subfile, name); break; /* Ignore repeated SOs */ } - end_symtab (valu, 0, 0, objfile); + end_symtab (valu, 0, 0, objfile, SECT_OFF_TEXT); end_stabs (); } start_stabs (); diff --git a/gdb/partial-stab.h b/gdb/partial-stab.h index d69f7f63e7e..e0831433d2a 100644 --- a/gdb/partial-stab.h +++ b/gdb/partial-stab.h @@ -1,6 +1,6 @@ /* Shared code to pre-read a stab (dbx-style), when building a psymtab. - Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992 Free Software Foundation, - Inc. + Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993 + Free Software Foundation, Inc. This file is part of GDB. @@ -518,9 +518,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Global functions were ignored here, but now they are put into the global psymtab like one would expect. - They're also in the misc fn vector... - FIXME, why did it used to ignore these? That broke - "i fun" on these functions. */ + They're also in the minimal symbol table. */ case 'F': #ifdef DBXREAD_ONLY /* Kludges for ELF/STABS with Sun ACC */ @@ -563,6 +561,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ Someone says sun cc puts out symbols like /foo/baz/maclib::/usr/local/bin/maclib, which would get here with a symbol type of ':'. */ + complain (&unknown_symchar_complaint, p[1]); continue; } diff --git a/gdb/utils.c b/gdb/utils.c index 895a62a4906..b69b21453fa 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -38,12 +38,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Prototypes for local functions */ -#if !defined (NO_MALLOC_CHECK) +#if defined (NO_MMALLOC) || defined (NO_MMALLOC_CHECK) +#else static void malloc_botch PARAMS ((void)); -#endif /* NO_MALLOC_CHECK */ +#endif /* NO_MMALLOC, etc */ static void fatal_dump_core (); /* Can't prototype with usage... */ @@ -1135,53 +1136,6 @@ fputs_filtered (linebuffer, stream) } } - -/* fputs_demangled attempts to demangle NAME, a symbol in language LANG, using - demangling args ARG_MODE, and print it filtered to STREAM. If the name is - not mangled, or the language for the name is unknown, or demangling is off, - the name is printed in its "raw" form. */ - -void -fputs_demangled (name, stream, arg_mode, lang) - char *name; - FILE *stream; - int arg_mode; - enum language lang; -{ - char *demangled; - - if (name != NULL) - { - /* If user wants to see raw output, no problem. */ - if (!demangle) - { - fputs_filtered (name, stream); - } - else - { - switch (lang) - { - case language_cplus: - demangled = cplus_demangle (name, arg_mode); - break; - /* start-sanitize-chill */ - case language_chill: - demangled = chill_demangle (name); - break; - /* end-sanitize-chill */ - default: - demangled = NULL; - break; - } - fputs_filtered (demangled ? demangled : name, stream); - if (demangled != NULL) - { - free (demangled); - } - } - } -} - /* Print a variable number of ARGS using format FORMAT. If this information is going to put the amount written (since the last call to REINITIALIZE_MORE_FILTER or the last page break) over the page size, @@ -1366,38 +1320,49 @@ print_spaces_filtered (n, stream) /* C++ demangler stuff. */ -/* Print NAME on STREAM, demangling if necessary. */ +/* fprintf_symbol_filtered attempts to demangle NAME, a symbol in language + LANG, using demangling args ARG_MODE, and print it filtered to STREAM. + If the name is not mangled, or the language for the name is unknown, or + demangling is off, the name is printed in its "raw" form. */ + void -fprint_symbol (stream, name) +fprintf_symbol_filtered (stream, name, lang, arg_mode) FILE *stream; char *name; + enum language lang; + int arg_mode; { - char *demangled = NULL; + char *demangled; - if (demangle) + if (name != NULL) { - /* Lacking a better method of knowing what demangler to use, pick - one appropriate for whatever the current language is. (FIXME) */ - switch (current_language -> la_language) + /* If user wants to see raw output, no problem. */ + if (!demangle) { - case language_cplus: - demangled = cplus_demangle (name, DMGL_PARAMS | DMGL_ANSI); - break; - /* start-sanitize-chill */ - case language_chill: - demangled = chill_demangle (name); - break; - /* end-sanitize-chill */ + fputs_filtered (name, stream); + } + else + { + switch (lang) + { + case language_cplus: + demangled = cplus_demangle (name, arg_mode); + break; + /* start-sanitize-chill */ + case language_chill: + demangled = chill_demangle (name); + break; + /* end-sanitize-chill */ + default: + demangled = NULL; + break; + } + fputs_filtered (demangled ? demangled : name, stream); + if (demangled != NULL) + { + free (demangled); + } } - } - if (demangled == NULL) - { - fputs_filtered (name, stream); - } - else - { - fputs_filtered (demangled, stream); - free (demangled); } } -- 2.30.2