* corelow.c, exec.c, inftarg.c, m3-nat.c, op50-rom.c, procfs.c,
[deliverable/binutils-gdb.git] / gdb / xcoffread.c
index 50a3e29125c9b043ae38e4222d97fd91947785a7..0cb2f3a6e2055076a0191b7cc34cdb6c86b0bc1b 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
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994
             Free Software Foundation, Inc.
    Derived from coffread.c, dbxread.c, and a lot of hacking.
    Contributed by IBM Corporation.
@@ -400,6 +400,7 @@ static int    inclIndx;                     /* last entry to table */
 static int       inclLength;                   /* table length */
 static int       inclDepth;                    /* nested include depth */
 
+static void allocate_include_entry PARAMS ((void));
 
 static void
 record_include_begin (cs)
@@ -418,27 +419,12 @@ struct coff_symbol *cs;
     }
   ++inclDepth;
 
-  /* allocate an include file, or make room for the new entry */
-  if (inclLength == 0) {
-    inclTable = (InclTable*) 
-       xmalloc (sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
-    memset (inclTable, '\0', sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
-    inclLength = INITIAL_INCLUDE_TABLE_LENGTH;
-    inclIndx = 0;
-  }
-  else if (inclIndx >= inclLength) {
-    inclLength += INITIAL_INCLUDE_TABLE_LENGTH;
-    inclTable = (InclTable*) 
-       xrealloc (inclTable, sizeof (InclTable) * inclLength);
-    memset (inclTable+inclLength-INITIAL_INCLUDE_TABLE_LENGTH, 
-                       '\0', sizeof (InclTable)*INITIAL_INCLUDE_TABLE_LENGTH);
-  }
+  allocate_include_entry ();
 
   inclTable [inclIndx].name  = cs->c_name;
   inclTable [inclIndx].begin = cs->c_value;
 }
 
-
 static void
 record_include_end (cs)
 struct coff_symbol *cs;
@@ -451,6 +437,8 @@ struct coff_symbol *cs;
       complain (&msg);
     }
 
+  allocate_include_entry ();
+
   pTbl = &inclTable [inclIndx];
   pTbl->end = cs->c_value;
 
@@ -458,9 +446,30 @@ struct coff_symbol *cs;
   ++inclIndx;
 }
 
+static void
+allocate_include_entry ()
+{
+  if (inclTable == NULL)
+    {
+      inclTable = (InclTable *) 
+       xmalloc (sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
+      memset (inclTable,
+             '\0', sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
+      inclLength = INITIAL_INCLUDE_TABLE_LENGTH;
+      inclIndx = 0;
+    }
+  else if (inclIndx >= inclLength)
+    {
+      inclLength += INITIAL_INCLUDE_TABLE_LENGTH;
+      inclTable = (InclTable *) 
+       xrealloc (inclTable, sizeof (InclTable) * inclLength);
+      memset (inclTable + inclLength - INITIAL_INCLUDE_TABLE_LENGTH, 
+             '\0', sizeof (InclTable)*INITIAL_INCLUDE_TABLE_LENGTH);
+    }
+}
 
-/* given the start and end addresses of a compilation unit (or a csect, at times)
-   process its lines and create appropriate line vectors. */
+/* given the start and end addresses of a compilation unit (or a csect,
+   at times) process its lines and create appropriate line vectors. */
 
 static void
 process_linenos (start, end)
@@ -1273,11 +1282,12 @@ read_xcoff_symtab (objfile, nsyms)
          break;                        /* switch CSECT_SCLAS() */
 
        case XTY_LD :
-         
-         /* a function entry point. */
-         if (CSECT_SCLAS (&main_aux) == XMC_PR) {
 
-function_entry_point:
+         switch (CSECT_SCLAS (&main_aux))
+           {
+           case XMC_PR:
+             /* a function entry point. */
+           function_entry_point:
            RECORD_MINIMAL_SYMBOL (cs->c_name, cs->c_value, mst_text, 
                                   symname_alloced, cs->c_secnum, objfile);
 
@@ -1348,45 +1358,32 @@ function_entry_point:
                           cs->c_value + ptb->fsize, objfile);
            }
            continue;
-         }
-         /* shared library function trampoline code entry point. */
-         else if (CSECT_SCLAS (&main_aux) == XMC_GL) {
 
-           /* record trampoline code entries as mst_solib_trampoline symbol.
-              When we lookup mst symbols, we will choose mst_text over
-              mst_solib_trampoline. */
-
-#if 1
-           /* After the implementation of incremental loading of shared
-              libraries, we don't want to access trampoline entries. This
-              approach has a consequence of the necessity to bring the whole 
-              shared library at first, in order do anything with it (putting
-              breakpoints, using malloc, etc). On the other side, this is
-              consistient with gdb's behaviour on a SUN platform. */
-
-           /* Trying to prefer *real* function entry over its trampoline,
-              by assigning `mst_solib_trampoline' type to trampoline entries
-              fails.  Gdb treats those entries as chars. FIXME. */
-
-           /* Recording this entry is necessary. Single stepping relies on
-              this vector to get an idea about function address boundaries. */
-
-           prim_record_minimal_symbol_and_info
-             ("<trampoline>", cs->c_value, mst_solib_trampoline,
-              (char *)NULL, cs->c_secnum, objfile);
-#else
+         case XMC_GL:
+           /* shared library function trampoline code entry point. */
 
            /* record trampoline code entries as mst_solib_trampoline symbol.
               When we lookup mst symbols, we will choose mst_text over
               mst_solib_trampoline. */
-
            RECORD_MINIMAL_SYMBOL (cs->c_name, cs->c_value,
                                   mst_solib_trampoline,
-                                  symname_alloced, objfile);
-#endif
+                                  symname_alloced, cs->c_secnum, objfile);
+           continue;
+
+         case XMC_DS:
+           /* The symbols often have the same names as debug symbols for
+              functions, and confuse lookup_symbol.  */
            continue;
+
+         default:
+           /* xlc puts each variable in a separate csect, so we get
+              an XTY_SD for each variable.  But gcc puts several
+              variables in a csect, so that each variable only gets
+              an XTY_LD.  We still need to record them.  This will
+              typically be XMC_RW; I suspect XMC_RO and XMC_BS might
+              be possible too.  */
+           break;
          }
-         continue;
 
        default :               /* all other XTY_XXXs */
          break;
@@ -1432,7 +1429,11 @@ function_entry_point:
         the symbol is ".file" and an auxent exists, otherwise use the symbol
         itself.  Simple enough.  */
       if (!strcmp (cs->c_name, ".file") && cs->c_naux > 0)
-       filestring = coff_getfilename (&main_aux);
+       {
+         bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
+                               0, cs->c_naux, &main_aux);
+         filestring = coff_getfilename (&main_aux);
+       }
       else
        filestring = cs->c_name;
 
This page took 0.02647 seconds and 4 git commands to generate.