gdb: Make ldirname return a std::string
[deliverable/binutils-gdb.git] / gdb / stabsread.c
index 3bad6ac85c8182a48959d35ca578c24721dd42e9..14122021c63863ad3b096a0c823f3cfd0e21d161 100644 (file)
@@ -1,6 +1,6 @@
 /* Support routines for decoding "stabs" debugging information format.
 
-   Copyright (C) 1986-2016 Free Software Foundation, Inc.
+   Copyright (C) 1986-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* Support routines for reading and decoding debugging information in
-   the "stabs" format.  This format is used with many systems that use
-   the a.out object file format, as well as some systems that use
-   COFF or ELF where the stabs data is placed in a special section.
-   Avoid placing any object file format specific code in this file.  */
+   the "stabs" format.  This format is used by some systems that use
+   COFF or ELF where the stabs data is placed in a special section (as
+   well as with many old systems that used the a.out object file
+   format).  Avoid placing any object file format specific code in
+   this file.  */
 
 #include "defs.h"
 #include "bfd.h"
@@ -353,6 +354,24 @@ dbx_alloc_type (int typenums[2], struct objfile *objfile)
   return (*type_addr);
 }
 
+/* Allocate a floating-point type of size BITS.  */
+
+static struct type *
+dbx_init_float_type (struct objfile *objfile, int bits)
+{
+  struct gdbarch *gdbarch = get_objfile_arch (objfile);
+  const struct floatformat **format;
+  struct type *type;
+
+  format = gdbarch_floatformat_for_type (gdbarch, NULL, bits);
+  if (format)
+    type = init_float_type (objfile, bits, NULL, format);
+  else
+    type = init_type (objfile, TYPE_CODE_ERROR, bits / TARGET_CHAR_BIT, NULL);
+
+  return type;
+}
+
 /* for all the stabs in a given stab vector, build appropriate types 
    and fix their symbols in given symbol vector.  */
 
@@ -631,7 +650,6 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
   int deftype;
   int synonym = 0;
   int i;
-  char *new_name = NULL;
 
   /* We would like to eliminate nameless symbols, but keep their types.
      E.g. stab entry ":t10=*2" should produce a type 10, which is a pointer
@@ -715,6 +733,8 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
   else
     {
     normal:
+      std::string new_name;
+
       if (SYMBOL_LANGUAGE (sym) == language_cplus)
        {
          char *name = (char *) alloca (p - string + 1);
@@ -723,10 +743,11 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
          name[p - string] = '\0';
          new_name = cp_canonicalize_string (name);
        }
-      if (new_name != NULL)
+      if (!new_name.empty ())
        {
-         SYMBOL_SET_NAMES (sym, new_name, strlen (new_name), 1, objfile);
-         xfree (new_name);
+         SYMBOL_SET_NAMES (sym,
+                           new_name.c_str (), new_name.length (),
+                           1, objfile);
        }
       else
        SYMBOL_SET_NAMES (sym, string, p - string, 1, objfile);
@@ -1624,17 +1645,18 @@ again:
          type_name = NULL;
          if (current_subfile->language == language_cplus)
            {
-             char *new_name, *name = (char *) alloca (p - *pp + 1);
+             char *name = (char *) alloca (p - *pp + 1);
 
              memcpy (name, *pp, p - *pp);
              name[p - *pp] = '\0';
-             new_name = cp_canonicalize_string (name);
-             if (new_name != NULL)
+
+             std::string new_name = cp_canonicalize_string (name);
+             if (!new_name.empty ())
                {
                  type_name
                    = (char *) obstack_copy0 (&objfile->objfile_obstack,
-                                             new_name, strlen (new_name));
-                 xfree (new_name);
+                                             new_name.c_str (),
+                                             new_name.length ());
                }
            }
          if (type_name == NULL)
@@ -1772,7 +1794,8 @@ again:
 
     case '&':                  /* Reference to another type */
       type1 = read_type (pp, objfile);
-      type = make_reference_type (type1, dbx_lookup_type (typenums, objfile));
+      type = make_reference_type (type1, dbx_lookup_type (typenums, objfile),
+                                  TYPE_CODE_REF);
       break;
 
     case 'f':                  /* Function returning another type */
@@ -3847,11 +3870,11 @@ read_sun_floating_type (char **pp, int typenums[2], struct objfile *objfile)
   if (details == NF_COMPLEX || details == NF_COMPLEX16
       || details == NF_COMPLEX32)
     {
-      rettype = init_float_type (objfile, nbits / 2, NULL, NULL);
+      rettype = dbx_init_float_type (objfile, nbits / 2);
       return init_complex_type (objfile, NULL, rettype);
     }
 
-  return init_float_type (objfile, nbits, NULL, NULL);
+  return dbx_init_float_type (objfile, nbits);
 }
 
 /* Read a number from the string pointed to by *PP.
@@ -4138,7 +4161,7 @@ read_range_type (char **pp, int typenums[2], int type_size,
   if (n3 == 0 && n2 > 0)
     {
       struct type *float_type
-       = init_float_type (objfile, n2 * TARGET_CHAR_BIT, NULL, NULL);
+       = dbx_init_float_type (objfile, n2 * TARGET_CHAR_BIT);
 
       if (self_subrange)
        return init_complex_type (objfile, NULL, float_type);
This page took 0.025539 seconds and 4 git commands to generate.