2012-02-24 Luis Machado <lgustavo@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / xcoffread.c
index a794f61643f7de265c4c623b2a9e663ea0729cd1..86ae8fb188a058900717872715518c6e10d2c49b 100644 (file)
@@ -1,7 +1,5 @@
 /* Read AIX xcoff symbol tables and convert to internal format, for GDB.
-   Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009,
-   2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1986-2004, 2007-2012 Free Software Foundation, Inc.
    Derived from coffread.c, dbxread.c, and a lot of hacking.
    Contributed by IBM Corporation.
 
@@ -152,6 +150,24 @@ struct coff_symfile_info
     CORE_ADDR toc_offset;
   };
 
+/* XCOFF names for dwarf sections.  There is no compressed sections.  */
+
+static const struct dwarf2_debug_sections dwarf2_xcoff_names = {
+  { ".dwinfo", NULL },
+  { ".dwabrev", NULL },
+  { ".dwline", NULL },
+  { ".dwloc", NULL },
+  { NULL, NULL }, /* debug_macinfo */
+  { NULL, NULL }, /* debug_macro */
+  { ".dwstr", NULL },
+  { ".dwrnges", NULL },
+  { NULL, NULL }, /* debug_types */
+  { ".dwframe", NULL },
+  { NULL, NULL }, /* eh_frame */
+  { NULL, NULL }, /* gdb_index */
+  23
+};
+
 static void
 bf_notfound_complaint (void)
 {
@@ -757,6 +773,10 @@ return_after_cleanup:
 static void
 aix_process_linenos (void)
 {
+  /* There is no linenos to read if there are only dwarf info.  */
+  if (this_symtab_psymtab == NULL)
+    return;
+
   /* Process line numbers and enter them into line vector.  */
   process_linenos (last_source_start_addr, cur_src_end_addr);
 }
@@ -862,7 +882,7 @@ enter_line_range (struct subfile *subfile, unsigned beginoffset,
 
 #define        RECORD_MINIMAL_SYMBOL(NAME, ADDR, TYPE, SECTION, OBJFILE) \
 {                                              \
-  char *namestr;                               \
+  const char *namestr;                         \
                                                \
   namestr = (NAME);                            \
   if (namestr[0] == '.') ++namestr;            \
@@ -944,7 +964,7 @@ read_xcoff_symtab (struct partial_symtab *pst)
     ((struct coff_symfile_info *) objfile->deprecated_sym_private)->strtbl;
   char *debugsec =
     ((struct coff_symfile_info *) objfile->deprecated_sym_private)->debugsec;
-  char *debugfmt = bfd_xcoff_is_xcoff64 (abfd) ? "XCOFF64" : "XCOFF";
+  const char *debugfmt = bfd_xcoff_is_xcoff64 (abfd) ? "XCOFF64" : "XCOFF";
 
   struct internal_syment symbol[1];
   union internal_auxent main_aux;
@@ -961,12 +981,12 @@ read_xcoff_symtab (struct partial_symtab *pst)
   struct coff_symbol fcn_stab_saved = { 0 };
 
   /* fcn_cs_saved is global because process_xcoff_symbol needs it.  */
-  union internal_auxent fcn_aux_saved;
+  union internal_auxent fcn_aux_saved = main_aux;
   struct context_stack *new;
 
   char *filestring = " _start_ ";      /* Name of the current file.  */
 
-  char *last_csect_name;       /* Last seen csect's name and value.  */
+  const char *last_csect_name; /* Last seen csect's name and value.  */
   CORE_ADDR last_csect_val;
   int last_csect_sec;
 
@@ -1585,7 +1605,11 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
             where we need to, which is not necessarily super-clean,
             but seems workable enough.  */
 
-         if (*name == ':' || (pp = (char *) strchr (name, ':')) == NULL)
+         if (*name == ':')
+           return NULL;
+
+         pp = strchr (name, ':');
+         if (pp == NULL)
            return NULL;
 
          ++pp;
@@ -1906,6 +1930,8 @@ xcoff_symfile_finish (struct objfile *objfile)
       inclTable = NULL;
     }
   inclIndx = inclLength = inclDepth = 0;
+
+  dwarf2_free_objfile (objfile);
 }
 
 
@@ -1963,10 +1989,6 @@ init_stringtab (bfd *abfd, file_ptr offset, struct objfile *objfile)
    for the psymtab.  */
 static unsigned int first_fun_line_offset;
 
-static struct partial_symtab *xcoff_start_psymtab
-  (struct objfile *, char *, int,
-   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.
 
@@ -1975,7 +1997,8 @@ static struct partial_symtab *xcoff_start_psymtab
    (normal).  */
 
 static struct partial_symtab *
-xcoff_start_psymtab (struct objfile *objfile, char *filename, int first_symnum,
+xcoff_start_psymtab (struct objfile *objfile,
+                    const char *filename, int first_symnum,
                     struct partial_symbol **global_syms,
                     struct partial_symbol **static_syms)
 {
@@ -1997,10 +2020,6 @@ xcoff_start_psymtab (struct objfile *objfile, char *filename, int first_symnum,
   return result;
 }
 
-static struct partial_symtab *xcoff_end_psymtab
-  (struct partial_symtab *, char **, int, 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.
 
@@ -2010,7 +2029,7 @@ static struct partial_symtab *xcoff_end_psymtab
    are the information for includes and dependencies.  */
 
 static struct partial_symtab *
-xcoff_end_psymtab (struct partial_symtab *pst, char **include_list,
+xcoff_end_psymtab (struct partial_symtab *pst, const char **include_list,
                   int num_includes, int capping_symbol_number,
                   struct partial_symtab **dependency_list,
                   int number_dependencies, int textlow_not_set)
@@ -2093,17 +2112,13 @@ xcoff_end_psymtab (struct partial_symtab *pst, char **include_list,
   return pst;
 }
 
-static void swap_sym (struct internal_syment *,
-                     union internal_auxent *, char **, char **,
-                     unsigned int *, struct objfile *);
-
 /* Swap raw symbol at *RAW and put the name in *NAME, the symbol in
    *SYMBOL, the first auxent in *AUX.  Advance *RAW and *SYMNUMP over
    the symbol and its auxents.  */
 
 static void
 swap_sym (struct internal_syment *symbol, union internal_auxent *aux,
-         char **name, char **raw, unsigned int *symnump,
+         const char **name, char **raw, unsigned int *symnump,
          struct objfile *objfile)
 {
   bfd_coff_swap_sym_in (objfile->obfd, *raw, symbol);
@@ -2163,9 +2178,9 @@ scan_xcoff_symtab (struct objfile *objfile)
 {
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   CORE_ADDR toc_offset = 0;    /* toc offset value in data section.  */
-  char *filestring = NULL;
+  const char *filestring = NULL;
 
-  char *namestring;
+  const char *namestring;
   int past_first_source_file = 0;
   bfd *abfd;
   asection *bfd_sect;
@@ -2175,7 +2190,7 @@ scan_xcoff_symtab (struct objfile *objfile)
   struct partial_symtab *pst;
 
   /* List of current psymtab's include files.  */
-  char **psymtab_include_list;
+  const char **psymtab_include_list;
   int includes_allocated;
   int includes_used;
 
@@ -2188,7 +2203,7 @@ scan_xcoff_symtab (struct objfile *objfile)
   union internal_auxent main_aux[5];
   unsigned int ssymnum;
 
-  char *last_csect_name = NULL;        /* Last seen csect's name and value.  */
+  const char *last_csect_name = NULL; /* Last seen csect's name and value.  */
   CORE_ADDR last_csect_val = 0;
   int last_csect_sec = 0;
   int misc_func_recorded = 0;  /* true if any misc. function.  */
@@ -2198,8 +2213,8 @@ scan_xcoff_symtab (struct objfile *objfile)
 
   includes_allocated = 30;
   includes_used = 0;
-  psymtab_include_list = (char **) alloca (includes_allocated *
-                                          sizeof (char *));
+  psymtab_include_list = (const char **) alloca (includes_allocated *
+                                                sizeof (const char *));
 
   dependencies_allocated = 30;
   dependencies_used = 0;
@@ -2593,13 +2608,13 @@ scan_xcoff_symtab (struct objfile *objfile)
            psymtab_include_list[includes_used++] = namestring;
            if (includes_used >= includes_allocated)
              {
-               char **orig = psymtab_include_list;
+               const char **orig = psymtab_include_list;
 
-               psymtab_include_list = (char **)
+               psymtab_include_list = (const char **)
                  alloca ((includes_allocated *= 2) *
-                         sizeof (char *));
+                         sizeof (const char *));
                memcpy (psymtab_include_list, orig,
-                       includes_used * sizeof (char *));
+                       includes_used * sizeof (const char *));
              }
            continue;
          }
@@ -2619,7 +2634,7 @@ scan_xcoff_symtab (struct objfile *objfile)
            swap_sym (&symbol, &main_aux[0], &namestring, &sraw_symbol,
                      &ssymnum, objfile);
 
-           p = (char *) strchr (namestring, ':');
+           p = strchr (namestring, ':');
            if (!p)
              continue;                 /* Not a debugging symbol.   */
 
@@ -3018,6 +3033,13 @@ xcoff_initial_scan (struct objfile *objfile, int symfile_flags)
 
   install_minimal_symbols (objfile);
 
+  /* DWARF2 sections.  */
+
+  if (dwarf2_has_info (objfile, &dwarf2_xcoff_names))
+    dwarf2_build_psymtabs (objfile);
+
+  dwarf2_build_frame_info (objfile);
+
   do_cleanups (back_to);
 }
 \f
@@ -3084,6 +3106,7 @@ static const struct sym_fns xcoff_sym_fns =
   xcoff_new_init,              /* init anything gbl to entire symtab */
   xcoff_symfile_init,          /* read initial info, setup for sym_read() */
   xcoff_initial_scan,          /* read a symbol file into symtab */
+  NULL,                                /* sym_read_psymbols */
   xcoff_symfile_finish,                /* finished with file, cleanup */
   xcoff_symfile_offsets,       /* xlate offsets ext->int form */
   default_symfile_segments,    /* Get segment information from a file.  */
This page took 0.050936 seconds and 4 git commands to generate.