public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 02/25] Use gnat_runtime_has_debug_info in Ada catchpoint tests
Date: Wed, 24 May 2023 10:36:53 -0600	[thread overview]
Message-ID: <20230427-ada-catch-exception-v1-2-947caa9905e3@adacore.com> (raw)
In-Reply-To: <20230427-ada-catch-exception-v1-0-947caa9905e3@adacore.com>

This changes the Ada catchpoint tests to use
gnat_runtime_has_debug_info.  This simplifies the code.
---
 gdb/testsuite/gdb.ada/catch_assert_if.exp  | 28 +------------------------
 gdb/testsuite/gdb.ada/catch_ex.exp         | 18 ++++------------
 gdb/testsuite/gdb.ada/catch_ex_std.exp     | 27 ++++++++----------------
 gdb/testsuite/gdb.ada/excep_handle.exp     | 24 +++++-----------------
 gdb/testsuite/gdb.ada/mi_catch_assert.exp  | 33 +-----------------------------
 gdb/testsuite/gdb.ada/mi_catch_ex.exp      | 31 ++--------------------------
 gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp | 32 +----------------------------
 gdb/testsuite/gdb.ada/mi_ex_cond.exp       | 33 +++---------------------------
 8 files changed, 25 insertions(+), 201 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/catch_assert_if.exp b/gdb/testsuite/gdb.ada/catch_assert_if.exp
index f5b6096ecb0..4078fa408d1 100644
--- a/gdb/testsuite/gdb.ada/catch_assert_if.exp
+++ b/gdb/testsuite/gdb.ada/catch_assert_if.exp
@@ -15,7 +15,7 @@
 
 load_lib "ada.exp"
 
-require allow_ada_tests
+require allow_ada_tests gnat_runtime_has_debug_info
 
 standard_ada_testfile bla
 
@@ -25,35 +25,9 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional
 
 clean_restart ${testfile}
 
-######################################################################
-# 1. Try catching all exceptions to check that runtime supports it.  #
-######################################################################
-
 set eol "\[\r\n\]+"
 set sp "\[ \t\]*"
 
-if {![runto_main]} {
-   return 0
-}
-
-set msg "insert catchpoint on all Ada exceptions"
-gdb_test_multiple "catch exception" $msg {
-    -re "Catchpoint $decimal: all Ada exceptions$eol$gdb_prompt $" {
-	pass $msg
-    }
-    -re "Your Ada runtime appears to be missing some debugging information.*$eol$gdb_prompt $" {
-	# If the runtime was not built with enough debug information,
-	# or if it was stripped, we can not test exception
-	# catchpoints.
-	unsupported $msg
-	return -1
-    }
-}
-
-##################################################
-# 2. Try catching conditional failed assertion.  #
-##################################################
-
 # Here is the scenario:
 #  - Restart the debugger from scratch, runto_main
 #    We'll catch assertions if Global_Var = 2
diff --git a/gdb/testsuite/gdb.ada/catch_ex.exp b/gdb/testsuite/gdb.ada/catch_ex.exp
index de1e53243fb..388eb949e37 100644
--- a/gdb/testsuite/gdb.ada/catch_ex.exp
+++ b/gdb/testsuite/gdb.ada/catch_ex.exp
@@ -15,7 +15,7 @@
 
 load_lib "ada.exp"
 
-require allow_ada_tests
+require allow_ada_tests gnat_runtime_has_debug_info
 
 standard_ada_testfile foo
 
@@ -44,19 +44,9 @@ if {![runto_main]} {
    return 0
 }
 
-set msg "insert catchpoint on all Ada exceptions"
-gdb_test_multiple "catch exception" $msg {
-    -re "Catchpoint $any_nb: all Ada exceptions$eol$gdb_prompt $" {
-	pass $msg
-    }
-    -re "Your Ada runtime appears to be missing some debugging information.*$eol$gdb_prompt $" {
-	# If the runtime was not built with enough debug information,
-	# or if it was stripped, we can not test exception
-	# catchpoints.
-	unsupported $msg
-	return -1
-    }
-}
+gdb_test "catch exception" \
+    "Catchpoint $any_nb: all Ada exceptions" \
+    "insert catchpoint on all Ada exceptions"
 
 gdb_test "info break" \
          "$info_break_header$eol.*$catch_exception_info" \
diff --git a/gdb/testsuite/gdb.ada/catch_ex_std.exp b/gdb/testsuite/gdb.ada/catch_ex_std.exp
index 73cbdaf90ca..3a2b10a8c13 100644
--- a/gdb/testsuite/gdb.ada/catch_ex_std.exp
+++ b/gdb/testsuite/gdb.ada/catch_ex_std.exp
@@ -17,7 +17,7 @@ require allow_shlib_tests
 
 load_lib "ada.exp"
 
-require allow_ada_tests
+require allow_ada_tests gnat_runtime_has_debug_info
 
 standard_ada_testfile foo
 
@@ -69,23 +69,12 @@ if {![runto_main]} {
    return 0
 }
 
-set can_catch_exceptions 0
-gdb_test_multiple "catch exception some_kind_of_error" "" {
-    -re "Catchpoint \[0-9\]+: `some_kind_of_error' Ada exception\r\n$gdb_prompt $" {
-	pass $gdb_test_name
-	set can_catch_exceptions 1
-    }
+gdb_test "catch exception some_kind_of_error" \
+    "Catchpoint \[0-9\]+: `some_kind_of_error' Ada exception"
 
-    -re "Your Ada runtime appears to be missing some debugging information.\r\nCannot insert Ada exception catchpoint in this configuration.\r\n$gdb_prompt $" {
-	    unsupported $gdb_test_name
-    }
-}
-
-if { $can_catch_exceptions } {
-    gdb_test "cont" \
-	"Catchpoint \[0-9\]+, .* at .*foo\.adb:\[0-9\]+.*" \
-	"caught the exception"
+gdb_test "cont" \
+    "Catchpoint \[0-9\]+, .* at .*foo\.adb:\[0-9\]+.*" \
+    "caught the exception"
 
-    gdb_test "print \$_ada_exception = some_package.some_kind_of_error'Address" \
-	" = true"
-}
+gdb_test "print \$_ada_exception = some_package.some_kind_of_error'Address" \
+    " = true"
diff --git a/gdb/testsuite/gdb.ada/excep_handle.exp b/gdb/testsuite/gdb.ada/excep_handle.exp
index 2cc80fbb988..deb3ace2987 100644
--- a/gdb/testsuite/gdb.ada/excep_handle.exp
+++ b/gdb/testsuite/gdb.ada/excep_handle.exp
@@ -15,7 +15,7 @@
 
 load_lib "ada.exp"
 
-require allow_ada_tests
+require allow_ada_tests gnat_runtime_has_debug_info
 
 standard_ada_testfile foo
 
@@ -40,32 +40,18 @@ set catchpoint_program_error_msg \
 set catchpoint_storage_error_msg \
   "Catchpoint $decimal, exception at $hex in foo \\\(\\\).*at .*foo.adb:$decimal$eol$decimal$sp$when Storage_Error =>"
 
-############################################
-# Check that runtime supports catchpoint.  #
-############################################
-
 if {![runto_main]} {
    return 0
 }
 
-set msg "insert catchpoint on all Ada exceptions handlers"
-gdb_test_multiple "catch handlers" $msg {
-    -re "Catchpoint $decimal: all Ada exceptions handlers$eol$gdb_prompt $" {
-	pass $msg
-    }
-    -re "Your Ada runtime appears to be missing some debugging information.*$eol$gdb_prompt $" {
-	# If the runtime was not built with enough debug information,
-	# or if it was stripped, we can not test exception handlers
-	# catchpoints.
-	unsupported $msg
-	return -1
-    }
-}
-
 ############################################
 # 1. Try catching all exceptions handlers. #
 ############################################
 
+gdb_test "catch handlers" \
+    "Catchpoint $decimal: all Ada exceptions handlers" \
+    "insert catchpoint on all Ada exceptions handlers"
+
 # Continue.  The program should stop at first exception handling.
 
 gdb_test "continue" \
diff --git a/gdb/testsuite/gdb.ada/mi_catch_assert.exp b/gdb/testsuite/gdb.ada/mi_catch_assert.exp
index c3673fab8e8..7586e0a4256 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_assert.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_assert.exp
@@ -15,7 +15,7 @@
 
 load_lib "ada.exp"
 
-require allow_ada_tests
+require allow_ada_tests gnat_runtime_has_debug_info
 
 standard_ada_testfile bla
 
@@ -23,37 +23,6 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional
   return -1
 }
 
-# Some global variables used to simplify the maintenance of some of
-# the regular expressions below.
-set eol "\[\r\n\]+"
-set sp "\[ \t\]*"
-
-# Before going any further, verify that we can insert exception
-# catchpoints...  That way, we won't have to do this while doing
-# the actual GDB/MI testing.
-
-clean_restart ${testfile}
-
-if {![runto_main]} {
-   return 0
-}
-
-set msg "insert catchpoint on all Ada exceptions"
-gdb_test_multiple "catch exception" $msg {
-    -re "Catchpoint $decimal: all Ada exceptions$eol$gdb_prompt $" {
-	pass $msg
-    }
-    -re "Your Ada runtime appears to be missing some debugging information.*\[\r\n\]+$gdb_prompt $" {
-	# If the runtime was not built with enough debug information,
-	# or if it was stripped, we can not test exception
-	# catchpoints.
-	unsupported $msg
-	return -1
-    }
-}
-
-# Now, we can start the GDB/MI testing itself...
-
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
diff --git a/gdb/testsuite/gdb.ada/mi_catch_ex.exp b/gdb/testsuite/gdb.ada/mi_catch_ex.exp
index d0dfbd59764..8cbcbe7e1a8 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_ex.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_ex.exp
@@ -15,7 +15,7 @@
 
 load_lib "ada.exp"
 
-require allow_ada_tests
+require allow_ada_tests gnat_runtime_has_debug_info
 
 standard_ada_testfile foo
 
@@ -23,36 +23,9 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional
   return -1
 }
 
-# Some global variables used to simplify the maintenance of some of
+# A global variable used to simplify the maintenance of some of
 # the regular expressions below.
 set any_nb "\[0-9\]+"
-set eol "\[\r\n\]+"
-
-# Before going any further, verify that we can insert exception
-# catchpoints...  That way, we won't have to do this while doing
-# the actual GDB/MI testing.
-
-clean_restart ${testfile}
-
-if {![runto_main]} {
-   return 0
-}
-
-set msg "insert catchpoint on all Ada exceptions"
-gdb_test_multiple "catch exception" $msg {
-    -re "Catchpoint $any_nb: all Ada exceptions$eol$gdb_prompt $" {
-	pass $msg
-    }
-    -re "Your Ada runtime appears to be missing some debugging information.*\[\r\n\]+$gdb_prompt $" {
-	# If the runtime was not built with enough debug information,
-	# or if it was stripped, we can not test exception
-	# catchpoints.
-	unsupported $msg
-	return -1
-    }
-}
-
-# Now, we can start the GDB/MI testing itself...
 
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
diff --git a/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp b/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
index 2cd175f098b..ae081448553 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
@@ -15,7 +15,7 @@
 
 load_lib "ada.exp"
 
-require allow_ada_tests
+require allow_ada_tests gnat_runtime_has_debug_info
 
 standard_ada_testfile foo
 
@@ -23,36 +23,6 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional
   return -1
 }
 
-# A global variable used to simplify the maintenance of some of
-# the regular expressions below.
-set eol "\[\r\n\]+"
-
-# Before going any further, verify that we can insert exception
-# handlers catchpoints...  That way, we won't have to do this while
-# doing the actual GDB/MI testing.
-
-clean_restart ${testfile}
-
-if {![runto_main]} {
-   return 0
-}
-
-set msg "insert catchpoint on all Ada exceptions handlers"
-gdb_test_multiple "catch handlers" $msg {
-    -re "Catchpoint $decimal: all Ada exceptions handlers$eol$gdb_prompt $" {
-	pass $msg
-    }
-    -re "Your Ada runtime appears to be missing some debugging information.*\[\r\n\]+$gdb_prompt $" {
-	# If the runtime was not built with enough debug information,
-	# or if it was stripped, we can not test exception
-	# catchpoints.
-	unsupported $msg
-	return -1
-    }
-}
-
-# Now, we can start the GDB/MI testing itself...
-
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
diff --git a/gdb/testsuite/gdb.ada/mi_ex_cond.exp b/gdb/testsuite/gdb.ada/mi_ex_cond.exp
index 54aa6b54ee1..c0bc079f5f9 100644
--- a/gdb/testsuite/gdb.ada/mi_ex_cond.exp
+++ b/gdb/testsuite/gdb.ada/mi_ex_cond.exp
@@ -15,7 +15,7 @@
 
 load_lib "ada.exp"
 
-require allow_ada_tests
+require allow_ada_tests gnat_runtime_has_debug_info
 
 standard_ada_testfile foo
 
@@ -23,36 +23,9 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional
   return -1
 }
 
-# # Some global variables used to simplify the maintenance of some of
-# # the regular expressions below.
+# A global variable used to simplify the maintenance of some of
+# the regular expressions below.
 set any_nb "\[0-9\]+"
-set eol "\[\r\n\]+"
-
-# Before going any further, verify that we can insert exception
-# catchpoints...  That way, we won't have to do this while doing
-# the actual GDB/MI testing.
-
-clean_restart ${testfile}
-
-if {![runto_main]} {
-   return 0
-}
-
-set msg "insert catchpoint on all Ada exceptions"
-gdb_test_multiple "catch exception" $msg {
-    -re "Catchpoint $any_nb: all Ada exceptions$eol$gdb_prompt $" {
-	pass $msg
-    }
-    -re "Your Ada runtime appears to be missing some debugging information.*\[\r\n\]+$gdb_prompt $" {
-	# If the runtime was not built with enough debug information,
-	# or if it was stripped, we can not test exception
-	# catchpoints.
-	unsupported $msg
-	return -1
-    }
-}
-
-# Now, we can start the GDB/MI testing itself...
 
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"

-- 
2.40.0


  parent reply	other threads:[~2023-05-24 16:37 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-24 16:36 [PATCH 00/25] Many updates to DAP implementation Tom Tromey
2023-05-24 16:36 ` [PATCH 01/25] Stop gdb in gnat_runtime_has_debug_info Tom Tromey
2023-05-24 16:36 ` Tom Tromey [this message]
2023-06-13 20:10   ` [PATCH 02/25] Use gnat_runtime_has_debug_info in Ada catchpoint tests Tom de Vries
2023-06-19  9:49     ` Tom de Vries
2023-06-20 13:56       ` Tom Tromey
2023-05-24 16:36 ` [PATCH 03/25] Pass tempflag to ada_catchpoint constructor Tom Tromey
2023-05-24 16:36 ` [PATCH 04/25] Transfer ownership of exception string to ada_catchpoint Tom Tromey
2023-05-24 16:36 ` [PATCH 05/25] Combine create_excep_cond_exprs and ada_catchpoint::re_set Tom Tromey
2023-05-24 16:36 ` [PATCH 06/25] Turn should_stop_exception into a method of ada_catchpoint Tom Tromey
2023-05-24 16:36 ` [PATCH 07/25] Mark members of ada_catchpoint "private" Tom Tromey
2023-05-24 16:36 ` [PATCH 08/25] Don't require inferior execution for Ada catchpoints Tom Tromey
2023-05-24 16:37 ` [PATCH 09/25] Implement DAP setExceptionBreakpoints request Tom Tromey
2023-05-24 16:37 ` [PATCH 10/25] Implement DAP attach request Tom Tromey
2023-05-24 16:53   ` Eli Zaretskii
2023-05-24 16:37 ` [PATCH 11/25] Implement DAP stepOut request Tom Tromey
2023-05-24 16:37 ` [PATCH 12/25] Add singleThread support to some DAP requests Tom Tromey
2023-05-24 16:37 ` [PATCH 13/25] Rename one DAP function Tom Tromey
2023-05-24 16:37 ` [PATCH 14/25] Add test for DAP pause request Tom Tromey
2023-05-24 16:37 ` [PATCH 15/25] Fix a latent bug in DAP request decorator Tom Tromey
2023-05-24 16:37 ` [PATCH 16/25] Use tuples for default arguments in DAP Tom Tromey
2023-05-24 16:37 ` [PATCH 17/25] Add type-checking to DAP requests Tom Tromey
2023-05-24 16:37 ` [PATCH 18/25] Add gdb.Value.assign method Tom Tromey
2023-05-24 16:54   ` Eli Zaretskii
2023-05-24 16:37 ` [PATCH 19/25] Implement DAP setExpression request Tom Tromey
2023-05-24 16:37 ` [PATCH 20/25] Handle DAP supportsVariableType capability Tom Tromey
2023-05-24 16:37 ` [PATCH 21/25] Add "target" parameter to DAP attach request Tom Tromey
2023-05-24 16:55   ` Eli Zaretskii
2023-05-24 16:37 ` [PATCH 22/25] Add "stop at main" extension to DAP launch request Tom Tromey
2023-05-24 16:56   ` Eli Zaretskii
2023-05-24 16:37 ` [PATCH 23/25] Implement DAP breakpointLocations request Tom Tromey
2023-05-24 16:37 ` [PATCH 24/25] Do not report totalFrames from DAP stackTrace request Tom Tromey
2023-05-24 16:37 ` [PATCH 25/25] Implement DAP conditional breakpoints Tom Tromey
2023-06-12 18:11 ` [PATCH 00/25] Many updates to DAP implementation Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230427-ada-catch-exception-v1-2-947caa9905e3@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).