aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2011-08-18 16:17:39 +0000
committerKeith Seitz <keiths@redhat.com>2011-08-18 16:17:39 +0000
commit3a93a0c2ef1629add02bfdb6efe81015819acd35 (patch)
tree40d5b97e7a1d2698688510f6cb66c831daac5da2 /gdb/python
parent7230378dfd17300cd58e07acda312299f6bd1936 (diff)
downloadgdb-3a93a0c2ef1629add02bfdb6efe81015819acd35.zip
gdb-3a93a0c2ef1629add02bfdb6efe81015819acd35.tar.gz
gdb-3a93a0c2ef1629add02bfdb6efe81015819acd35.tar.bz2
PR c++/12266
* cp-name-parser.y (struct demangle_info): Remove unused member PREV. (d_grab): Likewise. (allocate_info): Change return type to struct demangle_info *. Always allocate a new demangle_info. Remove unused PREV pointer. (cp_new_demangle_parse_info): New function. (cp_demangled_name_parse_free): New function. (do_demangled_name_parse_free_cleanup): New function. (make_cleanup_cp_demangled_name_parse_free): New function. (cp_demangled_name_to_comp): Change return type to struct demangle_parse_info *. Allocate a new storage for each call. (main): Update usage for cp_demangled_name_to_comp API change. * cp-support.h (struct demangle_parse_info): New structure. (cp_demangled_name_to_comp): Update API change for return type. (cp_new_demangle_parse_info): Declare. (make_cleanup_cp_demangled_name_parse_free): New declaration. (cp_demangled_name_parse_free): Declare. * cp-support.c (cp_canonicalize_string): Update API change for cp_demangled_name_to_comp. (mangled_name_to_comp): Likewise. Return struct demangle_parse_info, too. (cp_class_name_from_physname): Update mangled_name_to_comp API change. (method_name_from_physname): Likewise. (cp_func_name): Update API change for cp_demangled_name_to_comp. (cp_remove_params): Likewise. * python/py-type.c (typy_legacy_template_argument): Likewise. * cp-support.h (cp_canonicalize_string_no_typedefs): Declare. (cp_merge_demangle_parse_infos): Declare. * cp-support.c (ignore_typedefs): New file global. (copy_string_to_obstack): New function. (inspect_type): New function. (replace_typedefs): New function. (replace_typedefs_qualified_name): New function. (cp_canonicalize_string_no_typedefs): New function. * cp-name-parser.y (cp_merge_demangle_parse_infos): New function. (cp_new_demangle__parse_info): Allocate and initialize the obstack. * linespec.c (find_methods): Use cp_canonicalize_string_no_typedefs instead of cp_canonicalize_string. (find_method): Likewise. (decode_compound): Before looking up the name, call cp_canonicalize_string_no_typedefs. (decode_variable): Likewise.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-type.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 8ab18cf..335342e 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -577,8 +577,10 @@ typy_legacy_template_argument (struct type *type, struct block *block,
{
int i;
struct demangle_component *demangled;
+ struct demangle_parse_info *info;
const char *err;
struct type *argtype;
+ struct cleanup *cleanup;
if (TYPE_NAME (type) == NULL)
{
@@ -587,12 +589,14 @@ typy_legacy_template_argument (struct type *type, struct block *block,
}
/* Note -- this is not thread-safe. */
- demangled = cp_demangled_name_to_comp (TYPE_NAME (type), &err);
- if (! demangled)
+ info = cp_demangled_name_to_comp (TYPE_NAME (type), &err);
+ if (! info)
{
PyErr_SetString (PyExc_RuntimeError, err);
return NULL;
}
+ demangled = info->tree;
+ cleanup = make_cleanup_cp_demangled_name_parse_free (info);
/* Strip off component names. */
while (demangled->type == DEMANGLE_COMPONENT_QUAL_NAME
@@ -601,6 +605,7 @@ typy_legacy_template_argument (struct type *type, struct block *block,
if (demangled->type != DEMANGLE_COMPONENT_TEMPLATE)
{
+ do_cleanups (cleanup);
PyErr_SetString (PyExc_RuntimeError, _("Type is not a template."));
return NULL;
}
@@ -613,12 +618,14 @@ typy_legacy_template_argument (struct type *type, struct block *block,
if (! demangled)
{
+ do_cleanups (cleanup);
PyErr_Format (PyExc_RuntimeError, _("No argument %d in template."),
argno);
return NULL;
}
argtype = typy_lookup_type (demangled->u.s_binary.left, block);
+ do_cleanups (cleanup);
if (! argtype)
return NULL;