]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - binutils/ieee.c
Updated soruces in binutils/* to compile cleanly with -Wc++-compat.
[thirdparty/binutils-gdb.git] / binutils / ieee.c
index 4ffd8f59eef21b56d50543c3a2356d5c9e465c7f..fd8374b335ddfe07cd42dd79e938437ca7901046 100644 (file)
@@ -1,13 +1,13 @@
 /* ieee.c -- Read and write IEEE-695 debugging information.
-   Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003
-   Free Software Foundation, Inc.
+   Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007,
+   2008, 2009  Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>.
 
    This file is part of GNU Binutils.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
 
 /* This file reads and writes IEEE-695 debugging information.  */
 
-#include <stdio.h>
+#include "sysdep.h"
 #include <assert.h>
-
 #include "bfd.h"
 #include "ieee.h"
-#include "bucomm.h"
 #include "libiberty.h"
 #include "debug.h"
 #include "budbg.h"
@@ -61,6 +59,16 @@ struct ieee_blockstack
 
 /* This structure holds information for a variable.  */
 
+enum ieee_var_kind
+  {
+    IEEE_UNKNOWN,
+    IEEE_EXTERNAL,
+    IEEE_GLOBAL,
+    IEEE_STATIC,
+    IEEE_LOCAL,
+    IEEE_FUNCTION
+  };
+
 struct ieee_var
 {
   /* Start of name.  */
@@ -72,15 +80,7 @@ struct ieee_var
   /* Slot if we make an indirect type.  */
   debug_type *pslot;
   /* Kind of variable or function.  */
-  enum
-    {
-      IEEE_UNKNOWN,
-      IEEE_EXTERNAL,
-      IEEE_GLOBAL,
-      IEEE_STATIC,
-      IEEE_LOCAL,
-      IEEE_FUNCTION
-    } kind;
+  enum ieee_var_kind kind;
 };
 
 /* This structure holds all the variables.  */
@@ -1071,6 +1071,16 @@ parse_ieee_bb (struct ieee_info *info, const bfd_byte **pp)
              break;
          }
 
+       if (! info->saw_filename)
+         {
+           namcopy = savestring (name, namlen);
+           if (namcopy == NULL)
+             return FALSE;
+           if (! debug_set_filename (info->dhandle, namcopy))
+             return FALSE;
+           info->saw_filename = TRUE;
+         }
+
        namcopy = savestring (name, namlen);
        if (namcopy == NULL)
          return FALSE;
@@ -1788,6 +1798,7 @@ parse_ieee_ty (struct ieee_info *info, const bfd_byte **pp)
       break;
 
     case 'V':
+    case 'v':
       /* Void.  This is not documented, but the MRI compiler emits it.  */
       type = debug_make_void_type (dhandle);
       break;
@@ -2491,7 +2502,7 @@ ieee_read_cxx_misc (struct ieee_info *info, const bfd_byte **pp,
 
     case 'z':
       {
-       const char *name, *mangled, *class;
+       const char *name, *mangled, *cxx_class;
        unsigned long namlen, mangledlen, classlen;
        bfd_vma control;
 
@@ -2499,7 +2510,7 @@ ieee_read_cxx_misc (struct ieee_info *info, const bfd_byte **pp,
 
        if (! ieee_require_atn65 (info, pp, &name, &namlen)
            || ! ieee_require_atn65 (info, pp, &mangled, &mangledlen)
-           || ! ieee_require_atn65 (info, pp, &class, &classlen)
+           || ! ieee_require_atn65 (info, pp, &cxx_class, &classlen)
            || ! ieee_require_asn (info, pp, &control))
          return FALSE;
 
@@ -2524,7 +2535,7 @@ ieee_read_cxx_class (struct ieee_info *info, const bfd_byte **pp,
                     unsigned long count)
 {
   const bfd_byte *start;
-  bfd_vma class;
+  bfd_vma cxx_class;
   const char *tag;
   unsigned long taglen;
   struct ieee_tag *it;
@@ -2549,7 +2560,7 @@ ieee_read_cxx_class (struct ieee_info *info, const bfd_byte **pp,
 
   start = *pp;
 
-  if (! ieee_require_asn (info, pp, &class))
+  if (! ieee_require_asn (info, pp, &cxx_class))
     return FALSE;
   --count;
 
@@ -3171,7 +3182,7 @@ ieee_read_cxx_class (struct ieee_info *info, const bfd_byte **pp,
      it->slot.  We update it->slot to automatically update all
      references to this struct.  */
   it->slot = debug_make_object_type (dhandle,
-                                    class != 'u',
+                                    cxx_class != 'u',
                                     debug_get_type_size (dhandle,
                                                          it->slot),
                                     fields, baseclasses, dmethods,
@@ -3294,7 +3305,7 @@ ieee_read_reference (struct ieee_info *info, const bfd_byte **pp)
 {
   const bfd_byte *start;
   bfd_vma flags;
-  const char *class, *name;
+  const char *cxx_class, *name;
   unsigned long classlen, namlen;
   debug_type *pslot;
   debug_type target;
@@ -3308,7 +3319,7 @@ ieee_read_reference (struct ieee_info *info, const bfd_byte **pp)
      the spec.  */
   if (flags == 3)
     {
-      if (! ieee_require_atn65 (info, pp, &class, &classlen))
+      if (! ieee_require_atn65 (info, pp, &cxx_class, &classlen))
        return FALSE;
     }
 
@@ -3398,8 +3409,8 @@ ieee_read_reference (struct ieee_info *info, const bfd_byte **pp)
 
       for (it = info->tags; it != NULL; it = it->next)
        {
-         if (it->name[0] == class[0]
-             && strncmp (it->name, class, classlen) == 0
+         if (it->name[0] == cxx_class[0]
+             && strncmp (it->name, cxx_class, classlen) == 0
              && strlen (it->name) == classlen)
            {
              if (it->fslots != NULL)
@@ -4594,8 +4605,10 @@ write_ieee_debugging_info (bfd *abfd, void *dhandle)
   info.type_indx = 256;
   info.name_indx = 32;
 
-  if (! bfd_hash_table_init (&info.typedefs.root, ieee_name_type_newfunc)
-      || ! bfd_hash_table_init (&info.tags.root, ieee_name_type_newfunc))
+  if (!bfd_hash_table_init (&info.typedefs.root, ieee_name_type_newfunc,
+                           sizeof (struct ieee_name_type_hash_entry))
+      || !bfd_hash_table_init (&info.tags.root, ieee_name_type_newfunc,
+                              sizeof (struct ieee_name_type_hash_entry)))
     return FALSE;
 
   if (! ieee_init_buffer (&info, &info.global_types)
@@ -4676,14 +4689,10 @@ write_ieee_debugging_info (bfd *abfd, void *dhandle)
       return TRUE;
     }
   err = NULL;
-  s = bfd_make_section (abfd, ".debug");
+  s = bfd_make_section_with_flags (abfd, ".debug",
+                                  SEC_DEBUGGING | SEC_HAS_CONTENTS);
   if (s == NULL)
     err = "bfd_make_section";
-  if (err == NULL)
-    {
-      if (! bfd_set_section_flags (abfd, s, SEC_DEBUGGING | SEC_HAS_CONTENTS))
-       err = "bfd_set_section_flags";
-    }
   if (err == NULL)
     {
       bfd_size_type size;
@@ -5444,7 +5453,7 @@ ieee_pointer_type (void *p)
 
   if (! localp)
     {
-      m = ieee_get_modified_info (p, indx);
+      m = ieee_get_modified_info ((struct ieee_handle *) p, indx);
       if (m == NULL)
        return FALSE;
 
@@ -5502,7 +5511,7 @@ ieee_function_type (void *p, int argcount, bfd_boolean varargs)
   m = NULL;
   if (argcount < 0 && ! localp)
     {
-      m = ieee_get_modified_info (p, retindx);
+      m = ieee_get_modified_info ((struct ieee_handle *) p, retindx);
       if (m == NULL)
        return FALSE;
 
@@ -6192,7 +6201,7 @@ ieee_class_static_member (void *p, const char *name, const char *physname,
 /* Add a base class to a class.  */
 
 static bfd_boolean
-ieee_class_baseclass (void *p, bfd_vma bitpos, bfd_boolean virtual,
+ieee_class_baseclass (void *p, bfd_vma bitpos, bfd_boolean is_virtual,
                      enum debug_visibility visibility)
 {
   struct ieee_handle *info = (struct ieee_handle *) p;
@@ -6218,7 +6227,7 @@ ieee_class_baseclass (void *p, bfd_vma bitpos, bfd_boolean virtual,
      class.  The stabs debugging reader will create a field named
      _vb$CLASS for a virtual base class, so we just use that.  FIXME:
      we should not depend upon a detail of stabs debugging.  */
-  if (virtual)
+  if (is_virtual)
     {
       fname = (char *) xmalloc (strlen (bname) + sizeof "_vb$");
       sprintf (fname, "_vb$%s", bname);
@@ -6286,7 +6295,7 @@ ieee_class_method_var (struct ieee_handle *info, const char *physname,
 {
   unsigned int flags;
   unsigned int nindx;
-  bfd_boolean virtual;
+  bfd_boolean is_virtual;
 
   /* We don't need the type of the method.  An IEEE consumer which
      wants the type must track down the function by the physical name
@@ -6316,18 +6325,18 @@ ieee_class_method_var (struct ieee_handle *info, const char *physname,
 
   nindx = info->type_stack->type.classdef->indx;
 
-  virtual = context || voffset > 0;
+  is_virtual = context || voffset > 0;
 
   if (! ieee_change_buffer (info,
                            &info->type_stack->type.classdef->pmiscbuf)
-      || ! ieee_write_asn (info, nindx, virtual ? 'v' : 'm')
+      || ! ieee_write_asn (info, nindx, is_virtual ? 'v' : 'm')
       || ! ieee_write_asn (info, nindx, flags)
       || ! ieee_write_atn65 (info, nindx,
                             info->type_stack->type.classdef->method)
       || ! ieee_write_atn65 (info, nindx, physname))
     return FALSE;
 
-  if (virtual)
+  if (is_virtual)
     {
       if (voffset > info->type_stack->type.classdef->voffset)
        info->type_stack->type.classdef->voffset = voffset;