[binutils-gdb] gdb/testsuite: fix gdb.mi/mi-catch-cpp-exceptions.exp with clang

Guinevere Larsen blarsen@sourceware.org
Tue Sep 17 20:29:17 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bd26cd1810ce4296b228cd31d137a0b54e40c189

commit bd26cd1810ce4296b228cd31d137a0b54e40c189
Author: Guinevere Larsen <blarsen@redhat.com>
Date:   Tue Jul 23 13:56:17 2024 -0300

    gdb/testsuite: fix gdb.mi/mi-catch-cpp-exceptions.exp with clang
    
    Clang adds line table information for a try/catch block differently to
    gcc. Instead of linking the instructions related to __cxa_begin_catch to
    the line containing the "catch" statement in the source code, it links
    to the closing brace of the try block.
    
    This was causing gdb.mi/mi-catch-cpp-exceptions.exp to fail when tested
    with clang. The test was updated to have the catch in the same line as
    the closing brace so it passes with no additional modifications with
    clang.
    
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc b/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc
index be1f50fad7f..d41b55d27f6 100644
--- a/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc
+++ b/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc
@@ -43,8 +43,7 @@ foo ()
       try
 	{
 	  bar ();
-	}
-      catch (const my_exception &ex)	/* Catch 1.  */
+	} catch (const my_exception &ex)	/* Catch 1.  */
 	{
 	  if (i == 1)
 	    throw;	/* Throw 2.  */
@@ -60,8 +59,7 @@ main ()
       try
 	{
 	  foo ();
-	}
-      catch (const my_exception &ex)	/* Catch 2.  */
+	} catch (const my_exception &ex)	/* Catch 2.  */
 	{
 	  if (i == 1)
 	    return 1;	/* Stop here.  */


More information about the Gdb-cvs mailing list