Rewrite gdb.asm so that it doesn't assume a C comiler (or any C
[deliverable/binutils-gdb.git] / gdb / hp-psymtab-read.c
index 80c3073d711a2eb28e6fbd1d392cefb97c127d1a..f1aa4756e923fed5a7f0a1acb32bbdcb130cc19e 100644 (file)
@@ -15,7 +15,8 @@
 
    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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
 
    Written by the Center for Software Science at the University of Utah
    and by Cygnus Support.  */
 /* #define DUMPING         1 */
 
 /* To use the quick look-up tables, uncomment this define. */
-#define QUICK_LOOK_UP      0
+#define QUICK_LOOK_UP      1
 
 /* To call PXDB to process un-processed files, uncomment this define. */
 #define USE_PXDB           1
 
 /* Forward procedure declarations */
 
-void hpread_symfile_init
-  PARAMS ((struct objfile *));
+void hpread_symfile_init (struct objfile *);
 
-void hpread_build_psymtabs
-  PARAMS ((struct objfile *, struct section_offsets *, int));
+void do_pxdb (bfd *);
 
-void hpread_symfile_finish
-  PARAMS ((struct objfile *));
+void hpread_build_psymtabs (struct objfile *, int);
 
-static union dnttentry *hpread_get_gntt
-  PARAMS ((int, struct objfile *));
+void hpread_symfile_finish (struct objfile *);
 
-static unsigned long hpread_get_textlow
-  PARAMS ((int, int, struct objfile *, int));
+static union dnttentry *hpread_get_gntt (int, struct objfile *);
+
+static unsigned long hpread_get_textlow (int, int, struct objfile *, int);
 
 static struct partial_symtab *hpread_start_psymtab
-  PARAMS ((struct objfile *, struct section_offsets *, char *, CORE_ADDR, int,
-          struct partial_symbol **, struct partial_symbol **));
+  (struct objfile *, char *, CORE_ADDR, int,
+   struct partial_symbol **, struct partial_symbol **);
 
 static struct partial_symtab *hpread_end_psymtab
-  PARAMS ((struct partial_symtab *, char **, int, int, CORE_ADDR,
-          struct partial_symtab **, int));
+  (struct partial_symtab *, char **, int, int, CORE_ADDR,
+   struct partial_symtab **, int);
 
 /* End of forward routine declarations */
 
@@ -71,7 +69,6 @@ static struct partial_symtab *hpread_end_psymtab
 
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
 /* check for the existance of a file, given its full pathname */
 int
@@ -96,7 +93,7 @@ trans_lang (in_lang)
   else if (in_lang == HP_LANGUAGE_CPLUSPLUS)
     return language_cplus;
 
-  else if (in_lang == HP_LANGUAGE_F77)
+  else if (in_lang == HP_LANGUAGE_FORTRAN)
     return language_fortran;
 
   else
@@ -276,17 +273,38 @@ hpread_pxdb_needed (sym_bfd)
 
 #endif
 
-#ifdef QUICK_LOOK_UP
+/* Check whether the file needs to be preprocessed by pxdb. 
+   If so, call pxdb. */
+
+void
+do_pxdb (sym_bfd)
+     bfd *sym_bfd;
+{
+  /* The following code is HP-specific.  The "right" way of
+     doing this is unknown, but we bet would involve a target-
+     specific pre-file-load check using a generic mechanism. */
+
+  /* This code will not be executed if the file is not in SOM
+     format (i.e. if compiled with gcc) */
+  if (hpread_pxdb_needed (sym_bfd))
+    {
+      /*This file has not been pre-processed. Preprocess now */
 
-/* This flag can be set to zero to use the old
-   style psymtab (build from a scan of the LNTT)
-   or to one to try to use the quick look-up
-   tables. */
-int psym_new_style = 1;
+      if (hpread_call_pxdb (sym_bfd->filename))
+       {
+         /* The call above has changed the on-disk file, 
+            we can close the file anyway, because the
+            symbols will be reread in when the target is run */
+         bfd_close (sym_bfd);
+       }
+    }
+}
 \f
 
 
-/* Code to handle quick lookup-tables follows */
+#ifdef QUICK_LOOK_UP
+
+/* Code to handle quick lookup-tables follows. */
 
 
 /* Some useful macros */
@@ -339,10 +357,10 @@ int psym_new_style = 1;
    psymtabs created so far */
 
 typedef struct
-  {
-    int start;
-    int end;
-  }
+{
+  int start;
+  int end;
+}
 pst_syms_struct;
 
 static pst_syms_struct *pst_syms_array = 0;
@@ -492,7 +510,7 @@ find_next_module_isym (index, qMD, curr_md, pxdb_header_p)
    organized in a separate routine, although it does take lots of arguments. pai/1997-10-08 */
 
 static int
-scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile, section_offsets)
+scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile)
      int *curr_pd_p;           /* pointer to current proc index */
      quick_procedure_entry *qPD;       /* the procedure quick lookup table */
      int max_procs;            /* number of entries in proc. table */
@@ -501,7 +519,6 @@ scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile
      struct partial_symtab *pst;       /* current psymtab */
      char *vt_bits;            /* strings table of SOM debug space */
      struct objfile *objfile;  /* current object file */
-     struct section_offsets *section_offsets;  /* not really used for HP-UX currently */
 {
   union dnttentry *dn_bufp;
   int symbol_count = 0;                /* Total number of symbols in this psymtab */
@@ -560,49 +577,6 @@ scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile
          warning ("Procedure \"%s\" [0x%x] spans file or module boundaries.", rtn_name, curr_pd);
        }
 
-/* I asked for this in the hope it would fix bug CHFts22228, but
-   later decided it's not the right fix. I'm leaving the code
-   commented out for now in case we decide we actually want to do this.
-   - RT */
-#if 0
-      /* Check this routine--if it's a class member function,
-         add the class to the psymtab.  We only need to add
-         the class once in each module, so check. */
-      if (qPD[curr_pd].member)
-       {
-
-         class = qPD[curr_pd].icd;
-         if (!B_TST (class_entered, class))
-           {                   /* pai: (temp)  class_entered not a parameter */
-
-             class_name = &vt_bits[(long) qCD[class].sbClass];
-
-             /* Add to both the struct and var namespace */
-
-             add_psymbol_to_list (class_name,
-                                  strlen (class_name),
-                                  STRUCT_NAMESPACE,
-                                  LOC_UNDEF,   /* "I have no storage"     */
-                                  &objfile->global_psymbols,   /* assume classname is global */
-                                  0, 0,
-                                  trans_lang ((enum hp_language) qPD[curr_pd].language),
-                                  objfile);
-
-             add_psymbol_to_list (class_name,
-                                  strlen (class_name),
-                                  VAR_NAMESPACE,
-                                  LOC_UNDEF,   /* "I have no storage"     */
-                                  &objfile->global_psymbols,   /* assume classname is global */
-                                  0, 0,
-                                  trans_lang ((enum hp_language) qPD[curr_pd].language),
-                                  objfile);
-
-             B_SET (class_entered, class);     /* pai: (temp)  class_entered not a parameter */
-             symbol_count++;
-           }
-       }
-#endif
-
       /* Add this routine symbol to the list in the objfile. 
          Unfortunately we have to go to the LNTT to determine the
          correct list to put it on. An alternative (which the
@@ -620,10 +594,10 @@ scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile
                                           VAR_NAMESPACE,
                                           LOC_BLOCK,   /* "I am a routine"        */
                                           &objfile->global_psymbols,
-                                          (qPD[curr_pd].adrStart + /* Starting address of rtn */
-                                           ANOFFSET (section_offsets, SECT_OFF_TEXT)),
+                                          (qPD[curr_pd].adrStart +     /* Starting address of rtn */
+                                ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))),
                                           0,   /* core addr?? */
-                                          trans_lang ((enum hp_language) qPD[curr_pd].language),
+                     trans_lang ((enum hp_language) qPD[curr_pd].language),
                                           objfile);
       else
        add_psymbol_with_dem_name_to_list (rtn_name,
@@ -633,10 +607,10 @@ scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile
                                           VAR_NAMESPACE,
                                           LOC_BLOCK,   /* "I am a routine"        */
                                           &objfile->static_psymbols,
-                                          (qPD[curr_pd].adrStart +  /* Starting address of rtn */
-                                           ANOFFSET (section_offsets, SECT_OFF_TEXT)),
+                                          (qPD[curr_pd].adrStart +     /* Starting address of rtn */
+                                ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))),
                                           0,   /* core addr?? */
-                                          trans_lang ((enum hp_language) qPD[curr_pd].language),
+                     trans_lang ((enum hp_language) qPD[curr_pd].language),
                                           objfile);
 
       symbol_count++;
@@ -666,12 +640,11 @@ scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile
    entry for it, so in such cases we create a psymtab for the file.  */
 
 int
-hpread_quick_traverse (objfile,        section_offsets, gntt_bits, vt_bits, pxdb_header_p)     
-     struct objfile *objfile;        /* The object file descriptor */
-     struct section_offsets *section_offsets; /* ?? Null for HP */
-     char *gntt_bits;                /* GNTT entries, loaded in from the file */
-     char *vt_bits;                  /* VT (string) entries ditto. */
-     PXDB_header_ptr pxdb_header_p;  /* Pointer to pxdb header ditto */
+hpread_quick_traverse (objfile, gntt_bits, vt_bits, pxdb_header_p)
+     struct objfile *objfile;  /* The object file descriptor */
+     char *gntt_bits;          /* GNTT entries, loaded in from the file */
+     char *vt_bits;            /* VT (string) entries ditto. */
+     PXDB_header_ptr pxdb_header_p;    /* Pointer to pxdb header ditto */
 {
   struct partial_symtab *pst;
 
@@ -698,8 +671,8 @@ hpread_quick_traverse (objfile,     section_offsets, gntt_bits, vt_bits, pxdb_header
 
   struct partial_symbol **global_syms; /* We'll be filling in the "global"   */
   struct partial_symbol **static_syms; /* and "static" tables in the objfile
-                                           as we go, so we need a pair of     
-                                           current pointers. */
+                                          as we go, so we need a pair of     
+                                          current pointers. */
 
 #ifdef DUMPING
   /* Turn this on for lots of debugging information in this routine.
@@ -825,18 +798,6 @@ hpread_quick_traverse (objfile,    section_offsets, gntt_bits, vt_bits, pxdb_header
   global_syms = objfile->global_psymbols.list;
   static_syms = objfile->static_psymbols.list;
 
-#if 0                          /* pai: (temp) we don't need this any more */
-  /* elz: if the first module we see in the table is for
-     end.c, then return immediately with false. This happens
-     for F77 programs, for which there is no MODULE information
-     produced in the debug info. 
-     Returning false from this function will make the caller
-     (build_psymbols) scan the table from the beginning and 
-     not use the quick lookup tables.
-     F90 has modules so this poses no problem. */
-  if (!strcmp (&vt_bits[(long) qMD[0].sbMod], "end.c"))
-    return 0;
-#endif
 
   /* First skip over pseudo-entries with address 0.  These represent inlined
      routines and abstract (uninstantiated) template routines.
@@ -877,7 +838,7 @@ hpread_quick_traverse (objfile,     section_offsets, gntt_bits, vt_bits, pxdb_header
          in them but still have qMD entries.  They also have no qFD or
          qPD entries.  Their start address is -1 and their end address
          is 0.  */
-      if (VALID_CURR_MODULE && (CURR_MODULE_START == -1) && (CURR_MODULE_END == NULL))
+      if (VALID_CURR_MODULE && (CURR_MODULE_START == -1) && (CURR_MODULE_END == 0))
        {
 
          mod_name_string = &vt_bits[(long) qMD[curr_md].sbMod];
@@ -893,24 +854,23 @@ hpread_quick_traverse (objfile,   section_offsets, gntt_bits, vt_bits, pxdb_header
             might help.  */
 
          pst = hpread_start_psymtab (objfile,
-                                     section_offsets,          /* ?? */
                                      mod_name_string,
                                      CURR_MODULE_START,        /* Low text address: bogus! */
-                                     (CURR_MODULE_ISYM * sizeof (struct dntt_type_block)),
-                                                               /* ldsymoff */
+                      (CURR_MODULE_ISYM * sizeof (struct dntt_type_block)),
+         /* ldsymoff */
                                      global_syms,
                                      static_syms);
 
          pst = hpread_end_psymtab (pst,
                                    NULL,       /* psymtab_include_list */
-                                   0,          /* includes_used        */
-                                   end_sym * sizeof (struct dntt_type_block),
-                                               /* byte index in LNTT of end 
-                                                  = capping symbol offset  
-                                                  = LDSYMOFF of nextfile */
-                                    NULL,      /* text high            */
-                                    NULL,      /* dependency_list      */
-                                    0);        /* dependencies_used    */
+                                   0,  /* includes_used        */
+                                 end_sym * sizeof (struct dntt_type_block),
+         /* byte index in LNTT of end 
+            = capping symbol offset  
+            = LDSYMOFF of nextfile */
+                                   0,  /* text high            */
+                                   NULL,       /* dependency_list      */
+                                   0);         /* dependencies_used    */
 
          global_syms = objfile->global_psymbols.next;
          static_syms = objfile->static_psymbols.next;
@@ -995,11 +955,10 @@ hpread_quick_traverse (objfile,   section_offsets, gntt_bits, vt_bits, pxdb_header
                 And it's not even the right byte offset, as we're using
                 the size of a union! FIXME!  */
              pst = hpread_start_psymtab (objfile,
-                                         section_offsets,      /* ?? */
                                          full_name_string,
-                                         start_adr,            /* Low text address */
-                                         (start_sym * sizeof (struct dntt_type_block)),
-                                                               /* ldsymoff */
+                                         start_adr,    /* Low text address */
+                             (start_sym * sizeof (struct dntt_type_block)),
+             /* ldsymoff */
                                          global_syms,
                                          static_syms);
 
@@ -1011,8 +970,7 @@ hpread_quick_traverse (objfile,    section_offsets, gntt_bits, vt_bits, pxdb_header
                 file, based on the starting addresses. */
 
              syms_in_pst = scan_procs (&curr_pd, qPD, pxdb_header_p->pd_entries,
-                                       start_adr, end_adr,
-                                       pst, vt_bits, objfile, section_offsets);
+                                       start_adr, end_adr, pst, vt_bits, objfile);
 
              /* Get ending symbol offset */
 
@@ -1061,10 +1019,10 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header
              pst = hpread_end_psymtab (pst,
                                        NULL,   /* psymtab_include_list */
                                        0,      /* includes_used        */
-                                       end_sym * sizeof (struct dntt_type_block),
-                                               /* byte index in LNTT of end 
-                                                  = capping symbol offset   
-                                                  = LDSYMOFF of nextfile */
+                                 end_sym * sizeof (struct dntt_type_block),
+             /* byte index in LNTT of end 
+                = capping symbol offset   
+                = LDSYMOFF of nextfile */
                                        end_adr,        /* text high */
                                        NULL,   /* dependency_list */
                                        0);     /* dependencies_used */
@@ -1225,11 +1183,10 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header
                 And it's not even the right byte offset, as we're using
                 the size of a union! FIXME!  */
              pst = hpread_start_psymtab (objfile,
-                                         section_offsets,      /* ?? */
                                          full_name_string,
                                          start_adr,    /* Low text address */
-                                         (start_sym * sizeof (struct dntt_type_block)),
-                                                       /* ldsymoff */
+                             (start_sym * sizeof (struct dntt_type_block)),
+             /* ldsymoff */
                                          global_syms,
                                          static_syms);
 
@@ -1241,8 +1198,7 @@ hpread_quick_traverse (objfile,   section_offsets, gntt_bits, vt_bits, pxdb_header
                 module, based on the starting addresses. */
 
              syms_in_pst = scan_procs (&curr_pd, qPD, pxdb_header_p->pd_entries,
-                                       start_adr, end_adr,
-                                       pst, vt_bits, objfile, section_offsets);
+                                       start_adr, end_adr, pst, vt_bits, objfile);
 
              /* Get ending symbol offset */
 
@@ -1291,10 +1247,10 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header
              pst = hpread_end_psymtab (pst,
                                        NULL,   /* psymtab_include_list */
                                        0,      /* includes_used        */
-                                       end_sym * sizeof (struct dntt_type_block),
-                                               /* byte index in LNTT of end 
-                                                  = capping symbol offset   
-                                                  = LDSYMOFF of nextfile */
+                                 end_sym * sizeof (struct dntt_type_block),
+             /* byte index in LNTT of end 
+                = capping symbol offset   
+                = LDSYMOFF of nextfile */
                                        end_adr,        /* text high */
                                        NULL,   /* dependency_list      */
                                        0);     /* dependencies_used    */
@@ -1339,25 +1295,23 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header
        }
 #endif
       pst = hpread_start_psymtab (objfile,
-                                 section_offsets,      /* ?? */
                                  "orphans",
                                  start_adr,    /* Low text address */
-                                 (CURR_PROC_ISYM * sizeof (struct dntt_type_block)),
-                                               /* ldsymoff */
+                        (CURR_PROC_ISYM * sizeof (struct dntt_type_block)),
+      /* ldsymoff */
                                  global_syms,
                                  static_syms);
 
       scan_procs (&curr_pd, qPD, pxdb_header_p->pd_entries,
-                 start_adr, end_adr,
-                 pst, vt_bits, objfile, section_offsets);
+                 start_adr, end_adr, pst, vt_bits, objfile);
 
       pst = hpread_end_psymtab (pst,
                                NULL,   /* psymtab_include_list */
                                0,      /* includes_used */
-                               pxdb_header_p->globals * sizeof (struct dntt_type_block),
-                                       /* byte index in LNTT of end 
-                                          = capping symbol offset   
-                                          = LDSYMOFF of nextfile */
+                  pxdb_header_p->globals * sizeof (struct dntt_type_block),
+      /* byte index in LNTT of end 
+         = capping symbol offset   
+         = LDSYMOFF of nextfile */
                                end_adr,        /* text high  */
                                NULL,   /* dependency_list */
                                0);     /* dependencies_used */
@@ -1371,7 +1325,6 @@ hpread_quick_traverse (objfile,   section_offsets, gntt_bits, vt_bits, pxdb_header
      If null psts were kept on the chain, this would be
      a solution.  FIXME */
   pst = hpread_start_psymtab (objfile,
-                             section_offsets,
                              "globals",
                              0,
                              (pxdb_header_p->globals
@@ -1538,7 +1491,7 @@ hpread_symfile_init (objfile)
                     bfd_section_size (objfile->obfd, gntt_section));
 
   bfd_get_section_contents (objfile->obfd, gntt_section, GNTT (objfile),
-                           0, bfd_section_size (objfile->obfd, gntt_section));
+                        0, bfd_section_size (objfile->obfd, gntt_section));
 
   GNTT_SYMCOUNT (objfile)
     = bfd_section_size (objfile->obfd, gntt_section)
@@ -1560,7 +1513,7 @@ hpread_symfile_init (objfile)
                     bfd_section_size (objfile->obfd, lntt_section));
 
   bfd_get_section_contents (objfile->obfd, lntt_section, LNTT (objfile),
-                           0, bfd_section_size (objfile->obfd, lntt_section));
+                        0, bfd_section_size (objfile->obfd, lntt_section));
 
   LNTT_SYMCOUNT (objfile)
     = bfd_section_size (objfile->obfd, lntt_section)
@@ -1577,7 +1530,7 @@ hpread_symfile_init (objfile)
                   bfd_section_size (objfile->obfd, slt_section));
 
   bfd_get_section_contents (objfile->obfd, slt_section, SLT (objfile),
-                           0, bfd_section_size (objfile->obfd, slt_section));
+                         0, bfd_section_size (objfile->obfd, slt_section));
 
   /* Read in data from the $VT$ subspace.  $VT$ contains things like
      names and constants.  Keep track of the number of symbols in the VT.  */
@@ -1609,14 +1562,12 @@ hpread_symfile_init (objfile)
    We assume hpread_symfile_init has been called to initialize the
    symbol reader's private data structures.
 
-   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). */
+
 void
-hpread_build_psymtabs (objfile, section_offsets, mainline)
+hpread_build_psymtabs (objfile, mainline)
      struct objfile *objfile;
-     struct section_offsets *section_offsets;
      int mainline;
 {
 
@@ -1630,7 +1581,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline)
   struct cleanup *old_chain;
 
   int hp_symnum, symcount, i;
-  int scan_start;
+  int scan_start = 0;
 
   union dnttentry *dn_bufp;
   unsigned long valu;
@@ -1671,7 +1622,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline)
     (struct partial_symtab **) alloca (dependencies_allocated *
                                       sizeof (struct partial_symtab *));
 
-  old_chain = make_cleanup (free_objfile, objfile);
+  old_chain = make_cleanup_free_objfile (objfile);
 
   last_source_file = 0;
 
@@ -1684,87 +1635,60 @@ hpread_build_psymtabs (objfile, section_offsets, mainline)
        anyway, but it turns out to be not so easy. So this could 
        actually be commented out, but I leave it in, just in case
        we decide to add support for non-pxdb-ed stuff in the future. */
-    bfd *abfd;
-    abfd = symfile_bfd_open (objfile->name);
-    if (!hpread_pxdb_needed (abfd))
-      {
-       if (psym_new_style)
-         {
-           PXDB_header pxdb_header;
-           int found_modules_in_program;
+    PXDB_header pxdb_header;
+    int found_modules_in_program;
 
-           if (hpread_get_header (objfile, &pxdb_header))
-             {
-               /* Build a minimal table.  No types, no global variables,
-                  no include files.... */
+    if (hpread_get_header (objfile, &pxdb_header))
+      {
+       /* Build a minimal table.  No types, no global variables,
+          no include files.... */
 #ifdef DUMPING
-               if (dumping)
-                 printf ("\nNew method for %s\n", objfile->name);
+       if (dumping)
+         printf ("\nNew method for %s\n", objfile->name);
 #endif
 
-               /* elz: quick_traverse returns true if it found
-                  some modules in the main source file, other
-                  than those in end.c
-                  In C and C++, all the files have MODULES entries
-                  in the LNTT, and the quick table traverse is all 
-                  based on finding these MODULES entries. Without 
-                  those it cannot work. 
-                  It happens that F77 programs don't have MODULES
-                  so the quick traverse gets confused. F90 programs
-                  have modules, and the quick method still works.
-                  So, if modules (other than those in end.c) are
-                  not found we give up on the quick table stuff, 
-                  and fall back on the slower method  */
-               found_modules_in_program = hpread_quick_traverse (objfile,
-                                                                 section_offsets,
-                                                                 GNTT (objfile),
-                                                                 VT (objfile),
-                                                                 &pxdb_header);
-
-               discard_cleanups (old_chain);
-
-               /* Set up to scan the global section of the LNTT.
-
-                  This field is not always correct: if there are
-                  no globals, it will point to the last record in
-                  the regular LNTT, which is usually an END MODULE.
-
-                  Since it might happen that there could be a file
-                  with just one global record, there's no way to
-                  tell other than by looking at the record, so that's
-                  done below. */
-               if (found_modules_in_program)
-                 scan_start = pxdb_header.globals;
-               else
-                 scan_start = 0;
-             }
-
+       /* elz: quick_traverse returns true if it found
+          some modules in the main source file, other
+          than those in end.c
+          In C and C++, all the files have MODULES entries
+          in the LNTT, and the quick table traverse is all 
+          based on finding these MODULES entries. Without 
+          those it cannot work. 
+          It happens that F77 programs don't have MODULES
+          so the quick traverse gets confused. F90 programs
+          have modules, and the quick method still works.
+          So, if modules (other than those in end.c) are
+          not found we give up on the quick table stuff, 
+          and fall back on the slower method  */
+       found_modules_in_program = hpread_quick_traverse (objfile,
+                                                         GNTT (objfile),
+                                                         VT (objfile),
+                                                         &pxdb_header);
+
+       discard_cleanups (old_chain);
+
+       /* Set up to scan the global section of the LNTT.
+
+          This field is not always correct: if there are
+          no globals, it will point to the last record in
+          the regular LNTT, which is usually an END MODULE.
+
+          Since it might happen that there could be a file
+          with just one global record, there's no way to
+          tell other than by looking at the record, so that's
+          done below. */
+       if (found_modules_in_program)
+         scan_start = pxdb_header.globals;
+      }
 #ifdef DUMPING
-           else
-             {
-               if (dumping)
-                 printf ("\nGoing on to old method for %s\n", objfile->name);
-             }
-#endif
-
-         }                     /* End of new method code */
-      }                                /* end of if pxdb exists */
-    /* elz: if pxdb does not exists on the system, then scan the whole debug info
-       Actually this will never be reached because we error out in case there 
-       is no pxdb on the system. It turns out that the debug info cannot be
-       handled the same way as after bxdb has been run, and gdb gets very 
-       very confused. Ileave this in anyway, in case one day we want to 
-       support non pxdb-ed files. */
     else
-      scan_start = 0;
-
-    bfd_close (abfd);          /* close the bfd we opened to check for pxdb */
-
-  }                            /* end of ifdef QUICK_LOOK_UP */
-#else
-  scan_start = 0;              /* if we don't want quick lookup tables start
-                                  from the beginning */
+      {
+       if (dumping)
+         printf ("\nGoing on to old method for %s\n", objfile->name);
+      }
 #endif
+  }
+#endif /* QUICK_LOOK_UP */
 
   /* Make two passes, one over the GNTT symbols, the other for the
      LNTT symbols.
@@ -1809,7 +1733,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline)
                       ignore it and be done! */
                    continue;
                  }
-#endif
+#endif /* QUICK_LOOK_UP */
 
                /* A source file of some kind.  Note this may simply
                   be an included file.  */
@@ -1886,11 +1810,11 @@ hpread_build_psymtabs (objfile, section_offsets, mainline)
                  past_first_source_file = 1;
 
                valu = hpread_get_textlow (i, hp_symnum, objfile, symcount);
-               valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
-               pst = hpread_start_psymtab (objfile, section_offsets,
+               valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+               pst = hpread_start_psymtab (objfile,
                                            namestring, valu,
                                            (hp_symnum
-                                            * sizeof (struct dntt_type_block)),
+                                        * sizeof (struct dntt_type_block)),
                                            objfile->global_psymbols.next,
                                            objfile->static_psymbols.next);
                texthigh = valu;
@@ -1920,13 +1844,13 @@ hpread_build_psymtabs (objfile, section_offsets, mainline)
              /* Now begin a new module and a new psymtab for it */
              SET_NAMESTRING (dn_bufp, &namestring, objfile);
              valu = hpread_get_textlow (i, hp_symnum, objfile, symcount);
-             valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+             valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
              if (!pst)
                {
-                 pst = hpread_start_psymtab (objfile, section_offsets,
+                 pst = hpread_start_psymtab (objfile,
                                              namestring, valu,
                                              (hp_symnum
-                                              * sizeof (struct dntt_type_block)),
+                                        * sizeof (struct dntt_type_block)),
                                              objfile->global_psymbols.next,
                                              objfile->static_psymbols.next);
                  texthigh = valu;
@@ -1938,12 +1862,12 @@ hpread_build_psymtabs (objfile, section_offsets, mainline)
            case DNTT_TYPE_ENTRY:
              /* The beginning of a function.  DNTT_TYPE_ENTRY may also denote
                 a secondary entry point.  */
-             valu = dn_bufp->dfunc.hiaddr + ANOFFSET (section_offsets,
-                                                      SECT_OFF_TEXT);
+             valu = dn_bufp->dfunc.hiaddr + ANOFFSET (objfile->section_offsets,
+                                                      SECT_OFF_TEXT (objfile));
              if (valu > texthigh)
                texthigh = valu;
              valu = dn_bufp->dfunc.lowaddr +
-               ANOFFSET (section_offsets, SECT_OFF_TEXT);
+               ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
              SET_NAMESTRING (dn_bufp, &namestring, objfile);
              if (dn_bufp->dfunc.global)
                add_psymbol_to_list (namestring, strlen (namestring),
@@ -1959,12 +1883,12 @@ hpread_build_psymtabs (objfile, section_offsets, mainline)
              continue;
 
            case DNTT_TYPE_DOC_FUNCTION:
-             valu = dn_bufp->ddocfunc.hiaddr + ANOFFSET (section_offsets,
-                                                         SECT_OFF_TEXT);
+             valu = dn_bufp->ddocfunc.hiaddr + ANOFFSET (objfile->section_offsets,
+                                                         SECT_OFF_TEXT (objfile));
              if (valu > texthigh)
                texthigh = valu;
              valu = dn_bufp->ddocfunc.lowaddr +
-               ANOFFSET (section_offsets, SECT_OFF_TEXT);
+               ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
              SET_NAMESTRING (dn_bufp, &namestring, objfile);
              if (dn_bufp->ddocfunc.global)
                add_psymbol_to_list (namestring, strlen (namestring),
@@ -1997,7 +1921,8 @@ hpread_build_psymtabs (objfile, section_offsets, mainline)
                     ignore it and be done! */
                  continue;
                }
-#endif
+#endif /* QUICK_LOOK_UP */
+
              /* Scope block begin/end.  We only care about function
                 and file blocks right now.  */
 
@@ -2041,19 +1966,19 @@ hpread_build_psymtabs (objfile, section_offsets, mainline)
                SET_NAMESTRING (dn_bufp, &namestring, objfile);
                if (!pst)
                  {
-                   pst = hpread_start_psymtab (objfile, section_offsets,
+                   pst = hpread_start_psymtab (objfile,
                                                "globals", 0,
                                                (hp_symnum
-                                                * sizeof (struct dntt_type_block)),
-                                               objfile->global_psymbols.next,
-                                               objfile->static_psymbols.next);
+                                        * sizeof (struct dntt_type_block)),
+                                             objfile->global_psymbols.next,
+                                            objfile->static_psymbols.next);
                  }
 
                /* Compute address of the data symbol */
                valu = dn_bufp->dsvar.location;
                /* Relocate in case it's in a shared library */
                if (storage == LOC_STATIC)
-                 valu += ANOFFSET (section_offsets, SECT_OFF_DATA);
+                 valu += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
 
                /* Luckily, dvar, svar, typedef, and tagdef all
                   have their "global" bit in the same place, so it works
@@ -2104,7 +2029,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline)
                                                 VAR_NAMESPACE, storage,
                                                 &objfile->global_psymbols,
                                                 dn_bufp->dsvar.location,
-                                                0, language_unknown, objfile);
+                                             0, language_unknown, objfile);
                          }
                        else
                          {
@@ -2112,7 +2037,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline)
                                                 VAR_NAMESPACE, storage,
                                                 &objfile->static_psymbols,
                                                 dn_bufp->dsvar.location,
-                                                0, language_unknown, objfile);
+                                             0, language_unknown, objfile);
                          }
                      }
                  }
@@ -2125,10 +2050,10 @@ hpread_build_psymtabs (objfile, section_offsets, mainline)
              SET_NAMESTRING (dn_bufp, &namestring, objfile);
              if (!pst)
                {
-                 pst = hpread_start_psymtab (objfile, section_offsets,
+                 pst = hpread_start_psymtab (objfile,
                                              "globals", 0,
                                              (hp_symnum
-                                              * sizeof (struct dntt_type_block)),
+                                        * sizeof (struct dntt_type_block)),
                                              objfile->global_psymbols.next,
                                              objfile->static_psymbols.next);
                }
@@ -2268,20 +2193,19 @@ hpread_get_textlow (global, index, objfile, symcount)
    (normal). */
 
 static struct partial_symtab *
-hpread_start_psymtab (objfile, section_offsets,
+hpread_start_psymtab (objfile,
                      filename, textlow, ldsymoff, global_syms, static_syms)
      struct objfile *objfile;
-     struct section_offsets *section_offsets;
      char *filename;
      CORE_ADDR textlow;
      int ldsymoff;
      struct partial_symbol **global_syms;
      struct partial_symbol **static_syms;
 {
-  int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT);
+  int offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
   extern void hpread_psymtab_to_symtab ();
   struct partial_symtab *result =
-  start_psymtab_common (objfile, section_offsets,
+  start_psymtab_common (objfile, objfile->section_offsets,
                        filename, textlow, global_syms, static_syms);
 
   result->textlow += offset;
@@ -2316,7 +2240,7 @@ hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
 {
   int i;
   struct objfile *objfile = pst->objfile;
-  int offset = ANOFFSET (pst->section_offsets, SECT_OFF_TEXT);
+  int offset = ANOFFSET (pst->section_offsets, SECT_OFF_TEXT (objfile));
 
 #ifdef DUMPING
   /* Turn on to see what kind of a psymtab we've built. */
@@ -2352,7 +2276,7 @@ hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
     {
       pst->dependencies = (struct partial_symtab **)
        obstack_alloc (&objfile->psymbol_obstack,
-                      number_dependencies * sizeof (struct partial_symtab *));
+                   number_dependencies * sizeof (struct partial_symtab *));
       memcpy (pst->dependencies, dependency_list,
              number_dependencies * sizeof (struct partial_symtab *));
     }
@@ -2433,5 +2357,3 @@ hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
 ***c - basic - offset:4
 *** End:
 #endif
-
-
This page took 0.036033 seconds and 4 git commands to generate.