Re: [patch 2/2] Assert leftover cleanups in TRY_CATCH

Tom Tromey
2013-05-06T17:57:01Z

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> 2013-05-01 Jan Kratochvil <jan.kratochvil@redhat.com>
Jan> * cleanups.c (restore_my_cleanups): New gdb_assert for SENTINEL_CLEANUP.

Thanks for doing this. I think it is a nice addition.

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.

I think it would be possible to automate adding this declaration in all
needed spots. I'm curious what you think about it.

Tom