/* 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.
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};
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;
}
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);
+ }
}
}
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);
}
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 ();
/* 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.
/* 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 */
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;
}
/* 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 <varargs.h> usage... */
}
}
-
-/* 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,
\f
/* 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);
}
}