complain (&repeated_header_complaint, name, symnum);
repeated_header_complaint (name, symnum);
find_corresponding_bincl_psymtab PARAMS ((char *, int));static voidadd_bincl_to_list PARAMS ((struct partial_symtab *, char *, int));static voidinit_bincl_list PARAMS ((int, struct objfile *));static char *dbx_next_symbol_text PARAMS ((struct objfile *));static voidfill_symbuf PARAMS ((bfd *));static voiddbx_symfile_init PARAMS ((struct objfile *));static voiddbx_new_init PARAMS ((struct objfile *));static voiddbx_symfile_read PARAMS ((struct objfile *, struct section_offsets *, int));static voiddbx_symfile_finish PARAMS ((struct objfile *));static voidrecord_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *));static voidadd_new_header_file PARAMS ((char *, int));static voidadd_old_header_file PARAMS ((char *, int));static voidadd_this_object_header_file PARAMS ((int));/* Free up old header file tables */static voidfree_header_files (){  if (this_object_header_files)    {      free ((PTR)this_object_header_files);      this_object_header_files = NULL;    }  n_allocated_this_object_header_files = 0;}/* Allocate new header file tables */static voidinit_header_files (){  n_allocated_this_object_header_files = 10;  this_object_header_files = (int *) xmalloc (10 * sizeof (int));}/* Add header file number I for this object file   at the next successive FILENUM.  */static voidadd_this_object_header_file (i)     int i;{  if (n_this_object_header_files == n_allocated_this_object_header_files)    {      n_allocated_this_object_header_files *= 2;      this_object_header_files	= (int *) xrealloc ((char *) this_object_header_files,			    n_allocated_this_object_header_files * sizeof (int));    }  this_object_header_files[n_this_object_header_files++] = i;}/* Add to this file an "old" header file, one already seen in   a previous object file.  NAME is the header file's name.   INSTANCE is its instance code, to select among multiple   symbol tables for the same header file.  */static voidadd_old_header_file (name, instance)     char *name;     int instance;{  register struct header_file *p = HEADER_FILES (current_objfile);  register int i;  for (i = 0; i < N_HEADER_FILES (current_objfile); i++)    if (STREQ (p[i].name, name) && instance == p[i].instance)      {	add_this_object_header_file (i);	return;      }  complain (&repeated_header_complaint, name, symnum);}/* Add to this file a "new" header file: definitions for its types follow.   NAME is the header file's name.   Most often this happens only once for each distinct header file,   but not necessarily.  If it happens more than once, INSTANCE has   a different value each time, and references to the header file   use INSTANCE values to select among them.   dbx output contains "begin" and "end" markers for each new header file,   but at this level we just need to know which files there have been;   so we record the file when its "begin" is seen and ignore the "end".  */static voidadd_new_header_file (name, instance)     char *name;     int instance;{  register int i;  register struct header_file *hfile;  /* Make sure there is room for one more header file.  */  i = N_ALLOCATED_HEADER_FILES (current_objfile);  if (N_HEADER_FILES (current_objfile) == i)    {      if (i == 0)	{	  N_ALLOCATED_HEADER_FILES (current_objfile) = 10;	  HEADER_FILES (current_objfile) = (struct header_file *)	    xmalloc (10 * sizeof (struct header_file));	}      else	{	  i *= 2;	  N_ALLOCATED_HEADER_FILES (current_objfile) = i;	  HEADER_FILES (current_objfile) = (struct header_file *)	    xrealloc ((char *) HEADER_FILES (current_objfile),		      (i * sizeof (struct header_file)));	}    }  /* Create an entry for this header file.  */  i = N_HEADER_FILES (current_objfile)++;  hfile = HEADER_FILES (current_objfile) + i;  hfile->name = savestring (name, strlen(name));  hfile->instance = instance;  hfile->length = 10;  hfile->vector    = (struct type **) xmalloc (10 * sizeof (struct type *));  memset (hfile->vector, 0, 10 * sizeof (struct type *));  add_this_object_header_file (i);}#if 0static struct type **explicit_lookup_type (real_filenum, index)     int real_filenum, index;{  register struct header_file *f = &HEADER_FILES (current_objfile)[real_filenum];  if (index >= f->length)    {      f->length *= 2;      f->vector = (struct type **)	xrealloc (f->vector, f->length * sizeof (struct type *));      memset (&f->vector[f->length / 2],	     '\0', f->length * sizeof (struct type *) / 2);    }  return &f->vector[index];}#endifstatic voidrecord_minimal_symbol (name, address, type, objfile)     char *name;     CORE_ADDR address;     int type;     struct objfile *objfile;{  enum minimal_symbol_type ms_type;  int section;  switch (type)    {    case N_TEXT | N_EXT:      ms_type = mst_text;      section = SECT_OFF_TEXT;      break;    case N_DATA | N_EXT:      ms_type = mst_data;      section = SECT_OFF_DATA;      break;    case N_BSS | N_EXT:      ms_type = mst_bss;      section = SECT_OFF_BSS;      break;    case N_ABS | N_EXT:      ms_type = mst_abs;      section = -1;      break;#ifdef N_SETV    case N_SETV | N_EXT:      ms_type = mst_data;      section = SECT_OFF_DATA;      break;    case N_SETV:      /* I don't think this type actually exists; since a N_SETV is the result	 of going over many .o files, it doesn't make sense to have one	 file local.  */      ms_type = mst_file_data;      section = SECT_OFF_DATA;      break;#endif    case N_TEXT:    case N_NBTEXT:    case N_FN:    case N_FN_SEQ:      ms_type = mst_file_text;      section = SECT_OFF_TEXT;      break;    case N_DATA:      ms_type = mst_file_data;      /* Check for __DYNAMIC, which is used by Sun shared libraries. 	 Record it as global even if it's local, not global, so	 lookup_minimal_symbol can find it.  We don't check symbol_leading_char	 because for SunOS4 it always is '_'.  */      if (name[8] == 'C' && STREQ ("__DYNAMIC", name))	ms_type = mst_data;      /* Same with virtual function tables, both global and static.  */      {	char *tempstring = name;	if (tempstring[0] == bfd_get_symbol_leading_char (objfile->obfd))	  ++tempstring;	if (VTBL_PREFIX_P ((tempstring)))	  ms_type = mst_data;      }      section = SECT_OFF_DATA;      break;    case N_BSS:      ms_type = mst_file_bss;      section = SECT_OFF_BSS;      break;    default:      ms_type = mst_unknown;      section = -1;      break;  }  if ((ms_type == mst_file_text || ms_type == mst_text)      && address < lowest_text_address)    lowest_text_address = address;  prim_record_minimal_symbol_and_info    (name, address, ms_type, NULL, section, objfile);}/* Scan and build partial symbols for a symbol file.   We have been initialized by a call to dbx_symfile_init, which    put all the relevant info into a "struct dbx_symfile_info",   hung off the objfile structure.   SECTION_OFFSETS contains offsets relative to which the symbols in the   various sections are (depending where the sections were actually loaded).   MAINLINE is true if we are reading the main symbol   table (as opposed to a shared lib or dynamically loaded file).  */static voiddbx_symfile_read (objfile, section_offsets, mainline)     struct objfile *objfile;     struct section_offsets *section_offsets;     int mainline;	/* FIXME comments above */{  bfd *sym_bfd;  int val;  struct cleanup *back_to;  val = strlen (objfile->name);  sym_bfd = objfile->obfd;  /* .o and .nlm files are relocatables with text, data and bss segs based at     0.  This flag disables special (Solaris stabs-in-elf only) fixups for     symbols with a value of 0.  */  symfile_relocatable = bfd_get_file_flags (sym_bfd) & HAS_RELOC;  /* This is true for Solaris (and all other systems which put stabs     in sections, hopefully, since it would be silly to do things     differently from Solaris), and false for SunOS4 and other a.out     file formats.  */  block_address_function_relative =    ((0 == strncmp (bfd_get_target (sym_bfd), "elf", 3))     || (0 == strncmp (bfd_get_target (sym_bfd), "som", 3))     || (0 == strncmp (bfd_get_target (sym_bfd), "coff", 4))     || (0 == strncmp (bfd_get_target (sym_bfd), "pe", 2))     || (0 == strncmp (bfd_get_target (sym_bfd), "nlm", 3)));  val = bfd_seek (sym_bfd, DBX_SYMTAB_OFFSET (objfile), SEEK_SET);  if (val < 0)    perror_with_name (objfile->name);  /* If we are reinitializing, or if we have never loaded syms yet, init */  if (mainline      || objfile->global_psymbols.size == 0      || objfile->static_psymbols.size == 0)    init_psymbol_list (objfile, DBX_SYMCOUNT (objfile));  symbol_size = DBX_SYMBOL_SIZE (objfile);  symbol_table_offset = DBX_SYMTAB_OFFSET (objfile);  free_pending_blocks ();  back_to = make_cleanup (really_free_pendings, 0);  init_minimal_symbol_collection ();  make_cleanup (discard_minimal_symbols, 0);  /* Now that the symbol table data of the executable file are all in core,     process them and define symbols accordingly.  */  read_dbx_symtab (section_offsets, objfile,		   DBX_TEXT_ADDR (objfile),		   DBX_TEXT_SIZE (objfile));  /* Add the dynamic symbols.  */  read_dbx_dynamic_symtab (section_offsets, objfile);  /* Install any minimal symbols that have been collected as the current     minimal symbols for this objfile. */  install_minimal_symbols (objfile);  do_cleanups (back_to);}/* Initialize anything that needs initializing when a completely new   symbol file is specified (not just adding some symbols from another   file, e.g. a shared library).  */static voiddbx_new_init (ignore)     struct objfile *ignore;{  stabsread_new_init ();  buildsym_new_init ();  init_header_files ();}/* dbx_symfile_init ()   is the dbx-specific initialization routine for reading symbols.   It is passed a struct objfile which contains, among other things,   the BFD for the file whose symbols are being read, and a slot for a pointer   to "private data" which we fill with goodies.   We read the string table into malloc'd space and stash a pointer to it.   Since BFD doesn't know how to read debug symbols in a format-independent   way (and may never do so...), we have to do it ourselves.  We will never   be called unless this is an a.out (or very similar) file.    FIXME, there should be a cleaner peephole into the BFD environment here.  */#define DBX_STRINGTAB_SIZE_SIZE sizeof(long)   /* FIXME */static voiddbx_symfile_init (objfile)     struct objfile *objfile;{  int val;  bfd *sym_bfd = objfile->obfd;  char *name = bfd_get_filename (sym_bfd);  asection *text_sect;  unsigned char size_temp[DBX_STRINGTAB_SIZE_SIZE];  /* Allocate struct to keep track of the symfile */  objfile->sym_stab_info = (PTR)    xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info));  memset ((PTR) objfile->sym_stab_info, 0, sizeof (struct dbx_symfile_info));  /* FIXME POKING INSIDE BFD DATA STRUCTURES */#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 */  DBX_SYMFILE_INFO (objfile)->stab_section_info = NULL;    text_sect = bfd_get_section_by_name (sym_bfd, ".text");  if (!text_sect)    error ("Can't find .text section in symbol file");  DBX_TEXT_ADDR (objfile) = bfd_section_vma (sym_bfd, text_sect);  DBX_TEXT_SIZE (objfile) = bfd_section_size (sym_bfd, text_sect);  DBX_SYMBOL_SIZE (objfile) = obj_symbol_entry_size (sym_bfd);  DBX_SYMCOUNT (objfile) = bfd_get_symcount (sym_bfd);  DBX_SYMTAB_OFFSET (objfile) = SYMBOL_TABLE_OFFSET;  /* Read the string table and stash it away in the psymbol_obstack.  It is     only needed as long as we need to expand psymbols into full symbols,     so when we blow away the psymbol the string table goes away as well.     Note that gdb used to use the results of attempting to malloc the     string table, based on the size it read, as a form of sanity check     for botched byte swapping, on the theory that a byte swapped string     table size would be so totally bogus that the malloc would fail.  Now     that we put in on the psymbol_obstack, we can't do this since gdb gets     a fatal error (out of virtual memory) if the size is bogus.  We can     however at least check to see if the size is less than the size of     the size field itself, or larger than the size of the entire file.     Note that all valid string tables have a size greater than zero, since     the bytes used to hold the size are included in the count. */  if (STRING_TABLE_OFFSET == 0)    {      /* It appears that with the existing bfd code, STRING_TABLE_OFFSET	 will never be zero, even when there is no string table.  This	 would appear to be a bug in bfd. */      DBX_STRINGTAB_SIZE (objfile) = 0;      DBX_STRINGTAB (objfile) = NULL;    }  else    {      val = bfd_seek (sym_bfd, STRING_TABLE_OFFSET, SEEK_SET);      if (val < 0)	perror_with_name (name);            memset ((PTR) size_temp, 0, sizeof (size_temp));      val = bfd_read ((PTR) size_temp, sizeof (size_temp), 1, sym_bfd);      if (val < 0)	{	  perror_with_name (name);	}      else if (val == 0)	{	  /* With the existing bfd code, STRING_TABLE_OFFSET will be set to	     EOF if there is no string table, and attempting to read the size	     from EOF will read zero bytes. */	  DBX_STRINGTAB_SIZE (objfile) = 0;	  DBX_STRINGTAB (objfile) = NULL;	}      else	{	  /* Read some data that would appear to be the string table size.	     If there really is a string table, then it is probably the right	     size.  Byteswap if necessary and validate the size.  Note that	     the minimum is DBX_STRINGTAB_SIZE_SIZE.  If we just read some	     random data that happened to be at STRING_TABLE_OFFSET, because	     bfd can't tell us there is no string table, the sanity checks may	     or may not catch this. */	  DBX_STRINGTAB_SIZE (objfile) = bfd_h_get_32 (sym_bfd, size_temp);	  	  if (DBX_STRINGTAB_SIZE (objfile) < sizeof (size_temp)	      || DBX_STRINGTAB_SIZE (objfile) > bfd_get_size (sym_bfd))	    error ("ridiculous string table size (%d bytes).",		   DBX_STRINGTAB_SIZE (objfile));	  	  DBX_STRINGTAB (objfile) =	    (char *) obstack_alloc (&objfile -> psymbol_obstack,				    DBX_STRINGTAB_SIZE (objfile));	  OBJSTAT (objfile, sz_strtab += DBX_STRINGTAB_SIZE (objfile));	  	  /* Now read in the string table in one big gulp.  */	  	  val = bfd_seek (sym_bfd, STRING_TABLE_OFFSET, SEEK_SET);	  if (val < 0)	    perror_with_name (name);	  val = bfd_read (DBX_STRINGTAB (objfile), DBX_STRINGTAB_SIZE (objfile), 1,			  sym_bfd);	  if (val != DBX_STRINGTAB_SIZE (objfile))	    perror_with_name (name);	}    }}/* Perform any local cleanups required when we are done with a particular   objfile.  I.E, we are in the process of discarding all symbol information   for an objfile, freeing up all memory held for it, and unlinking the   objfile struct from the global list of known objfiles. */static voiddbx_symfile_finish (objfile)     struct objfile *objfile;{  if (objfile->sym_stab_info != NULL)    {      if (HEADER_FILES (objfile) != NULL)	{	  register int i = N_HEADER_FILES (objfile);	  register struct header_file *hfiles = HEADER_FILES (objfile);	  while (--i >= 0)	    {	      free (hfiles [i].name);	      free (hfiles [i].vector);	    }	  free ((PTR) hfiles);	}      mfree (objfile -> md, objfile->sym_stab_info);    }  free_header_files ();}/* Buffer for reading the symbol table entries.  */static struct external_nlist symbuf[4096];static int symbuf_idx;static int symbuf_end;/* cont_elem is used for continuing information in cfront.   It saves information about which types need to be fixed up and    completed after all the stabs are read.  */struct cont_elem   {    /* sym and stabsstring for continuing information in cfront */    struct symbol * sym;    char * stabs;    /* state dependancies (statics that must be preserved) */    int sym_idx;    int sym_end;    int symnum;    /* other state dependancies include:       (assumption is that these will not change since process_now FIXME!!)        stringtab_global        n_stabs        objfile        symfile_bfd */};static struct cont_elem cont_list[100];static int cont_count = 0;void process_later(sym,p)  struct symbol * sym;  char * p;{  /* save state so we can process these stabs later */  cont_list[cont_count].sym_idx = symbuf_idx;  cont_list[cont_count].sym_end = symbuf_end;  cont_list[cont_count].symnum = symnum;  cont_list[cont_count].sym = sym;  cont_list[cont_count].stabs = p;  cont_count++;}static void process_now(objfile)   struct objfile * objfile;{  int i;  /* save original state */  int save_symbuf_idx = symbuf_idx;  int save_symbuf_end = symbuf_end;  int save_symnum = symnum;  for (i=0; i<cont_count; i++)     {      /* set state as if we were parsing stabs strings          for this symbol */      symbuf_idx = cont_list[i].sym_idx;   /* statics used by gdb */      symbuf_end = cont_list[i].sym_end;        symnum = cont_list[i].symnum;        resolve_cfront_continuation(objfile,cont_list[i].sym,cont_list[i].stabs);    }  /* restore original state */  symbuf_idx = save_symbuf_idx;  symbuf_end = save_symbuf_end;  symnum = save_symnum;  cont_count=0;  /* reset for next run */}/* Name of last function encountered.  Used in Solaris to approximate   object file boundaries.  */static char *last_function_name;/* 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 by read_dbx_symtab when building psymtabs, and by   read_ofile_symtab when building symtabs, and is used only by   next_symbol_text.  FIXME: If that is true, we don't need it when   building psymtabs, right?  */static char *stringtab_global;/* These variables are used to control fill_symbuf when the stabs   symbols are not contiguous (as may be the case when a COFF file is   linked using --split-by-reloc).  */static struct stab_section_list *symbuf_sections;static unsigned int symbuf_left;static unsigned int symbuf_read;/* Refill the symbol table input buffer   and set the variables that control fetching entries from it.   Reports an error if no data available.   This function can read past the end of the symbol table   (into the string table) but this does no harm.  */static voidfill_symbuf (sym_bfd)     bfd *sym_bfd;{  unsigned int count;  int nbytes;  if (symbuf_sections == NULL)    count = sizeof (symbuf);  else    {      if (symbuf_left <= 0)	{	  file_ptr filepos = symbuf_sections->section->filepos;	  if (bfd_seek (sym_bfd, filepos, SEEK_SET) != 0)	    perror_with_name (bfd_get_filename (sym_bfd));	  symbuf_left = bfd_section_size (sym_bfd, symbuf_sections->section);	  symbol_table_offset = filepos - symbuf_read;	  symbuf_sections = symbuf_sections->next;	}      count = symbuf_left;      if (count > sizeof (symbuf))	count = sizeof (symbuf);    }  nbytes = bfd_read ((PTR)symbuf, count, 1, sym_bfd);  if (nbytes < 0)    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;  symbuf_left -= nbytes;  symbuf_read += nbytes;}#define SWAP_SYMBOL(symp, abfd) \  { \    (symp)->n_strx = bfd_h_get_32(abfd,			\				(unsigned char *)&(symp)->n_strx);	\    (symp)->n_desc = bfd_h_get_16 (abfd,			\				(unsigned char *)&(symp)->n_desc);  	\    (symp)->n_value = bfd_h_get_32 (abfd,			\				(unsigned char *)&(symp)->n_value); 	\  }#define INTERNALIZE_SYMBOL(intern, extern, abfd)			\  {									\    (intern).n_type = bfd_h_get_8 (abfd, (extern)->e_type);		\    (intern).n_strx = bfd_h_get_32 (abfd, (extern)->e_strx);		\    (intern).n_desc = bfd_h_get_16 (abfd, (extern)->e_desc);  		\    (intern).n_value = bfd_h_get_32 (abfd, (extern)->e_value);		\  }/* Invariant: The symbol pointed to by symbuf_idx is the first one   that hasn't been swapped.  Swap the symbol at the same time   that symbuf_idx is incremented.  *//* dbx allows the text of a symbol name to be continued into the   next symbol name!  When such a continuation is encountered   (a \ at the end of the text of a name)   call this function to get the continuation.  */static char *dbx_next_symbol_text (objfile)     struct objfile *objfile;{  struct internal_nlist nlist;  if (symbuf_idx == symbuf_end)    fill_symbuf (symfile_bfd);  symnum++;  INTERNALIZE_SYMBOL(nlist, &symbuf[symbuf_idx], symfile_bfd);  OBJSTAT (objfile, n_stabs++);  symbuf_idx++;  return nlist.n_strx + stringtab_global + file_string_table_offset;}/* Initialize the list of bincls to contain none and have some   allocated.  */static voidinit_bincl_list (number, objfile)     int number;     struct objfile *objfile;{  bincls_allocated = number;  next_bincl = bincl_list = (struct header_file_location *)    xmmalloc (objfile -> md, bincls_allocated * sizeof(struct header_file_location));}/* Add a bincl to the list.  */static voidadd_bincl_to_list (pst, name, instance)     struct partial_symtab *pst;     char *name;     int instance;{  if (next_bincl >= bincl_list + bincls_allocated)    {      int offset = next_bincl - bincl_list;      bincls_allocated *= 2;      bincl_list = (struct header_file_location *)	xmrealloc (pst->objfile->md, (char *)bincl_list,		  bincls_allocated * sizeof (struct header_file_location));      next_bincl = bincl_list + offset;    }  next_bincl->pst = pst;  next_bincl->instance = instance;  next_bincl++->name = name;}/* Given a name, value pair, find the corresponding   bincl in the list.  Return the partial symtab associated   with that header_file_location.  */static struct partial_symtab *find_corresponding_bincl_psymtab (name, instance)     char *name;     int instance;{  struct header_file_location *bincl;  for (bincl = bincl_list; bincl < next_bincl; bincl++)    if (bincl->instance == instance	&& STREQ (name, bincl->name))      return bincl->pst;  complain (&repeated_header_complaint, name, symnum);  return (struct partial_symtab *) 0;}