* param-no-tm.h: Change users to define TM_FILE_OVERRIDE instead.
* param.h, param-no-tm.h: Removed.
* Update copyrights in all changed files.
* dbxread.c, dwarfread.c, inflow.c, infrun.c, m2-exp.y, putenv.c,
solib.c, symtab.h, tm-umax.h, valprint.c: Lint.
* tm-convex.h, tm-hp300hpux.h, tm-merlin.h, tm-sparc.h,
xm-merlin.h: Avoid host include files in target descriptions.
* getpagesize.h: Removed, libiberty copes now.
+Thu Nov 21 10:23:52 1991 John Gilmore (gnu at cygnus.com)
+
+ * defs.h: Incorporate param.h. All users changed.
+ * param-no-tm.h: Change users to define TM_FILE_OVERRIDE instead.
+ * param.h, param-no-tm.h: Removed.
+ * Update copyrights in all changed files.
+ * dbxread.c, dwarfread.c, inflow.c, infrun.c, m2-exp.y, putenv.c,
+ solib.c, symtab.h, tm-umax.h, valprint.c: Lint.
+ * tm-convex.h, tm-hp300hpux.h, tm-merlin.h, tm-sparc.h,
+ xm-merlin.h: Avoid host include files in target descriptions.
+ * getpagesize.h: Removed, libiberty copes now.
+
Wed Nov 20 18:35:56 1991 John Gilmore (gnu at cygnus.com)
* Remove gdb/hp-include. Support for HP a.out oddities should be
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
/* Target-machine dependent code for the AMD 29000
- Copyright (C) 1990 Free Software Foundation, Inc.
+ Copyright 1990, 1991 Free Software Foundation, Inc.
Contributed by Cygnus Support. Written by Jim Kingdon.
This file is part of GDB.
#include <stdio.h>
#include "frame.h"
#include "value.h"
-#include "param.h"
#include "symtab.h"
#include "inferior.h"
-/* Print ARM instructions for GDB, the GNU debugger.
- Copyright (C) 1986, 1989 Free Software Foundation, Inc.
+/* Print Acorn Risc Machine instructions for GDB, the GNU debugger.
+ Copyright 1986, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <assert.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "arm-opcode.h"
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "arm-opcode.h"
make xcoffread.c more maintainable by sharing code. */
#include "defs.h"
-#include "param.h"
#include "obstack.h"
#include "symtab.h"
#include "breakpoint.h"
#include <stdio.h>
#include <string.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "frame.h"
#include "expression.h"
\f
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "breakpoint.h"
#include "bfd.h"
-/* Library for reading command lines and decoding commands.
- Copyright (C) 1986, 1989, 1990 Free Software Foundation, Inc.
+/* Handle lists of commands, their decoding and documentation, for GDB.
+ Copyright 1986, 1989, 1990, 1991 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "command.h"
#include "symtab.h"
#include "value.h"
/* Print Convex instructions for GDB, the GNU debugger.
- Copyright (C) 1989 Free Software Foundation, Inc.
+ Copyright 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
/* reg (fmt_field, inst_field) --
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "command.h"
#include "symtab.h"
#include "value.h"
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "command.h"
#include "symtab.h"
#include "value.h"
/* Work with core dump and executable files, for GDB.
- Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <signal.h>
#include <fcntl.h>
#include "defs.h"
-#include "param.h"
#include "frame.h" /* required by inferior.h */
#include "inferior.h"
#include "symtab.h"
this file is more machine-specific. */
#include "defs.h"
-#include "param.h"
#include "gdbcore.h"
#include <stdio.h>
/* Demangler for GNU C++
- Copyright (C) 1989 Free Software Foundation, Inc.
+ Copyright 1989, 1991 Free Software Foundation, Inc.
written by James Clark (jjc@jclark.uucp)
This program is free software; you can redistribute it and/or modify
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* This is for g++ 1.36.1 (November 6 version). It will probably
- require changes for any other version.
-
- Modified for g++ 1.36.2 (November 18 version).
-
- Modified for g++ 1.90.06 (December 31 version).
-
- Modified for g++ 1.95.03 (November 13 verison). */
+/* This is for g++ 1.95.03 (November 13 verison). */
/* This file exports one function
/* GDB-specific, FIXME. */
#include "defs.h"
-#include "param.h"
#ifdef USG
#include <memory.h>
#include <stdio.h>
#include <string.h>
#include "defs.h"
-#include "param.h"
#ifdef USG
#include <sys/types.h>
char *stringtab; /* The actual string table */
int stringtab_size; /* Its size */
off_t symtab_offset; /* Offset in file to symbol table */
- int desc; /* File descriptor of symbol file */
};
static void read_dbx_symtab ();
static void init_psymbol_list ();
static void process_one_symbol ();
-static struct symbol *define_symbol ();
void start_subfile ();
int hashname ();
static struct pending *copy_pending ();
static struct symtab *read_ofile_symtab ();
static void dbx_psymtab_to_symtab ();
-static const char vptr_name[] = { '_','v','p','t','r',CPLUS_MARKER,'\0' };
-static const char vb_name[] = { '_','v','b',CPLUS_MARKER,'\0' };
-
/* Macro to determine which symbols to ignore when reading the first symbol
of a file. Some machines override this definition. */
#ifndef IGNORE_SYMBOL
/* Nonzero means give verbose info on gdb action. From main.c. */
extern int info_verbose;
-/* The BFD for this file -- only good while we're actively reading
- symbols into a psymtab or a symtab. */
+/* The BFD for this file -- implicit parameter to next_symbol_text. */
static bfd *symfile_bfd;
+/* The objfile for this file -- only good in process_one_symbol(). */
+
+static struct objfile *our_objfile;
+
/* String table for the main symbol file. It is kept in memory
permanently, to speed up symbol reading. Other files' symbol tables
are read in on demand. FIXME, this should be cleaner. */
struct complaint lbrac_rbrac_complaint =
{"block start larger than block end", 0, 0};
+
+struct complaint lbrac_unmatched_complaint =
+ {"unmatched N_LBRAC before symtab pos %d", 0, 0};
+
+struct complaint lbrac_mismatch_complaint =
+ {"N_LBRAC/N_RBRAC symbol mismatch at symtab pos %d", 0, 0};
\f
/* During initial symbol readin, we need to have a structure to keep
track of which psymtabs have which bincls in them. This structure
static struct header_file_location *bincl_list, *next_bincl;
static int bincls_allocated;
-/* When a header file is getting special overriding definitions
- for one source file, record here the header_files index
- of its normal definition vector.
- At other times, this is -1. */
-
-static int header_file_prev_index;
-
/* Free up old header file tables, and allocate new ones.
We're reading a new symbol file now. */
}
#endif
\f
-/* Handle the N_BINCL and N_EINCL symbol types
- that act like N_SOL for switching source files
- (different subfiles, as we call them) within one object file,
- but using a stack rather than in an arbitrary order. */
-
-struct subfile_stack
-{
- struct subfile_stack *next;
- char *name;
- int prev_index;
-};
-
-struct subfile_stack *subfile_stack;
-
-static void
-push_subfile ()
-{
- register struct subfile_stack *tem
- = (struct subfile_stack *) xmalloc (sizeof (struct subfile_stack));
-
- tem->next = subfile_stack;
- subfile_stack = tem;
- if (current_subfile == 0 || current_subfile->name == 0)
- abort ();
- tem->name = current_subfile->name;
- tem->prev_index = header_file_prev_index;
-}
-
-static char *
-pop_subfile ()
-{
- register char *name;
- register struct subfile_stack *link = subfile_stack;
-
- if (link == 0)
- abort ();
-
- name = link->name;
- subfile_stack = link->next;
- header_file_prev_index = link->prev_index;
- free (link);
-
- return name;
-}
-\f
static void
record_misc_function (name, address, type)
char *name;
int mainline; /* FIXME comments above */
{
struct dbx_symfile_info *info = (struct dbx_symfile_info *) (sf->sym_private);
- bfd *sym_bfd = sf->sym_bfd;
+ bfd *sym_bfd = sf->objfile->obfd;
int val;
- char *filename = bfd_get_filename (sym_bfd);
- val = lseek (info->desc, info->symtab_offset, L_SET);
+ val = bfd_seek (sf->objfile->obfd, info->symtab_offset, L_SET);
if (val < 0)
- perror_with_name (filename);
+ perror_with_name (sf->objfile->name);
/* If mainline, set global string table pointers, and reinitialize global
partial symbol list. */
if (mainline || global_psymbols.size == 0 || static_psymbols.size == 0)
init_psymbol_list (info->symcount);
- symfile_bfd = sym_bfd; /* Kludge for SWAP_SYMBOL */
-
/* FIXME POKING INSIDE BFD DATA STRUCTURES */
symbol_size = obj_symbol_entry_size (sym_bfd);
/* Now that the symbol table data of the executable file are all in core,
process them and define symbols accordingly. */
- read_dbx_symtab (filename,
- addr - bfd_section_vma (sym_bfd, info->text_sect), /*offset*/
- info->desc, info->stringtab, info->stringtab_size,
+ read_dbx_symtab (addr - bfd_section_vma (sym_bfd, info->text_sect), /*offset*/
+ sf->objfile, info->stringtab, info->stringtab_size,
info->symcount,
bfd_section_vma (sym_bfd, info->text_sect),
bfd_section_size (sym_bfd, info->text_sect));
struct sym_fns *sf;
{
int val;
- int desc;
- struct stat statbuf;
- bfd *sym_bfd = sf->sym_bfd;
+ bfd *sym_bfd = sf->objfile->obfd;
char *name = bfd_get_filename (sym_bfd);
struct dbx_symfile_info *info;
unsigned char size_temp[4];
info = (struct dbx_symfile_info *)sf->sym_private;
/* FIXME POKING INSIDE BFD DATA STRUCTURES */
- desc = fileno ((FILE *)(sym_bfd->iostream)); /* Raw file descriptor */
#define STRING_TABLE_OFFSET (sym_bfd->origin + obj_str_filepos (sym_bfd))
#define SYMBOL_TABLE_OFFSET (sym_bfd->origin + obj_sym_filepos (sym_bfd))
/* FIXME POKING INSIDE BFD DATA STRUCTURES */
- info->desc = desc;
info->text_sect = bfd_get_section_by_name (sym_bfd, ".text");
if (!info->text_sect)
abort();
info->symcount = bfd_get_symcount (sym_bfd);
/* Read the string table size and check it for bogosity. */
- val = lseek (desc, STRING_TABLE_OFFSET, L_SET);
+ val = bfd_seek (sym_bfd, STRING_TABLE_OFFSET, L_SET);
if (val < 0)
perror_with_name (name);
- if (fstat (desc, &statbuf) == -1)
- perror_with_name (name);
- val = myread (desc, size_temp, sizeof (long));
+ val = bfd_read (size_temp, sizeof (long), 1, sym_bfd);
if (val < 0)
perror_with_name (name);
info->stringtab_size = bfd_h_get_32 (sym_bfd, size_temp);
- if (info->stringtab_size >= 0 && info->stringtab_size < statbuf.st_size)
+ if (info->stringtab_size >= 0)
{
info->stringtab = (char *) xmalloc (info->stringtab_size);
/* Caller is responsible for freeing the string table. No cleanup. */
/* Now read in the string table in one big gulp. */
- val = lseek (desc, STRING_TABLE_OFFSET, L_SET);
+ val = bfd_seek (sym_bfd, STRING_TABLE_OFFSET, L_SET);
if (val < 0)
perror_with_name (name);
- val = myread (desc, info->stringtab, info->stringtab_size);
- if (val < 0)
+ val = bfd_read (info->stringtab, info->stringtab_size, 1, sym_bfd);
+ if (val != info->stringtab_size)
perror_with_name (name);
/* Record the position of the symbol table for later use. */
static int symbuf_idx;
static int symbuf_end;
-/* I/O descriptor for reading the symbol table. */
-static int symtab_input_desc;
-
/* The address in memory of the string table of the object file we are
reading (which might not be the "main" object file, but might be a
shared library or some other dynamically loaded thing). This is set
This function can read past the end of the symbol table
(into the string table) but this does no harm. */
-static int
-fill_symbuf ()
+static void
+fill_symbuf (sym_bfd)
+ bfd *sym_bfd;
{
- int nbytes = myread (symtab_input_desc, symbuf, sizeof (symbuf));
+ int nbytes = bfd_read (symbuf, sizeof (symbuf), 1, sym_bfd);
if (nbytes < 0)
- perror_with_name ("<symbol file>");
+ perror_with_name (bfd_get_filename (sym_bfd));
else if (nbytes == 0)
error ("Premature end of file reading symbol table");
symbuf_end = nbytes / symbol_size;
symbuf_idx = 0;
- return 1;
}
-#define SWAP_SYMBOL(symp) \
+#define SWAP_SYMBOL(symp, abfd) \
{ \
- (symp)->n_strx = bfd_h_get_32(symfile_bfd, \
+ (symp)->n_strx = bfd_h_get_32(abfd, \
(unsigned char *)&(symp)->n_strx); \
- (symp)->n_desc = bfd_h_get_16 (symfile_bfd, \
+ (symp)->n_desc = bfd_h_get_16 (abfd, \
(unsigned char *)&(symp)->n_desc); \
- (symp)->n_value = bfd_h_get_32 (symfile_bfd, \
+ (symp)->n_value = bfd_h_get_32 (abfd, \
(unsigned char *)&(symp)->n_value); \
}
next_symbol_text ()
{
if (symbuf_idx == symbuf_end)
- fill_symbuf ();
+ fill_symbuf (symfile_bfd);
symnum++;
- SWAP_SYMBOL(&symbuf[symbuf_idx]);
+ SWAP_SYMBOL(&symbuf[symbuf_idx], symfile_bfd);
return symbuf[symbuf_idx++].n_strx + stringtab_global;
}
\f
and ADDR is its relocated address (if incremental) or 0 (if not). */
static void
-read_dbx_symtab (symfile_name, addr,
- desc, stringtab, stringtab_size, nlistlen,
+read_dbx_symtab (addr, objfile, stringtab, stringtab_size, nlistlen,
text_addr, text_size)
- char *symfile_name;
CORE_ADDR addr;
- int desc;
+ struct objfile *objfile;
register char *stringtab;
register long stringtab_size;
register int nlistlen;
CORE_ADDR last_o_file_start = 0;
struct cleanup *old_chain;
char *p;
+ bfd *abfd;
/* End of the text segment of the executable file. */
CORE_ADDR end_of_text_addr;
(struct partial_symtab **) alloca (dependencies_allocated *
sizeof (struct partial_symtab *));
- /* FIXME!! If an error occurs, this blows away the whole symbol table!
- It should only blow away the psymtabs created herein. We could
- be reading a shared library or a dynloaded file! */
- old_chain = make_cleanup (free_all_psymtabs, 0);
+ old_chain = make_cleanup (free_objfile, objfile);
/* Init bincl list */
init_bincl_list (20);
end_of_text_addr = text_addr + addr + text_size; /* Relocate */
#endif
- symtab_input_desc = desc; /* This is needed for fill_symbuf below */
+ symfile_bfd = objfile->obfd; /* For next_text_symbol */
+ abfd = objfile->obfd;
symbuf_end = symbuf_idx = 0;
for (symnum = 0; symnum < nlistlen; symnum++)
/* Get the symbol for this run and pull out some info */
QUIT; /* allow this to be interruptable */
if (symbuf_idx == symbuf_end)
- fill_symbuf ();
+ fill_symbuf (abfd);
bufp = &symbuf[symbuf_idx++];
/*
*/
if (bufp->n_type == (unsigned char)N_SLINE) continue;
- SWAP_SYMBOL (bufp);
+ SWAP_SYMBOL (bufp, abfd);
/* Ok. There is a lot of code duplicated in the rest of this
switch statement (for efficiency reasons). Since I don't
give a fake name, and print a single error message per symbol file read,
rather than abort the symbol reading or flood the user with messages. */
#define SET_NAMESTRING()\
- if (bufp->n_strx < 0 || bufp->n_strx >= stringtab_size) { \
+ if (((unsigned)bufp->n_strx) >= stringtab_size) { \
complain (&string_table_offset_complaint, symnum); \
namestring = "foo"; \
} else \
/* Peek at the next symbol. If it is also an N_SO, the
first one just indicates the directory. */
if (symbuf_idx == symbuf_end)
- fill_symbuf ();
+ fill_symbuf (abfd);
bufp = &symbuf[symbuf_idx];
/* n_type is only a char, so swapping swapping is irrelevant. */
if (bufp->n_type == (unsigned char)N_SO)
{
- SWAP_SYMBOL (bufp);
+ SWAP_SYMBOL (bufp, abfd);
SET_NAMESTRING ();
valu = bufp->n_value;
symbuf_idx++;
else
past_first_source_file = 1;
- pst = start_psymtab (symfile_name, addr,
+ pst = start_psymtab (objfile, addr,
namestring, valu,
first_symnum * symbol_size,
global_psymbols.next, static_psymbols.next);
static struct partial_symtab *
-start_psymtab (symfile_name, addr,
+start_psymtab (objfile, addr,
filename, textlow, ldsymoff, global_syms, static_syms)
- char *symfile_name;
+ struct objfile *objfile;
CORE_ADDR addr;
char *filename;
CORE_ADDR textlow;
result->addr = addr;
- result->symfile_name =
- (char *) obstack_alloc (psymbol_obstack,
- strlen (symfile_name) + 1);
- strcpy (result->symfile_name, symfile_name);
-
result->filename =
(char *) obstack_alloc (psymbol_obstack,
strlen (filename) + 1);
result->n_global_syms = 0;
result->n_static_syms = 0;
+ /* Chain it to the list owned by the current object file. */
+ result->objfile = objfile;
+ result->objfile_chain = objfile->psymtabs;
+ objfile->psymtabs = result;
return result;
}
for (i = 0; i < num_includes; i++)
{
- /* Eventually, put this on obstack */
struct partial_symtab *subpst =
(struct partial_symtab *)
obstack_alloc (psymbol_obstack,
strlen (include_list[i]) + 1);
strcpy (subpst->filename, include_list[i]);
- subpst->symfile_name = pst->symfile_name;
+ /* Chain it to the list that this object file owns. */
+ subpst->objfile = pst->objfile;
+ subpst->objfile_chain = pst->objfile->psymtabs;
+ pst->objfile->psymtabs = subpst;
+
subpst->addr = pst->addr;
subpst->read_symtab_private = (char *) obstack_alloc (psymbol_obstack,
sizeof (struct symloc));
This happens in VxWorks. */
free_named_symtabs (pst->filename);
- /* Put the psymtab on the psymtab list */
- pst->next = partial_symtab_list;
- partial_symtab_list = pst;
+ if (num_includes == 0
+ && number_dependencies == 0
+ && pst->n_global_syms == 0
+ && pst->n_static_syms == 0) {
+ /* Throw away this psymtab, it's empty. We can't deallocate it, since
+ it is on the obstack, but we can forget to chain it on the list. */
+ ;
+ } else {
+ /* Put the psymtab on the psymtab list */
+ pst->next = partial_symtab_list;
+ partial_symtab_list = pst;
+ }
}
\f
static void
-psymtab_to_symtab_1 (pst, desc, stringtab, stringtab_size, sym_offset)
+psymtab_to_symtab_1 (pst, stringtab, stringtab_size, sym_offset)
struct partial_symtab *pst;
- int desc;
char *stringtab;
int stringtab_size;
int sym_offset;
wrap_here (""); /* Flush output */
fflush (stdout);
}
- psymtab_to_symtab_1 (pst->dependencies[i], desc,
+ psymtab_to_symtab_1 (pst->dependencies[i],
stringtab, stringtab_size, sym_offset);
}
old_chain = make_cleanup (really_free_pendings, 0);
/* Read in this files symbols */
- lseek (desc, sym_offset, L_SET);
+ bfd_seek (pst->objfile->obfd, sym_offset, L_SET);
pst->symtab =
- read_ofile_symtab (desc, stringtab, stringtab_size,
+ read_ofile_symtab (pst->objfile, stringtab, stringtab_size,
LDSYMOFF(pst),
LDSYMLEN(pst), pst->textlow,
pst->texthigh - pst->textlow, pst->addr);
dbx_psymtab_to_symtab (pst)
struct partial_symtab *pst;
{
- int desc;
char *stringtab;
int stsize, val;
- struct stat statbuf;
- struct cleanup *old_chain;
bfd *sym_bfd;
long st_temp;
fflush (stdout);
}
- /* Open symbol file and read in string table. Symbol_file_command
- guarantees that the symbol file name will be absolute, so there is
- no need for openp. */
- desc = open(pst->symfile_name, O_RDONLY, 0);
-
- if (desc < 0)
- perror_with_name (pst->symfile_name);
+ sym_bfd = pst->objfile->obfd;
- sym_bfd = bfd_fdopenr (pst->symfile_name, NULL, desc);
- if (!sym_bfd)
- {
- (void)close (desc);
- error ("Could not open `%s' to read symbols: %s",
- pst->symfile_name, bfd_errmsg (bfd_error));
- }
- old_chain = make_cleanup (bfd_close, sym_bfd);
- if (!bfd_check_format (sym_bfd, bfd_object))
- error ("\"%s\": can't read symbols: %s.",
- pst->symfile_name, bfd_errmsg (bfd_error));
-
- /* We keep the string table for symfile resident in memory, but
+ /* We keep the string table for the main symfile resident in memory, but
not the string table for any other symbol files. */
- if ((symfile == 0) || 0 != strcmp(pst->symfile_name, symfile))
+ if (symfile_objfile != pst->objfile)
{
/* Read in the string table */
/* FIXME, this uses internal BFD variables. See above in
dbx_symbol_file_open where the macro is defined! */
- lseek (desc, STRING_TABLE_OFFSET, L_SET);
+ bfd_seek (sym_bfd, STRING_TABLE_OFFSET, L_SET);
- val = myread (desc, &st_temp, sizeof st_temp);
+ val = bfd_read (&st_temp, sizeof st_temp, 1, sym_bfd);
if (val < 0)
- perror_with_name (pst->symfile_name);
+ perror_with_name (pst->objfile->name);
stsize = bfd_h_get_32 (sym_bfd, (unsigned char *)&st_temp);
+#if 0
+ /* BFD doesn't provide a way to know the total file size, sigh */
+ struct stat statbuf;
if (fstat (desc, &statbuf) < 0)
- perror_with_name (pst->symfile_name);
+ perror_with_name (pst->objfile->name);
if (stsize >= 0 && stsize < statbuf.st_size)
+#else
+ if (stsize >= 0)
+#endif
{
#ifdef BROKEN_LARGE_ALLOCA
stringtab = (char *) xmalloc (stsize);
/* FIXME, this uses internal BFD variables. See above in
dbx_symbol_file_open where the macro is defined! */
- val = lseek (desc, STRING_TABLE_OFFSET, L_SET);
+ val = bfd_seek (sym_bfd, STRING_TABLE_OFFSET, L_SET);
if (val < 0)
- perror_with_name (pst->symfile_name);
- val = myread (desc, stringtab, stsize);
+ perror_with_name (pst->objfile->name);
+ val = bfd_read (stringtab, stsize, 1, sym_bfd);
if (val < 0)
- perror_with_name (pst->symfile_name);
+ perror_with_name (pst->objfile->name);
}
else
{
stsize = symfile_string_table_size;
}
- symfile_bfd = sym_bfd; /* Kludge for SWAP_SYMBOL */
/* FIXME POKING INSIDE BFD DATA STRUCTURES */
symbol_size = obj_symbol_entry_size (sym_bfd);
/* FIXME, this uses internal BFD variables. See above in
dbx_symbol_file_open where the macro is defined! */
- psymtab_to_symtab_1 (pst, desc, stringtab, stsize,
+ psymtab_to_symtab_1 (pst, stringtab, stsize,
SYMBOL_TABLE_OFFSET);
/* Match with global symbols. This only needs to be done once,
after all of the symtabs and dependencies have been read in. */
scan_file_globals ();
- do_cleanups (old_chain);
-
/* Finish up the debug error message. */
if (info_verbose)
printf_filtered ("done.\n");
}
}
-/* Process a pair of symbols. Currently they must both be N_SO's. */
-/* ARGSUSED */
-static void
-process_symbol_pair (type1, desc1, value1, name1,
- type2, desc2, value2, name2)
- int type1;
- int desc1;
- CORE_ADDR value1;
- char *name1;
- int type2;
- int desc2;
- CORE_ADDR value2;
- char *name2;
-{
- /* No need to check PCC_SOL_BROKEN, on the assumption that such
- broken PCC's don't put out N_SO pairs. */
- if (last_source_file)
- (void)end_symtab (value2, 0, 0);
- start_symtab (name2, name1, value2);
-}
-
/*
* Read in a defined section of a specific object file's symbols.
*
*/
static struct symtab *
-read_ofile_symtab (desc, stringtab, stringtab_size, sym_offset,
+read_ofile_symtab (objfile, stringtab, stringtab_size, sym_offset,
sym_size, text_offset, text_size, offset)
- int desc;
+ struct objfile *objfile;
register char *stringtab;
unsigned int stringtab_size;
int sym_offset;
int offset;
{
register char *namestring;
- struct internal_nlist *bufp;
+ register struct internal_nlist *bufp;
unsigned char type;
unsigned max_symnum;
+ register bfd *abfd;
+
subfile_stack = 0;
stringtab_global = stringtab;
last_source_file = 0;
- symtab_input_desc = desc;
+ abfd = objfile->obfd;
+ symfile_bfd = objfile->obfd; /* Implicit param to next_text_symbol */
+ our_objfile = objfile; /* For end_symtab calls in process_one_symbol */
symbuf_end = symbuf_idx = 0;
/* It is necessary to actually read one symbol *before* the start
would slow down initial readin, so we look for it here instead. */
if (sym_offset >= (int)symbol_size)
{
- lseek (desc, sym_offset - symbol_size, L_INCR);
- fill_symbuf ();
+ bfd_seek (symfile_bfd, sym_offset - symbol_size, L_INCR);
+ fill_symbuf (abfd);
bufp = &symbuf[symbuf_idx++];
- SWAP_SYMBOL (bufp);
+ SWAP_SYMBOL (bufp, abfd);
SET_NAMESTRING ();
/* The N_SO starting this symtab is the first symbol, so we
better not check the symbol before it. I'm not this can
happen, but it doesn't hurt to check for it. */
- lseek(desc, sym_offset, L_INCR);
+ bfd_seek (symfile_bfd, sym_offset, L_INCR);
processing_gcc_compilation = 0;
}
if (symbuf_idx == symbuf_end)
- fill_symbuf();
+ fill_symbuf (abfd);
bufp = &symbuf[symbuf_idx];
if (bufp->n_type != (unsigned char)N_SO)
error("First symbol in segment of executable not a source symbol");
{
QUIT; /* Allow this to be interruptable */
if (symbuf_idx == symbuf_end)
- fill_symbuf();
+ fill_symbuf(abfd);
bufp = &symbuf[symbuf_idx++];
- SWAP_SYMBOL (bufp);
+ SWAP_SYMBOL (bufp, abfd);
type = bufp->n_type;
if (type == (unsigned char)N_CATCH)
SET_NAMESTRING ();
- if (type & N_STAB)
- {
+ if (type & N_STAB) {
+ /* Check for a pair of N_SO symbols, which give both a new
+ source file name (second) and its directory (first). */
+ if (type == (unsigned char)N_SO) {
+ /* Save the outer values */
short bufp_n_desc = bufp->n_desc;
unsigned long valu = bufp->n_value;
- /* Check for a pair of N_SO symbols. */
- if (type == (unsigned char)N_SO)
- {
- if (symbuf_idx == symbuf_end)
- fill_symbuf ();
- bufp = &symbuf[symbuf_idx];
- if (bufp->n_type == (unsigned char)N_SO)
- {
- char *namestring1 = namestring;
+ if (symbuf_idx == symbuf_end)
+ fill_symbuf (abfd);
+ bufp = &symbuf[symbuf_idx];
+ if (bufp->n_type == (unsigned char)N_SO) {
+ char *namestring1 = namestring;
+
+ SWAP_SYMBOL (bufp, abfd);
+ bufp->n_value += offset; /* Relocate */
+ symbuf_idx++;
+ symnum++;
+ SET_NAMESTRING ();
+
+ /* No need to check PCC_SOL_BROKEN, on the assumption that
+ such broken PCC's don't put out N_SO pairs. */
+ if (last_source_file)
+ (void)end_symtab (bufp->n_value, 0, 0, objfile);
+ start_symtab (namestring, namestring1, bufp->n_value);
+ } else {
+ /* N_SO without a following N_SO */
+ process_one_symbol(type, bufp_n_desc, valu, namestring);
+ /* our_objfile is an implicit parameter. */
+ }
+ } else {
- SWAP_SYMBOL (bufp);
- bufp->n_value += offset; /* Relocate */
- symbuf_idx++;
- symnum++;
- SET_NAMESTRING ();
+ /* Ordinary symbol
+
+ HERE IS WHERE THE REAL WORK GETS DONE!
+ */
+ process_one_symbol (type, bufp->n_desc, bufp->n_value,
+ namestring);
+ /* our_objfile is an implicit parameter. */
- process_symbol_pair (N_SO, bufp_n_desc, valu, namestring1,
- N_SO, bufp->n_desc, bufp->n_value,
- namestring);
- }
- else
- process_one_symbol(type, bufp_n_desc, valu, namestring);
- }
- else
- process_one_symbol (type, bufp_n_desc, valu, namestring);
}
+ }
/* We skip checking for a new .o or -l file; that should never
happen in this routine. */
else if (type == N_TEXT
}
}
- return end_symtab (text_offset + text_size, 0, 0);
+ return end_symtab (text_offset + text_size, 0, 0, objfile);
}
\f
int
within_function = 1;
if (context_stack_depth > 0)
{
- new = &context_stack[--context_stack_depth];
+ new = pop_context ();
/* Make a block for the local symbols within. */
finish_block (new->name, &local_symbols, new->old_blocks,
new->start_addr, valu);
}
/* Stack must be empty now. */
if (context_stack_depth != 0)
- error ("Invalid symbol data: unmatched N_LBRAC before symtab pos %d.",
- symnum);
+ complain (lbrac_unmatched_complaint, symnum);
- new = &context_stack[context_stack_depth++];
- new->old_blocks = pending_blocks;
- new->start_addr = valu;
+ new = push_context (0, valu);
new->name = define_symbol (valu, name, desc, type);
- local_symbols = 0;
break;
case N_CATCH:
valu = last_pc_address;
}
#endif
- if (context_stack_depth == context_stack_size)
- {
- context_stack_size *= 2;
- context_stack = (struct context_stack *)
- xrealloc (context_stack,
- (context_stack_size
- * sizeof (struct context_stack)));
- }
-
- new = &context_stack[context_stack_depth++];
- new->depth = desc;
- new->locals = local_symbols;
- new->old_blocks = pending_blocks;
- new->start_addr = valu;
- new->name = 0;
- local_symbols = 0;
+ new = push_context (desc, valu);
break;
case N_RBRAC:
valu += last_source_start_addr;
#endif
- new = &context_stack[--context_stack_depth];
+ new = pop_context();
if (desc != new->depth)
- error ("Invalid symbol data: N_LBRAC/N_RBRAC symbol mismatch, symtab pos %d.", symnum);
+ complain (lbrac_mismatch_complaint, symnum);
/* Some compilers put the variable decls inside of an
LBRAC/RBRAC block. This macro should be nonzero if this
}
}
\f
-/* To handle GNU C++ typename abbreviation, we need to be able to
- fill in a type's name as soon as space for that type is allocated.
- `type_synonym_name' is the name of the type being allocated.
- It is cleared as soon as it is used (lest all allocated types
- get this name). */
-static char *type_synonym_name;
-
-/* ARGSUSED */
-static struct symbol *
-define_symbol (valu, string, desc, type)
- unsigned int valu;
- char *string;
- int desc;
- int type;
-{
- register struct symbol *sym;
- char *p = (char *) strchr (string, ':');
- int deftype;
- int synonym = 0;
- register int i;
-
- /* Ignore syms with empty names. */
- if (string[0] == 0)
- return 0;
-
- /* Ignore old-style symbols from cc -go */
- if (p == 0)
- return 0;
-
- sym = (struct symbol *)obstack_alloc (symbol_obstack, sizeof (struct symbol));
-
- if (processing_gcc_compilation) {
- /* GCC 2.x puts the line number in desc. SunOS apparently puts in the
- number of bytes occupied by a type or object, which we ignore. */
- SYMBOL_LINE(sym) = desc;
- } else {
- SYMBOL_LINE(sym) = 0; /* unknown */
- }
-
- if (string[0] == CPLUS_MARKER)
- {
- /* Special GNU C++ names. */
- switch (string[1])
- {
- case 't':
- SYMBOL_NAME (sym) = "this";
- break;
- case 'v': /* $vtbl_ptr_type */
- /* Was: SYMBOL_NAME (sym) = "vptr"; */
- goto normal;
- case 'e':
- SYMBOL_NAME (sym) = "eh_throw";
- break;
-
- case '_':
- /* This was an anonymous type that was never fixed up. */
- goto normal;
-
- default:
- abort ();
- }
- }
- else
- {
- normal:
- SYMBOL_NAME (sym)
- = (char *) obstack_alloc (symbol_obstack, ((p - string) + 1));
- /* Open-coded bcopy--saves function call time. */
- {
- register char *p1 = string;
- register char *p2 = SYMBOL_NAME (sym);
- while (p1 != p)
- *p2++ = *p1++;
- *p2++ = '\0';
- }
- }
- p++;
- /* Determine the type of name being defined. */
- /* The Acorn RISC machine's compiler can put out locals that don't
- start with "234=" or "(3,4)=", so assume anything other than the
- deftypes we know how to handle is a local. */
- /* (Peter Watkins @ Computervision)
- Handle Sun-style local fortran array types 'ar...' .
- (gnu@cygnus.com) -- this strchr() handles them properly?
- (tiemann@cygnus.com) -- 'C' is for catch. */
- if (!strchr ("cfFGpPrStTvVXC", *p))
- deftype = 'l';
- else
- deftype = *p++;
-
- /* c is a special case, not followed by a type-number.
- SYMBOL:c=iVALUE for an integer constant symbol.
- SYMBOL:c=rVALUE for a floating constant symbol.
- SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
- e.g. "b:c=e6,0" for "const b = blob1"
- (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
- if (deftype == 'c')
- {
- if (*p++ != '=')
- error ("Invalid symbol data at symtab pos %d.", symnum);
- switch (*p++)
- {
- case 'r':
- {
- double d = atof (p);
- char *dbl_valu;
-
- SYMBOL_TYPE (sym) = builtin_type_double;
- dbl_valu =
- (char *) obstack_alloc (symbol_obstack, sizeof (double));
- bcopy (&d, dbl_valu, sizeof (double));
- SWAP_TARGET_AND_HOST (dbl_valu, sizeof (double));
- SYMBOL_VALUE_BYTES (sym) = dbl_valu;
- SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
- }
- break;
- case 'i':
- {
- SYMBOL_TYPE (sym) = builtin_type_int;
- SYMBOL_VALUE (sym) = atoi (p);
- SYMBOL_CLASS (sym) = LOC_CONST;
- }
- break;
- case 'e':
- /* SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
- e.g. "b:c=e6,0" for "const b = blob1"
- (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
- {
- int typenums[2];
-
- read_type_number (&p, typenums);
- if (*p++ != ',')
- error ("Invalid symbol data: no comma in enum const symbol");
-
- SYMBOL_TYPE (sym) = *dbx_lookup_type (typenums);
- SYMBOL_VALUE (sym) = atoi (p);
- SYMBOL_CLASS (sym) = LOC_CONST;
- }
- break;
- default:
- error ("Invalid symbol data at symtab pos %d.", symnum);
- }
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &file_symbols);
- return sym;
- }
-
- /* Now usually comes a number that says which data type,
- and possibly more stuff to define the type
- (all of which is handled by read_type) */
-
- if (deftype == 'p' && *p == 'F')
- /* pF is a two-letter code that means a function parameter in Fortran.
- The type-number specifies the type of the return value.
- Translate it into a pointer-to-function type. */
- {
- p++;
- SYMBOL_TYPE (sym)
- = lookup_pointer_type (lookup_function_type (read_type (&p)));
- }
- else
- {
- struct type *type_read;
- synonym = *p == 't';
-
- if (synonym)
- {
- p += 1;
- type_synonym_name = obsavestring (SYMBOL_NAME (sym),
- strlen (SYMBOL_NAME (sym)));
- }
-
- type_read = read_type (&p);
-
- if ((deftype == 'F' || deftype == 'f')
- && TYPE_CODE (type_read) != TYPE_CODE_FUNC)
- {
-#if 0
-/* This code doesn't work -- it needs to realloc and can't. */
- struct type *new = (struct type *)
- obstack_alloc (symbol_obstack, sizeof (struct type));
-
- /* Generate a template for the type of this function. The
- types of the arguments will be added as we read the symbol
- table. */
- *new = *lookup_function_type (type_read);
- SYMBOL_TYPE(sym) = new;
- in_function_type = new;
-#else
- SYMBOL_TYPE (sym) = lookup_function_type (type_read);
-#endif
- }
- else
- SYMBOL_TYPE (sym) = type_read;
- }
-
- switch (deftype)
- {
- case 'C':
- /* The name of a caught exception. */
- SYMBOL_CLASS (sym) = LOC_LABEL;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- SYMBOL_VALUE_ADDRESS (sym) = valu;
- add_symbol_to_list (sym, &local_symbols);
- break;
-
- case 'f':
- SYMBOL_CLASS (sym) = LOC_BLOCK;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &file_symbols);
- break;
-
- case 'F':
- SYMBOL_CLASS (sym) = LOC_BLOCK;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &global_symbols);
- break;
-
- case 'G':
- /* For a class G (global) symbol, it appears that the
- value is not correct. It is necessary to search for the
- corresponding linker definition to find the value.
- These definitions appear at the end of the namelist. */
- i = hashname (SYMBOL_NAME (sym));
- SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
- global_sym_chain[i] = sym;
- SYMBOL_CLASS (sym) = LOC_STATIC;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &global_symbols);
- break;
-
- /* This case is faked by a conditional above,
- when there is no code letter in the dbx data.
- Dbx data never actually contains 'l'. */
- case 'l':
- SYMBOL_CLASS (sym) = LOC_LOCAL;
- SYMBOL_VALUE (sym) = valu;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &local_symbols);
- break;
-
- case 'p':
- /* Normally this is a parameter, a LOC_ARG. On the i960, it
- can also be a LOC_LOCAL_ARG depending on symbol type. */
-#ifndef DBX_PARM_SYMBOL_CLASS
-#define DBX_PARM_SYMBOL_CLASS(type) LOC_ARG
-#endif
- SYMBOL_CLASS (sym) = DBX_PARM_SYMBOL_CLASS (type);
- SYMBOL_VALUE (sym) = valu;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
-#if 0
- /* This doesn't work yet. */
- add_param_to_type (&in_function_type, sym);
-#endif
- add_symbol_to_list (sym, &local_symbols);
-
- /* If it's gcc-compiled, if it says `short', believe it. */
- if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION)
- break;
-
-#if defined(BELIEVE_PCC_PROMOTION_TYPE)
- /* This macro is defined on machines (e.g. sparc) where
- we should believe the type of a PCC 'short' argument,
- but shouldn't believe the address (the address is
- the address of the corresponding int). Note that
- this is only different from the BELIEVE_PCC_PROMOTION
- case on big-endian machines.
-
- My guess is that this correction, as opposed to changing
- the parameter to an 'int' (as done below, for PCC
- on most machines), is the right thing to do
- on all machines, but I don't want to risk breaking
- something that already works. On most PCC machines,
- the sparc problem doesn't come up because the calling
- function has to zero the top bytes (not knowing whether
- the called function wants an int or a short), so there
- is no practical difference between an int and a short
- (except perhaps what happens when the GDB user types
- "print short_arg = 0x10000;").
-
- Hacked for SunOS 4.1 by gnu@cygnus.com. In 4.1, the compiler
- actually produces the correct address (we don't need to fix it
- up). I made this code adapt so that it will offset the symbol
- if it was pointing at an int-aligned location and not
- otherwise. This way you can use the same gdb for 4.0.x and
- 4.1 systems. */
-
- if (0 == SYMBOL_VALUE (sym) % sizeof (int))
- {
- if (SYMBOL_TYPE (sym) == builtin_type_char
- || SYMBOL_TYPE (sym) == builtin_type_unsigned_char)
- SYMBOL_VALUE (sym) += 3;
- else if (SYMBOL_TYPE (sym) == builtin_type_short
- || SYMBOL_TYPE (sym) == builtin_type_unsigned_short)
- SYMBOL_VALUE (sym) += 2;
- }
- break;
-
-#else /* no BELIEVE_PCC_PROMOTION_TYPE. */
-
- /* If PCC says a parameter is a short or a char,
- it is really an int. */
- if (SYMBOL_TYPE (sym) == builtin_type_char
- || SYMBOL_TYPE (sym) == builtin_type_short)
- SYMBOL_TYPE (sym) = builtin_type_int;
- else if (SYMBOL_TYPE (sym) == builtin_type_unsigned_char
- || SYMBOL_TYPE (sym) == builtin_type_unsigned_short)
- SYMBOL_TYPE (sym) = builtin_type_unsigned_int;
- break;
-
-#endif /* no BELIEVE_PCC_PROMOTION_TYPE. */
-
- case 'P':
- SYMBOL_CLASS (sym) = LOC_REGPARM;
- SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &local_symbols);
- break;
-
- case 'r':
- SYMBOL_CLASS (sym) = LOC_REGISTER;
- SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &local_symbols);
- break;
-
- case 'S':
- /* Static symbol at top level of file */
- SYMBOL_CLASS (sym) = LOC_STATIC;
- SYMBOL_VALUE_ADDRESS (sym) = valu;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &file_symbols);
- break;
-
- case 't':
- SYMBOL_CLASS (sym) = LOC_TYPEDEF;
- SYMBOL_VALUE (sym) = valu;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0
- && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0)
- TYPE_NAME (SYMBOL_TYPE (sym)) =
- obsavestring (SYMBOL_NAME (sym),
- strlen (SYMBOL_NAME (sym)));
- /* C++ vagaries: we may have a type which is derived from
- a base type which did not have its name defined when the
- derived class was output. We fill in the derived class's
- base part member's name here in that case. */
- else if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
- || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
- && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)))
- {
- int j;
- for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--)
- if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0)
- TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) =
- type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), j));
- }
-
- add_symbol_to_list (sym, &file_symbols);
- break;
-
- case 'T':
- SYMBOL_CLASS (sym) = LOC_TYPEDEF;
- SYMBOL_VALUE (sym) = valu;
- SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
- if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0
- && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0)
- TYPE_NAME (SYMBOL_TYPE (sym))
- = obconcat ("",
- (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_ENUM
- ? "enum "
- : (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
- ? "struct " : "union ")),
- SYMBOL_NAME (sym));
- add_symbol_to_list (sym, &file_symbols);
-
- if (synonym)
- {
- register struct symbol *typedef_sym
- = (struct symbol *) obstack_alloc (symbol_obstack, sizeof (struct symbol));
- SYMBOL_NAME (typedef_sym) = SYMBOL_NAME (sym);
- SYMBOL_TYPE (typedef_sym) = SYMBOL_TYPE (sym);
-
- SYMBOL_CLASS (typedef_sym) = LOC_TYPEDEF;
- SYMBOL_VALUE (typedef_sym) = valu;
- SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE;
- add_symbol_to_list (typedef_sym, &file_symbols);
- }
- break;
-
- case 'V':
- /* Static symbol of local scope */
- SYMBOL_CLASS (sym) = LOC_STATIC;
- SYMBOL_VALUE_ADDRESS (sym) = valu;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &local_symbols);
- break;
-
- case 'v':
- /* Reference parameter */
- SYMBOL_CLASS (sym) = LOC_REF_ARG;
- SYMBOL_VALUE (sym) = valu;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &local_symbols);
- break;
-
- case 'X':
- /* This is used by Sun FORTRAN for "function result value".
- Sun claims ("dbx and dbxtool interfaces", 2nd ed)
- that Pascal uses it too, but when I tried it Pascal used
- "x:3" (local symbol) instead. */
- SYMBOL_CLASS (sym) = LOC_LOCAL;
- SYMBOL_VALUE (sym) = valu;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- add_symbol_to_list (sym, &local_symbols);
- break;
-
- default:
- error ("Invalid symbol data: unknown symbol-type code `%c' at symtab pos %d.", deftype, symnum);
- }
- return sym;
-}
-\f
-#if 0
-/* This would be a good idea, but it doesn't really work. The problem
- is that in order to get the virtual context for a particular type,
- you need to know the virtual info from all of its basetypes,
- and you need to have processed its methods. Since GDB reads
- symbols on a file-by-file basis, this means processing the symbols
- of all the files that are needed for each baseclass, which
- means potentially reading in all the debugging info just to fill
- in information we may never need. */
-
-/* This page contains subroutines of read_type. */
-
-/* FOR_TYPE is a struct type defining a virtual function NAME with type
- FN_TYPE. The `virtual context' for this virtual function is the
- first base class of FOR_TYPE in which NAME is defined with signature
- matching FN_TYPE. OFFSET serves as a hash on matches here.
-
- TYPE is the current type in which we are searching. */
-
-static struct type *
-virtual_context (for_type, type, name, fn_type, offset)
- struct type *for_type, *type;
- char *name;
- struct type *fn_type;
- int offset;
-{
- struct type *basetype = 0;
- int i;
-
- if (for_type != type)
- {
- /* Check the methods of TYPE. */
- /* Need to do a check_stub_type here, but that breaks
- things because we can get infinite regress. */
- for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i)
- if (!strcmp (TYPE_FN_FIELDLIST_NAME (type, i), name))
- break;
- if (i >= 0)
- {
- int j = TYPE_FN_FIELDLIST_LENGTH (type, i);
- struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
-
- while (--j >= 0)
- if (TYPE_FN_FIELD_VOFFSET (f, j) == offset-1)
- return TYPE_FN_FIELD_FCONTEXT (f, j);
- }
- }
- for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
- {
- basetype = virtual_context (for_type, TYPE_BASECLASS (type, i), name,
- fn_type, offset);
- if (basetype != for_type)
- return basetype;
- }
- return for_type;
-}
-#endif
-\f
/* Copy a pending list, used to record the contents of a common
block for later fixup. */
static struct pending *
-/* Basic definitions for GDB, the GNU debugger.
+/* Basic, host-specific, and target-specific definitions for GDB.
Copyright (C) 1986, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
extern char *reg_names[];
/* Indicate that these routines do not return to the caller. */
extern volatile void error(), fatal();
+extern void warning_setup(), warning();
/* Various possibilities for alloca. */
#ifndef alloca
language_unknown, /* Language not known */
language_auto, /* Placeholder for automatic setting */
language_c, /* C */
+ language_cplus, /* C++ */
language_m2, /* Modula-2 */
};
char *local_hex_string (); /* language.c */
char *local_hex_string_custom (); /* language.c */
+\f
+/* System-dependent parameters for GDB.
+
+ The standard thing is to include defs.h. However, files that are
+ specific to a particular target can define TM_FILE_OVERRIDE before
+ including defs.h, then can include any particular tm-file they desire. */
+
+/* Target machine definition. This will be a symlink to one of the
+ tm-*.h files, built by the `configure' script. */
+
+#ifndef TM_FILE_OVERRIDE
+#include "tm.h"
+#endif
+
+/* Host machine definition. This will be a symlink to one of the
+ xm-*.h files, built by the `configure' script. */
+
+#include "xm.h"
+
+/* TARGET_BYTE_ORDER and HOST_BYTE_ORDER should be defined to one of these. */
+#if !defined (BIG_ENDIAN)
+#define BIG_ENDIAN 4321
+#endif
+
+#if !defined (LITTLE_ENDIAN)
+#define LITTLE_ENDIAN 1234
+#endif
+
+/* The bit byte-order has to do just with numbering of bits in
+ debugging symbols and such. Conceptually, it's quite separate
+ from byte/word byte order. */
+
+#if !defined (BITS_BIG_ENDIAN)
+#if TARGET_BYTE_ORDER == BIG_ENDIAN
+#define BITS_BIG_ENDIAN 1
+#endif /* Big endian. */
+
+#if TARGET_BYTE_ORDER == LITTLE_ENDIAN
+#define BITS_BIG_ENDIAN 0
+#endif /* Little endian. */
+#endif /* BITS_BIG_ENDIAN not defined. */
+
+/* Swap LEN bytes at BUFFER between target and host byte-order. */
+#if TARGET_BYTE_ORDER == HOST_BYTE_ORDER
+#define SWAP_TARGET_AND_HOST(buffer,len)
+#else /* Target and host byte order differ. */
+#define SWAP_TARGET_AND_HOST(buffer,len) \
+ { \
+ char tmp; \
+ char *p = (char *)(buffer); \
+ char *q = ((char *)(buffer)) + len - 1; \
+ for (; p < q; p++, q--) \
+ { \
+ tmp = *q; \
+ *q = *p; \
+ *p = tmp; \
+ } \
+ }
+#endif /* Target and host byte order differ. */
+
+/* On some machines there are bits in addresses which are not really
+ part of the address, but are used by the kernel, the hardware, etc.
+ for special purposes. ADDR_BITS_REMOVE takes out any such bits
+ so we get a "real" address such as one would find in a symbol
+ table. ADDR_BITS_SET sets those bits the way the system wants
+ them. */
+#if !defined (ADDR_BITS_REMOVE)
+#define ADDR_BITS_REMOVE(addr) (addr)
+#define ADDR_BITS_SET(addr) (addr)
+#endif /* No ADDR_BITS_REMOVE. */
+
+#if !defined (SYS_SIGLIST_MISSING)
+#define SYS_SIGLIST_MISSING defined (USG)
+#endif /* No SYS_SIGLIST_MISSING */
#endif /* no DEFS_H */
#include <fcntl.h>
#include "defs.h"
-#include "param.h"
#include "bfd.h"
#include "symtab.h"
#include "symfile.h"
static void
DEFUN(dwarf_psymtab_to_symtab, (pst), struct partial_symtab *pst)
{
- int desc;
- bfd *sym_bfd;
-
+
if (!pst)
{
return;
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "elf-common.h"
#include "elf-external.h"
#include "elf-internal.h"
/* Work with executable files, for GDB.
- Copyright (C) 1988, 1989 Free Software Foundation, Inc.
+ Copyright 1988, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "target.h"
error ("\"%s\": not in executable format: %s.",
scratch_pathname, bfd_errmsg (bfd_error));
-#if FIXME
-/* This code needs to be incorporated into BFD */
-#ifdef COFF_ENCAPSULATE
- /* If we have a coff header, it can give us better values for
- text_start and exec_data_start. This is particularly useful
- for remote debugging of embedded systems. */
- if (N_FLAGS(exec_aouthdr) & N_FLAGS_COFF_ENCAPSULATE)
- {
- struct coffheader ch;
- int val;
- val = lseek (execchan, -(sizeof (AOUTHDR) + sizeof (ch)), 1);
- if (val == -1)
- perror_with_name (filename);
- val = myread (execchan, &ch, sizeof (ch));
- if (val < 0)
- perror_with_name (filename);
- text_start = ch.text_start;
- exec_data_start = ch.data_start;
- } else
-#endif
- {
- text_start =
- IS_OBJECT_FILE (exec_aouthdr) ? 0 : N_TXTADDR (exec_aouthdr);
- exec_data_start = IS_OBJECT_FILE (exec_aouthdr)
- ? exec_aouthdr.a_text : N_DATADDR (exec_aouthdr);
- }
-#endif FIXME
-
if (build_section_table (exec_bfd, &exec_ops.sections,
&exec_ops.sections_end))
error ("Can't find the file sections in `%s': %s",
{
struct section_table *p;
- printf ("\tExecutable file `%s'.\n", bfd_get_filename(exec_bfd));
+ printf_filtered ("\t`%s', ", bfd_get_filename(exec_bfd));
+ wrap_here (" ");
+ printf_filtered ("file type %s.\n", bfd_get_target(exec_bfd));
for (p = exec_ops.sections; p < exec_ops.sections_end; p++) {
- printf("\t%s", local_hex_string_custom (p->addr, "08"));
- printf(" - %s is %s\n", local_hex_string_custom (p->endaddr, "08"),
+ printf_filtered ("\t%s", local_hex_string_custom (p->addr, "08"));
+ printf_filtered (" - %s is %s\n",
+ local_hex_string_custom (p->endaddr, "08"),
bfd_section_name (exec_bfd, p->sec_ptr));
}
}
/* Find a variable's value in memory, for GDB, the GNU debugger.
- Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "frame.h"
#include "value.h"
}
case LOC_STATIC:
- case LOC_EXTERNAL:
addr = SYMBOL_VALUE_ADDRESS (var);
break;
{
CORE_ADDR addr = 0;
struct type *type = SYMBOL_TYPE (var);
- struct type *result_type;
value lazy_value;
/* Evaluate it first; if the result is a memory address, we're fine.
type = TYPE_TARGET_TYPE (type);
}
- /* Address of an array is of the type of address of it's elements. */
- /* FIXME, this is probably wrong now for ANSI C. */
- result_type =
- lookup_pointer_type (TYPE_CODE (type) == TYPE_CODE_ARRAY ?
- TYPE_TARGET_TYPE (type) : type);
-
- return value_cast (result_type,
- value_from_long (builtin_type_long, (LONGEST) addr));
+ return value_from_longest (lookup_pointer_type (type), (LONGEST) addr);
}
/* Not a memory address; check what the problem was. */
/* Print GOULD RISC instructions for GDB, the GNU debugger.
- Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
-#include "gdbcore.h"
-
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "frame.h"
+#include "gdbcore.h"
#if defined GOULD_PN
#include "pn-opcode.h"
#else
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
/* For the GDB interface at the bottom of the file... */
#include "defs.h"
-#include "param.h"
#include "gdbcore.h"
#define Eb OP_E, b_mode
This file is part of GDB.
-GDB is free software; you can redistribute it and/or modify
+This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
-GDB is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GDB; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "gdbcore.h"
-#ifdef USG
-#include <sys/types.h>
-#endif
-
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <sys/user.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-
-#ifndef N_SET_MAGIC
-#ifdef COFF_FORMAT
-#define N_SET_MAGIC(exec, val) ((exec).magic = (val))
-#else
-#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val))
-#endif
-#endif
-
-#include <sys/file.h>
-#include <sys/stat.h>
-
/* helper functions for tm-i386.h */
/* stdio style buffering to minimize calls to ptrace */
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "language.h"
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "language.h"
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include <stdio.h>
#include <signal.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "value.h"
#include "frame.h"
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
-#include "param.h"
#include "ieee-float.h"
#include <math.h> /* ldexp */
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "command.h"
static struct tchars tc_ours;
#endif
-#ifdef TIOCGLTC
+#if defined(TIOCGLTC) && !defined(TIOCGLTC_BROKEN)
static struct ltchars ltc_inferior;
static struct ltchars ltc_ours;
#endif
#endif
#ifdef TIOCGPGRP
+# ifdef SHORT_PGRP
+static short pgrp_inferior;
+static short pgrp_ours;
+# else
static int pgrp_inferior;
static int pgrp_ours;
+# endif
#else
static void (*sigint_ours) ();
static void (*sigquit_ours) ();
tc_inferior = tc_ours;
#endif
-#ifdef TIOCGLTC
+#if defined(TIOCGLTC) && !defined(TIOCGLTC_BROKEN)
ltc_inferior = ltc_ours;
#endif
#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN)
ioctl (0, TIOCSETC, &tc_inferior);
#endif
-#ifdef TIOCGLTC
+#if defined(TIOCGLTC) && !defined(TIOCGLTC_BROKEN)
ioctl (0, TIOCSLTC, <c_inferior);
#endif
#ifdef TIOCLGET
#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN)
ioctl (0, TIOCGETC, &tc_inferior);
#endif
-#ifdef TIOCGLTC
+#if defined(TIOCGLTC) && !defined(TIOCGLTC_BROKEN)
ioctl (0, TIOCGLTC, <c_inferior);
#endif
#ifdef TIOCLGET
#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN)
ioctl (0, TIOCSETC, &tc_ours);
#endif
-#ifdef TIOCGLTC
+#if defined(TIOCGLTC) && !defined(TIOCGLTC_BROKEN)
ioctl (0, TIOCSLTC, <c_ours);
#endif
#ifdef TIOCLGET
printf_filtered ("\n");
#endif
-#ifdef TIOCGLTC
+#if defined(TIOCGLTC) && !defined(TIOCGLTC_BROKEN)
printf_filtered ("ltchars: ");
for (i = 0; i < (int)sizeof (struct ltchars); i++)
printf_filtered ("0x%x ", ((char *)<c_inferior)[i]);
become debugger target processes. This actually switches to
the terminal specified in the NEW_TTY_PREFORK call. */
+void
new_tty_prefork (ttyname)
char *ttyname;
{
/* Now open the specified new terminal. */
+#ifdef USE_O_NOCTTY
+ tty = open(inferior_thisrun_terminal, O_RDWR | O_NOCTTY);
+#else
tty = open(inferior_thisrun_terminal, O_RDWR);
+#endif
if (tty == -1)
{
print_sys_errmsg (inferior_thisrun_terminal, errno);
#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN)
ioctl (0, TIOCGETC, &tc_ours);
#endif
-#ifdef TIOCGLTC
+#if defined(TIOCGLTC) && !defined(TIOCGLTC_BROKEN)
ioctl (0, TIOCGLTC, <c_ours);
#endif
#ifdef TIOCLGET
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "target.h"
#include <stdio.h>
#include <string.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "frame.h"
#include "inferior.h"
-/* Main loop for the standalone kernel debugger.
- Copyright (C) 1989, Free Software Foundation, Inc.
+/* Main loop for the standalone kernel debugger, for GDB, the GNU Debugger.
+ Copyright 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
-#include "param.h"
static char *args[] = {"kdb", "kdb-symbols", 0};
#include <stdio.h>
#include <string.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "frame.h"
#include "expression.h"
case LOC_REGISTER:
case LOC_ARG:
case LOC_LOCAL:
+ case LOC_REF_ARG:
+ case LOC_REGPARM:
+ case LOC_LOCAL_ARG:
if (innermost_block == 0 ||
contained_in (block_found,
innermost_block))
innermost_block = block_found;
+ break;
+
+ case LOC_UNDEF:
+ case LOC_CONST:
+ case LOC_STATIC:
+ case LOC_TYPEDEF:
+ case LOC_LABEL: /* maybe should go above? */
+ case LOC_BLOCK:
+ case LOC_CONST_BYTES:
+ /* These are listed so gcc -Wall will reveal
+ un-handled cases. */
+ break;
}
write_exp_elt_opcode (OP_VAR_VALUE);
write_exp_elt_sym (sym);
-/* Print m68k instructions for GDB, the GNU debugger.
- Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+/* Print Motorola 68k instructions for GDB, the GNU debugger.
+ Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "m68k-opcode.h"
#include "gdbcore.h"
-/* This file has been modified by Data General Corporation, November 1989. */
+/* Print instructions for the Motorola 88000, for GDB and GNU Binutils.
+ Copyright 1986, 1987, 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
+ Contributed by Data General Corporation, November 1989.
+ Partially derived from an earlier printcmd.c.
+
+This file is part of GDB and the GNU Binutils.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+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. */
#include <stdio.h>
#include "m88k-opcode.h"
void sprint_address ();
-/* Changed hashtab to hashtable to avoid naming conflict
- with libdc.o (used for tdesc) for m88k.
-*/
-
INSTAB *hashtable[HASHVAL] = {0};
/*
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "value.h"
-/* Copyright (C) 1988, 1990 Free Software Foundation, Inc.
+/* Host-dependent Motorola 88xxx support for GDB, the GNU Debugger.
+ Copyright 1988, 1990, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "signame.h"
-/* Top level for GDB, the GNU debugger.
- Copyright (C) 1986, 1987, 1988, 1989, 1990 Free Software Foundation, Inc.
+/* Top level `main' program for GDB, the GNU debugger.
+ Copyright 1986, 1987, 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
This file is part of GDB.
int fclose ();
#include "defs.h"
#include "gdbcmd.h"
-#include "param.h"
#include "symtab.h"
#include "inferior.h"
#include "signals.h"
printf_filtered ("\n");
error_pre_print = "\n";
+ /* Set the initial language. */
+ {
+ extern enum language deduce_language_from_filename ();
+ extern struct partial_symtab *find_main_psymtab ();
+ struct partial_symtab *pst = find_main_psymtab ();
+ enum language lang = language_unknown;
+ if (pst == NULL) ;
+#if 0
+ /* A better solution would set the language when reading the psymtab.
+ This would win for symbol file formats that encode the langauge,
+ such as dwarf. But, we don't do that yet. FIXME */
+ else if (pst->language != language_unknown)
+ lang = pst->language;
+#endif
+ else if (pst->filename != NULL)
+ lang = deduce_language_from_filename (pst->filename);
+ if (lang == language_unknown) /* Make C the default language */
+ lang = language_c;
+ set_language (lang);
+ }
+
if (corearg != NULL)
if (!setjmp (to_top_level))
core_file_command (corearg, !batch);
current_directory = dir;
else
{
- current_directory = concat (current_directory, "/", dir);
+ current_directory = concat (current_directory, "/", dir, NULL);
free (dir);
}
/* We include the current directory so that if the user changes
directories the file written will be the same as the one
that was read. */
- history_filename = concat (current_directory, "/.gdb_history", "");
+ history_filename = concat (current_directory, "/.gdb_history", NULL);
}
read_history (history_filename);
}
-/* Simulate breakpoints by patching locations in the target system.
- Copyright (C) 1990 Free Software Foundation, Inc.
+/* Simulate breakpoints by patching locations in the target system, for GDB.
+ Copyright 1990, 1991 Free Software Foundation, Inc.
+ Contributed by Cygnus Support. Written by John Gilmore.
This file is part of GDB.
-GDB is free software; you can redistribute it and/or modify
+This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
-GDB is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GDB; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
-#include "param.h"
#ifdef BREAKPOINT
/* This file is only useful if BREAKPOINT is set. If not, we punt. */
}
-#if 0
-/* This should move back into breakpoint.c, sad to say. Encapsulate
- sizeof (BREAKPOINT) by export it as an int from mem-break.c. */
+int memory_breakpoint_size = sizeof (break_insn);
-/* Like target_read_memory() but if breakpoints are inserted, return
- the shadow contents instead of the breakpoints themselves. */
-int
-read_memory_nobpt (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- unsigned len;
-{
- int status;
- struct breakpoint *b;
- ALL_BREAKPOINTS (b)
- {
- if (b->address == NULL || !b->inserted)
- continue;
- else if (b->address + sizeof (break_insn) <= memaddr)
- /* The breakpoint is entirely before the chunk of memory
- we are reading. */
- continue;
- else if (b->address >= memaddr + len)
- /* The breakpoint is entirely after the chunk of memory we
- are reading. */
- continue;
- else
- {
- /* Copy the breakpoint from the shadow contents, and recurse
- for the things before and after. */
-
- /* Addresses and length of the part of the breakpoint that
- we need to copy. */
- CORE_ADDR membpt = b->address;
- unsigned int bptlen = sizeof (break_insn);
- /* Offset within shadow_contents. */
- int bptoffset = 0;
-
- if (membpt < memaddr)
- {
- /* Only copy the second part of the breakpoint. */
- bptlen -= memaddr - membpt;
- bptoffset = memaddr - membpt;
- membpt = memaddr;
- }
-
- if (membpt + bptlen > memaddr + len)
- {
- /* Only copy the first part of the breakpoint. */
- bptlen -= (membpt + bptlen) - (memaddr + len);
- }
-
- bcopy (b->shadow_contents + bptoffset,
- myaddr + membpt - memaddr, bptlen);
-
- if (membpt > memaddr)
- {
- /* Copy the section of memory before the breakpoint. */
- status = read_memory_nobpt (memaddr, myaddr, membpt - memaddr);
- if (status != 0)
- return status;
- }
-
- if (membpt + bptlen < memaddr + len)
- {
- /* Copy the section of memory after the breakpoint. */
- status = read_memory_nobpt
- (membpt + bptlen,
- myaddr + membpt + bptlen - memaddr,
- memaddr + len - (membpt + bptlen));
- if (status != 0)
- return status;
- }
- return 0;
- }
- }
- /* Nothing overlaps. Just call read_memory_noerr. */
- return target_read_memory (memaddr, myaddr, len);
-}
-#endif /* 0 */
#else /* BREAKPOINT */
return 0; /* lint */
}
+int memory_breakpoint_size = -1;
+
#endif /* BREAKPOINT */
/* Print mips instructions for GDB, the GNU debugger.
- Copyright (C) 1989 Free Software Foundation, Inc.
+ Copyright 1989, 1991 Free Software Foundation, Inc.
Contributed by Nobuyuki Hikichi(hikichi@sra.co.jp)
This file is part of GDB.
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "mips-opcode.h"
-/* Work with core dump and executable files, for GDB on MIPS.
- This code would be in core.c if it weren't machine-dependent. */
-
-/* Low level interface to ptrace, for GDB when running under Unix.
- Copyright (C) 1988, 1989, 1990 Free Software Foundation, Inc.
+/* Target-dependent code for the MIPS architecture, for GDB, the GNU Debugger.
+ Copyright 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU
and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* FIXME: Can a MIPS porter/tester determine which of these include
- files we still need? -- gnu@cygnus.com */
#include <stdio.h>
-#ifdef sgi
-#include <sys/inst.h>
-#else
-#include <mips/inst.h>
-#endif
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "symtab.h"
for (ireg = 32; --ireg >= 0; )
if (PROC_FREG_MASK(proc_desc) & (1 << ireg))
{
- buffer = read_register (ireg);
+ buffer = read_register (ireg + FP0_REGNUM);
write_memory (save_address, &buffer, 4);
save_address -= 4;
}
if (PROC_REG_MASK(proc_desc) & (1 << regnum))
write_register (regnum,
read_memory_integer (frame->saved_regs->regs[regnum], 4));
- for (regnum = 64; --regnum >= 32; )
+ for (regnum = 32; --regnum >= 0; )
if (PROC_FREG_MASK(proc_desc) & (1 << regnum))
- write_register (regnum,
- read_memory_integer (frame->saved_regs->regs[regnum], 4));
+ write_register (regnum + FP0_REGNUM,
+ read_memory_integer (frame->saved_regs->regs[regnum + FP0_REGNUM], 4));
}
write_register (SP_REGNUM, new_sp);
flush_cached_frames ();
#include <mips/inst.h>
#endif
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "symtab.h"
a pointer in the psymtab to do this. */
#include <stdio.h>
-#include "param.h"
-#include "obstack.h"
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/stat.h>
#include "defs.h"
#include "symtab.h"
#include "gdbcore.h"
#include "symfile.h"
+#include "obstack.h"
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/stat.h>
#ifdef CMUCS
#include <mips/syms.h>
#else /* not CMUCS */
sh = s_idx + (SYMR *) fh->isymBase;
- if (sh->sc == scUndefined || sh->sc == scNil) {
+ if (sh->sc == scUndefined || sh->sc == scNil ||
+ sh->index == 0xfffff) {
/* FIXME, premature? */
s_idx++;
continue;
/* Chain it to its object file */
pst->objfile = objfile;
- pst->objfile_chain = sym_objfile->psymtabs;
- sym_objfile->psymtabs = pst;
+ pst->objfile_chain = objfile->psymtabs;
+ objfile->psymtabs = pst;
pst->next = partial_symtab_list;
partial_symtab_list = pst;
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "frame.h"
-/* Print 32000 instructions for GDB, the GNU debugger.
- Copyright (C) 1986,1988 Free Software Foundation, Inc.
+/* Print National Semiconductor 32000 instructions for GDB, the GNU debugger.
+ Copyright 1986, 1988, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "ns32k-opcode.h"
#include "gdbcore.h"
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "frame.h"
#include "expression.h"
/* Print values for GNU debugger GDB.
- Copyright (C) 1986-1991 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <stdio.h>
#include <string.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "symtab.h"
#include "value.h"
resides in memory.\n",
"\n\
EXP may be preceded with /FMT, where FMT is a format letter\n\
-but no count or size letter (see \"x\" command)."));
+but no count or size letter (see \"x\" command).", NULL));
add_com_alias ("p", "print", class_vars, 1);
add_com ("inspect", class_vars, inspect_command,
#include "defs.h"
-#include "param.h"
#ifdef USE_PROC_FS /* Entire file goes away if not using /proc */
/****************************************************************/
/*
-From pacbell!ames!ll-xn!mit-eddie!uw-beaver!ssc-vax!uvicctr!tholm Wed May 4 23:40:52 1988
Path: hoptoad!pacbell!ames!ll-xn!mit-eddie!uw-beaver!ssc-vax!uvicctr!tholm
From: tholm@uvicctr.UUCP (Terrence W. Holm)
Newsgroups: comp.os.minix
Subject: putenv(3)
Message-ID: <395@uvicctr.UUCP>
Date: 5 May 88 06:40:52 GMT
-Reply-To: tholm@uvicctr.UUCP (Terrence W. Holm)
Organization: University of Victoria, Victoria B.C. Canada
-Lines: 296
-
EFTH Minix report #2 - May 1988 - putenv(3)
-
This is an implementation of putenv(3) that we
wrote for Minix. Please consider this a public
domain program.
#include <stdio.h>
-
#define PSIZE sizeof(char *)
-
extern char **environ;
-
char *index();
char *malloc();
-
/****************************************************************/
/* */
+/* int */
/* putenv( entry ) */
/* */
/* The "entry" should follow the form */
/****************************************************************/
+int
putenv( entry )
char *entry;
-
- {
+{
unsigned length;
unsigned size;
char **p;
environ = new_environ;
return(NULL);
- }
+}
-/* Disassembler for the Pyramid Technology 90x
- Copyright (C) 1988,1989 Free Software Foundation, Inc.
+/* Print Pyramid Technology 90x instructions for GDB, the GNU Debugger.
+ Copyright 1988, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB, the GNU disassembler.
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "pyr-opcode.h"
#include "gdbcore.h"
Pyramids. (The Pyramid-dependent handling of register values for
windowed registers is known to be buggy.)
- When debugging, these functions supplant the normal definitions of some
- of the macros in m-pyramid.h The quantity of information produced
+ When debugging, these functions can supplant the normal definitions of some
+ of the macros in tm-pyramid.h The quantity of information produced
when these functions are used makes the gdb unusable as a
debugger for user programs. */
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#include "param.h"
#include "defs.h"
/*** Prettier register printing. ***/
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include <stdio.h>
#include <string.h>
#include "defs.h"
-#include "tm.h"
-#include "param-no-tm.h"
#include "inferior.h"
#include "wait.h"
#include "value.h"
#include <stdio.h>
#include <string.h>
+#define TM_FILE_OVERRIDE
#include "defs.h"
#include "tm-29k.h"
-#include "param-no-tm.h"
#include "inferior.h"
#include "wait.h"
#include "value.h"
#include <setjmp.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "target.h"
#include <setjmp.h>
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "value.h"
#include "inferior.h"
/* Memory-access and commands for remote VxWorks processes, for GDB.
- Copyright (C) 1990 Free Software Foundation, Inc.
+ Copyright 1990, 1991 Free Software Foundation, Inc.
Contributed by Wind River Systems and Cygnus Support.
This file is part of GDB.
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+#define TM_FILE_OVERRIDE
#include "defs.h"
#include "tm-vxworks68.h"
-#include "param-no-tm.h"
#include "frame.h"
#include "inferior.h"
#include "wait.h"
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "wait.h"
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "symtab.h"
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "symtab.h"
-/* Convert between signal names and numbers.
- Copyright (C) 1990 Free Software Foundation, Inc.
+/* Convert between signal names and numbers, for GDB.
+ Copyright 1990, 1991 Free Software Foundation, Inc.
This file is part of GDB.
/* GDB-specific, FIXME. (This is for the SYS_SIGLIST_MISSING define). */
#include "defs.h"
-#include "param.h"
#ifdef __STDC__
#define CONST const
-/* Disassembler for the sparc.
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Print SPARC instructions for GDB, the GNU Debugger.
+ Copyright 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB, the GNU disassembler.
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "sparc-opcode.h"
#include "gdbcore.h"
-/* Machine-dependent code which would otherwise be in inflow.c and core.c,
- for GDB, the GNU debugger, for SPARC host systems.
-
- Copyright (C) 1986, 1987, 1989, 1990 Free Software Foundation, Inc.
+/* Host-dependent code for SPARC host systems, for GDB, the GNU debugger.
+ Copyright 1986, 1987, 1989, 1990, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <stdio.h>
#include "defs.h"
-#include "tm-sparc.h"
-#include "param-no-tm.h"
#include "inferior.h"
#include "target.h"
#endif /* SIGTSTP and SIGIO defined (must be 4.2) */
#include "defs.h"
-#include "param.h"
#include "signals.h"
#include "symtab.h"
#include "frame.h"
-/* Sun-3 Machine-dependent code which would otherwise be in inflow.c and core.c,
- for GDB, the GNU debugger.
- Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+/* Host-dependent code for Sun-3 for GDB, the GNU debugger.
+ Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "inferior.h"
+#include "gdbcore.h"
#include <sys/ptrace.h>
#define KERNEL /* To get floating point reg definitions */
#include <machine/reg.h>
-#include "gdbcore.h"
-
extern int errno;
#if defined (GDB_TARGET_IS_SUN3)
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "signame.h"
#include <stdio.h>
#include "defs.h"
#include "symtab.h"
-#include "param.h"
#include "gdbcore.h"
#include "frame.h"
#include "target.h"
extern CORE_ADDR startup_file_end; /* From blockframe.c */
/* Functions this file defines */
-static bfd *symfile_open();
-static struct sym_fns *symfile_init();
-static void clear_symtab_users_once();
+static struct objfile *symfile_open ();
+static struct sym_fns *symfile_init ();
+static void clear_symtab_users_once ();
+
+static void free_all_psymtabs ();
+static void free_all_symtabs ();
/* List of all available sym_fns. */
struct obstack *psymbol_obstack = &obstack2;
-/* File name symbols were loaded from. */
-
-char *symfile = 0;
+/* The object file that the main symbol table was loaded from (e.g. the
+ argument to the "symbol-file" or "file" command). */
-/* The modification date of the file when they were loaded. */
-
-long /* really time_t */ symfile_mtime = 0;
+struct objfile *symfile_objfile = 0;
/* Structures with which to manage partial symbol allocation. */
-#include "param.h"
struct psymbol_allocation_list global_psymbols = {0}, static_psymbols = {0};
/* Flag for whether user will be reloading symbols multiple times.
}
}
+/* After adding things to the vector, sort or re-sort it into address order. */
+void
+sort_misc_function_vector ()
+{
+ qsort (misc_function_vector, misc_function_count,
+ sizeof (struct misc_function),
+ compare_misc_functions);
+}
+
+/* Compact duplicate entries out of the misc function vector by walking
+ through the vector and compacting out entries with duplicate addresses
+ and matching names.
+
+ When files contain multiple sources of symbol information, it is
+ possible for the misc function vector to contain many duplicate entries.
+ As an example, SVR4 systems use ELF formatted object files, which
+ usually contain at least two different types of symbol tables (a
+ standard ELF one and a smaller dynamic linking table), as well as
+ DWARF debugging information for files compiled with -g.
+
+ Without compacting, the misc function vector for gdb itself contains
+ over a 1000 duplicates, about a third of the total table size. Aside
+ from the potential trap of not noticing that two successive entries
+ identify the same location, this duplication impacts the time required
+ to linearly scan the table, which is done in a number of places. So
+ just do one linear scan here and toss out the duplicates.
+
+ Note that the strings themselves are allocated on the symbol_obstack,
+ so we can't easily reclaim their memory. They will get automatically
+ freed when the symbol table is freed.
+
+ Also note we only go up to the next to last entry within the loop
+ and then copy the last entry explicitly after the loop terminates.
+
+ Since the different sources of information for each symbol may
+ have different levels of "completeness", we may have duplicates
+ that have one entry with type "mf_unknown" and the other with a
+ known type. So if the one we are leaving alone has type mf_unknown,
+ overwrite it's type with the type from the one we are compacting out.
+*/
+
+
+static void
+compact_misc_function_vector ()
+{
+ struct misc_function *copyfrom;
+ struct misc_function *copyto;
+
+ copyfrom = copyto = misc_function_vector;
+ while (copyfrom < misc_function_vector + misc_function_count - 1)
+ {
+ if (copyfrom -> address == (copyfrom + 1) -> address
+ && (strcmp (copyfrom -> name, (copyfrom + 1) -> name) == 0))
+ {
+ if ((copyfrom + 1) -> type == mf_unknown)
+ {
+ (copyfrom + 1) -> type = copyfrom -> type;
+ }
+ copyfrom++;
+ }
+ else
+ {
+ *copyto++ = *copyfrom++;
+ }
+ }
+ *copyto++ = *copyfrom++;
+ misc_function_count = copyto - misc_function_vector;
+ misc_function_vector = (struct misc_function *)
+ xrealloc (misc_function_vector,
+ misc_function_count * sizeof (struct misc_function));
+
+}
+
/* INCLINK nonzero means bunches are from an incrementally-linked file.
Add them to the existing bunches.
Otherwise INCLINK is zero, and we start from scratch. */
/* Sort the misc functions by address. */
- qsort (misc_function_vector, misc_function_count,
- sizeof (struct misc_function),
- compare_misc_functions);
+ sort_misc_function_vector ();
+
+ /* Compact out any duplicates. */
+
+ compact_misc_function_vector ();
}
where the text segment was loaded. */
void
-syms_from_bfd (sym_bfd, addr, mainline)
- bfd *sym_bfd;
+syms_from_objfile (objfile, addr, mainline)
+ struct objfile *objfile;
CORE_ADDR addr;
int mainline;
{
asection *text_sect;
struct sym_fns *sf;
- char *realname;
+ bfd *sym_bfd = objfile->obfd;
/* There is a distinction between having no symbol table
(we refuse to read the file, leaving the old set of symbols around)
startup_file_end = 0;
}
- sf = symfile_init (sym_bfd);
- realname = bfd_get_filename (sym_bfd);
- realname = savestring (realname, strlen (realname));
- /* FIXME, this probably creates a storage leak... */
+ sf = symfile_init (objfile);
if (mainline)
{
/* Since no error yet, throw away the old symbol table. */
- if (symfile)
- free (symfile);
- symfile = 0;
- free_all_symtabs ();
- free_all_psymtabs ();
+ if (symfile_objfile)
+ free_objfile (symfile_objfile);
+ symfile_objfile = 0;
(*sf->sym_new_init) ();
if (mainline)
{
/* OK, make it the "real" symbol file. */
- symfile = realname;
+ symfile_objfile = objfile;
symfile_fns = sf;
}
CORE_ADDR addr;
int mainline;
{
+ struct objfile *objfile;
bfd *sym_bfd;
- sym_bfd = symfile_open (name);
-
- if (mainline)
- symfile_mtime = bfd_get_mtime (sym_bfd);
+ objfile = symfile_open (name);
+ sym_bfd = objfile->obfd;
/* There is a distinction between having no symbol table
(we refuse to read the file, leaving the old set of symbols around)
and having no debugging symbols in your symbol table (we read
- the file and end up with a mostly empty symbol table). */
+ the file and end up with a mostly empty symbol table, but with lots
+ of stuff in the misc function vector). */
if (!(bfd_get_file_flags (sym_bfd) & HAS_SYMS))
{
fflush (stdout);
}
- syms_from_bfd (sym_bfd, addr, mainline);
+ syms_from_objfile (objfile, addr, mainline);
if (from_tty)
{
if (name == 0)
{
- if ((symtab_list || partial_symtab_list)
- && from_tty
- && !query ("Discard symbol table from `%s'? ", symfile))
- error ("Not confirmed.");
- if (symfile)
- free (symfile);
- symfile = 0;
- free_all_symtabs ();
- free_all_psymtabs ();
+ if (symfile_objfile) {
+ if ((symtab_list || partial_symtab_list)
+ && from_tty
+ && !query ("Discard symbol table from `%s'? ",
+ symfile_objfile->name))
+ error ("Not confirmed.");
+ free_objfile (symfile_objfile);
+ }
+ symfile_objfile = 0;
/* FIXME, this does not account for the main file and subsequent
files (shared libs, dynloads, etc) having different formats.
It only calls the cleanup routine for the main file's format. */
}
/* Open NAME and hand it off to BFD for preliminary analysis. Result
- is a BFD *, which includes a new copy of NAME dynamically allocated
- (which will be freed by the cleanup chain). In case of trouble,
- error() is called. */
+ is newly malloc'd struct objfile *, which includes a newly malloc'd`
+ copy of NAME (tilde-expanded and made absolute).
+ In case of trouble, error() is called. */
-static bfd *
+static struct objfile *
symfile_open (name)
char *name;
{
bfd *sym_bfd;
int desc;
char *absolute_name;
+ struct objfile *objfile;
- name = tilde_expand (name);
- make_cleanup (free, name);
+ name = tilde_expand (name); /* Returns 1st new malloc'd copy */
+ /* Look down path for it, allocate 2nd new malloc'd copy. */
desc = openp (getenv ("PATH"), 1, name, O_RDONLY, 0, &absolute_name);
- if (desc < 0)
+ if (desc < 0) {
+ make_cleanup (free, name);
perror_with_name (name);
- else
- {
- make_cleanup (free, absolute_name);
- name = absolute_name;
- }
+ }
+ free (name); /* Free 1st new malloc'd copy */
+ name = absolute_name; /* Keep 2nd malloc'd copy in objfile and bfd */
sym_bfd = bfd_fdopenr (name, NULL, desc);
if (!sym_bfd)
{
close (desc);
+ make_cleanup (free, name);
error ("Could not open `%s' to read symbols: %s",
name, bfd_errmsg (bfd_error));
}
- make_cleanup (bfd_close, sym_bfd);
- if (!bfd_check_format (sym_bfd, bfd_object))
+ if (!bfd_check_format (sym_bfd, bfd_object)) {
+ bfd_close (sym_bfd); /* This also closes desc */
+ make_cleanup (free, name);
error ("\"%s\": can't read symbols: %s.",
name, bfd_errmsg (bfd_error));
+ }
- return sym_bfd;
+ objfile = allocate_objfile (sym_bfd, name);
+ return objfile;
}
+
+/* Allocate a new objfile struct, fill it in as best we can, and return it.
+ FIXME-soon! Eventually, the objfile will contain the obstack in which
+ the symtabs and psymtabs are contained, so they can all be blown away
+ cheaply and easily. */
+
+struct objfile *
+allocate_objfile (abfd, filename)
+ bfd *abfd;
+ char *filename;
+{
+ struct objfile *objfile;
+
+ objfile = (struct objfile *) xmalloc (sizeof (struct objfile));
+ bzero (objfile, sizeof (*objfile));
+
+ objfile->obfd = abfd;
+ objfile->name = filename;
+
+ objfile->symtabs = 0; /* Don't have any yet */
+ objfile->psymtabs = 0; /* Don't have any yet */
+
+ objfile->mtime = bfd_get_mtime (abfd);
+
+ /* Chain it to the list. */
+ objfile->next = object_files;
+ object_files = objfile;
+
+ return objfile;
+}
+
+
+/* Destroy an objfile and all the symtabs and psymtabs under it. */
+
+void
+free_objfile (objfile)
+ struct objfile *objfile;
+{
+ struct objfile *ofp;
+
+ if (objfile->name)
+ free (objfile->name);
+ if (objfile->obfd)
+ bfd_close (objfile->obfd);
+
+ /* Remove it from the chain of all objfiles. */
+ if (object_files == objfile)
+ object_files = objfile->next;
+ else for (ofp = object_files; ofp; ofp = ofp->next) {
+ if (ofp->next == objfile)
+ ofp->next = objfile->next;
+ }
+
+ /* FIXME! This should only free those associated with the objfile
+ being passed to us. THIS IS A KLUDGE TO BOOTSTRAP US. */
+ free_all_psymtabs ();
+ free_all_symtabs ();
+
+ free (objfile);
+}
+
+
/* Link a new symtab_fns into the global symtab_fns list.
Called by various _initialize routines. */
that contains cached information about the symbol file. */
static struct sym_fns *
-symfile_init (sym_bfd)
- bfd *sym_bfd;
+symfile_init (objfile)
+ struct objfile *objfile;
{
struct sym_fns *sf, *sf2;
+ bfd *sym_bfd = objfile->obfd;
for (sf = symtab_fns; sf != NULL; sf = sf->next)
{
sf2 = (struct sym_fns *)xmalloc (sizeof (*sf2));
/* FIXME, who frees this? */
*sf2 = *sf;
+ sf2->objfile = objfile;
sf2->sym_bfd = sym_bfd;
sf2->sym_private = 0; /* Not alloc'd yet */
(*sf2->sym_init) (sf2);
symbol_file_add (name, 0, text_addr, 0);
}
\f
-/* Re-read symbols if the symbol-file has changed. */
+/* Re-read symbols if a symbol-file has changed. */
void
reread_symbols ()
{
- struct stat symstat;
+ struct objfile *objfile;
+ long new_modtime;
+ int reread_one = 0;
/* With the addition of shared libraries, this should be modified,
the load time should be saved in the partial symbol tables, since
and see if the symbol table that it originates from has been changed
*/
- if (stat (symfile, &symstat) < 0)
- /* Can't read symbol-file. Assume it is up to date. */
- return;
-
- if (symstat.st_mtime > symfile_mtime)
- {
- printf_filtered ("Symbol file has changed; re-reading symbols.\n");
- symbol_file_command (symfile, 0);
- breakpoint_re_set ();
+ for (objfile = object_files; objfile; objfile = objfile->next) {
+ if (objfile->obfd) {
+ objfile->obfd->mtime_set = false; /* Force it to reread. */
+ new_modtime = bfd_get_mtime (objfile->obfd);
+ if (new_modtime != objfile->mtime) {
+ printf_filtered ("`%s' has changed; re-reading symbols.\n",
+ objfile->name);
+ /* FIXME, this should use a different command...that would only
+ affect this objfile's symbols. */
+ symbol_file_command (objfile->name, 0);
+ objfile->mtime = new_modtime;
+ reread_one = 1;
+ }
}
+ }
+
+ if (reread_one)
+ breakpoint_re_set ();
}
/* This function is really horrible, but to avoid it, there would need
static unsigned stop_whining = 0;
/* Print a complaint about the input symbols, and link the complaint block
- into a chain for later handling. Result is 1 if the complaint was
- printed, 0 if it was suppressed. */
+ into a chain for later handling. */
-int
+void
complain (complaint, val)
struct complaint *complaint;
char *val;
complaint_root->next = complaint;
}
if (complaint->counter > stop_whining)
- return 0;
+ return;
wrap_here ("");
if (!info_verbose) {
puts_filtered ("During symbol reading...");
wrap_here("");
if (!info_verbose)
puts_filtered ("\n");
- return 1;
}
/* Clear out all complaint counters that have ever been incremented. */
p->counter = 0;
}
\f
+enum language
+deduce_language_from_filename (filename)
+ char *filename;
+{
+ char *c = rindex (filename, '.');
+
+ if (!c) ; /* Get default. */
+ else if(!strcmp(c,".mod"))
+ return language_m2;
+ else if(!strcmp(c,".c"))
+ return language_c;
+ else if(!strcmp(c,".cc") || !strcmp(c,".C"))
+ return language_cplus;
+
+ return language_unknown; /* default */
+}
+\f
/* allocate_symtab:
Allocate and partly initialize a new symbol table. Return a pointer
*/
struct symtab *
-allocate_symtab(name)
+allocate_symtab(name, objfile)
char *name;
+ struct objfile *objfile;
{
register struct symtab *symtab;
- char *c;
symtab = (struct symtab *) xmalloc (sizeof (struct symtab));
bzero (symtab, sizeof (*symtab));
symtab->nlines = 0;
symtab->line_charpos = 0;
symtab->version = 0;
- symtab->language = language_unknown; /* default */
+ symtab->language = deduce_language_from_filename (name);
- c = rindex (name, '.');
-
- if (!c) {
- ; /* Don't know language of file. */
- } else if(!strcmp(c,".mod")) {
- symtab->language = language_m2;
- } else if(!strcmp(c,".c") || !strcmp(c,".cc")) {
- symtab->language = language_c;
- }
+ /* Hook it to the objfile it comes from */
+ symtab->objfile = objfile;
+ symtab->objfile_chain = objfile->symtabs;
+ objfile->symtabs = symtab;
+
+#ifdef INIT_EXTRA_SYMTAB_INFO
+ INIT_EXTRA_SYMTAB_INFO(symtab);
+#endif
return symtab;
}
return blewit;
}
\f
+/*
+ * Free all partial_symtab storage.
+ */
+static void
+free_all_psymtabs()
+{
+ obstack_free (psymbol_obstack, 0);
+ obstack_init (psymbol_obstack);
+ partial_symtab_list = (struct partial_symtab *) 0;
+}
+
+/* Free all the symtabs that are currently installed,
+ and all storage associated with them.
+ Leaves us in a consistent state with no symtabs installed. */
+
+static void
+free_all_symtabs ()
+{
+ register struct symtab *s, *snext;
+
+ /* All values will be invalid because their types will be! */
+
+ clear_value_history ();
+ clear_displays ();
+ clear_internalvars ();
+#if defined (CLEAR_SOLIB)
+ CLEAR_SOLIB ();
+#endif
+ set_default_breakpoint (0, 0, 0, 0);
+
+ current_source_symtab = 0;
+
+ for (s = symtab_list; s; s = snext)
+ {
+ snext = s->next;
+ free_symtab (s);
+ }
+ symtab_list = 0;
+ obstack_free (symbol_obstack, 0);
+ obstack_init (symbol_obstack);
+
+ if (misc_function_vector)
+ free (misc_function_vector);
+ misc_function_count = 0;
+ misc_function_vector = 0;
+ clear_pc_function_cache();
+}
+\f
void
_initialize_symfile ()
{
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "symtab.h"
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "symtab.h"
#include <stdio.h>
#include "defs.h"
#include "symtab.h"
-#include "param.h"
#include "gdbcore.h"
#include "frame.h"
#include "target.h"
if(!strncmp(name,"enum ",5))
return name + 5;
else return name;
+ default:
+ return name;
}
-
- return TYPE_NAME (type);
}
/* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
+ strlen (TYPE_FN_FIELD_PHYSNAME (f, j))
+ 1);
+ /* Only needed for GNU-mangled names. ANSI-mangled names
+ work with the normal mechanisms. */
if (OPNAME_PREFIX_P (field_name))
{
- char *opname = cplus_mangle_opname (field_name + 3);
+ char *opname = cplus_mangle_opname (field_name + 3, 0);
if (opname == NULL)
error ("No mangling for \"%s\"", field_name);
mangled_name_len += strlen (opname);
}
/* Given a type TYPE, return a type of pointers to that type.
- May need to construct such a type if this is the first use.
-
- C++: use TYPE_MAIN_VARIANT and TYPE_CHAIN to keep pointer
- to member types under control. */
+ May need to construct such a type if this is the first use. */
struct type *
lookup_pointer_type (type)
struct type *type;
{
register struct type *ptype = TYPE_POINTER_TYPE (type);
- if (ptype) return TYPE_MAIN_VARIANT (ptype);
+ if (ptype) return ptype;
/* This is the first time anyone wanted a pointer to a TYPE. */
if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
sizeof (struct type));
bzero (ptype, sizeof (struct type));
- TYPE_MAIN_VARIANT (ptype) = ptype;
TYPE_TARGET_TYPE (ptype) = type;
TYPE_POINTER_TYPE (type) = ptype;
/* New type is permanent if type pointed to is permanent. */
struct type *type;
{
register struct type *rtype = TYPE_REFERENCE_TYPE (type);
- if (rtype) return TYPE_MAIN_VARIANT (rtype);
+ if (rtype) return rtype;
/* This is the first time anyone wanted a pointer to a TYPE. */
if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
sizeof (struct type));
bzero (rtype, sizeof (struct type));
- TYPE_MAIN_VARIANT (rtype) = rtype;
TYPE_TARGET_TYPE (rtype) = type;
TYPE_REFERENCE_TYPE (type) = rtype;
/* New type is permanent if type pointed to is permanent. */
/* In practice, this is never used. */
TYPE_LENGTH (btype) = 1;
TYPE_CODE (btype) = TYPE_CODE_STRUCT;
+ TYPE_CPLUS_SPECIFIC (btype)
+ = (struct cplus_struct_type *) obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type)));
+ bzero (TYPE_CPLUS_SPECIFIC (btype), sizeof (struct cplus_struct_type));
return btype;
}
type = (struct type *) xmalloc (sizeof (struct type));
bzero (type, sizeof *type);
- TYPE_MAIN_VARIANT (type) = type;
TYPE_CODE (type) = code;
TYPE_LENGTH (type) = length;
TYPE_FLAGS (type) = uns ? TYPE_FLAG_UNSIGNED : 0;
TYPE_NAME (type) = name;
/* C++ fancies. */
- TYPE_NFN_FIELDS (type) = 0;
- TYPE_N_BASECLASSES (type) = 0;
+ if (code == TYPE_CODE_STRUCT)
+ {
+ TYPE_CPLUS_SPECIFIC (type)
+ = (struct cplus_struct_type *) xmalloc (sizeof (struct cplus_struct_type));
+ TYPE_MAIN_VARIANT (type) = type;
+ TYPE_NFN_FIELDS (type) = 0;
+ TYPE_N_BASECLASSES (type) = 0;
+ }
return type;
}
#if !defined (SYMTAB_H)
#define SYMTAB_H 1
-#include <obstack.h>
+#include "obstack.h"
/* An obstack to hold objects that should be freed
when we load a new symbol table.
/* Some definitions and declarations to go with use of obstacks. */
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
-#ifdef __STDC__
-extern void *xmalloc ();
-#else
-extern char *xmalloc ();
-#endif
-extern void free ();
/* Some macros for char-based bitfields. */
#define B_SET(a,x) (a[x>>3] |= (1 << (x&7)))
-/*
- * Ported by the State University of New York at Buffalo by the Distributed
- * Computer Systems Lab, Department of Computer Science, 1991.
- */
+/* Print instructions for Tahoe target machines, for GDB.
+ Copyright 1986, 1989, 1991 Free Software Foundation, Inc.
+ Contributed by the State University of New York at Buffalo, by the
+ Distributed Computer Systems Lab, Department of Computer Science, 1991.
-#include <stdio.h>
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+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. */
+
+#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "tahoe-opcode.h"
case 0:
case 1:
case 2:
- case 3: /* Liter>al(short immediate byte) mode */
+ case 3: /* Literal (short immediate byte) mode */
if (d[1] == 'd' || d[1] == 'f' || d[1] == 'g' || d[1] == 'h')
{
*(int *)&floatlitbuf = 0x4000 + ((p[-1] & 0x3f) << 4);
#define TARGET_BYTE_ORDER BIG_ENDIAN
-/* I don't know if this will work for cross-debugging, even if you do get
- the right files. */
-/* Include certain files for dbxread.c */
-#include <convex/filehdr.h>
-#include <convex/opthdr.h>
-#include <convex/scnhdr.h>
-#include <nlist.h>
-
/* Define this if the C compiler puts an underscore at the front
of external names before giving them to the linker. */
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#include HAVE_68881
+#define HAVE_68881
/* Define BPT_VECTOR if it is different than the default.
This is the vector number used by traps to indicate a breakpoint. */
#define TARGET_BYTE_ORDER LITTLE_ENDIAN
-/* I don't know if this will work for cross-debugging, even if you do get
- a copy of the right include file. */
-#include <machine/reg.h>
-
/* Define this if the C compiler puts an underscore at the front
of external names before giving them to the linker. */
#define SAVED_PC_AFTER_CALL(frame) PC_ADJUST (read_register (RP_REGNUM))
-/* Address of the end of stack space. We get this from the system
- include files. */
-#include <sys/types.h>
-#include <machine/vmparam.h>
-#define STACK_END_ADDR USRSTACK
+/* Stack grows downward. */
#define INNER_THAN <
Returns positive address > 1 if pc is between enter/exit,
1 if pc before enter or after exit, 0 otherwise. */
-#ifndef CORE_ADDR
-#include "defs.h" /* Make sure CORE_ADDR is defined. */
-#endif
-
extern CORE_ADDR ns32k_get_enter_addr ();
/* Return number of args passed to a frame.
#define DEBUG
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "symtab.h"
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include <string.h>
#include "defs.h"
-#include "param.h"
#include "signals.h"
#include "gdbcmd.h"
#include "terminal.h"
#define ISATTY(FP) (isatty (fileno (FP)))
#endif
-#ifdef MISSING_VPRINTF
-#ifdef __GNU_LIBRARY
-#undef MISSING_VPRINTF
-#else /* !__GNU_LIBRARY */
-
-#ifndef vfprintf
-/* Can't #define it since language.c needs it (though FIXME it shouldn't) */
-void
-vfprintf (file, format, ap)
- FILE *file;
- char *format;
- va_list ap;
-{
- _doprnt (format, ap, file);
-}
-#endif /* vfprintf */
-
-#ifndef vprintf
-/* Can't #define it since printcmd.c needs it */
-void
-vprintf (format, ap)
- char *format;
- va_list ap;
-{
- vfprintf (stdout, format, ap);
-}
-#endif /* vprintf */
-
-#endif /* GNU_LIBRARY */
-#endif /* MISSING_VPRINTF */
-
void error ();
void fatal ();
return savestring (ptr, strlen (ptr));
}
-char *
-concat (s1, s2, s3)
- char *s1, *s2, *s3;
-{
- register int len = strlen (s1) + strlen (s2) + strlen (s3) + 1;
- register char *val = (char *) xmalloc (len);
- strcpy (val, s1);
- strcat (val, s2);
- strcat (val, s3);
- return val;
-}
-
void
print_spaces (n, file)
register int n;
(since prompt_for_continue may do so) so this routine should not be
called when cleanups are not in place. */
-#if !defined(MISSING_VPRINTF) || defined (vsprintf)
/* VARARGS */
void
vfprintf_filtered (stream, format, args)
va_list args;
-#else
-void fprintf_filtered (stream, format, arg1, arg2, arg3, arg4, arg5, arg6)
-#endif
FILE *stream;
char *format;
{
/* This won't blow up if the restrictions described above are
followed. */
-#if !defined(MISSING_VPRINTF) || defined (vsprintf)
(void) vsprintf (linebuffer, format, args);
-#else
- (void) sprintf (linebuffer, format, arg1, arg2, arg3, arg4, arg5, arg6);
-#endif
fputs_filtered (linebuffer, stream);
}
-#if !defined(MISSING_VPRINTF) || defined (vsprintf)
/* VARARGS */
void
fprintf_filtered (va_alist)
(void) vfprintf_filtered (stdout, format, args);
va_end (args);
}
-#else
-void
-printf_filtered (format, arg1, arg2, arg3, arg4, arg5, arg6)
- char *format;
- int arg1, arg2, arg3, arg4, arg5, arg6;
-{
- fprintf_filtered (stdout, format, arg1, arg2, arg3, arg4, arg5, arg6);
-}
-#endif
/* Easy */
/* Perform non-arithmetic operations on values, for GDB.
- Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "value.h"
#include "frame.h"
return (value)value_virtual_fn_field (arg1, f, j, type);
if (TYPE_FN_FIELD_STATIC_P (f, j) && static_memfuncp)
*static_memfuncp = 1;
- return (value)value_fn_field (arg1, i, j);
+ return (value)value_fn_field (f, j);
}
j--;
}
if (!args[1])
{
/* destructors are a special case. */
- return (value)value_fn_field (*argp, 0,
+ return (value)value_fn_field (TYPE_FN_FIELDLIST1 (t, 0),
TYPE_FN_FIELDLIST_LENGTH (t, 0));
}
else
if (name[0] == '~')
{
char *dname = type_name_no_tag (type);
-
- if (! TYPE_HAS_DESTRUCTOR (type))
- error ("type `%s' does not have destructor defined", dname);
if (strcmp (dname, name+1))
error ("name of destructor must equal name of class");
else
-/* Print values for GNU debugger gdb.
- Copyright (C) 1986, 1988, 1989 Free Software Foundation, Inc.
+/* Print values for GDB, the GNU debugger.
+ Copyright 1986, 1988, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <stdio.h>
#include <string.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "value.h"
#include "gdbcore.h"
{
#ifdef _LANG_c
case language_c:
+ case language_cplus:
fprintf_filtered(stream, "typedef ");
type_print(type,"",stream,0);
if(TYPE_NAME ((SYMBOL_TYPE (new))) == 0
case TYPE_CODE_FLT:
case TYPE_CODE_VOID:
case TYPE_CODE_ERROR:
+ case TYPE_CODE_CHAR:
+ case TYPE_CODE_BOOL:
/* These types need no prefix. They are listed here so that
gcc -Wall will reveal any types that haven't been handled. */
break;
case TYPE_CODE_FLT:
case TYPE_CODE_VOID:
case TYPE_CODE_ERROR:
+ case TYPE_CODE_CHAR:
+ case TYPE_CODE_BOOL:
/* These types do not need a suffix. They are listed so that
gcc -Wall will report types that may not have been considered. */
break;
-/* Low level packing and unpacking of values for GDB.
- Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+/* Low level packing and unpacking of values for GDB, the GNU Debugger.
+ Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <stdio.h>
#include <string.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "value.h"
#include "gdbcore.h"
-/* Print vax instructions for GDB, the GNU debugger.
- Copyright (C) 1986, 1989 Free Software Foundation, Inc.
+/* Print VAX instructions for GDB, the GNU debugger.
+ Copyright 1986, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "vax-opcode.h"
#include <sys/ldr.h>
#include "defs.h"
-#include "param.h"
#include "frame.h"
#include "inferior.h"
#include "target.h"
#include "defs.h"
#include "bfd.h"
-#include "param.h"
#include <stdio.h>
/* Definitions to make GDB run on Convex Unix (4bsd)
- Copyright (C) 1989 Free Software Foundation, Inc.
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
/* Hook to call after creating inferior process. */
#define CREATE_INFERIOR_HOOK create_inferior_hook
-
-\f
-/* Interface definitions for kernel debugger KDB. */
-
-/* (no kdb) */
/* Definitions to make GDB run on a merlin under utek 2.1
- Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+#include <machine/reg.h>
+
/* This machine doesn't have the siginterrupt call. */
#define NO_SIGINTERRUPT
/* Parameters for execution on a Sun 4, for GDB, the GNU debugger.
- Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@mcc.com)
+
This file is part of GDB.
This program is free software; you can redistribute it and/or modify