/* Read os9/os9k symbol tables and convert to internal format, for GDB.
- Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994
+ Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996
Free Software Foundation, Inc.
This file is part of GDB.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* This module provides three functions: os9k_symfile_init,
which initializes to read a symbol file; os9k_new_init, which
for real. os9k_psymtab_to_symtab() is the function that does this */
#include "defs.h"
-#include <string.h>
+#include "gdb_string.h"
#include <stdio.h>
#if defined(USG) || defined(__CYGNUSCLIB__)
#include <fcntl.h>
#endif
-#include <obstack.h>
+#include "obstack.h"
#include <sys/param.h>
#ifndef NO_SYS_FILE
#include <sys/file.h>
#endif
-#include <sys/stat.h>
+#include "gdb_stat.h"
#include <ctype.h>
#include "symtab.h"
#include "breakpoint.h"
#include "os9k.h"
#include "stabsread.h"
-#if !defined (SEEK_SET)
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#endif
-
/* Each partial symbol table entry contains a pointer to private data for the
read_symtab() function to use when expanding a partial symbol table entry
to a full symbol table entry.
#endif
\f
/* Local function prototypes */
+
+static void
+read_minimal_symbols PARAMS ((struct objfile *, struct section_offsets *));
+
static void
os9k_read_ofile_symtab PARAMS ((struct partial_symtab *));
read_os9k_psymtab PARAMS ((struct section_offsets *, struct objfile *,
CORE_ADDR, int));
-static void
-init_psymbol_list PARAMS ((struct objfile *));
-
static int
fill_sym PARAMS ((FILE *, bfd *));
static struct partial_symtab *
os9k_start_psymtab PARAMS ((struct objfile *, struct section_offsets *, char *,
- CORE_ADDR, int, int, struct partial_symbol *,
- struct partial_symbol *));
+ CORE_ADDR, int, int, struct partial_symbol **,
+ struct partial_symbol **));
static struct partial_symtab *
os9k_end_psymtab PARAMS ((struct partial_symtab *, char **, int, int, CORE_ADDR,
ms_type = mst_unknown; break;
}
- prim_record_minimal_symbol
- (obsavestring (name, strlen(name), &objfile->symbol_obstack),
- address, ms_type, objfile);
+ prim_record_minimal_symbol (name, address, ms_type, objfile);
}
/* read and process .stb file and store in minimal symbol table */
/* If we are reinitializing, or if we have never loaded syms yet, init */
if (mainline || objfile->global_psymbols.size == 0 ||
objfile->static_psymbols.size == 0)
- init_psymbol_list (objfile);
+ init_psymbol_list (objfile, DBX_SYMCOUNT (objfile));
pending_blocks = 0;
back_to = make_cleanup (really_free_pendings, 0);
/* Now that the symbol table data of the executable file are all in core,
process them and define symbols accordingly. */
read_os9k_psymtab (section_offsets, objfile,
- bfd_section_vma (sym_bfd, DBX_TEXT_SECT (objfile)),
- bfd_section_size (sym_bfd, DBX_TEXT_SECT (objfile)));
+ DBX_TEXT_ADDR (objfile),
+ DBX_TEXT_SIZE (objfile));
do_cleanups (back_to);
}
char dbgname[512], stbname[512];
FILE *symfile = 0;
FILE *minfile = 0;
-
+ asection *text_sect;
strcpy(dbgname, name);
strcat(dbgname, ".dbg");
xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info));
DBX_SYMFILE_INFO (objfile)->stab_section_info = NULL;
- DBX_TEXT_SECT (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
- if (!DBX_TEXT_SECT (objfile))
+ text_sect = bfd_get_section_by_name (sym_bfd, ".text");
+ if (!text_sect)
error ("Can't find .text section in file");
+ DBX_TEXT_ADDR (objfile) = bfd_section_vma (sym_bfd, text_sect);
+ DBX_TEXT_SIZE (objfile) = bfd_section_size (sym_bfd, text_sect);
DBX_SYMBOL_SIZE (objfile) = 0; /* variable size symbol */
DBX_SYMCOUNT (objfile) = 0; /* used to be bfd_get_symcount(sym_bfd) */
return 1;
}
\f
-/* Initializes storage for all of the partial symbols that will be
- created by read_dbx_symtab and subsidiaries. */
-
-static void
-init_psymbol_list (objfile)
- struct objfile *objfile;
-{
- /* Free any previously allocated psymbol lists. */
- if (objfile -> global_psymbols.list)
- mfree (objfile -> md, (PTR)objfile -> global_psymbols.list);
- if (objfile -> static_psymbols.list)
- mfree (objfile -> md, (PTR)objfile -> static_psymbols.list);
-
- /* Current best guess is that there are approximately a twentieth
- of the total symbols (in a debugging file) are global or static
- oriented symbols */
- objfile -> global_psymbols.size = DBX_SYMCOUNT (objfile) / 10;
- objfile -> static_psymbols.size = DBX_SYMCOUNT (objfile) / 10;
- objfile -> global_psymbols.next = objfile -> global_psymbols.list = (struct partial_symbol *)
- xmmalloc (objfile -> md, objfile -> global_psymbols.size * sizeof (struct partial_symbol));
- objfile -> static_psymbols.next = objfile -> static_psymbols.list = (struct partial_symbol *)
- xmmalloc (objfile -> md, objfile -> static_psymbols.size * sizeof (struct partial_symbol));
-}
-
/* Given pointers to an a.out symbol table in core containing dbx
style data, setup partial_symtab's describing each source file for
which debugging information is available.
}
case 'v':
- ADD_PSYMBOL_ADDR_TO_LIST (namestring, p - namestring,
- VAR_NAMESPACE, LOC_STATIC,
- objfile->static_psymbols,
- CUR_SYMBOL_VALUE,
- psymtab_language, objfile);
+ add_psymbol_to_list (namestring, p - namestring,
+ VAR_NAMESPACE, LOC_STATIC,
+ &objfile->static_psymbols,
+ 0, CUR_SYMBOL_VALUE,
+ psymtab_language, objfile);
continue;
case 'V':
- ADD_PSYMBOL_ADDR_TO_LIST (namestring, p - namestring,
- VAR_NAMESPACE, LOC_STATIC,
- objfile->global_psymbols,
- CUR_SYMBOL_VALUE,
- psymtab_language, objfile);
+ add_psymbol_to_list (namestring, p - namestring,
+ VAR_NAMESPACE, LOC_STATIC,
+ &objfile->global_psymbols,
+ 0, CUR_SYMBOL_VALUE,
+ psymtab_language, objfile);
continue;
case 'T':
if (p != namestring) /* a name is there, not just :T... */
{
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring,
STRUCT_NAMESPACE, LOC_TYPEDEF,
- objfile->static_psymbols,
- CUR_SYMBOL_VALUE,
+ &objfile->static_psymbols,
+ CUR_SYMBOL_VALUE, 0,
psymtab_language, objfile);
if (p[2] == 't')
{
/* Also a typedef with the same name. */
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring,
VAR_NAMESPACE, LOC_TYPEDEF,
- objfile->static_psymbols,
- CUR_SYMBOL_VALUE, psymtab_language,
+ &objfile->static_psymbols,
+ CUR_SYMBOL_VALUE, 0, psymtab_language,
objfile);
p += 1;
}
else if (psymtab_language == language_cplus)
{
/* Also a typedef with the same name. */
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring,
VAR_NAMESPACE, LOC_TYPEDEF,
- objfile->static_psymbols,
- CUR_SYMBOL_VALUE, psymtab_language,
+ &objfile->static_psymbols,
+ CUR_SYMBOL_VALUE, 0, psymtab_language,
objfile);
}
}
case 't':
if (p != namestring) /* a name is there, not just :T... */
{
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring,
VAR_NAMESPACE, LOC_TYPEDEF,
- objfile->static_psymbols,
- CUR_SYMBOL_VALUE,
+ &objfile->static_psymbols,
+ CUR_SYMBOL_VALUE, 0,
psymtab_language, objfile);
}
check_enum:
/* Check for and handle cretinous dbx symbol name
continuation!
if (*p == '\\')
- p = next_symbol_text ();
+ p = next_symbol_text (objfile);
*/
/* Point to the character after the name
;
/* Note that the value doesn't matter for
enum constants in psymtabs, just in symtabs. */
- ADD_PSYMBOL_TO_LIST (p, q - p,
+ add_psymbol_to_list (p, q - p,
VAR_NAMESPACE, LOC_CONST,
- objfile->static_psymbols, 0,
- psymtab_language, objfile);
+ &objfile->static_psymbols, 0,
+ 0, psymtab_language, objfile);
/* Point past the name. */
p = q;
/* Skip over the value. */
continue;
case 'c':
/* Constant, e.g. from "const" in Pascal. */
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring,
VAR_NAMESPACE, LOC_CONST,
- objfile->static_psymbols, CUR_SYMBOL_VALUE,
- psymtab_language, objfile);
+ &objfile->static_psymbols, CUR_SYMBOL_VALUE,
+ 0, psymtab_language, objfile);
continue;
case 'f':
if (pst && pst->textlow == 0)
pst->textlow = CUR_SYMBOL_VALUE;
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring,
VAR_NAMESPACE, LOC_BLOCK,
- objfile->static_psymbols, CUR_SYMBOL_VALUE,
- psymtab_language, objfile);
+ &objfile->static_psymbols, CUR_SYMBOL_VALUE,
+ 0, psymtab_language, objfile);
continue;
case 'F':
if (pst && pst->textlow == 0)
pst->textlow = CUR_SYMBOL_VALUE;
- ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring,
VAR_NAMESPACE, LOC_BLOCK,
- objfile->global_psymbols, CUR_SYMBOL_VALUE,
- psymtab_language, objfile);
+ &objfile->global_psymbols, CUR_SYMBOL_VALUE,
+ 0, psymtab_language, objfile);
continue;
case 'p':
CORE_ADDR textlow;
int ldsymoff;
int ldsymcnt;
- struct partial_symbol *global_syms;
- struct partial_symbol *static_syms;
+ struct partial_symbol **global_syms;
+ struct partial_symbol **static_syms;
{
struct partial_symtab *result =
start_psymtab_common(objfile, section_offsets,
which comes from pst->textlow is correct. */
if (last_source_start_addr == 0)
last_source_start_addr = text_offset;
- pst->symtab = end_symtab (text_offset + text_size, 0, 0, objfile,
- SECT_OFF_TEXT);
+ pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT);
end_stabs ();
}
case N_SYM_SLINE:
/* This type of "symbol" really just records
one line-number -- core-address correspondence.
- Enter it in the line list for this symbol table. */
+ Enter it in the line list for this symbol table. */
/* Relocate for dynamic loading and for ELF acc fn-relative syms. */
valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ /* FIXME: loses if sizeof (char *) > sizeof (int) */
record_line (current_subfile, (int)name, valu);
break;
*p = '\0';
if (symfile_depth++ == 0) {
if (last_source_file) {
- end_symtab (valu, 0, 0, objfile, SECT_OFF_TEXT);
+ end_symtab (valu, objfile, SECT_OFF_TEXT);
end_stabs ();
}
start_stabs ();
}
previous_stab_code = type;
}
-\f
-/* Parse the user's idea of an offset for dynamic linking, into our idea
- of how to represent it for fast symbol reading. */
-
-static struct section_offsets *
-os9k_symfile_offsets (objfile, addr)
- struct objfile *objfile;
- CORE_ADDR addr;
-{
- struct section_offsets *section_offsets;
- int i;
-
- objfile->num_sections = SECT_OFF_MAX;
- section_offsets = (struct section_offsets *)
- obstack_alloc (&objfile -> psymbol_obstack,
- sizeof (struct section_offsets)
- + sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1));
- for (i = 0; i < SECT_OFF_MAX; i++)
- ANOFFSET (section_offsets, i) = addr;
-
- return section_offsets;
-}
-\f
static struct sym_fns os9k_sym_fns =
{
bfd_target_os9k_flavour,
os9k_symfile_init, /* sym_init: read initial info, setup for sym_read() */
os9k_symfile_read, /* sym_read: read a symbol file into symtab */
os9k_symfile_finish, /* sym_finish: finished with file, cleanup */
- os9k_symfile_offsets, /* sym_offsets: parse user's offsets to internal form*/
+ default_symfile_offsets,
+ /* sym_offsets: parse user's offsets to internal form*/
NULL /* next: pointer to next struct sym_fns */
};