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

Jan Kratochvil
2013-05-07T14:20:22Z

On Tue, 07 May 2013 08:23:05 +0200, Joel Brobecker wrote:
> 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?

I forgot the direction GDB should not crash on recoverable issues.

Jan

gdb/
2013-05-07 Jan Kratochvil <jan.kratochvil@redhat.com>

* cleanups.c (restore_my_cleanups): Replace gdb_assert by
internal_warning.

diff --git a/gdb/cleanups.c b/gdb/cleanups.c
index 02db9f5..1b5d973 100644
--- a/gdb/cleanups.c
+++ b/gdb/cleanups.c
@@ -261,7 +261,10 @@ save_final_cleanups (void)
static void
restore_my_cleanups (struct cleanup **pmy_chain, struct cleanup *chain)
{
- gdb_assert (*pmy_chain == SENTINEL_CLEANUP);
+ if (*pmy_chain != SENTINEL_CLEANUP)
+ internal_warning (__FILE__, __LINE__,
+ _("restore_my_cleanups has found a stale cleanup"));
+
*pmy_chain = chain;
}