/* Save its name and compilation directory name */
subfile->name = strdup (name);
- if (dirname == NULL)
- {
- subfile->dirname = NULL;
- }
- else
- {
- subfile->dirname = strdup (dirname);
- }
+ subfile->dirname = (dirname == NULL) ? NULL : strdup (dirname);
/* Initialize line-number recording for this subfile. */
subfile->line_vector = NULL;
}
+/* For stabs readers, the first N_SO symbol is assumed to be the source
+ file name, and the subfile struct is initialized using that assumption.
+ If another N_SO symbol is later seen, immediately following the first
+ one, then the first one is assumed to be the directory name and the
+ second one is really the source file name.
+
+ So we have to patch up the subfile struct by moving the old name value to
+ dirname and remembering the new name. Some sanity checking is performed
+ to ensure that the state of the subfile struct is reasonable and that the
+ old name we are assuming to be a directory name actually is (by checking
+ for a trailing '/'). */
+
+void
+patch_subfile_names (subfile, name)
+ struct subfile *subfile;
+ char *name;
+{
+ if (subfile != NULL && subfile->dirname == NULL && subfile->name != NULL
+ && subfile->name[strlen(subfile->name)-1] == '/')
+ {
+ subfile->dirname = subfile->name;
+ subfile->name = strdup (name);
+ }
+}
+
\f
/* Handle the N_BINCL and N_EINCL symbol types
that act like N_SOL for switching source files
symtab->nonreloc = TRUE;
#endif
}
- if (subfile->line_vector)
+ if (subfile->name != NULL)
+ {
+ free ((PTR) subfile->name);
+ }
+ if (subfile->dirname != NULL)
+ {
+ free ((PTR) subfile->dirname);
+ }
+ if (subfile->line_vector != NULL)
{
- free ((PTR)subfile->line_vector);
+ free ((PTR) subfile->line_vector);
}
nextsub = subfile->next;
#include "symfile.h"
#include "objfiles.h"
#include "buildsym.h"
+#include "stabsread.h"
#include "gdb-stabs.h"
+#include "demangle.h"
#include "aout/aout64.h"
#include "aout/stab_gnu.h" /* We always use GNU stabs, not native, now */
dbx_new_init (ignore)
struct objfile *ignore;
{
+ stabsread_new_init ();
buildsym_new_init ();
init_header_files ();
}
init_bincl_list (20, objfile);
make_cleanup (free_bincl_list, objfile);
- last_source_file = 0;
+ last_source_file = NULL;
#ifdef END_OF_TEXT_DEFAULT
end_of_text_addr = END_OF_TEXT_DEFAULT;
if (LDSYMLEN(pst)) /* Otherwise it's a dummy */
{
/* Init stuff necessary for reading in symbols */
+ stabsread_init ();
buildsym_init ();
old_chain = make_cleanup (really_free_pendings, 0);
file_string_table_offset = FILE_STRING_OFFSET (pst);
unsigned char type;
unsigned max_symnum;
register bfd *abfd;
+ struct symtab *rtn;
current_objfile = objfile;
- subfile_stack = 0;
+ subfile_stack = NULL;
#ifdef hp9000s800
stringtab_global = HP_STRINGTAB (objfile);
#else
stringtab_global = DBX_STRINGTAB (objfile);
#endif
- last_source_file = 0;
+ last_source_file = NULL;
abfd = objfile->obfd;
symfile_bfd = objfile->obfd; /* Implicit param to next_text_symbol */
(bufp->n_type == N_TEXT
&& (strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL) == 0
|| strcmp(namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0));
+
+ /* Try to select a C++ demangling based on the compilation unit
+ producer. */
+
+ if (processing_gcc_compilation)
+ {
+#if 1 /* Works, but is experimental. -fnf */
+ if (current_demangling_style == auto_demangling)
+ {
+ set_demangling_style (GNU_DEMANGLING_STYLE_STRING);
+ }
+#endif
+ }
}
else
{
else if (type == N_TEXT
&& (strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL) == 0
|| strcmp (namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0))
- /* I don't think this code will ever be executed, because
- the GCC_COMPILED_FLAG_SYMBOL usually is right before
- the N_SO symbol which starts this source file.
- However, there is no reason not to accept
- the GCC_COMPILED_FLAG_SYMBOL anywhere. */
- processing_gcc_compilation = 1;
+ {
+ /* I don't think this code will ever be executed, because
+ the GCC_COMPILED_FLAG_SYMBOL usually is right before
+ the N_SO symbol which starts this source file.
+ However, there is no reason not to accept
+ the GCC_COMPILED_FLAG_SYMBOL anywhere. */
+ processing_gcc_compilation = 1;
+#if 1 /* Works, but is experimental. -fnf */
+ if (current_demangling_style == auto_demangling)
+ {
+ set_demangling_style (GNU_DEMANGLING_STYLE_STRING);
+ }
+#endif
+ }
else if (type & N_EXT || type == (unsigned char)N_TEXT
|| type == (unsigned char)N_NBTEXT
) {
if (last_source_start_addr == 0)
last_source_start_addr = text_offset;
- return end_symtab (text_offset + text_size, 0, 0, objfile);
+ rtn = end_symtab (text_offset + text_size, 0, 0, objfile);
+ end_stabs ();
+ return (rtn);
}
\f
/* This handles a single symbol from the symbol-file, building symbols
/* Something is wrong if we see real data before
seeing a source file name. */
- if (last_source_file == 0 && type != (unsigned char)N_SO)
+ if (last_source_file == NULL && type != (unsigned char)N_SO)
{
/* Currently this ignores N_ENTRY on Gould machines, N_NSYM on machines
where that code is defined. */
Patch things up. */
if (previous_stab_code == N_SO)
{
- if (current_subfile && current_subfile->dirname == NULL
- && current_subfile->name != NULL
- && current_subfile->name[strlen(current_subfile->name)-1] == '/')
- {
- current_subfile->dirname = current_subfile->name;
- current_subfile->name =
- obsavestring (name, strlen (name),
- &objfile -> symbol_obstack);
- }
+ patch_subfile_names (current_subfile, name);
break; /* Ignore repeated SOs */
}
end_symtab (valu, 0, 0, objfile);
+ end_stabs ();
}
+ start_stabs ();
start_symtab (name, NULL, valu);
break;
if (name)
{
if (!strcmp (name, GCC2_COMPILED_FLAG_SYMBOL))
- processing_gcc_compilation = 1;
+ {
+ processing_gcc_compilation = 1;
+#if 1 /* Works, but is experimental. -fnf */
+ if (current_demangling_style == auto_demangling)
+ {
+ set_demangling_style (GNU_DEMANGLING_STYLE_STRING);
+ }
+#endif
+ }
}
break;
if (val != stabstrsize)
perror_with_name (name);
+ stabsread_new_init ();
buildsym_new_init ();
free_header_files ();
init_header_files ();