public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/29335] New: [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element
@ 2022-07-08  8:00 vries at gcc dot gnu.org
  2023-04-19 18:24 ` [Bug ada/29335] " tromey at sourceware dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2022-07-08  8:00 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29335

            Bug ID: 29335
           Summary: [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp:
                    print v1 element
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ada
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

With test-case gdb.ada/local-enum.exp and target board debug-types, I run into:
...
(gdb) print v1(three)^M
No name 'three' in enumeration type 'local__e1'^M
(gdb) FAIL: gdb.ada/local-enum.exp: print v1 element
print v2(three)^M
No name 'three' in enumeration type 'local__e2'^M
(gdb) FAIL: gdb.ada/local-enum.exp: print v2 element
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug ada/29335] [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element
  2022-07-08  8:00 [Bug ada/29335] New: [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element vries at gcc dot gnu.org
@ 2023-04-19 18:24 ` tromey at sourceware dot org
  2023-04-20  8:03 ` vries at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at sourceware dot org @ 2023-04-19 18:24 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29335

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
FWIW this passes for me on x86-64 Fedora 36:

murgatroyd. runtest --target_board=debug-types gdb.ada/local-enum.exp
...
                === gdb Summary ===

# of expected passes            7

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug ada/29335] [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element
  2022-07-08  8:00 [Bug ada/29335] New: [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element vries at gcc dot gnu.org
  2023-04-19 18:24 ` [Bug ada/29335] " tromey at sourceware dot org
@ 2023-04-20  8:03 ` vries at gcc dot gnu.org
  2023-04-20  8:57 ` vries at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2023-04-20  8:03 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29335

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom Tromey from comment #1)
> FWIW this passes for me on x86-64 Fedora 36:
> 
> murgatroyd. runtest --target_board=debug-types gdb.ada/local-enum.exp
> ...
> 		=== gdb Summary ===
> 
> # of expected passes		7

Fails for me with GNATMAKE 11.3.0 (and all the way back to 7.5.0).

Passes for me with GNATMAKE 12.2.1.

Fedora 36 uses gcc 12 AFAICT (
https://fedoraproject.org/wiki/Changes/GNUToolchainF36 ) so that makes sense.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug ada/29335] [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element
  2022-07-08  8:00 [Bug ada/29335] New: [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element vries at gcc dot gnu.org
  2023-04-19 18:24 ` [Bug ada/29335] " tromey at sourceware dot org
  2023-04-20  8:03 ` vries at gcc dot gnu.org
@ 2023-04-20  8:57 ` vries at gcc dot gnu.org
  2023-04-27 16:30 ` tromey at sourceware dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2023-04-20  8:57 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29335

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
With gnatmake-11:
...
$ readelf -WS leap-15-4/build/gdb/testsuite/outputs/gdb.ada/local-enum/local |
grep debug | sed 's/.*\.//' | awk '{print $1}'
debug_aranges
debug_info
debug_abbrev
debug_line
debug_str
debug_loc
debug_ranges
debug_types
...

With gnatmake-12:
...
$ readelf -WS leap-15-4/build/gdb/testsuite/outputs/gdb.ada/local-enum/local |
grep debug | sed 's/.*\.//' | awk '{print $1}'
debug_aranges
debug_info
debug_abbrev
debug_line
debug_str
debug_loc
debug_ranges
...

So, the test-case passes with gnatmake-12 because .debug_types is no longer
generated.

I wrote some C program that has an enum:
...
$ cat test.c
enum a {
  b, c ,d
};

enum a
foo (enum a e)
{
  return e;
}

int
main (void)
{
  foo (b);
  return 0;
}
...
and tried:
...
$ gcc-11 test.c -g -fdebug-types-section; readelf -S -W a.out | grep -c
debug_types
1
$ gcc-12 test.c -g -fdebug-types-section; readelf -S -W a.out | grep -c
debug_types
1
...
so it's not that support for fdebug-types-section disappeared.

It's just that the ada compiler no longer generates the .debug_types section
for a DW_TAG_type_unit which is used here:
...
 <1><15f2>: Abbrev Number: 19 (DW_TAG_array_type)
    <15f3>   DW_AT_name        : (indirect string, offset: 0x1e5a): local__a2
    <15f7>   DW_AT_GNAT_descriptive_type: signature: 0x76b135b6e23e0b79
    <15ff>   DW_AT_type        : <0x15ce>
...
referenced using a DW_AT_GNAT_descriptive_type.

The FAIL is back if we add additional_flags=-fgnat-encodings=all.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug ada/29335] [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element
  2022-07-08  8:00 [Bug ada/29335] New: [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-04-20  8:57 ` vries at gcc dot gnu.org
@ 2023-04-27 16:30 ` tromey at sourceware dot org
  2023-09-07 10:27 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at sourceware dot org @ 2023-04-27 16:30 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29335

--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
(In reply to Tom de Vries from comment #3)

> The FAIL is back if we add additional_flags=-fgnat-encodings=all.

FWIW with new-enough versions of gcc, I encourage people
to use "minimal" encodings and not GNAT encodings.
I'd like to deprecate these eventually.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug ada/29335] [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element
  2022-07-08  8:00 [Bug ada/29335] New: [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-04-27 16:30 ` tromey at sourceware dot org
@ 2023-09-07 10:27 ` vries at gcc dot gnu.org
  2023-09-07 15:10 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-07 10:27 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29335

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
Tentative patch:
...
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 2e1b9664fdc..2496c099f19 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -204,6 +204,8 @@ static symbol_name_matcher_ftype
*ada_get_symbol_name_matcher

 static int symbols_are_identical_enums
   (const std::vector<struct block_symbol> &syms);
+
+static int ada_identical_enum_types_p (struct type *type1, struct type
*type2);



 /* The character set used for source files.  */
@@ -3801,11 +3803,24 @@ ada_resolve_enum (std::vector<struct block_symbol>
&syms,
   gdb_assert (context_type->code () == TYPE_CODE_ENUM);
   context_type = ada_check_typedef (context_type);

+  /* We already know the name matches, so we're just looking for
+     an element of the correct enum type.  */
+  struct type *type1 = context_type;
+  for (int i = 0; i < syms.size (); ++i)
+    {
+      struct type *type2 = ada_check_typedef (syms[i].symbol->type ());
+      if (type1 == type2)
+       return i;
+    }
+
   for (int i = 0; i < syms.size (); ++i)
     {
-      /* We already know the name matches, so we're just looking for
-        an element of the correct enum type.  */
-      if (ada_check_typedef (syms[i].symbol->type ()) == context_type)
+      struct type *type2 = ada_check_typedef (syms[i].symbol->type ());
+      if (type1->num_fields () != type2->num_fields ())
+       continue;
+      if (strcmp (type1->name (), type2->name ()) != 0)
+       continue;
+      if (ada_identical_enum_types_p (type1, type2))
        return i;
     }

...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug ada/29335] [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element
  2022-07-08  8:00 [Bug ada/29335] New: [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-09-07 10:27 ` vries at gcc dot gnu.org
@ 2023-09-07 15:10 ` vries at gcc dot gnu.org
  2023-09-07 19:53 ` cvs-commit at gcc dot gnu.org
  2023-09-07 19:54 ` vries at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-07 15:10 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29335

--- Comment #6 from Tom de Vries <vries at gcc dot gnu.org> ---
https://sourceware.org/pipermail/gdb-patches/2023-September/202201.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug ada/29335] [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element
  2022-07-08  8:00 [Bug ada/29335] New: [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element vries at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-09-07 15:10 ` vries at gcc dot gnu.org
@ 2023-09-07 19:53 ` cvs-commit at gcc dot gnu.org
  2023-09-07 19:54 ` vries at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-09-07 19:53 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29335

--- Comment #7 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

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

commit 74c36641b0e997ce81294e5bd4fe2d2ce017ea57
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu Sep 7 21:53:17 2023 +0200

    [gdb/ada] Extend type equivalence test in ada_resolve_enum

    When running test-case gdb.ada/local-enum.exp with target board
debug-types, I
    run into:
    ...
    (gdb) print v1(three)^M
    No name 'three' in enumeration type 'local__e1'^M
    (gdb) FAIL: gdb.ada/local-enum.exp: print v1 element
    ...

    The array V1 is of type A1 which is an array with index type E1, containing
    "three" as enumerator:
    ...
      type E1 is (one, two, three);
      type A1 is array (E1) of Integer;
      V1 : A1 := (0, 1, 2);
    ...

    There's also a type E2 that contains three as enumerator:
    ...
      type E2 is (three, four, five);
    ...

    When doing "print v1(three)", it's the job of ada_resolve_enum to resolve
    "three" to type E1 rather than type E2.

    When using target board debug-types, the enums E1 and E2 are replicated in
the
    .debug_types section, and consequently in ada_resolve_enum the type
    equivalence check using a pointer comparison fails:
    ...
      for (int i = 0; i < syms.size (); ++i)
        {
          /* We already know the name matches, so we're just looking for
             an element of the correct enum type.  */
          if (ada_check_typedef (syms[i].symbol->type ()) == context_type)
            return i;
        }
    ...

    Fix this by also trying a structural comparison using
    ada_identical_enum_types_p.

    Tested on x86_64-linux.

    Approved-By: Tom Tromey <tom@tromey.com>

    PR ada/29335
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29335

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug ada/29335] [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element
  2022-07-08  8:00 [Bug ada/29335] New: [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element vries at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2023-09-07 19:53 ` cvs-commit at gcc dot gnu.org
@ 2023-09-07 19:54 ` vries at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-07 19:54 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29335

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.1
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #8 from Tom de Vries <vries at gcc dot gnu.org> ---
Fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-09-07 19:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08  8:00 [Bug ada/29335] New: [gdb/ada, debug-types] FAIL: gdb.ada/local-enum.exp: print v1 element vries at gcc dot gnu.org
2023-04-19 18:24 ` [Bug ada/29335] " tromey at sourceware dot org
2023-04-20  8:03 ` vries at gcc dot gnu.org
2023-04-20  8:57 ` vries at gcc dot gnu.org
2023-04-27 16:30 ` tromey at sourceware dot org
2023-09-07 10:27 ` vries at gcc dot gnu.org
2023-09-07 15:10 ` vries at gcc dot gnu.org
2023-09-07 19:53 ` cvs-commit at gcc dot gnu.org
2023-09-07 19:54 ` vries at gcc dot gnu.org

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