Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Keith Seitz <keiths@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] c++/12266 (again) [cp_demangled_name_parse_free-4.patch]
Date: Tue, 02 Aug 2011 20:28:00 -0000	[thread overview]
Message-ID: <20110802202825.GA13092@host1.jankratochvil.net> (raw)
In-Reply-To: <4E31EE1A.5040204@redhat.com>

On Fri, 29 Jul 2011 01:17:46 +0200, Keith Seitz wrote:
> diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
> index 8736777..f745a31 100644
> --- a/gdb/cp-name-parser.y
> +++ b/gdb/cp-name-parser.y
[...]
> +/* A cleanup wrapper for cp_demangled_name_parse_free.  */
> +
> +static void
> +do_demangled_name_parse_free_cleanup (void *data)
> +{
> +  struct demangle_parse_info *info = (struct demangle_parse_info *) data;
> +
> +  cp_demangled_name_parse_free (info);
> +}
> +
> +/* Create a cleanup for C++ name parsing.  */
> +
> +struct cleanup *
> +make_cleanup_cp_demangled_name_parse_free (struct demangle_parse_info *info)
> +{
> +  return make_cleanup (do_demangled_name_parse_free_cleanup, info);
> +}

$ make test-cp-name-parser
cp-name-parser.y:2018: undefined reference to `make_cleanup'


[...]
> -struct demangle_component *
> +struct demangle_parse_info *
>  cp_demangled_name_to_comp (const char *demangled_name, const char **errmsg)
>  {
>    static char errbuf[60];
> -  struct demangle_component *result;
> +  struct demangle_parse_info *result;
>  
>    prev_lexptr = lexptr = demangled_name;
>    error_lexptr = NULL;
>    global_errmsg = NULL;
>  
> -  allocate_info ();
> +  demangle_info = allocate_info ();
> +
> +  result = ((struct demangle_parse_info *)
> +	    malloc (sizeof (struct demangle_parse_info)));

This cast seems redundant to me.


[...]
> @@ -153,23 +154,29 @@ cp_canonicalize_string (const char *string)
>     freed when finished with the tree, or NULL if none was needed.
>     OPTIONS will be passed to the demangler.  */
>  
> -static struct demangle_component *
> +static struct demangle_parse_info *
>  mangled_name_to_comp (const char *mangled_name, int options,
>  		      void **memory, char **demangled_p)
>  {
> -  struct demangle_component *ret;
>    char *demangled_name;
> +  struct demangle_parse_info *info;
>  
>    /* If it looks like a v3 mangled name, then try to go directly
>       to trees.  */
>    if (mangled_name[0] == '_' && mangled_name[1] == 'Z')
>      {
> +      struct demangle_component *ret;
> +
>        ret = cplus_demangle_v3_components (mangled_name,
>  					  options, memory);
>        if (ret)
>  	{
> +	  info = ((struct demangle_parse_info *)
> +		  xmalloc (sizeof (struct demangle_parse_info)));

Redundant cast.


[...]
> --- a/gdb/cp-support.h
> +++ b/gdb/cp-support.h
> @@ -46,6 +46,17 @@ struct demangle_component;
>  
>  #define CP_ANONYMOUS_NAMESPACE_LEN 21
>  
> +/* The result of parsing a name.  */
> +
> +struct demangle_parse_info
> +{
> +  /* The memory used during the parse.  */
> +  struct demangle_info *info;
> +
> +  /* The result of the parse.  */
> +  struct demangle_component *tree;
> +};

I guess you have been considering it but anyway:

Its ->tree items can reference for s_name the original string being demangled,
as you even state in some comments.  Due to it it also requires later explicit
handling of `free_list'.  Could this struct already have the original string
duplicated and this struct would track its freeing?
cp_merge_demangle_parse_infos would then track all the source strings in the
merged destination demangle_parse_info.



Thanks,
Jan


  parent reply	other threads:[~2011-08-02 20:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-29 13:16 [RFA] c++/12266 (again) Keith Seitz
2011-08-01 20:38 ` Tom Tromey
2011-08-02 16:08 ` Tom Tromey
2011-08-02 17:58   ` Keith Seitz
2011-08-02 20:28 ` Jan Kratochvil [this message]
2011-08-09 20:23   ` [RFA] c++/12266 (again) [cp_demangled_name_parse_free-4.patch] Keith Seitz
2011-08-13 16:51     ` Jan Kratochvil
2011-08-18 16:22       ` Keith Seitz
2011-08-02 20:37 ` [RFA] c++/12266 (again) [cp_canonicalize_no_typedefs-4.patch] Jan Kratochvil
2011-08-09 20:48   ` Keith Seitz
2011-08-13 16:50     ` Jan Kratochvil
2011-08-18 16:25       ` Keith Seitz
2011-08-18 16:35         ` Keith Seitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110802202825.GA13092@host1.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox