* bcache.c, bcache.h: New files to implement a byte cache.
[deliverable/binutils-gdb.git] / gdb / os9kread.c
index 4a1f3653866b6864c1224862fcfaff6695b09597..2de292219b4773198c21b44448d2aa85ed0e4162 100644 (file)
@@ -1,5 +1,5 @@
 /* Read os9/os9k symbol tables and convert to internal format, for GDB.
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -16,7 +16,7 @@ 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.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 /* This module provides three functions: os9k_symfile_init,
    which initializes to read a symbol file; os9k_new_init, which 
@@ -33,7 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
    for real.  os9k_psymtab_to_symtab() is the function that does this */
 
 #include "defs.h"
-#include <string.h>
+#include "gdb_string.h"
 #include <stdio.h>
 
 #if defined(USG) || defined(__CYGNUSCLIB__)
@@ -41,19 +41,18 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <fcntl.h>
 #endif
 
-#include <obstack.h>
+#include "obstack.h"
 #include <sys/param.h>
 #ifndef        NO_SYS_FILE
 #include <sys/file.h>
 #endif
-#include <sys/stat.h>
+#include "gdb_stat.h"
 #include <ctype.h>
 #include "symtab.h"
 #include "breakpoint.h"
 #include "command.h"
 #include "target.h"
 #include "gdbcore.h"           /* for bfd stuff */
-#include "libbfd.h"            /* FIXME Secret internal BFD stuff (bfd_read) */
 #include "libaout.h"           /* FIXME Secret internal BFD stuff for a.out */
 #include "symfile.h"
 #include "objfiles.h"
@@ -65,11 +64,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "os9k.h"
 #include "stabsread.h"
 
-#if !defined (SEEK_SET)
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#endif
-
 /* Each partial symbol table entry contains a pointer to private data for the
    read_symtab() function to use when expanding a partial symbol table entry
    to a full symbol table entry.
@@ -105,9 +99,6 @@ extern int info_verbose;
 
 extern int previous_stab_code;
 
-/* The BFD for this file -- implicit parameter to next_symbol_text.  */
-static bfd *symfile_bfd;
-
 /* Name of last function encountered.  Used in Solaris to approximate
    object file boundaries.  */
 static char *last_function_name;
@@ -125,12 +116,13 @@ extern struct complaint repeated_header_complaint;
 
 extern struct complaint repeated_header_name_complaint;
 
+#if 0
 static struct complaint lbrac_unmatched_complaint =
   {"unmatched Increment Block Entry before symtab pos %d", 0, 0};
 
 static struct complaint lbrac_mismatch_complaint =
   {"IBE/IDE symbol mismatch at symtab pos %d", 0, 0};
-
+#endif
 \f
 /* Local function prototypes */
 static void
@@ -146,12 +138,6 @@ static void
 read_os9k_psymtab PARAMS ((struct section_offsets *, struct objfile *,
                          CORE_ADDR, int));
 
-static void
-init_psymbol_list PARAMS ((struct objfile *));
-
-static char *
-os9k_next_symbol_text PARAMS ((void));
-
 static int
 fill_sym PARAMS ((FILE *, bfd *));
 
@@ -173,8 +159,8 @@ os9k_process_one_symbol PARAMS ((int, int, CORE_ADDR, char *,
 
 static struct partial_symtab *
 os9k_start_psymtab PARAMS ((struct objfile *, struct section_offsets *, char *,
-                       CORE_ADDR, int, int, struct partial_symbol *,
-                       struct partial_symbol *));
+                       CORE_ADDR, int, int, struct partial_symbol **,
+                       struct partial_symbol **));
 
 static struct partial_symtab *
 os9k_end_psymtab PARAMS ((struct partial_symtab *, char **, int, int, CORE_ADDR,
@@ -265,7 +251,7 @@ struct stbsymbol {
 };
 #define STBSYMSIZE 10
 
-static int 
+static void
 read_minimal_symbols(objfile, section_offsets)
      struct objfile *objfile;
      struct section_offsets *section_offsets;
@@ -320,7 +306,7 @@ char buf[64], buf1[128];
     off += STBSYMSIZE;
   };
   install_minimal_symbols (objfile);
-  return 1;
+  return;
 }
 \f
 /* Scan and build partial symbols for a symbol file.
@@ -340,15 +326,13 @@ os9k_symfile_read (objfile, section_offsets, mainline)
      int mainline;     /* FIXME comments above */
 {
   bfd *sym_bfd;
-  int val;
-  int stb_exist;
   struct cleanup *back_to;
 
   sym_bfd = objfile->obfd;
   /* If we are reinitializing, or if we have never loaded syms yet, init */
   if (mainline || objfile->global_psymbols.size == 0 || 
     objfile->static_psymbols.size == 0)
-    init_psymbol_list (objfile);
+    init_psymbol_list (objfile, DBX_SYMCOUNT (objfile));
 
   pending_blocks = 0;
   back_to = make_cleanup (really_free_pendings, 0);
@@ -359,14 +343,8 @@ os9k_symfile_read (objfile, section_offsets, mainline)
   /* Now that the symbol table data of the executable file are all in core,
      process them and define symbols accordingly.  */
   read_os9k_psymtab (section_offsets, objfile,
-                  bfd_section_vma  (sym_bfd, DBX_TEXT_SECT (objfile)),
-                  bfd_section_size (sym_bfd, DBX_TEXT_SECT (objfile)));
-
-  if (!have_partial_symbols ()) {
-    wrap_here ("");
-    printf_filtered ("(no debugging symbols found)...");
-    wrap_here ("");
-  }
+                    DBX_TEXT_ADDR (objfile),
+                    DBX_TEXT_SIZE (objfile));
 
   do_cleanups (back_to);
 }
@@ -401,13 +379,12 @@ static void
 os9k_symfile_init (objfile)
      struct objfile *objfile;
 {
-  int val;
   bfd *sym_bfd = objfile->obfd;
   char *name = bfd_get_filename (sym_bfd);
   char dbgname[512], stbname[512];
   FILE *symfile = 0;
   FILE *minfile = 0;
-
+  asection *text_sect;
 
   strcpy(dbgname, name);
   strcat(dbgname, ".dbg");
@@ -429,9 +406,11 @@ os9k_symfile_init (objfile)
     xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info));
   DBX_SYMFILE_INFO (objfile)->stab_section_info = NULL;
 
-  DBX_TEXT_SECT (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
-  if (!DBX_TEXT_SECT (objfile))
+  text_sect = bfd_get_section_by_name (sym_bfd, ".text");
+  if (!text_sect)
     error ("Can't find .text section in file");
+  DBX_TEXT_ADDR (objfile) = bfd_section_vma (sym_bfd, text_sect);
+  DBX_TEXT_SIZE (objfile) = bfd_section_size (sym_bfd, text_sect);
 
   DBX_SYMBOL_SIZE (objfile) = 0;     /* variable size symbol */
   DBX_SYMCOUNT (objfile) =  0;  /* used to be bfd_get_symcount(sym_bfd) */
@@ -502,7 +481,6 @@ fill_sym (dbg_file, abfd)
      FILE *dbg_file;
      bfd *abfd;
 {
-short id;
 short si, nmask;
 long li;
 int ii;
@@ -566,30 +544,6 @@ char *p;
     return 1;
 }
 \f
-/* Initializes storage for all of the partial symbols that will be
-   created by read_dbx_symtab and subsidiaries.  */
-
-static void
-init_psymbol_list (objfile)
-     struct objfile *objfile;
-{
-  /* Free any previously allocated psymbol lists.  */
-  if (objfile -> global_psymbols.list)
-    mfree (objfile -> md, (PTR)objfile -> global_psymbols.list);
-  if (objfile -> static_psymbols.list)
-    mfree (objfile -> md, (PTR)objfile -> static_psymbols.list);
-
-  /* Current best guess is that there are approximately a twentieth
-     of the total symbols (in a debugging file) are global or static
-     oriented symbols */
-  objfile -> global_psymbols.size = DBX_SYMCOUNT (objfile) / 10;
-  objfile -> static_psymbols.size = DBX_SYMCOUNT (objfile) / 10;
-  objfile -> global_psymbols.next = objfile -> global_psymbols.list = (struct partial_symbol *)
-    xmmalloc (objfile -> md, objfile -> global_psymbols.size * sizeof (struct partial_symbol));
-  objfile -> static_psymbols.next = objfile -> static_psymbols.list = (struct partial_symbol *)
-    xmmalloc (objfile -> md, objfile -> static_psymbols.size * sizeof (struct partial_symbol));
-}
-
 /* Given pointers to an a.out symbol table in core containing dbx
    style data, setup partial_symtab's describing each source file for
    which debugging information is available.
@@ -606,10 +560,11 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
 {
   register struct internal_symstruct *bufp = 0;        /* =0 avoids gcc -Wall glitch*/
   register char *namestring;
-  int nsl;
   int past_first_source_file = 0;
   CORE_ADDR last_o_file_start = 0;
+#if 0
   struct cleanup *back_to;
+#endif
   bfd *abfd;
   FILE *fp;
 
@@ -719,34 +674,43 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
              {
                unsigned long valu;
                enum language tmp_language;
+               char *str, *p;
+               int n;
                
                valu = CUR_SYMBOL_VALUE;
                if (valu)
                  valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
                past_first_source_file = 1;
 
+                p = strchr(namestring, ':');
+                if (p) n = p-namestring;
+                else n = strlen(namestring);
+                str = alloca(n+1);
+                strncpy(str, namestring, n);
+                str[n] = '\0';
+
                if (psymfile_depth == 0) {
                  if (!pst)
                    pst = os9k_start_psymtab (objfile, section_offsets,
-                                namestring, valu,
+                                str, valu,
                                 cursymoffset,
                                 symnum-1,
                                 objfile -> global_psymbols.next,
                                 objfile -> static_psymbols.next);
                } else { /* this is a include file */
-                 tmp_language = deduce_language_from_filename (namestring);
+                 tmp_language = deduce_language_from_filename (str);
                  if (tmp_language != language_unknown
                        && (tmp_language != language_c
                        || psymtab_language != language_cplus))
                        psymtab_language = tmp_language;
 
 /*
-                 if (pst && STREQ (namestring, pst->filename))
+                 if (pst && STREQ (str, pst->filename))
                    continue;
                  {
                    register int i;
                    for (i = 0; i < includes_used; i++)
-                     if (STREQ (namestring, psymtab_include_list[i]))
+                     if (STREQ (str, psymtab_include_list[i]))
                        {
                          i = -1; 
                          break;
@@ -756,7 +720,7 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
                  }
 */
 
-                  psymtab_include_list[includes_used++] = namestring;
+                  psymtab_include_list[includes_used++] = str;
                   if (includes_used >= includes_allocated)
                     {
                       char **orig = psymtab_include_list;
@@ -868,7 +832,7 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size)
                      /* Check for and handle cretinous dbx symbol name
                         continuation! 
                      if (*p == '\\')
-                       p = next_symbol_text ();
+                       p = next_symbol_text (objfile);
                      */
 
                      /* Point to the character after the name
@@ -1008,8 +972,8 @@ os9k_start_psymtab (objfile, section_offsets,
      CORE_ADDR textlow;
      int ldsymoff;
      int ldsymcnt;
-     struct partial_symbol *global_syms;
-     struct partial_symbol *static_syms;
+     struct partial_symbol **global_syms;
+     struct partial_symbol **static_syms;
 {
   struct partial_symtab *result =
       start_psymtab_common(objfile, section_offsets,
@@ -1086,7 +1050,7 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt,
     strncpy (p, last_function_name, n);
     p[n] = 0;
     
-    minsym = lookup_minimal_symbol (p, objfile);
+    minsym = lookup_minimal_symbol (p, NULL, objfile);
 
     if (minsym) {
       pst->texthigh = SYMBOL_VALUE_ADDRESS(minsym)+(long)MSYMBOL_INFO(minsym);
@@ -1397,8 +1361,8 @@ os9k_read_ofile_symtab (pst)
       bufp = symbuf;
       type = bufp->n_type;
 
-      os9k_process_one_symbol (type, bufp->n_desc, bufp->n_value,
-             bufp->n_strx, section_offsets, objfile);
+      os9k_process_one_symbol ((int)type, (int)bufp->n_desc, 
+      (CORE_ADDR)bufp->n_value, bufp->n_strx, section_offsets, objfile);
 
       /* We skip checking for a new .o or -l file; that should never
          happen in this routine. */
@@ -1445,8 +1409,7 @@ os9k_read_ofile_symtab (pst)
      which comes from pst->textlow is correct. */
   if (last_source_start_addr == 0)
     last_source_start_addr = text_offset;
-  pst->symtab = end_symtab (text_offset + text_size, 0, 0, objfile,
-                           SECT_OFF_TEXT);
+  pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT);
   end_stabs ();
 }
 
@@ -1602,7 +1565,7 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile)
              *p = '\0';
              if (symfile_depth++ == 0) {
                if (last_source_file) {
-                 end_symtab (valu, 0, 0, objfile, SECT_OFF_TEXT);
+                 end_symtab (valu, objfile, SECT_OFF_TEXT);
                  end_stabs ();
                }
                start_stabs ();
This page took 0.039074 seconds and 4 git commands to generate.