public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed] [gdb/testsuite] Fix gdb.ada/same_enum.exp
@ 2023-09-06 15:25 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2023-09-06 15:25 UTC (permalink / raw)
  To: gdb-patches

Test-case gdb.ada/same_enum.exp is supposed to be a regression test for this
bit of code in remove_extra_symbols:
...
  if (symbols_are_identical_enums (syms))
    syms.resize (1);
...

The test-case does "print red" and expects one of these two choices to be
picked by remove_extra_symbols:
...
  type Color is (Black, Red, Green, Blue, White);
  type RGB_Color is new Color range Red .. Blue;
...
but because only the type Color is used:
...
  FC : Color := Red;
  SC : Color := Green;
...
the RGB_Color type is eliminated from the debug info, and consequently
remove_extra_symbols has no effect for the test-case.

In other words, we have:
...
(gdb) ptype Color ^M
type = (black, red, green, blue, white)^M
(gdb) ptype RGB_Color^M
No definition of "rgb_color" in current context.^M
...

Fix this by changing the type of SC to RGB_Color, and add prints of the two
types to check that they're both available.

With the test-case fixed, if we disable the bit of code in
remove_extra_symbols we get:
...
(gdb) print red^M
Multiple matches for red^M
[0] cancel^M
[1] pck.color'(pck.red) (enumeral)^M
[2] pck.rgb_colorB'(pck.red) (enumeral)^M
> FAIL: gdb.ada/same_enum.exp: print red (timeout)
...
in other words, the test-case now properly functions as a regression test.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.ada/same_enum.exp   | 4 +++-
 gdb/testsuite/gdb.ada/same_enum/a.adb | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/same_enum.exp b/gdb/testsuite/gdb.ada/same_enum.exp
index e476c271338..92620d1fbe2 100644
--- a/gdb/testsuite/gdb.ada/same_enum.exp
+++ b/gdb/testsuite/gdb.ada/same_enum.exp
@@ -32,4 +32,6 @@ clean_restart ${testfile}
 # it's because the two types are strongly related).
 gdb_test "print red" "= red"
 
-
+# Check that both types are in fact present.
+gdb_test "ptype Color " "^type = .*"
+gdb_test "ptype RGB_Color"  "^type = .*"
diff --git a/gdb/testsuite/gdb.ada/same_enum/a.adb b/gdb/testsuite/gdb.ada/same_enum/a.adb
index ef2cceb3e60..4612aaa7283 100644
--- a/gdb/testsuite/gdb.ada/same_enum/a.adb
+++ b/gdb/testsuite/gdb.ada/same_enum/a.adb
@@ -17,7 +17,7 @@ with Pck; use Pck;
 
 procedure A is
    FC : Color := Red;
-   SC : Color := Green;
+   SC : RGB_Color := Green;
 begin
    Do_Nothing (FC'Address);
    Do_Nothing (SC'Address);

base-commit: e061219f5d600af5b33418553f192e0cb9fc9ca9
-- 
2.35.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-06 15:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-06 15:25 [pushed] [gdb/testsuite] Fix gdb.ada/same_enum.exp Tom de Vries

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).