aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2011-05-18 16:30:37 +0000
committerTom Tromey <tromey@redhat.com>2011-05-18 16:30:37 +0000
commit1d06ead6876712e45010dae36b8e4745fa3321ea (patch)
treef62b4d275fdbd3b21ba54d5e7185bcf47e644cd4
parent5652e397663c31faf0c1bbc4dc4ba6ef8760ae6d (diff)
downloadgdb-1d06ead6876712e45010dae36b8e4745fa3321ea.zip
gdb-1d06ead6876712e45010dae36b8e4745fa3321ea.tar.gz
gdb-1d06ead6876712e45010dae36b8e4745fa3321ea.tar.bz2
* 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.
-rw-r--r--gdb/ChangeLog19
-rw-r--r--gdb/c-typeprint.c24
-rw-r--r--gdb/dwarf2read.c6
-rw-r--r--gdb/gdbtypes.h2
-rw-r--r--gdb/jv-typeprint.c3
-rw-r--r--gdb/linespec.c11
-rw-r--r--gdb/p-lang.h2
-rw-r--r--gdb/p-typeprint.c14
-rw-r--r--gdb/stabsread.c2
-rw-r--r--gdb/symtab.c2
-rw-r--r--gdb/value.c2
11 files changed, 58 insertions, 29 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c1408c1..d7a31a6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 2e23dd7..0212232 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -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");
}
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 6558bfe..562361e 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -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 : "";
}
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 5a588a2..f771bed 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -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",
diff --git a/gdb/jv-typeprint.c b/gdb/jv-typeprint.c
index 0a709e9..8d9ebfd 100644
--- a/gdb/jv-typeprint.c
+++ b/gdb/jv-typeprint.c
@@ -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);
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 94bb86f..871d37d 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -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);
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index c284c1d..520accf 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -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: */
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index 54a761d..5ac3bc5 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -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);
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index c7d8a6c..5331bce 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -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;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 439bb78..8879ddf 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -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
diff --git a/gdb/value.c b/gdb/value.c
index cb7cae5..2a8f3fc 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -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;