]> Git Repo - binutils.git/blobdiff - gdb/xcoffread.c
PR 8511, keep new test cases
[binutils.git] / gdb / xcoffread.c
index b8c5ff1c48197c8c4b0348dc4fc758f0d8338e49..c4b868fe4cfd38e24f7884683c1e6bf784f7d6d9 100644 (file)
@@ -1,5 +1,5 @@
 /* Read AIX xcoff symbol tables and convert to internal format, for GDB.
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
             Free Software Foundation, Inc.
    Derived from coffread.c, dbxread.c, and a lot of hacking.
    Contributed by IBM Corporation.
@@ -20,12 +20,6 @@ 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.  */
 
-/* RS/6000 and PowerPC only:
-   Needs xcoff_add_toc_to_loadinfo and xcoff_init_loadinfo in
-   rs6000-tdep.c from target.
-   However, if you define FAKING_RS6000, then this code will link with
-   any target.  */
-
 #include "defs.h"
 #include "bfd.h"
 
@@ -94,6 +88,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 /* This is output from LD.  */
 #define N_SETV 0x1C            /* Pointer to set vector in data area.  */
+
+/* Hook for recording the toc offset value of a symbol table into
+   the ldinfo structure. */
+
+void (*xcoff_add_toc_to_loadinfo_hook) PARAMS ((unsigned long)) = NULL;
+
+/* Hook for recording how to call xcoff_init_loadinfo for a native
+   rs6000 config only. */
+
+void (*xcoff_init_loadinfo_hook) PARAMS ((void)) = NULL;
+
 \f
 /* We put a pointer to this structure in the read_symtab_private field
    of the psymtab.  */
@@ -194,6 +199,18 @@ static struct complaint ef_complaint =
 static struct complaint eb_complaint = 
   {"Mismatched .eb symbol ignored starting at symnum %d", 0, 0};
 
+static void
+xcoff_initial_scan PARAMS ((struct objfile *, struct section_offsets *, int));
+
+static void
+scan_xcoff_symtab PARAMS ((struct section_offsets *, struct objfile *));
+
+static char *
+xcoff_next_symbol_text PARAMS ((struct objfile *));
+
+static void
+record_include_begin PARAMS ((struct coff_symbol *));
+
 static void
 enter_line_range PARAMS ((struct subfile *, unsigned, unsigned,
                          CORE_ADDR, CORE_ADDR, unsigned *));
@@ -234,8 +251,22 @@ process_xcoff_symbol PARAMS ((struct coff_symbol *, struct objfile *));
 static void
 read_xcoff_symtab PARAMS ((struct partial_symtab *));
 
+#if 0
 static void
 add_stab_to_list PARAMS ((char *, struct pending_stabs **));
+#endif
+
+static int
+compare_lte PARAMS ((const void *, const void *));
+
+static struct linetable *
+arrange_linetable PARAMS ((struct linetable *));
+
+static void
+record_include_end PARAMS ((struct coff_symbol *));
+
+static void
+process_linenos PARAMS ((CORE_ADDR, CORE_ADDR));
 
 \f
 /* Translate from a COFF section number (target_index) to a SECT_OFF_*
@@ -283,6 +314,8 @@ secnum_to_section (secnum, objfile)
 \f
 /* add a given stab string into given stab vector. */
 
+#if 0
+
 static void
 add_stab_to_list (stabname, stabvector)
 char *stabname;
@@ -303,6 +336,9 @@ struct pending_stabs **stabvector;
   }
   (*stabvector)->stab [(*stabvector)->count++] = stabname;
 }
+
+#endif
+
 \f
 /* Linenos are processed on a file-by-file basis.
 
@@ -359,14 +395,17 @@ struct pending_stabs **stabvector;
 /* compare line table entry addresses. */
 
 static int
-compare_lte (lte1, lte2)
-     struct linetable_entry *lte1, *lte2;
+compare_lte (lte1p, lte2p)
+     const void *lte1p;
+     const void *lte2p;
 {
+  struct linetable_entry *lte1 = (struct linetable_entry *) lte1p;
+  struct linetable_entry *lte2 = (struct linetable_entry *) lte2p;
   return lte1->pc - lte2->pc;
 }
 
-/* Give a line table with function entries are marked, arrange its functions
-   in assending order and strip off function entry markers and return it in
+/* Given a line table with function entries are marked, arrange its functions
+   in ascending order and strip off function entry markers and return it in
    a newly created table. If the old one is good enough, return the old one. */
 /* FIXME: I think all this stuff can be replaced by just passing
    sort_linevec = 1 to end_symtab.  */
@@ -847,14 +886,17 @@ static char *raw_symbol;
 
 /* This is the function which stabsread.c calls to get symbol
    continuations.  */
+
 static char *
-xcoff_next_symbol_text ()
+xcoff_next_symbol_text (objfile)
+     struct objfile *objfile;
 {
   struct internal_syment symbol;
   static struct complaint msg =
     {"Unexpected symbol continuation", 0, 0};
   char *retval;
-  struct objfile *objfile = this_symtab_psymtab->objfile;
+  /* FIXME: is this the same as the passed arg? */
+  objfile = this_symtab_psymtab->objfile;
 
   bfd_coff_swap_sym_in (objfile->obfd, raw_symbol, &symbol);
   if (symbol.n_zeroes)
@@ -1021,7 +1063,7 @@ read_xcoff_symtab (pst)
          if (last_source_file)
            {
              pst->symtab =
-               end_symtab (cur_src_end_addr, 1, 0, objfile, SECT_OFF_TEXT);
+               end_symtab (cur_src_end_addr, objfile, SECT_OFF_TEXT);
              end_stabs ();
            }
 
@@ -1085,8 +1127,7 @@ read_xcoff_symtab (pst)
                        {
                          complete_symtab (filestring, file_start_addr);
                          cur_src_end_addr = file_end_addr;
-                         end_symtab (file_end_addr, 1, 0, objfile,
-                                     SECT_OFF_TEXT);
+                         end_symtab (file_end_addr, objfile, SECT_OFF_TEXT);
                          end_stabs ();
                          start_stabs ();
                          /* Give all csects for this source file the same
@@ -1201,7 +1242,7 @@ read_xcoff_symtab (pst)
 
          complete_symtab (filestring, file_start_addr);
          cur_src_end_addr = file_end_addr;
-         end_symtab (file_end_addr, 1, 0, objfile, SECT_OFF_TEXT);
+         end_symtab (file_end_addr, objfile, SECT_OFF_TEXT);
          end_stabs ();
 
          /* XCOFF, according to the AIX 3.2 documentation, puts the filename
@@ -1391,7 +1432,7 @@ read_xcoff_symtab (pst)
 
       complete_symtab (filestring, file_start_addr);
       cur_src_end_addr = file_end_addr;
-      s = end_symtab (file_end_addr, 1, 0, objfile, SECT_OFF_TEXT);
+      s = end_symtab (file_end_addr, objfile, SECT_OFF_TEXT);
       /* When reading symbols for the last C_FILE of the objfile, try
          to make sure that we set pst->symtab to the symtab for the
          file, not to the _globals_ symtab.  I'm not sure whether this
@@ -1409,7 +1450,7 @@ read_xcoff_symtab (pst)
   
  
 #define        SYMNAME_ALLOC(NAME, ALLOCED)    \
-  (ALLOCED) ? (NAME) : obstack_copy0 (&objfile->symbol_obstack, (NAME), strlen (NAME));
+  (ALLOCED) ? (NAME) : obsavestring ((NAME), strlen (NAME), &objfile->symbol_obstack);
 
 
 static struct type *func_symbol_type;
@@ -1842,6 +1883,12 @@ xcoff_symfile_init (objfile)
   /* Allocate struct to keep track of the symfile */
   objfile -> sym_private = xmmalloc (objfile -> md,
                                     sizeof (struct coff_symfile_info));
+
+  /* XCOFF objects may be reordered, so set OBJF_REORDERED.  If we
+     find this causes a significant slowdown in gdb then we could
+     set it in the debug symbol readers only when necessary.  */
+  objfile->flags |= OBJF_REORDERED;
+
   init_entry_point_info (objfile);
 }
 
@@ -1882,7 +1929,7 @@ init_stringtab (abfd, offset, objfile)
 
   ((struct coff_symfile_info *)objfile->sym_private)->strtbl = NULL;
 
-  if (bfd_seek (abfd, offset, L_SET) < 0)
+  if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     error ("cannot seek to string table in %s: %s",
           bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ()));
 
@@ -1926,7 +1973,7 @@ static unsigned int first_fun_line_offset;
 
 static struct partial_symtab *xcoff_start_psymtab
   PARAMS ((struct objfile *, struct section_offsets *, char *, int,
-          struct partial_symbol *, struct partial_symbol *));
+          struct partial_symbol **, struct partial_symbol **));
 
 /* Allocate and partially fill a partial symtab.  It will be
    completely filled at the end of the symbol list.
@@ -1942,8 +1989,8 @@ xcoff_start_psymtab (objfile, section_offsets,
      struct section_offsets *section_offsets;
      char *filename;
      int first_symnum;
-     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,
@@ -1965,7 +2012,7 @@ xcoff_start_psymtab (objfile, section_offsets,
 
 static struct partial_symtab *xcoff_end_psymtab
   PARAMS ((struct partial_symtab *, char **, int, int,
-          struct partial_symtab **, int));
+          struct partial_symtab **, int, int));
 
 /* Close off the current usage of PST.  
    Returns PST, or NULL if the partial symtab was empty and thrown away.
@@ -1977,13 +2024,14 @@ static struct partial_symtab *xcoff_end_psymtab
 
 static struct partial_symtab *
 xcoff_end_psymtab (pst, include_list, num_includes, capping_symbol_number,
-                  dependency_list, number_dependencies)
+                  dependency_list, number_dependencies, textlow_not_set)
      struct partial_symtab *pst;
      char **include_list;
      int num_includes;
      int capping_symbol_number;
      struct partial_symtab **dependency_list;
      int number_dependencies;
+     int textlow_not_set;
 {
   int i;
   struct objfile *objfile = pst -> objfile;
@@ -2176,6 +2224,7 @@ scan_xcoff_symtab (section_offsets, objfile)
   CORE_ADDR last_csect_val = 0;
   int last_csect_sec = 0;
   int  misc_func_recorded = 0;         /* true if any misc. function */
+  int textlow_not_set = 1;
 
   pst = (struct partial_symtab *) 0;
 
@@ -2265,10 +2314,9 @@ scan_xcoff_symtab (section_offsets, objfile)
                               each program csect, because their text
                               sections need not be adjacent.  */
                            xcoff_end_psymtab
-                             (pst, psymtab_include_list,
-                              includes_used,
-                              symnum_before,
-                              dependency_list, dependencies_used);
+                             (pst, psymtab_include_list, includes_used,
+                              symnum_before, dependency_list,
+                              dependencies_used, textlow_not_set);
                            includes_used = 0;
                            dependencies_used = 0;
                            /* Give all psymtabs for this source file the same
@@ -2430,8 +2478,8 @@ scan_xcoff_symtab (section_offsets, objfile)
            if (pst)
              {
                xcoff_end_psymtab (pst, psymtab_include_list, includes_used,
-                                  symnum_before,
-                                  dependency_list, dependencies_used);
+                                  symnum_before, dependency_list,
+                                  dependencies_used, textlow_not_set);
                includes_used = 0;
                dependencies_used = 0;
              }
@@ -2543,7 +2591,7 @@ scan_xcoff_symtab (section_offsets, objfile)
    called from DBXREAD_ONLY or N_SO code.  Likewise for the symnum
    variable.  */
 #define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms) 0
-#define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps)\
+#define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set)\
   do {} while (0)
 /* We have already set the namestring.  */
 #define SET_NAMESTRING() /* */
@@ -2555,17 +2603,16 @@ scan_xcoff_symtab (section_offsets, objfile)
   if (pst)
     {
       xcoff_end_psymtab (pst, psymtab_include_list, includes_used,
-                        ssymnum,
-                        dependency_list, dependencies_used);
+                        ssymnum, dependency_list,
+                        dependencies_used, textlow_not_set);
     }
 
   /* Record the toc offset value of this symbol table into ldinfo structure.
      If no XMC_TC0 is found, toc_offset should be zero. Another place to obtain
      this information would be file auxiliary header. */
 
-#ifndef FAKING_RS6000
-  xcoff_add_toc_to_loadinfo (toc_offset);
-#endif
+  if (xcoff_add_toc_to_loadinfo_hook != NULL)
+    (*xcoff_add_toc_to_loadinfo_hook) ((unsigned long) toc_offset);
 }
 
 /* Scan and build partial symbols for a symbol file.
@@ -2594,11 +2641,9 @@ xcoff_initial_scan (objfile, section_offsets, mainline)
   char *name;
   unsigned int size;
 
-#ifndef FAKING_RS6000
   /* Initialize load info structure. */
-  if (mainline)
-    xcoff_init_loadinfo ();
-#endif
+  if (mainline && xcoff_init_loadinfo_hook != NULL)
+    (*xcoff_init_loadinfo_hook) ();
 
   info = (struct coff_symfile_info *) objfile -> sym_private;
   symfile_bfd = abfd = objfile->obfd;
@@ -2648,7 +2693,7 @@ xcoff_initial_scan (objfile, section_offsets, mainline)
 
   /* Read the symbols.  We keep them in core because we will want to
      access them randomly in read_symbol*.  */
-  val = bfd_seek (abfd, symtab_offset, L_SET);
+  val = bfd_seek (abfd, symtab_offset, SEEK_SET);
   if (val < 0)
     error ("Error reading symbols from %s: %s",
           name, bfd_errmsg (bfd_get_error ()));
@@ -2673,7 +2718,7 @@ xcoff_initial_scan (objfile, section_offsets, mainline)
        include N_SLINE.  */
     init_psymbol_list (objfile, num_symbols);
 
-  pending_blocks = 0;
+  free_pending_blocks ();
   back_to = make_cleanup (really_free_pendings, 0);
 
   init_minimal_symbol_collection ();
This page took 0.037719 seconds and 4 git commands to generate.