From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: Yao Qi <qiyaoltc@gmail.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [RFA] PR python/18565 - make Frame.function work for inline frames
Date: Tue, 26 Jul 2016 11:14:00 -0000 [thread overview]
Message-ID: <5ab877f8-9e39-6e02-2ece-46fcbcdacc0a@redhat.com> (raw)
In-Reply-To: <87bn1lu5h9.fsf@tromey.com>
On 07/25/2016 04:01 PM, Tom Tromey wrote:
> *funname = xstrdup (SYMBOL_PRINT_NAME (func));
> [...]
> if (*funlang == language_cplus)
> {
> /* It seems appropriate to use SYMBOL_PRINT_NAME() here,
> to display the demangled name that we already have
> stored in the symbol table, but we stored a version
> with DMGL_PARAMS turned on, and here we don't want to
> display parameters. So remove the parameters. */
> char *func_only = cp_remove_params (*funname);
>
> I'm not 100% sure that cp_remove_params cannot throw.
> However, it's
> simple to deal with this by adding a cleanup in find_frame_funname. I'm
> happy to do this if desired.
>
> Another approach might be to have a free_current_contents cleanup at the
> start of find_frame_funname and discard it at the exit. This would
> maybe make it a bit safer in the face of future changes.
Yet another approach would be to push the xstrdup call to after the
cp_remove_params call, and remove the xfree call, something like:
if (*funlang == language_cplus)
{
char *func_only = cp_remove_params (SYMBOL_PRINT_NAME (func));
if (func_only)
*funname = func_only;
else
*funname = xstrdup (SYMBOL_PRINT_NAME (func));
}
else
*funname = xstrdup (SYMBOL_PRINT_NAME (func));
}
In any case, IMO this would be the subject of a separate patch.
> Alternatively, if we need a try/catch in the caller to possibly free the
> function name, then several other callers are incorrect (ada-lang.c and
> stack.c).
Yeah. I think that if a function has such a requirement, then it needs
to be clearly documented as that being part of its API contract.
Otherwise, it's too easy for the called function to change in a way that
makes the caller try to free a dangling output pointer.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2016-07-26 11:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-20 16:11 Tom Tromey
[not found] ` <86ziqfq6sz.fsf@gmail.com>
2016-06-22 18:43 ` Tom Tromey
2016-07-25 10:23 ` Yao Qi
2016-07-25 11:04 ` Pedro Alves
2016-07-25 15:01 ` Tom Tromey
2016-07-26 11:14 ` Pedro Alves [this message]
2016-07-26 13:18 ` Tom Tromey
2016-07-26 14:33 ` Pedro Alves
2016-08-03 8:15 ` Yao Qi
2016-08-03 15:14 ` Tom Tromey
2016-08-03 17:57 ` Pedro Alves
2016-08-03 8:07 ` Yao Qi
2016-08-03 11:35 ` Pedro Alves
2016-08-03 13:15 ` Yao Qi
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=5ab877f8-9e39-6e02-2ece-46fcbcdacc0a@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=qiyaoltc@gmail.com \
--cc=tom@tromey.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