Make tui_default_win_height static
[deliverable/binutils-gdb.git] / gdb / coffread.c
index b89c0e2e8038030afc2e2fd7196920ca133f98a3..e24ab8d2f4bb50a133778f319ea2395a0408c4a5 100644 (file)
@@ -31,7 +31,6 @@
 #include "libcoff.h"           /* FIXME secret internal data from BFD */
 #include "objfiles.h"
 #include "buildsym-legacy.h"
-#include "gdb-stabs.h"
 #include "stabsread.h"
 #include "complaints.h"
 #include "target.h"
 #include "psymtab.h"
 #include "build-id.h"
 
-/* Key for COFF-associated data.  */
-
-static const struct objfile_data *coff_objfile_data_key;
-
 /* The objfile we are currently reading.  */
 
 static struct objfile *coffread_objfile;
 
 struct coff_symfile_info
   {
-    file_ptr min_lineno_offset;        /* Where in file lowest line#s are.  */
-    file_ptr max_lineno_offset;        /* 1+last byte of line#s in file.  */
+    file_ptr min_lineno_offset = 0;    /* Where in file lowest line#s are.  */
+    file_ptr max_lineno_offset = 0;    /* 1+last byte of line#s in file.  */
 
-    CORE_ADDR textaddr;                /* Addr of .text section.  */
-    unsigned int textsize;     /* Size of .text section.  */
+    CORE_ADDR textaddr = 0;            /* Addr of .text section.  */
+    unsigned int textsize = 0; /* Size of .text section.  */
     std::vector<asection *> *stabsects;        /* .stab sections.  */
-    asection *stabstrsect;     /* Section pointer for .stab section.  */
-    char *stabstrdata;
+    asection *stabstrsect = nullptr;   /* Section pointer for .stab section.  */
+    char *stabstrdata = nullptr;
   };
 
+/* Key for COFF-associated data.  */
+
+static const struct objfile_key<coff_symfile_info> coff_objfile_data_key;
+
 /* Translate an external name string into a user-visible name.  */
 #define        EXTERNAL_NAME(string, abfd) \
        (string[0] == bfd_get_symbol_leading_char (abfd) \
@@ -463,7 +462,8 @@ record_minimal_symbol (minimal_symbol_reader &reader,
       return NULL;
     }
 
-  return reader.record_with_info (cs->c_name, address, type, section);
+  return reader.record_full (cs->c_name, strlen (cs->c_name), true, address,
+                            type, section);
 }
 \f
 /* coff_symfile_init ()
@@ -483,16 +483,8 @@ record_minimal_symbol (minimal_symbol_reader &reader,
 static void
 coff_symfile_init (struct objfile *objfile)
 {
-  struct dbx_symfile_info *dbx;
-  struct coff_symfile_info *coff;
-
-  /* Allocate struct to keep track of stab reading.  */
-  dbx = XCNEW (struct dbx_symfile_info);
-  set_objfile_data (objfile, dbx_objfile_data_key, dbx);
-
   /* Allocate struct to keep track of the symfile.  */
-  coff = XCNEW (struct coff_symfile_info);
-  set_objfile_data (objfile, coff_objfile_data_key, coff);
+  coff_objfile_data_key.emplace (objfile);
 
   /* COFF objects may be reordered, so set OBJF_REORDERED.  If we
      find this causes a significant slowdown in gdb then we could
@@ -553,8 +545,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   int stringtab_offset;
   int stabstrsize;
   
-  info = (struct coff_symfile_info *) objfile_data (objfile,
-                                                   coff_objfile_data_key);
+  info = coff_objfile_data_key.get (objfile);
   symfile_bfd = abfd;          /* Kludge for swap routines.  */
 
   std::vector<asection *> stabsects;
@@ -1495,7 +1486,7 @@ patch_type (struct type *type, struct type *real_type)
 static void
 patch_opaque_types (struct symtab *s)
 {
-  struct block *b;
+  const struct block *b;
   struct block_iterator iter;
   struct symbol *real_sym;
 
@@ -1737,7 +1728,7 @@ process_coff_symbol (struct coff_symbol *cs,
                && *SYMBOL_LINKAGE_NAME (sym) != '~'
                && *SYMBOL_LINKAGE_NAME (sym) != '.')
              TYPE_NAME (SYMBOL_TYPE (sym)) =
-               concat (SYMBOL_LINKAGE_NAME (sym), (char *)NULL);
+               xstrdup (SYMBOL_LINKAGE_NAME (sym));
 
          add_symbol_to_list (sym, get_file_symbols ());
          break;
@@ -1793,11 +1784,9 @@ decode_type (struct coff_symbol *cs, unsigned int c_type,
          base_type = decode_type (cs, new_c_type, aux, objfile);
          index_type = objfile_type (objfile)->builtin_int;
          range_type
-           = create_static_range_type ((struct type *) NULL,
-                                       index_type, 0, n - 1);
+           = create_static_range_type (NULL, index_type, 0, n - 1);
          type =
-           create_array_type ((struct type *) NULL, 
-                              base_type, range_type);
+           create_array_type (NULL, base_type, range_type);
        }
       return type;
     }
@@ -2030,9 +2019,7 @@ coff_read_struct_type (int index, int length, int lastsym,
          list = newobj;
 
          /* Save the data.  */
-         list->field.name
-           = (const char *) obstack_copy0 (&objfile->objfile_obstack,
-                                           name, strlen (name));
+         list->field.name = obstack_strdup (&objfile->objfile_obstack, name);
          FIELD_TYPE (list->field) = decode_type (ms, ms->c_type,
                                                  &sub_aux, objfile);
          SET_FIELD_BITPOS (list->field, 8 * ms->c_value);
@@ -2048,9 +2035,7 @@ coff_read_struct_type (int index, int length, int lastsym,
          list = newobj;
 
          /* Save the data.  */
-         list->field.name
-           = (const char *) obstack_copy0 (&objfile->objfile_obstack,
-                                           name, strlen (name));
+         list->field.name = obstack_strdup (&objfile->objfile_obstack, name);
          FIELD_TYPE (list->field) = decode_type (ms, ms->c_type,
                                                  &sub_aux, objfile);
          SET_FIELD_BITPOS (list->field, ms->c_value);
@@ -2120,8 +2105,7 @@ coff_read_enum_type (int index, int length, int lastsym,
        case C_MOE:
          sym = allocate_symbol (objfile);
 
-         name = (char *) obstack_copy0 (&objfile->objfile_obstack, name,
-                                        strlen (name));
+         name = obstack_strdup (&objfile->objfile_obstack, name);
          SYMBOL_SET_LINKAGE_NAME (sym, name);
          SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
          SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
@@ -2210,22 +2194,11 @@ static const struct sym_fns coff_sym_fns =
   &psym_functions
 };
 
-/* Free the per-objfile COFF data.  */
-
-static void
-coff_free_info (struct objfile *objfile, void *arg)
-{
-  xfree (arg);
-}
-
 void
 _initialize_coffread (void)
 {
   add_symtab_fns (bfd_target_coff_flavour, &coff_sym_fns);
 
-  coff_objfile_data_key = register_objfile_data_with_cleanup (NULL,
-                                                             coff_free_info);
-
   coff_register_index
     = register_symbol_register_impl (LOC_REGISTER, &coff_register_funcs);
 }
This page took 0.025581 seconds and 4 git commands to generate.