use remote-utils facilities for baud_rate
[deliverable/binutils-gdb.git] / gdb / xcoffread.c
index 585a4f0687b354989672c22bdc6ff42d6f87ad42..c6a138aeaaabb91e3dabff58d2234c7154e29907 100644 (file)
@@ -56,12 +56,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 /* For interface with stabsread.c.  */
 #include "aout/stab_gnu.h"
 
-/* Define this if you want gdb to ignore typdef stabs. This was needed for
-   one of Transarc, to reduce the size of the symbol table. Types won't be
-   recognized, but tag names will be. */
-
-/* #define     NO_TYPEDEFS  1 */
-
 /* Simplified internal version of coff symbol table information */
 
 struct coff_symbol {
@@ -190,6 +184,9 @@ xcoff_symfile_offsets PARAMS ((struct objfile *, CORE_ADDR));
 static int
 init_lineno PARAMS ((bfd *, file_ptr, int));
 
+static void
+free_linetab PARAMS ((void));
+
 static void
 find_linenos PARAMS ((bfd *, sec_ptr, PTR));
 
@@ -298,6 +295,8 @@ compare_lte (lte1, lte2)
 /* 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
    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.  */
 
 static struct linetable *
 arrange_linetable (oldLineTb)
@@ -427,7 +426,7 @@ struct coff_symbol *cs;
   if (inclLength == 0) {
     inclTable = (InclTable*) 
        xmalloc (sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
-    bzero (inclTable, sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
+    memset (inclTable, '\0', sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
     inclLength = INITIAL_INCLUDE_TABLE_LENGTH;
     inclIndx = 0;
   }
@@ -435,8 +434,8 @@ struct coff_symbol *cs;
     inclLength += INITIAL_INCLUDE_TABLE_LENGTH;
     inclTable = (InclTable*) 
        xrealloc (inclTable, sizeof (InclTable) * inclLength);
-    bzero (inclTable+inclLength-INITIAL_INCLUDE_TABLE_LENGTH, 
-                       sizeof (InclTable)*INITIAL_INCLUDE_TABLE_LENGTH);
+    memset (inclTable+inclLength-INITIAL_INCLUDE_TABLE_LENGTH, 
+                       '\0', sizeof (InclTable)*INITIAL_INCLUDE_TABLE_LENGTH);
   }
 
   inclTable [inclIndx].name  = cs->c_name;
@@ -491,7 +490,7 @@ process_linenos (start, end)
   if (!(offset = first_fun_line_offset))
     goto return_after_cleanup;
 
-  bzero (&main_subfile, sizeof (main_subfile));
+  memset (&main_subfile, '\0', sizeof (main_subfile));
   first_fun_line_offset = 0;
 
   if (inclIndx == 0)
@@ -520,7 +519,7 @@ process_linenos (start, end)
       tmpSubfile = inclTable[ii].subfile = (struct subfile*) 
                                xmalloc (sizeof (struct subfile));
 
-      bzero (tmpSubfile, sizeof (struct subfile));
+      memset (tmpSubfile, '\0', sizeof (struct subfile));
       firstLine = &(inclTable[ii].funStartLine);
 
       /* enter include file's lines now. */
@@ -620,7 +619,7 @@ return_after_cleanup:
   inclIndx = 0;
 
   /* start with a fresh subfile structure for the next file. */
-  bzero (&main_subfile, sizeof (struct subfile));
+  memset (&main_subfile, '\0', sizeof (struct subfile));
 }
 
 void
@@ -718,7 +717,7 @@ retrieve_tracebackinfo (abfd, textsec, cs)
 
   int functionstart = cs->c_value - textsec->vma;
 
-  bzero (&tbInfo, sizeof (tbInfo));
+  memset (&tbInfo, '\0', sizeof (tbInfo));
 
   /* keep reading blocks of data from the text section, until finding a zero
      word and a traceback table. */
@@ -1163,14 +1162,16 @@ read_xcoff_symtab (objfile, nsyms)
            case XMC_PR :                       /* a `.text' csect.     */
              {
 
-               /* A program csect is seen.
-                
-                  We have to allocate one symbol table for each program csect. Normally
-                  gdb prefers one symtab for each compilation unit (CU). In case of AIX, one
-                  CU might include more than one prog csect, and they don't have to be
-                  adjacent in terms of the space they occupy in memory. Thus, one single
-                  CU might get fragmented in the memory and gdb's file start and end address
-                  approach does not work!  */
+               /* A program csect is seen.  We have to allocate one
+                  symbol table for each program csect.  Normally gdb
+                  prefers one symtab for each source file.  In case
+                  of AIX, one source file might include more than one
+                  [PR] csect, and they don't have to be adjacent in
+                  terms of the space they occupy in memory. Thus, one
+                  single source file might get fragmented in the
+                  memory and gdb's file start and end address
+                  approach does not work!  GCC (and I think xlc) seem
+                  to put all the code in the unnamed program csect.  */
 
                if (last_csect_name) {
 
@@ -1191,7 +1192,9 @@ read_xcoff_symtab (objfile, nsyms)
                              textsec->target_index);
                  end_stabs ();
                  start_stabs ();
-                 start_symtab ((char *)NULL, (char *)NULL, (CORE_ADDR)0);
+                 /* Give all csects for this source file the same
+                    name.  */
+                 start_symtab (filestring, (char *)NULL, (CORE_ADDR)0);
                }
 
                /* If this is the very first csect seen, basically `__start'. */
@@ -1554,7 +1557,7 @@ process_xcoff_symbol (cs, objfile)
   if (name[0] == '.')
     ++name;
 
-  bzero (sym, sizeof (struct symbol));
+  memset (sym, '\0', sizeof (struct symbol));
 
   /* default assumptions */
   SYMBOL_VALUE (sym) = cs->c_value;
@@ -1624,7 +1627,7 @@ process_xcoff_symbol (cs, objfile)
         /* FIXME: I believe this is to avoid a Sun-specific hack somewhere.
           Needs more investigation.  */
 
-       if (*name == ':' || (pp = (char *) index (name, ':')) == NULL)
+       if (*name == ':' || (pp = (char *) strchr(name, ':')) == NULL)
          return NULL;
 
        ++pp;
@@ -1819,6 +1822,8 @@ init_lineno (abfd, offset, size)
 {
   int val;
 
+  free_linetab ();
+
   if (bfd_seek(abfd, offset, L_SET) < 0)
     return -1;
 
@@ -1830,9 +1835,16 @@ init_lineno (abfd, offset, size)
 
   linetab_offset = offset;
   linetab_size = size;
-  make_cleanup (free, linetab);        /* Be sure it gets de-allocated. */
   return 0;
 }
+
+static void
+free_linetab ()
+{
+  if (linetab)
+    free (linetab);
+  linetab = NULL;
+}
 \f
 /* dbx allows the text of a symbol name to be continued into the
    next symbol name!  When such a continuation is encountered
@@ -1932,7 +1944,7 @@ init_stringtab(abfd, offset, objfile)
   if (strtbl == NULL)
     return -1;
 
-  bcopy(&length, strtbl, sizeof length);
+  memcpy(strtbl, &length, sizeof length);
   if (length == sizeof length)
     return 0;
 
@@ -1998,6 +2010,7 @@ xcoff_symfile_read (objfile, section_offset, mainline)
   bfd *abfd;
   struct coff_symfile_info *info;
   char *name;
+  struct cleanup *back_to = make_cleanup (null_cleanup, 0);
 
   info = (struct coff_symfile_info *) objfile -> sym_private;
   symfile_bfd = abfd = objfile->obfd;
@@ -2017,6 +2030,7 @@ xcoff_symfile_read (objfile, section_offset, mainline)
       && info->max_lineno_offset > info->min_lineno_offset) {
 
     /* only read in the line # table if one exists */
+    make_cleanup (free_linetab, 0);
     val = init_lineno(abfd, info->min_lineno_offset,
        (int) (info->max_lineno_offset - info->min_lineno_offset));
 
@@ -2068,6 +2082,8 @@ xcoff_symfile_read (objfile, section_offset, mainline)
      minimal symbols for this objfile. */
 
   install_minimal_symbols (objfile);
+
+  do_cleanups (back_to);
 }
 
 /* XCOFF-specific parsing routine for section offsets.  */
This page took 0.025376 seconds and 4 git commands to generate.