]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
fix "stale cleanup" internal-warning when using "catch assert" command
authorJoel Brobecker <brobecker@adacore.com>
Tue, 22 May 2018 14:04:15 +0000 (10:04 -0400)
committerJoel Brobecker <brobecker@adacore.com>
Tue, 22 May 2018 14:25:50 +0000 (10:25 -0400)
Trying to insert a catchpoint on all Ada assertions now triggers
the following internal warning regardless of the situation. For
instance, not even debugging any program:

    (gdb) catch assert
    /[...]/gdb/common/cleanups.c:264: internal-warning:
    restore_my_cleanups has found a stale cleanup

This is due to a small bug in the following C++-ification commit:

    commit bc18fbb575437dd10089ef4619e46c0b9a93097d
    Author: Tom Tromey <tom@tromey.com>
    Date:   Fri May 18 15:58:50 2018 -0600
    Subject: Change ada_catchpoint::excep_string to be a std::string

The stale cleanup in question is the following one in top.c:execute_command:

    cleanup_if_error = make_bpstat_clear_actions_cleanup ();

This cleanup is expected to be discarded if there are no exception.
There were no GDB exception; however, a C++ exception was triggered,
because we passed NULL as the excep_string argument when calling
create_ada_exception_catchpoint, which is a reference to a const
string. So we get a C++ exception during the std::string constructor,
which propagates up, causing the cleanup to unexpectedly remain
in the cleanup chain.

This patch fixes the immediate issue of the incorrect call to
create_ada_exception_catchpoint.

gdb/ChangeLog:

        * ada-lang.c (catch_assert_command): Pass empty string instead
        of NULL for excep_string argument.

Tested on x86_64-linux, fixes the following failures:

  * catch_assert_if.exp: insert catchpoint on failed assertions with condition
  * catch_ex.exp: insert catchpoint on failed assertions

This also fixes about a dozen UNRESOLVED tests that are a consequence
of the two tests above failing and crashing GDB.

gdb/ChangeLog
gdb/ada-lang.c

index 8d425a72a0d3b3be36e1a3294539956ded561283..653771ab24a35b5c5467ac7c4696aca1c00759c5 100644 (file)
@@ -1,3 +1,8 @@
+2018-05-22  Joel Brobecker  <brobecker@adacore.com>
+
+       * ada-lang.c (catch_assert_command): Pass empty string instead
+       of NULL for excep_string argument.
+
 2018-05-22  Maciej W. Rozycki  <macro@mips.com>
 
        * mips-linux-nat.c (mips64_linux_register_addr): Return -1 if
index eaf30585f5dc2031ba38a46a2ef7667e8ccd8aa3..64bddc267076abbb43259ef255ae6122a721c203 100644 (file)
@@ -13408,7 +13408,7 @@ catch_assert_command (const char *arg_entry, int from_tty,
     arg = "";
   catch_ada_assert_command_split (arg, cond_string);
   create_ada_exception_catchpoint (gdbarch, ada_catch_assert,
-                                  NULL, cond_string,
+                                  "", cond_string,
                                   tempflag, 1 /* enabled */,
                                   from_tty);
 }