public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 11/11] Update test cases that work with minimal encodings
Date: Wed,  8 Apr 2020 11:54:52 -0600	[thread overview]
Message-ID: <20200408175452.30637-12-tromey@adacore.com> (raw)
In-Reply-To: <20200408175452.30637-1-tromey@adacore.com>

Some test cases already work fine with minimal encodings (in some
cases perhaps due to the variant parts series) This patch updates
these tests as appropriate.

gdb/testsuite/ChangeLog
2020-04-08  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/frame_arg_lang.exp: Run with multiple -fgnat-encodings
	values.
	* gdb.ada/funcall_ref.exp: Run with multiple -fgnat-encodings
	values.  Update test for minimal encodings.
	* gdb.ada/lang_switch.exp: Update test for minimal encodings.
	* gdb.ada/var_rec_arr.exp: Run with multiple -fgnat-encodings
	values.  Update test for minimal encodings.
---
 gdb/testsuite/ChangeLog                  | 10 +++
 gdb/testsuite/gdb.ada/frame_arg_lang.exp | 93 +++++++++++++---------
 gdb/testsuite/gdb.ada/funcall_ref.exp    | 98 +++++++++++++++---------
 gdb/testsuite/gdb.ada/lang_switch.exp    |  5 +-
 gdb/testsuite/gdb.ada/packed_tagged.exp  | 46 ++++++++++-
 gdb/testsuite/gdb.ada/var_rec_arr.exp    | 73 +++++++++++-------
 6 files changed, 221 insertions(+), 104 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/frame_arg_lang.exp b/gdb/testsuite/gdb.ada/frame_arg_lang.exp
index 92baf7dfa10..dc08d261334 100644
--- a/gdb/testsuite/gdb.ada/frame_arg_lang.exp
+++ b/gdb/testsuite/gdb.ada/frame_arg_lang.exp
@@ -21,53 +21,70 @@ set csrcfile ${srcdir}/${subdir}/${testdir}/${cfile}.c
 set cobject [standard_output_file ${cfile}.o]
 
 gdb_compile "${csrcfile}" "${cobject}" object [list debug]
-if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-largs additional_flags=${cobject} additional_flags=-margs]] != "" } {
-  return -1
-}
 
-clean_restart ${testfile}
+# Note we don't test the "none" (no -fgnat-encodings option) scenario
+# here, because "all" and "minimal" cover the cases, and this way we
+# don't have to update the test when gnat changes its default.
+foreach_with_prefix scenario {all minimal} {
+    set flags [list debug additional_flags=-largs \
+		   additional_flags=${cobject} \
+		   additional_flags=-margs \
+		   additional_flags=-fgnat-encodings=$scenario]
+
+    if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != ""} {
+	return -1
+    }
 
-set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.c]
-runto "foo.c:$bp_location"
+    clean_restart ${testfile}
 
-gdb_test_no_output "set print frame-arguments all"
+    set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.c]
+    runto "foo.c:$bp_location"
 
-# Here is the scenario:
-#  - Once stopped in a C function, with language_mode set to auto, print
-#    backtrace, we should see the Ada frame arguments printed using Ada
-#    syntax.
-#  - Set language to C, then check that printing backtrace shows the Ada
-#    frame arguments using C syntax.
-#  - Set language back to auto, check language mode value, then print
-#    backtrace, we should see Ada frame arguments printed using Ada C
-#    syntax.
+    gdb_test_no_output "set print frame-arguments all"
 
-gdb_test "show lang" \
-         "The current source language is \"auto; currently c\"." \
-         "show language when set to 'auto; c'"
+    # Here is the scenario:
+    #  - Once stopped in a C function, with language_mode set to auto, print
+    #    backtrace, we should see the Ada frame arguments printed using Ada
+    #    syntax.
+    #  - Set language to C, then check that printing backtrace shows the Ada
+    #    frame arguments using C syntax.
+    #  - Set language back to auto, check language mode value, then print
+    #    backtrace, we should see Ada frame arguments printed using Ada C
+    #    syntax.
 
-gdb_test "bt" \
-         "#1  $hex in pck\\.call_me \\(s=\"test\"\\).*" \
-         "backtrace with auto: c"
+    gdb_test "show lang" \
+	"The current source language is \"auto; currently c\"." \
+	"show language when set to 'auto; c'"
 
-gdb_test_no_output "set language c" \
-                   "Set current source language to \"manual; currently c\"."
+    gdb_test "bt" \
+	"#1  $hex in pck\\.call_me \\(s=\"test\"\\).*" \
+	"backtrace with auto: c"
 
-gdb_test "show lang" \
-         "The current source language is \"c\"." \
-         "show language when set to 'c'"
+    gdb_test_no_output "set language c" \
+	"Set current source language to \"manual; currently c\"."
 
-gdb_test "bt" \
-         "#1  $hex in pck\\.call_me \\(s={P_ARRAY = $hex, P_BOUNDS = $hex}\\).*" \
-         "backtrace with language forced to 'c'"
+    gdb_test "show lang" \
+	"The current source language is \"c\"." \
+	"show language when set to 'c'"
 
-gdb_test_no_output "set language auto" \
-                   "Set current source language to \"auto; currently c\"."
+    # With -fgnat-encodings=minimal, this works properly in C as well.
+    if {$scenario == "minimal"} {
+	set expected "\"test\""
+    } else {
+	set expected "{P_ARRAY = $hex, P_BOUNDS = $hex}"
+    }
+    gdb_test "bt" \
+	"#1  $hex in pck\\.call_me \\(s=$expected\\).*" \
+	"backtrace with language forced to 'c'"
 
-gdb_test "show lang" \
-         "The current source language is \"auto; currently c\"." \
-         "show language when set back to 'auto; c'"
+    gdb_test_no_output "set language auto" \
+	"Set current source language to \"auto; currently c\"."
 
-gdb_test "bt" \
-         "#1  $hex in pck\\.call_me \\(s=\"test\"\\).*" \
-         "backtrace with language back to 'auto; c'"
+    gdb_test "show lang" \
+	"The current source language is \"auto; currently c\"." \
+	"show language when set back to 'auto; c'"
+
+    gdb_test "bt" \
+	"#1  $hex in pck\\.call_me \\(s=\"test\"\\).*" \
+	"backtrace with language back to 'auto; c'"
+}
diff --git a/gdb/testsuite/gdb.ada/funcall_ref.exp b/gdb/testsuite/gdb.ada/funcall_ref.exp
index 02664f6ad32..e260e908643 100644
--- a/gdb/testsuite/gdb.ada/funcall_ref.exp
+++ b/gdb/testsuite/gdb.ada/funcall_ref.exp
@@ -17,43 +17,71 @@ load_lib "ada.exp"
 
 standard_ada_testfile foo
 
-if {[gdb_compile_ada "${srcfile}" "${binfile}" executable \
-                     [list debug]] != "" } {
-  return -1
-}
+# Note we don't test the "none" (no -fgnat-encodings option) scenario
+# here, because "all" and "minimal" cover the cases, and this way we
+# don't have to update the test when gnat changes its default.
+foreach_with_prefix scenario {all minimal} {
+    set flags [list debug additional_flags=-fgnat-encodings=$scenario]
 
-clean_restart ${testfile}
-
-set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
-runto "foo.adb:$bp_location"
-
-# Test printing and type-printing of a discriminated record that a function
-# returns by reference.
-
-# Currently, GCC describes such functions as returning pointers (instead of
-# references).
-set pass_re [multi_line "type = <ref> record" \
-		 "    n: natural;" \
-		 "    s: access array \\(1 \\.\\. n\\) of character;" \
-		 "end record"]
-set unsupported_re [multi_line "type = access record" \
-		 "    n: natural;" \
-		 "    s: access array \\(1 \\.\\. n\\) of character;" \
-		 "end record"]
-set supported 1
-gdb_test_multiple "ptype get (\"Hello world!\")" "" {
-    -re -wrap $pass_re {
-	pass $gdb_test_name
+    if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != ""} {
+	return -1
     }
-    -re -wrap $unsupported_re {
-	unsupported $gdb_test_name
-	set supported 0
+
+    clean_restart ${testfile}
+
+    set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
+    runto "foo.adb:$bp_location"
+
+    # Test printing and type-printing of a discriminated record that a function
+    # returns by reference.
+
+    # Currently, GCC describes such functions as returning pointers (instead of
+    # references).
+    set pass_re [multi_line "type = <ref> record" \
+		     "    n: natural;" \
+		     "    s: access array \\(1 \\.\\. n\\) of character;" \
+		     "end record"]
+    # With DWARF we get debuginfo that could in theory show "1..n" for
+    # the range:
+    #     <3><1230>: Abbrev Number: 15 (DW_TAG_member)
+    #     <1231>   DW_AT_name        : n
+    # ...
+    #  <4><1257>: Abbrev Number: 18 (DW_TAG_subrange_type)
+    #     <1258>   DW_AT_type        : <0x126e>
+    #     <125c>   DW_AT_upper_bound : <0x1230>
+    # However, we don't currently record the needed information in the
+    # location batons.  In the meantime, we accept and kfail the
+    # compromise output.
+    set dwarf_kfail_re [multi_line "type = <ref> record" \
+			    "    n: natural;" \
+			    "    s: array \\(<>\\) of character;" \
+			    "end record"]
+    set unsupported_re [multi_line "type = access record" \
+			    "    n: natural;" \
+			    "    s: access array \\(1 \\.\\. n\\) of character;" \
+			    "end record"]
+    set supported 1
+    gdb_test_multiple "ptype get (\"Hello world!\")" "" {
+	-re -wrap $pass_re {
+	    pass $gdb_test_name
+	}
+	-re -wrap $dwarf_kfail_re {
+	    if {$scenario == "minimal"} {
+		setup_kfail "symbolic names in location batons" *-*-*
+	    }
+	    fail $gdb_test_name
+	    set supported 0
+	}
+	-re -wrap $unsupported_re {
+	    unsupported $gdb_test_name
+	    set supported 0
+	}
     }
-}
 
-if { $supported == 0 } {
-    return 0
-}
+    if { $supported == 0 } {
+	return 0
+    }
 
-gdb_test "p get (\"Hello world!\")" \
-    "= \\(n => 12, s => \"Hello world!\"\\)"
+    gdb_test "p get (\"Hello world!\")" \
+	"= \\(n => 12, s => \"Hello world!\"\\)"
+}
diff --git a/gdb/testsuite/gdb.ada/lang_switch.exp b/gdb/testsuite/gdb.ada/lang_switch.exp
index 006cae05913..7d9bd617504 100644
--- a/gdb/testsuite/gdb.ada/lang_switch.exp
+++ b/gdb/testsuite/gdb.ada/lang_switch.exp
@@ -41,6 +41,9 @@ gdb_test "bt" \
 # Now, make sure that the language doesn't get automatically switched
 # if the current language is not "auto".
 gdb_test "set lang c"
+# This gives different output with -fgnat-encodings=minimal and
+# -fgnat-encodings=all, but since we don't care so much about the
+# precise details here, we just accept anything.
 gdb_test "bt" \
-         ".*#1.*lang_switch\\.ada_procedure\\s*\\(msg=(@$hex: +)?{.*\\).*" \
+         ".*#1.*lang_switch\\.ada_procedure\\s*\\(msg=(@$hex: +)?.*\\).*" \
          "backtrace with lang set to C"
diff --git a/gdb/testsuite/gdb.ada/packed_tagged.exp b/gdb/testsuite/gdb.ada/packed_tagged.exp
index 72ae29c08d4..d6ee8454c5a 100644
--- a/gdb/testsuite/gdb.ada/packed_tagged.exp
+++ b/gdb/testsuite/gdb.ada/packed_tagged.exp
@@ -17,7 +17,10 @@ load_lib "ada.exp"
 
 standard_ada_testfile comp_bug
 
-foreach_with_prefix scenario {none all minimal} {
+# Note we don't test the "none" (no -fgnat-encodings option) scenario
+# here, because "all" and "minimal" cover the cases, and this way we
+# don't have to update the test when gnat changes its default.
+foreach_with_prefix scenario {all minimal} {
     set flags {debug}
     if {$scenario != "none"} {
 	lappend flags additional_flags=-fgnat-encodings=$scenario
@@ -32,10 +35,25 @@ foreach_with_prefix scenario {none all minimal} {
     set bp_location [gdb_get_line_number "STOP" ${testdir}/comp_bug.adb]
     runto "comp_bug.adb:$bp_location"
 
-    gdb_test "print x" \
+    set pass_re \
 	"= \\(exists => true, value => 10\\)"
+    # There is a compiler bug that causes this output.
+    set kfail_re \
+	"= \\(exists => true\\)"
 
-    gdb_test "ptype x" \
+    gdb_test_multiple "print x" "" {
+	-re -wrap $pass_re {
+	    pass $gdb_test_name
+	}
+	-re -wrap $kfail_re {
+	    if {$scenario == "minimal"} {
+		setup_kfail "gnat compiler bug" *-*-*
+	    }
+	    fail $gdb_test_name
+	}
+    }
+
+    set pass_re \
 	[multi_line "type = record" \
 	     "    exists: (boolean|range false \\.\\. true);" \
 	     "    case exists is" \
@@ -44,4 +62,26 @@ foreach_with_prefix scenario {none all minimal} {
 	     "        when others => null;" \
 	     "    end case;" \
 	     "end record" ]
+    # There is a compiler bug that causes this output.
+    set kfail_re \
+	[multi_line "type = record" \
+	     "    exists: (boolean|range false \\.\\. true);" \
+	     "    case \\? is" \
+	     "        when others =>" \
+	     "            value: range 0 \\.\\. 255;" \
+	     "        when others => null;" \
+	     "    end case;" \
+	     "end record" ]
+
+    gdb_test_multiple "ptype x" "" {
+	-re -wrap $pass_re {
+	    pass $gdb_test_name
+	}
+	-re -wrap $kfail_re {
+	    if {$scenario == "minimal"} {
+		setup_kfail "gnat compiler bug" *-*-*
+	    }
+	    fail $gdb_test_name
+	}
+    }
 }
diff --git a/gdb/testsuite/gdb.ada/var_rec_arr.exp b/gdb/testsuite/gdb.ada/var_rec_arr.exp
index 146ad5e8dc0..80ec32616a9 100644
--- a/gdb/testsuite/gdb.ada/var_rec_arr.exp
+++ b/gdb/testsuite/gdb.ada/var_rec_arr.exp
@@ -17,41 +17,60 @@ load_lib "ada.exp"
 
 standard_ada_testfile foo_na09_042
 
-if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } {
-  return -1
-}
+# Note we don't test the "none" (no -fgnat-encodings option) scenario
+# here, because "all" and "minimal" cover the cases, and this way we
+# don't have to update the test when gnat changes its default.
+foreach_with_prefix scenario {all minimal} {
+    set flags [list debug additional_flags=-fgnat-encodings=$scenario]
+
+    if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != ""} {
+	return -1
+    }
 
-clean_restart ${testfile}
+    clean_restart ${testfile}
 
-set bp_location [gdb_get_line_number "STOP" ${testdir}/foo_na09_042.adb]
-runto "foo_na09_042.adb:$bp_location"
+    set bp_location [gdb_get_line_number "STOP" ${testdir}/foo_na09_042.adb]
+    runto "foo_na09_042.adb:$bp_location"
 
-gdb_test "print a1" \
-         " = \\(\\(i => 0, s => \"\"\\), \\(i => 1, s => \"A\"\\), \\(i => 2, s => \"AB\"\\)\\)"
+    gdb_test "print a1" \
+	" = \\(\\(i => 0, s => \"\"\\), \\(i => 1, s => \"A\"\\), \\(i => 2, s => \"AB\"\\)\\)"
 
-gdb_test "print a1(1)" \
-         " = \\(i => 0, s => \"\"\\)"
+    gdb_test "print a1(1)" \
+	" = \\(i => 0, s => \"\"\\)"
 
-gdb_test "print a1(2)" \
-         " = \\(i => 1, s => \"A\"\\)"
+    gdb_test "print a1(2)" \
+	" = \\(i => 1, s => \"A\"\\)"
 
-gdb_test "print a1(3)" \
-         " = \\(i => 2, s => \"AB\"\\)"
+    gdb_test "print a1(3)" \
+	" = \\(i => 2, s => \"AB\"\\)"
 
-gdb_test "print a2" \
-         " = \\(\\(i => 2, s => \"AB\"\\), \\(i => 1, s => \"A\"\\), \\(i => 0, s => \"\"\\)\\)"
+    gdb_test "print a2" \
+	" = \\(\\(i => 2, s => \"AB\"\\), \\(i => 1, s => \"A\"\\), \\(i => 0, s => \"\"\\)\\)"
 
-gdb_test "print a2(1)" \
-         " = \\(i => 2, s => \"AB\"\\)"
+    gdb_test "print a2(1)" \
+	" = \\(i => 2, s => \"AB\"\\)"
 
-gdb_test "print a2(2)" \
-         " = \\(i => 1, s => \"A\"\\)"
+    gdb_test "print a2(2)" \
+	" = \\(i => 1, s => \"A\"\\)"
 
-gdb_test "print a2(3)" \
-         " = \\(i => 0, s => \"\"\\)"
+    gdb_test "print a2(3)" \
+	" = \\(i => 0, s => \"\"\\)"
 
-gdb_test "ptype a1(1)" \
-         [multi_line "type = record" \
-                     "    i: pck\\.small_type;" \
-                     "    s: access array \\((<>|1 \\.\\. i)\\) of character;" \
-                     "end record"]
+    # Note that the "access" is only printed when the gnat encodings
+    # are used.  This is due to how the encodings work -- the type
+    # doesn't actually have the "access", and so here the DWARF
+    # encoding is more correct.
+    if {$scenario == "all"} {
+	set ex [multi_line "type = record" \
+		    "    i: pck\\.small_type;" \
+		    "    s: access array \\((<>|1 \\.\\. i)\\) of character;" \
+		    "end record"]
+    } else {
+	set ex [multi_line "type = record" \
+		    "    i: pck\\.small_type;" \
+		    "    s: array \\((<>|1 \\.\\. i)\\) of character;" \
+		    "end record"]
+    }
+
+    gdb_test "ptype a1(1)" $ex
+}
-- 
2.21.1


  parent reply	other threads:[~2020-04-08 17:54 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-08 17:54 [PATCH 0/11] Variant part support, plus more Tom Tromey
2020-04-08 17:54 ` [PATCH 01/11] Rename "variant" to "ppc_variant" Tom Tromey
2020-04-08 17:54 ` [PATCH 02/11] Add new variant part code Tom Tromey
2020-04-08 17:54 ` [PATCH 03/11] Allow DWARF expression to push the initial address Tom Tromey
2020-04-08 17:54 ` [PATCH 04/11] Prefer existing data when evaluating DWARF expression Tom Tromey
2020-04-08 17:54 ` [PATCH 05/11] Rewrite the existing variant part code Tom Tromey
2020-06-04  8:13   ` Tom de Vries
2020-06-15 17:30     ` Tom Tromey
2020-06-17 16:11       ` Tom de Vries
2020-06-17 16:45         ` Tom Tromey
     [not found]           ` <af2905c9-739a-be03-6925-2109e308540a@suse.de>
2020-06-19 20:51             ` Tom Tromey
2020-04-08 17:54 ` [PATCH 06/11] Add support for dynamic type lengths Tom Tromey
2020-04-08 17:54 ` [PATCH 07/11] Add support for variable field offsets Tom Tromey
2020-04-08 17:54 ` [PATCH 08/11] Update Ada ptype support for dynamic types Tom Tromey
2020-04-08 17:54 ` [PATCH 09/11] Add tests for Ada changes Tom Tromey
2020-04-08 17:54 ` [PATCH 10/11] Add Python support for dynamic types Tom Tromey
2020-04-08 18:59   ` Eli Zaretskii
2020-04-09  0:20   ` Christian Biesinger
2020-04-09 18:44     ` Tom Tromey
2020-04-10 17:44       ` Christian Biesinger
2020-04-24 19:42         ` Tom Tromey
2020-04-24 20:35         ` Tom Tromey
2020-04-25  8:43           ` Matt Rice
2020-04-08 17:54 ` Tom Tromey [this message]
2020-04-28  6:38   ` [PATCH 11/11] Update test cases that work with minimal encodings Tom de Vries
2020-04-28 15:35     ` Tom Tromey
2020-04-30  6:45       ` Tom de Vries
2020-05-11 20:31       ` [committed][gdb/testsuite] Change kfail into xfail in gdb.ada/packed_tagged.exp Tom de Vries
2020-04-24 19:39 ` [PATCH 0/11] Variant part support, plus more 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=20200408175452.30637-12-tromey@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).