This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch 2/2] Assert leftover cleanups in TRY_CATCH
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: Jan Kratochvil <jan dot kratochvil at redhat dot com>, gdb-patches at sourceware dot org
- Date: Tue, 7 May 2013 10:23:05 +0400
- Subject: Re: [patch 2/2] Assert leftover cleanups in TRY_CATCH
- References: <20130501165750 dot GA453 at host2 dot jankratochvil dot net> <87obcoyot3 dot fsf at fleche dot redhat dot com>
> Thanks for doing this. I think it is a nice addition.
I agree. My only additional comment, after having hit this assertion,
is that it seems a bit harsh to be doing an abort in this case.
The problem showed up during a testsuite run, and so I would
investigate it regardless. But I can imagine the same issue
occurring during a real debugging session trying to chase a bug -
I'd be pretty upset to see my session ended like that.
Should we consider changing it into an internal_warning?
> We could do this for all cleanup-creating functions, at least when using
> GCC, if we didn't mind putting a declaration at the start of each such
> function:
>
> #if ... gcc ..
> #define CHECK_CLEANUP \
> struct cleanup *__dummy ## __LINE__ \
> __attribute__ ((cleanup (check_cleanup))) \
> = get_checking_cleanup_pointer ();
> #endif
>
>
> This would call check_cleanup when the function exited normally, so we
> could verify that the cleanup chain was properly reset.
That would have helped my investigation, because the error
was raised in a frame long after the function causing the problem
had returned. Looking at the contents of the cleanup_chain,
you get a hint of what it might be, but in my case, it was
a null_cleanup, so not so helpful...
> I think it would be possible to automate adding this declaration in
> all needed spots. I'm curious what you think about it.
I'm certainly curious about the suggestion. How would the current
code be adapted to make this work?
--
Joel