This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v3 1/9] Code cleanup: Make parts of print_command_1 public
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches at sourceware dot org, Phil Muldoon <pmuldoon at redhat dot com>
- Date: Wed, 29 Apr 2015 22:43:11 +0200
- Subject: Re: [PATCH v3 1/9] Code cleanup: Make parts of print_command_1 public
- Authentication-results: sourceware.org; auth=none
- References: <20150411194322 dot 29128 dot 52477 dot stgit at host1 dot jankratochvil dot net> <20150411194333 dot 29128 dot 30245 dot stgit at host1 dot jankratochvil dot net> <5540FC34 dot 3050200 at redhat dot com>
On Wed, 29 Apr 2015 17:43:48 +0200, Pedro Alves wrote:
> I read the series, and AFAICS, this will be used by
> compile_print_command in patch #7. But then AFAICS, compile_print_command
> leaks fmtp.
Yes, you are right it gets leaked in the end.
> I think this all ends up simpler if it follows the pattern that
> the current code already follows.
It was reworked because struct format_data * becomes a part of struct
do_module_cleanup which can be processed independently in the future.
So the forgotten xfree was inteded+forgotten to be in do_module_cleanup.
OTOH this COMPILE_I_PRINT_ADDRESS_SCOPE and COMPILE_I_PRINT_VALUE_SCOPE
processing in do_module_cleanup is suppressed if the caller no longer exists
(the 'compile print' command already finished). That means that you are right
do_module_cleanup can depend on a local variable of the compile_print_command
caller.
I have to mention with sub-classing and C++ automatic memory management there
would be nothing left to solve.
Jan