* value.c (value_fn_field): Constify.
authorTom Tromey <tromey@redhat.com>
Wed, 18 May 2011 16:30:37 +0000 (16:30 +0000)
committerTom Tromey <tromey@redhat.com>
Wed, 18 May 2011 16:30:37 +0000 (16:30 +0000)
* symtab.c (gdb_mangle_name): Constify.
* stabsread.c (update_method_name_from_physname): Make 'physname'
argument const.
* p-typeprint.c (pascal_type_print_method_args): Make arguments
const.  Use explicit fputc_filtered loop.
(pascal_type_print_base): Constify.
* p-lang.h (pascal_type_print_method_args): Update.
* linespec.c (add_matching_methods): Constify.
(add_constructors): Likewise.
* jv-typeprint.c (java_type_print_base): Constify.
* gdbtypes.h (struct cplus_struct_type)
<fn_fieldlist.fn_field.physname>: Now const.
* dwarf2read.c (compute_delayed_physnames): Constify.
(dwarf2_add_member_fn): Likewise.
* c-typeprint.c (c_type_print_base): Constify.  Use cleanups.

gdb/ChangeLog
gdb/c-typeprint.c
gdb/dwarf2read.c
gdb/gdbtypes.h
gdb/jv-typeprint.c
gdb/linespec.c
gdb/p-lang.h
gdb/p-typeprint.c
gdb/stabsread.c
gdb/symtab.c
gdb/value.c

index c1408c144d2d4b55020dd430a24e6611959386fb..d7a31a6d91795590072abbf9691aee006af4f27c 100644 (file)
@@ -1,3 +1,22 @@
+2011-05-18  Tom Tromey  <tromey@redhat.com>
+
+       * value.c (value_fn_field): Constify.
+       * symtab.c (gdb_mangle_name): Constify.
+       * stabsread.c (update_method_name_from_physname): Make 'physname'
+       argument const.
+       * p-typeprint.c (pascal_type_print_method_args): Make arguments
+       const.  Use explicit fputc_filtered loop.
+       (pascal_type_print_base): Constify.
+       * p-lang.h (pascal_type_print_method_args): Update.
+       * linespec.c (add_matching_methods): Constify.
+       (add_constructors): Likewise.
+       * jv-typeprint.c (java_type_print_base): Constify.
+       * gdbtypes.h (struct cplus_struct_type)
+       <fn_fieldlist.fn_field.physname>: Now const.
+       * dwarf2read.c (compute_delayed_physnames): Constify.
+       (dwarf2_add_member_fn): Likewise.
+       * c-typeprint.c (c_type_print_base): Constify.  Use cleanups.
+
 2011-05-18  Pedro Alves  <pedro@codesourcery.com>
 
        * infrun.c (resume): Mention which is the current thread, and its
index 2e23dd7f9f1eee6de04cdb8809db85ecce1ad788..021223217eb3445b727ce25ae3f49767c0e9a8a4 100644 (file)
@@ -719,9 +719,6 @@ c_type_print_base (struct type *type, struct ui_file *stream,
   int i;
   int len, real_len;
   int lastval;
-  char *mangled_name;
-  char *demangled_name;
-  char *demangled_no_static;
   enum
     {
       s_none, s_public, s_private, s_protected
@@ -1001,7 +998,10 @@ c_type_print_base (struct type *type, struct ui_file *stream,
 
              for (j = 0; j < len2; j++)
                {
-                 char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
+                 const char *mangled_name;
+                 char *demangled_name;
+                 struct cleanup *inner_cleanup;
+                 const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
                  int is_full_physname_constructor =
                    is_constructor_name (physname) 
                    || is_destructor_name (physname)
@@ -1011,6 +1011,8 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                  if (TYPE_FN_FIELD_ARTIFICIAL (f, j))
                    continue;
 
+                 inner_cleanup = make_cleanup (null_cleanup, NULL);
+
                  QUIT;
                  if (TYPE_FN_FIELD_PROTECTED (f, j))
                    {
@@ -1064,8 +1066,14 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                      fputs_filtered (" ", stream);
                    }
                  if (TYPE_FN_FIELD_STUB (f, j))
-                   /* Build something we can demangle.  */
-                   mangled_name = gdb_mangle_name (type, i, j);
+                   {
+                     char *tem;
+
+                     /* Build something we can demangle.  */
+                     tem = gdb_mangle_name (type, i, j);
+                     make_cleanup (xfree, tem);
+                     mangled_name = tem;
+                   }
                  else
                    mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j);
 
@@ -1107,6 +1115,7 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                      if (p != NULL)
                        {
                          int length = p - demangled_no_class;
+                         char *demangled_no_static;
 
                          demangled_no_static
                            = (char *) xmalloc (length + 1);
@@ -1121,8 +1130,7 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                      xfree (demangled_name);
                    }
 
-                 if (TYPE_FN_FIELD_STUB (f, j))
-                   xfree (mangled_name);
+                 do_cleanups (inner_cleanup);
 
                  fprintf_filtered (stream, ";\n");
                }
index 6558bfed863c3419a7b8779e6d870b98fe959d1d..562361eab1d67d68154b50c5d17a212d935cf8a2 100644 (file)
@@ -4609,10 +4609,10 @@ compute_delayed_physnames (struct dwarf2_cu *cu)
   struct delayed_method_info *mi;
   for (i = 0; VEC_iterate (delayed_method_info, cu->method_list, i, mi) ; ++i)
     {
-      char *physname;
+      const char *physname;
       struct fn_fieldlist *fn_flp
        = &TYPE_FN_FIELDLIST (mi->type, mi->fnfield_index);
-      physname = (char *) dwarf2_physname ((char *) mi->name, mi->die, cu);
+      physname = dwarf2_physname ((char *) mi->name, mi->die, cu);
       fn_flp->fn_fields[mi->index].physname = physname ? physname : "";
     }
 }
@@ -6792,7 +6792,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
     }
   else
     {
-      char *physname = (char *) dwarf2_physname (fieldname, die, cu);
+      const char *physname = dwarf2_physname (fieldname, die, cu);
       fnp->physname = physname ? physname : "";
     }
 
index 5a588a20b00d8a800c2002f89820b09c0e321e3f..f771bed46f82c18ed47d3fc852e8edc5add4fb79 100644 (file)
@@ -773,7 +773,7 @@ struct cplus_struct_type
               arguments.  See gdb_mangle_name for the conversion from this
               format to the one used if is_stub is clear.  */
 
-           char *physname;
+           const char *physname;
 
            /* The function type for the method.
               (This comment used to say "The return value of the method",
index 0a709e9d977a7f6546de9d07fce0115561c563c6..8d9ebfd9ccd70cfb9f2871bbac77947cd36a0536 100644 (file)
@@ -221,7 +221,8 @@ java_type_print_base (struct type *type, struct ui_file *stream, int show,
 
              for (j = 0; j < n_overloads; j++)
                {
-                 char *real_physname, *physname, *p;
+                 const char *real_physname;
+                 char *physname, *p;
                  int is_full_physname_constructor;
 
                  real_physname = TYPE_FN_FIELD_PHYSNAME (f, j);
index 94bb86f90e0be6d2e8efaa685e4c8859d06b7ac6..871d37d95364e52bc46bb338530cadbcf6681e51 100644 (file)
@@ -312,20 +312,21 @@ add_matching_methods (int method_counter, struct type *t,
        --field_counter)
     {
       struct fn_field *f;
-      char *phys_name;
+      const char *phys_name;
 
       f = TYPE_FN_FIELDLIST1 (t, method_counter);
 
       if (TYPE_FN_FIELD_STUB (f, field_counter))
        {
-         char *tmp_name;
+         char *tmp_name, *tmp2;
 
          tmp_name = gdb_mangle_name (t,
                                      method_counter,
                                      field_counter);
-         phys_name = alloca (strlen (tmp_name) + 1);
-         strcpy (phys_name, tmp_name);
+         tmp2 = alloca (strlen (tmp_name) + 1);
+         strcpy (tmp2, tmp_name);
          xfree (tmp_name);
+         phys_name = tmp2;
        }
       else
        phys_name = TYPE_FN_FIELD_PHYSNAME (f, field_counter);
@@ -373,7 +374,7 @@ add_constructors (int method_counter, struct type *t,
        --field_counter)
     {
       struct fn_field *f;
-      char *phys_name;
+      const char *phys_name;
 
       f = TYPE_FN_FIELDLIST1 (t, method_counter);
 
index c284c1dfa57b33b15e36255c093e27b24c125a3c..520accf6039622c146bc3df5e70183d5c32f2abb 100644 (file)
@@ -44,7 +44,7 @@ extern int pascal_val_print (struct type *, const gdb_byte *, int,
 extern int pascal_value_print (struct value *, struct ui_file *,
                               const struct value_print_options *);
 
-extern void pascal_type_print_method_args (char *, char *,
+extern void pascal_type_print_method_args (const char *, const char *,
                                           struct ui_file *);
 
 /* These are in p-lang.c: */
index 54a761d464a0bb1bf6443f7de477802d483e4e4b..5ac3bc5431a9c7aee0a74cb339c8be75a0047ae9 100644 (file)
@@ -153,7 +153,7 @@ pascal_type_print_derivation_info (struct ui_file *stream, struct type *type)
 /* Print the Pascal method arguments ARGS to the file STREAM.  */
 
 void
-pascal_type_print_method_args (char *physname, char *methodname,
+pascal_type_print_method_args (const char *physname, const char *methodname,
                               struct ui_file *stream)
 {
   int is_constructor = (strncmp (physname, "__ct__", 6) == 0);
@@ -173,8 +173,7 @@ pascal_type_print_method_args (char *physname, char *methodname,
       while (isdigit (physname[0]))
        {
          int len = 0;
-         int i;
-         char storec;
+         int i, j;
          char *argname;
 
          while (isdigit (physname[len]))
@@ -183,10 +182,11 @@ pascal_type_print_method_args (char *physname, char *methodname,
            }
          i = strtol (physname, &argname, 0);
          physname += len;
-         storec = physname[i];
-         physname[i] = 0;
+
+         for (j = 0; j < i; ++j)
+           fputc_filtered (physname[i], stream);
          fputs_filtered (physname, stream);
-         physname[i] = storec;
+
          physname += i;
          if (physname[0] != 0)
            {
@@ -638,7 +638,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
                 It might work for GNU pascal.  */
              for (j = 0; j < len2; j++)
                {
-                 char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
+                 const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
 
                  int is_constructor = (strncmp (physname, "__ct__", 6) == 0);
                  int is_destructor = (strncmp (physname, "__dt__", 6) == 0);
index c7d8a6c4743dd18ce008aa8ae8f6bf3c5c0093c2..5331bce45268e3676edd242e86d4a09bff5d6bfc 100644 (file)
@@ -2236,7 +2236,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
 /* Replace *OLD_NAME with the method name portion of PHYSNAME.  */
 
 static void
-update_method_name_from_physname (char **old_name, char *physname)
+update_method_name_from_physname (char **old_name, const char *physname)
 {
   char *method_name;
 
index 439bb780a03ed18c37b6ecae9f8d097e3ed7cbf5..8879ddf4fc2dacb7e200333ce29d00f4c39365ea 100644 (file)
@@ -278,7 +278,7 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id)
   struct fn_field *f = TYPE_FN_FIELDLIST1 (type, method_id);
   struct fn_field *method = &f[signature_id];
   char *field_name = TYPE_FN_FIELDLIST_NAME (type, method_id);
-  char *physname = TYPE_FN_FIELD_PHYSNAME (f, signature_id);
+  const char *physname = TYPE_FN_FIELD_PHYSNAME (f, signature_id);
   char *newname = type_name_no_tag (type);
 
   /* Does the form of physname indicate that it is the full mangled name
index cb7cae5774487132e1b75b0e6811d10052b91927..2a8f3fce26ade1f898ec7697a4e87b3c7ef1baf6 100644 (file)
@@ -2559,7 +2559,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f,
 {
   struct value *v;
   struct type *ftype = TYPE_FN_FIELD_TYPE (f, j);
-  char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
+  const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
   struct symbol *sym;
   struct minimal_symbol *msym;