#include "cp-abi.h"
#include "cp-support.h"
#include "psympriv.h"
+#include "block.h"
#include "gdb_assert.h"
#include "gdb_string.h"
static void read_ofile_symtab (struct objfile *, struct partial_symtab *);
-static void dbx_psymtab_to_symtab (struct objfile *, struct partial_symtab *);
+static void dbx_read_symtab (struct partial_symtab *self,
+ struct objfile *objfile);
static void dbx_psymtab_to_symtab_1 (struct objfile *, struct partial_symtab *);
{
enum minimal_symbol_type ms_type;
int section;
- asection *bfd_section;
switch (type)
{
case N_TEXT | N_EXT:
ms_type = mst_text;
section = SECT_OFF_TEXT (objfile);
- bfd_section = DBX_TEXT_SECTION (objfile);
break;
case N_DATA | N_EXT:
ms_type = mst_data;
section = SECT_OFF_DATA (objfile);
- bfd_section = DBX_DATA_SECTION (objfile);
break;
case N_BSS | N_EXT:
ms_type = mst_bss;
section = SECT_OFF_BSS (objfile);
- bfd_section = DBX_BSS_SECTION (objfile);
break;
case N_ABS | N_EXT:
ms_type = mst_abs;
section = -1;
- bfd_section = NULL;
break;
#ifdef N_SETV
case N_SETV | N_EXT:
ms_type = mst_data;
section = SECT_OFF_DATA (objfile);
- bfd_section = DBX_DATA_SECTION (objfile);
break;
case N_SETV:
/* I don't think this type actually exists; since a N_SETV is the result
file local. */
ms_type = mst_file_data;
section = SECT_OFF_DATA (objfile);
- bfd_section = DBX_DATA_SECTION (objfile);
break;
#endif
case N_TEXT:
case N_FN_SEQ:
ms_type = mst_file_text;
section = SECT_OFF_TEXT (objfile);
- bfd_section = DBX_TEXT_SECTION (objfile);
break;
case N_DATA:
ms_type = mst_file_data;
ms_type = mst_data;
}
section = SECT_OFF_DATA (objfile);
- bfd_section = DBX_DATA_SECTION (objfile);
break;
case N_BSS:
ms_type = mst_file_bss;
section = SECT_OFF_BSS (objfile);
- bfd_section = DBX_BSS_SECTION (objfile);
break;
default:
ms_type = mst_unknown;
section = -1;
- bfd_section = NULL;
break;
}
lowest_text_address = address;
prim_record_minimal_symbol_and_info
- (name, address, ms_type, section, bfd_section, objfile);
+ (name, address, ms_type, section, objfile);
}
\f
/* Scan and build partial symbols for a symbol file.
init_bincl_list (20, objfile);
back_to = make_cleanup_free_bincl_list (objfile);
- last_source_file = NULL;
+ set_last_source_file (NULL);
lowest_text_address = (CORE_ADDR) -1;
if (new_name != NULL)
{
sym_len = strlen (new_name);
- sym_name = obsavestring (new_name, sym_len,
- &objfile->objfile_obstack);
+ sym_name = obstack_copy0 (&objfile->objfile_obstack,
+ new_name, sym_len);
xfree (new_name);
}
xfree (name);
result->read_symtab_private = obstack_alloc (&objfile->objfile_obstack,
sizeof (struct symloc));
LDSYMOFF (result) = ldsymoff;
- result->read_symtab = dbx_psymtab_to_symtab;
+ result->read_symtab = dbx_read_symtab;
SYMBOL_SIZE (result) = symbol_size;
SYMBOL_OFFSET (result) = symbol_table_offset;
STRING_OFFSET (result) = string_table_offset;
}
/* Read in all of the symbols for a given psymtab for real.
- Be verbose about it if the user wants that. PST is not NULL. */
+ Be verbose about it if the user wants that. SELF is not NULL. */
static void
-dbx_psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
+dbx_read_symtab (struct partial_symtab *self, struct objfile *objfile)
{
bfd *sym_bfd;
- struct cleanup *back_to = NULL;
- if (pst->readin)
+ if (self->readin)
{
fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in. "
"Shouldn't happen.\n",
- pst->filename);
+ self->filename);
return;
}
- if (LDSYMLEN (pst) || pst->number_of_dependencies)
+ if (LDSYMLEN (self) || self->number_of_dependencies)
{
+ struct cleanup *back_to;
+
/* Print the message now, before reading the string table,
to avoid disconcerting pauses. */
if (info_verbose)
{
- printf_filtered ("Reading in symbols for %s...", pst->filename);
+ printf_filtered ("Reading in symbols for %s...", self->filename);
gdb_flush (gdb_stdout);
}
next_symbol_text_func = dbx_next_symbol_text;
+ back_to = make_cleanup (null_cleanup, NULL);
+
if (DBX_STAB_SECTION (objfile))
{
stabs_data
NULL);
if (stabs_data)
- back_to = make_cleanup (free_current_contents,
- (void *) &stabs_data);
+ make_cleanup (free_current_contents, (void *) &stabs_data);
}
- dbx_psymtab_to_symtab_1 (objfile, pst);
+ dbx_psymtab_to_symtab_1 (objfile, self);
- if (back_to)
- do_cleanups (back_to);
+ do_cleanups (back_to);
/* Match with global symbols. This only needs to be done once,
after all of the symtabs and dependencies have been read in. */
subfile_stack = NULL;
stringtab_global = DBX_STRINGTAB (objfile);
- last_source_file = NULL;
+ set_last_source_file (NULL);
abfd = objfile->obfd;
symfile_bfd = objfile->obfd; /* Implicit param to next_text_symbol. */
if (strncmp (tempstring, "__gnu_compiled", 14) == 0)
processing_gcc_compilation = 2;
}
-
- /* Try to select a C++ demangling based on the compilation unit
- producer. */
-
-#if 0
- /* For now, stay with AUTO_DEMANGLING for g++ output, as we don't
- know whether it will use the old style or v3 mangling. */
- if (processing_gcc_compilation)
- {
- if (AUTO_DEMANGLING)
- {
- set_demangling_style (GNU_DEMANGLING_STYLE_STRING);
- }
- }
-#endif
}
else
{
processing_gcc_compilation = 1;
else if (strcmp (namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0)
processing_gcc_compilation = 2;
-
-#if 0
- /* For now, stay with AUTO_DEMANGLING for g++ output, as we don't
- know whether it will use the old style or v3 mangling. */
- if (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)
}
\f
+/* Record the namespace that the function defined by SYMBOL was
+ defined in, if necessary. BLOCK is the associated block; use
+ OBSTACK for allocation. */
+
+static void
+cp_set_block_scope (const struct symbol *symbol,
+ struct block *block,
+ struct obstack *obstack)
+{
+ if (SYMBOL_DEMANGLED_NAME (symbol) != NULL)
+ {
+ /* Try to figure out the appropriate namespace from the
+ demangled name. */
+
+ /* FIXME: carlton/2003-04-15: If the function in question is
+ a method of a class, the name will actually include the
+ name of the class as well. This should be harmless, but
+ is a little unfortunate. */
+
+ const char *name = SYMBOL_DEMANGLED_NAME (symbol);
+ unsigned int prefix_len = cp_entire_prefix_len (name);
+
+ block_set_scope (block,
+ obstack_copy0 (obstack, name, prefix_len),
+ obstack);
+ }
+}
+
/* This handles a single symbol from the symbol-file, building symbols
into a GDB symtab. It takes these arguments and an implicit argument.
void
process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
- struct section_offsets *section_offsets,
+ const struct section_offsets *section_offsets,
struct objfile *objfile)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
/* Something is wrong if we see real data before seeing a source
file name. */
- if (last_source_file == NULL && type != (unsigned char) N_SO)
+ if (get_last_source_file () == NULL && type != (unsigned char) N_SO)
{
/* Ignore any symbols which appear before an N_SO symbol.
Currently no one puts symbols there, but we should deal
/* For C++, set the block's scope. */
if (SYMBOL_LANGUAGE (new->name) == language_cplus)
- cp_set_block_scope (new->name, block, &objfile->objfile_obstack,
- "", 0);
+ cp_set_block_scope (new->name, block, &objfile->objfile_obstack);
/* May be switching to an assembler file which may not be using
block relative stabs, so reset the offset. */
n_opt_found = 0;
- if (last_source_file)
+ if (get_last_source_file ())
{
/* Check if previous symbol was also an N_SO (with some
sanity checks). If so, that one was actually the
&& gdbarch_sofun_address_maybe_missing (gdbarch))
{
CORE_ADDR minsym_valu =
- find_stab_function_addr (name, last_source_file, objfile);
+ find_stab_function_addr (name, get_last_source_file (),
+ objfile);
/* The function find_stab_function_addr will return
0 if the minimal symbol wasn't found.
/* For C++, set the block's scope. */
if (SYMBOL_LANGUAGE (new->name) == language_cplus)
cp_set_block_scope (new->name, block,
- &objfile->objfile_obstack,
- "", 0);
+ &objfile->objfile_obstack);
}
new = push_context (0, valu);
if (strcmp (name, GCC2_COMPILED_FLAG_SYMBOL) == 0)
{
processing_gcc_compilation = 2;
-#if 0 /* Works, but is experimental. -fnf */
- /* For now, stay with AUTO_DEMANGLING for g++ output, as
- we don't know whether it will use the old style or v3
- mangling. */
- if (AUTO_DEMANGLING)
- {
- set_demangling_style (GNU_DEMANGLING_STYLE_STRING);
- }
-#endif
}
else
n_opt_found = 1;