/* Read dbx symbol tables and convert to internal format, for GDB.
- Copyright (C) 1986-2013 Free Software Foundation, Inc.
+ Copyright (C) 1986-2014 Free Software Foundation, Inc.
This file is part of GDB.
for real. dbx_psymtab_to_symtab() is the function that does this */
#include "defs.h"
-#include "gdb_string.h"
-
#if defined(__CYGNUSCLIB__)
#include <sys/types.h>
#include <fcntl.h>
#endif
#include "gdb_obstack.h"
-#include "gdb_stat.h"
+#include <sys/stat.h>
#include "symtab.h"
#include "breakpoint.h"
#include "target.h"
#include "psympriv.h"
#include "block.h"
-#include "gdb_assert.h"
-#include "gdb_string.h"
-
#include "aout/aout64.h"
#include "aout/stab_gnu.h" /* We always use GNU stabs, not
native, now. */
static void dbx_symfile_finish (struct objfile *);
-static void record_minimal_symbol (char *, CORE_ADDR, int, struct objfile *);
+static void record_minimal_symbol (const char *, CORE_ADDR, int,
+ struct objfile *);
static void add_new_header_file (char *, int);
#endif
\f
static void
-record_minimal_symbol (char *name, CORE_ADDR address, int type,
+record_minimal_symbol (const char *name, CORE_ADDR address, int type,
struct objfile *objfile)
{
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;
/* Same with virtual function tables, both global and static. */
{
- char *tempstring = name;
+ const char *tempstring = name;
if (tempstring[0] == bfd_get_symbol_leading_char (objfile->obfd))
++tempstring;
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.
val = bfd_seek (sym_bfd, DBX_SYMTAB_OFFSET (objfile), SEEK_SET);
if (val < 0)
- perror_with_name (objfile->name);
+ perror_with_name (objfile_name (objfile));
/* Size the symbol table. */
if (objfile->global_psymbols.size == 0 && objfile->static_psymbols.size == 0)
long dynrel_count;
arelent **dynrels;
CORE_ADDR sym_value;
- char *name;
+ const char *name;
/* Check that the symbol file has dynamic symbols that we know about.
bfd_arch_unknown can happen if we are reading a sun3 symbol file
if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
{
- sym_value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT (objfile));
type = N_TEXT;
}
else if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
{
- sym_value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_DATA (objfile));
type = N_DATA;
}
else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
{
- sym_value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_BSS (objfile));
type = N_BSS;
}
else
if (sym->flags & BSF_GLOBAL)
type |= N_EXT;
- record_minimal_symbol ((char *) bfd_asymbol_name (sym), sym_value,
+ record_minimal_symbol (bfd_asymbol_name (sym), sym_value,
type, objfile);
}
}
counter++, relptr++)
{
arelent *rel = *relptr;
- CORE_ADDR address =
- rel->address + ANOFFSET (objfile->section_offsets,
- SECT_OFF_DATA (objfile));
+ CORE_ADDR address = rel->address;
switch (bfd_get_arch (abfd))
{
continue;
}
- name = (char *) bfd_asymbol_name (*rel->sym_ptr_ptr);
+ name = bfd_asymbol_name (*rel->sym_ptr_ptr);
prim_record_minimal_symbol (name, address, mst_solib_trampoline,
objfile);
}
find_stab_function_addr (char *namestring, const char *filename,
struct objfile *objfile)
{
- struct minimal_symbol *msym;
+ struct bound_minimal_symbol msym;
char *p;
int n;
p[n] = 0;
msym = lookup_minimal_symbol (p, filename, objfile);
- if (msym == NULL)
+ if (msym.minsym == NULL)
{
/* Sun Fortran appends an underscore to the minimal symbol name,
try again with an appended underscore if the minimal symbol
msym = lookup_minimal_symbol (p, filename, objfile);
}
- if (msym == NULL && filename != NULL)
+ if (msym.minsym == NULL && filename != NULL)
{
/* Try again without the filename. */
p[n] = 0;
msym = lookup_minimal_symbol (p, NULL, objfile);
}
- if (msym == NULL && filename != NULL)
+ if (msym.minsym == NULL && filename != NULL)
{
/* And try again for Sun Fortran, but without the filename. */
p[n] = '_';
msym = lookup_minimal_symbol (p, NULL, objfile);
}
- return msym == NULL ? 0 : SYMBOL_VALUE_ADDRESS (msym);
+ return msym.minsym == NULL ? 0 : BMSYMBOL_VALUE_ADDRESS (msym);
}
static void
char *namestring;
int nsl;
int past_first_source_file = 0;
- CORE_ADDR last_o_file_start = 0;
CORE_ADDR last_function_start = 0;
struct cleanup *back_to;
bfd *abfd;
case N_TEXT | N_EXT:
case N_NBTEXT | N_EXT:
- nlist.n_value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT (objfile));
goto record_it;
case N_DATA | N_EXT:
case N_NBDATA | N_EXT:
- nlist.n_value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_DATA (objfile));
goto record_it;
case N_BSS:
case N_BSS | N_EXT:
case N_NBBSS | N_EXT:
case N_SETV | N_EXT: /* FIXME, is this in BSS? */
- nlist.n_value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_BSS (objfile));
goto record_it;
case N_ABS | N_EXT:
record_it:
namestring = set_namestring (objfile, &nlist);
- bss_ext_symbol:
record_minimal_symbol (namestring, nlist.n_value,
nlist.n_type, objfile); /* Always */
continue;
case N_FN:
case N_FN_SEQ:
case N_TEXT:
- nlist.n_value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT (objfile));
namestring = set_namestring (objfile, &nlist);
if ((namestring[0] == '-' && namestring[1] == 'l')
|| (namestring[(nsl = strlen (namestring)) - 1] == 'o'
&& namestring[nsl - 2] == '.'))
{
+ nlist.n_value += ANOFFSET (objfile->section_offsets,
+ SECT_OFF_TEXT (objfile));
+
if (past_first_source_file && pst
/* The gould NP1 uses low values for .o and -l symbols
which are not the address. */
}
else
past_first_source_file = 1;
- last_o_file_start = nlist.n_value;
}
else
goto record_it;
continue;
case N_DATA:
- nlist.n_value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_DATA (objfile));
goto record_it;
case N_UNDF | N_EXT:
{
char *p;
int n;
- struct minimal_symbol *minsym;
+ struct bound_minimal_symbol minsym;
p = strchr (last_function_name, ':');
if (p == NULL)
p[n] = 0;
minsym = lookup_minimal_symbol (p, pst->filename, objfile);
- if (minsym == NULL)
+ if (minsym.minsym == NULL)
{
/* Sun Fortran appends an underscore to the minimal symbol name,
try again with an appended underscore if the minimal symbol
minsym = lookup_minimal_symbol (p, pst->filename, objfile);
}
- if (minsym)
- pst->texthigh = SYMBOL_VALUE_ADDRESS (minsym) + MSYMBOL_SIZE (minsym);
+ if (minsym.minsym)
+ pst->texthigh = (BMSYMBOL_VALUE_ADDRESS (minsym)
+ + MSYMBOL_SIZE (minsym.minsym));
last_function_name = NULL;
}
dbx_read_symtab (struct partial_symtab *self, struct objfile *objfile)
{
bfd *sym_bfd;
- struct cleanup *back_to = NULL;
if (self->readin)
{
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)
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, 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. */
section_offsets = pst->section_offsets;
dbxread_objfile = objfile;
- subfile_stack = NULL;
stringtab_global = DBX_STRINGTAB (objfile);
set_last_source_file (NULL);
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);
N_MAIN within a given objfile, complain() and choose
arbitrarily. (kingdon) */
if (name != NULL)
- set_main_name (name);
+ set_objfile_main_name (objfile, name, language_unknown);
break;
/* The following symbol types can be ignored. */
\f
static const struct sym_fns aout_sym_fns =
{
- bfd_target_aout_flavour,
dbx_new_init, /* init anything gbl to entire symtab */
dbx_symfile_init, /* read initial info, setup for sym_read() */
dbx_symfile_read, /* read a symbol file into symtab */
void
_initialize_dbxread (void)
{
- add_symtab_fns (&aout_sym_fns);
+ add_symtab_fns (bfd_target_aout_flavour, &aout_sym_fns);
dbx_objfile_data_key
= register_objfile_data_with_cleanup (NULL, dbx_free_symfile_info);