public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug testsuite/31592] New: [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp drops epilogue_begin entry
@ 2024-04-02  6:37 vries at gcc dot gnu.org
  2024-04-02  6:38 ` [Bug testsuite/31592] " vries at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2024-04-02  6:37 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 31592
           Summary: [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp
                    drops epilogue_begin entry
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: testsuite
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

In https://sourceware.org/pipermail/gdb-patches/2024-March/207709.html it was
mentioned that test-case gdb.dwarf2/dw2-epilogue-begin.exp exercises cornercase
behaviour, so I investigated and found the following.

Test-case gdb.dwarf2/dw2-epilogue-begin.exp contains the following dwarf
assembly:
...
            DW_LNE_set_address main_epilogue
            line $main_epilogue
            DW_LNS_set_epilogue_begin
            DW_LNS_copy

            DW_LNE_end_sequence
...
which translates into the following decoded linetable with readelf -wL:
...
dw2-epilogue-begin.c:
File name                        Line number    Starting address    View   
Stmt

/data/vries/gdb/src/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.c:
dw2-epilogue-begin.c                      20            0x4004b7              
x
dw2-epilogue-begin.c                      27            0x4004be              
x
dw2-epilogue-begin.c                      34            0x4004d0              
x
dw2-epilogue-begin.c                      37            0x4004de              
x
dw2-epilogue-begin.c                      38            0x4004ec              
x
dw2-epilogue-begin.c                      43            0x4004ef              
x
dw2-epilogue-begin.c                      47            0x4004fa              
x
dw2-epilogue-begin.c                      50            0x4004ff              
x
dw2-epilogue-begin.c                       -            0x4004ff
...
or alternatively, with llvm-dwarfdump --debug-line:
...
Address            Line   Column File   ISA Discriminator Flags
------------------ ------ ------ ------ --- ------------- -------------
0x00000000004004b7     20      0      0   0             0  is_stmt prologue_end
epilogue_begin
0x00000000004004be     27      0      0   0             0  is_stmt
0x00000000004004d0     34      0      0   0             0  is_stmt prologue_end
0x00000000004004de     37      0      0   0             0  is_stmt
epilogue_begin
0x00000000004004ec     38      0      0   0             0  is_stmt
0x00000000004004ef     43      0      0   0             0  is_stmt prologue_end
0x00000000004004fa     47      0      0   0             0  is_stmt
0x00000000004004ff     50      0      0   0             0  is_stmt
epilogue_begin
0x00000000004004ff     50      0      0   0             0  is_stmt end_sequence
...

Note that the end of sequence is at 0x4004ff, which excludes the entry at line
50 with the same address from that sequence, which gdb indeed does:
...
$ gdb -q -batch outputs/gdb.dwarf2/dw2-epilogue-begin/dw2-epilogue-begin -ex
start -ex "maint info line-tab"
Temporary breakpoint 1 at 0x4004ef: file
/data/vries/gdb/src/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.c, line 43.

Temporary breakpoint 1, main () at
/data/vries/gdb/src/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.c:43
43      {                                                       /* main
prologue */
objfile:
/data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.dwarf2/dw2-epilogue-begin/dw2-epilogue-begin
((struct objfile *) 0x3ed4570)
compunit_symtab: dw2-prologue-end.c ((struct compunit_symtab *) 0x3ebec70)
symtab: dw2-prologue-end.c ((struct symtab *) 0x3ebf370)
linetable: ((struct linetable *) 0x0):
No line table.

objfile:
/data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.dwarf2/dw2-epilogue-begin/dw2-epilogue-begin
((struct objfile *) 0x3ed4570)
compunit_symtab: dw2-prologue-end.c ((struct compunit_symtab *) 0x3ebec70)
symtab:
/data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.c
((struct symtab *) 0x3ebed00)
linetable: ((struct linetable *) 0x3ebf2d0):
INDEX  LINE   REL-ADDRESS        UNREL-ADDRESS      IS-STMT PROLOGUE-END
EPILOGUE-BEGIN 
0      20     0x00000000004004b7 0x00000000004004b7 Y       Y            Y      
1      27     0x00000000004004be 0x00000000004004be Y                           
2      34     0x00000000004004d0 0x00000000004004d0 Y       Y                   
3      37     0x00000000004004de 0x00000000004004de Y                    Y      
4      38     0x00000000004004ec 0x00000000004004ec Y                           
5      43     0x00000000004004ef 0x00000000004004ef Y       Y                   
6      47     0x00000000004004fa 0x00000000004004fa Y                           
7      END    0x00000000004004ff 0x00000000004004ff Y                           
...

So, either this is intended behaviour and the test-case requires a comment, or
the test-case needs fixing.

Anyway the test-case passes in the current form, so it's not clear if the
dropped entry is actually needed.

Note that dropping the entry explicitly in the dwarf assembly like so:
...
@@ -130,10 +130,6 @@ Dwarf::assemble $asm_file {
            DW_LNS_copy

            DW_LNE_set_address main_epilogue
-           line $main_epilogue
-           DW_LNS_set_epilogue_begin
-           DW_LNS_copy
-
            DW_LNE_end_sequence
        }
     }
...
still exercises the same cornercase.

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

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

* [Bug testsuite/31592] [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp drops epilogue_begin entry
  2024-04-02  6:37 [Bug testsuite/31592] New: [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp drops epilogue_begin entry vries at gcc dot gnu.org
@ 2024-04-02  6:38 ` vries at gcc dot gnu.org
  2024-04-02  7:22 ` vries at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2024-04-02  6:38 UTC (permalink / raw)
  To: gdb-prs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |blarsen at redhat dot com

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

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

* [Bug testsuite/31592] [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp drops epilogue_begin entry
  2024-04-02  6:37 [Bug testsuite/31592] New: [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp drops epilogue_begin entry vries at gcc dot gnu.org
  2024-04-02  6:38 ` [Bug testsuite/31592] " vries at gcc dot gnu.org
@ 2024-04-02  7:22 ` vries at gcc dot gnu.org
  2024-04-04 15:20 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2024-04-02  7:22 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
This:
...
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp
b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp
index f646e23da62..7ae14fa9b5a 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp
@@ -134,6 +134,7 @@ Dwarf::assemble $asm_file {
            DW_LNS_set_epilogue_begin
            DW_LNS_copy

+           DW_LNE_set_address "$main_start + $main_len"
            DW_LNE_end_sequence
        }
     }
...
prevents the entry from being dropped:
...
INDEX  LINE   REL-ADDRESS        UNREL-ADDRESS      IS-STMT PROLOGUE-END
EPILOGUE-BEGIN 
0      20     0x00000000004004b7 0x00000000004004b7 Y       Y            Y      
1      27     0x00000000004004be 0x00000000004004be Y                           
2      34     0x00000000004004d0 0x00000000004004d0 Y       Y                   
3      37     0x00000000004004de 0x00000000004004de Y                    Y      
4      38     0x00000000004004ec 0x00000000004004ec Y                           
5      43     0x00000000004004ef 0x00000000004004ef Y       Y                   
6      47     0x00000000004004fa 0x00000000004004fa Y                           
7      50     0x00000000004004ff 0x00000000004004ff Y                    Y      
8      END    0x000000000040050d 0x000000000040050d Y                           
...
but no longer exercises the corner case.

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

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

* [Bug testsuite/31592] [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp drops epilogue_begin entry
  2024-04-02  6:37 [Bug testsuite/31592] New: [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp drops epilogue_begin entry vries at gcc dot gnu.org
  2024-04-02  6:38 ` [Bug testsuite/31592] " vries at gcc dot gnu.org
  2024-04-02  7:22 ` vries at gcc dot gnu.org
@ 2024-04-04 15:20 ` vries at gcc dot gnu.org
  2024-04-04 19:17 ` blarsen at redhat dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2024-04-04 15:20 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
https://sourceware.org/pipermail/gdb-patches/2024-April/207826.html

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

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

* [Bug testsuite/31592] [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp drops epilogue_begin entry
  2024-04-02  6:37 [Bug testsuite/31592] New: [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp drops epilogue_begin entry vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-04-04 15:20 ` vries at gcc dot gnu.org
@ 2024-04-04 19:17 ` blarsen at redhat dot com
  2024-04-17 10:54 ` cvs-commit at gcc dot gnu.org
  2024-04-17 10:55 ` vries at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: blarsen at redhat dot com @ 2024-04-04 19:17 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from Guinevere Larsen <blarsen at redhat dot com> ---
Sorry about the long time in replying here (vacation does that to you).

I don't think having the epilogue as the exact final entry was a corner case I
was really interested in. I think I was just going for 3 cases,
1. epilogue the same as prologue
2. epilogue immediately after
3. epilogue with entries in between.

So I think the change would be fine

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

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

* [Bug testsuite/31592] [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp drops epilogue_begin entry
  2024-04-02  6:37 [Bug testsuite/31592] New: [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp drops epilogue_begin entry vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-04-04 19:17 ` blarsen at redhat dot com
@ 2024-04-17 10:54 ` cvs-commit at gcc dot gnu.org
  2024-04-17 10:55 ` vries at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-17 10:54 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from Sourceware Commits <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=d52ba54add0d2500403db63c09878e3f3cde8449

commit d52ba54add0d2500403db63c09878e3f3cde8449
Author: Tom de Vries <tdevries@suse.de>
Date:   Wed Apr 17 12:55:00 2024 +0200

    [gdb/testsuite] Require address update for DW_LNE_end_sequence

    With test-case gdb.dwarf2/dw2-epilogue-begin.exp, we have an end_sequence
    entry with the same address as the line entry before it:
    ...
    File name                    Line number    Starting address    View   
Stmt

    dw2-epilogue-begin.c                  44            0x4101e8              
x
    dw2-epilogue-begin.c                  47            0x4101ec              
x
    dw2-epilogue-begin.c                   -            0x4101ec
    ...
    and consequently the line entry is removed by gdb:
    ...
    INDEX  LINE   REL-ADDRESS        UNREL-ADDRESS      IS-STMT PRO EPI
    0      20     0x00000000004101a8 0x00000000004101a8 Y       Y   Y
    1      27     0x00000000004101b0 0x00000000004101b0 Y
    2      32     0x00000000004101b8 0x00000000004101b8 Y       Y
    3      34     0x00000000004101c0 0x00000000004101c0 Y           Y
    4      35     0x00000000004101c8 0x00000000004101c8 Y
    5      40     0x00000000004101d4 0x00000000004101d4 Y       Y
    6      44     0x00000000004101e8 0x00000000004101e8 Y
    7      END    0x00000000004101ec 0x00000000004101ec Y
    ...

    This is a common mistake in dwarf assembly test-cases.

    Fix this by:
    - requiring an address update for each DW_LNE_end_sequence, and
    - fixing the test-cases where that triggers an error.

    I also encountered the error in test-case gdb.dwarf2/dw2-bad-elf.exp, and
in
    this case I worked around it using "DW_LNS_advance_pc 0".

    Tested on aarch64-linux.

    PR testsuite/31592
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31592

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

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

* [Bug testsuite/31592] [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp drops epilogue_begin entry
  2024-04-02  6:37 [Bug testsuite/31592] New: [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp drops epilogue_begin entry vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-04-17 10:54 ` cvs-commit at gcc dot gnu.org
@ 2024-04-17 10:55 ` vries at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2024-04-17 10:55 UTC (permalink / raw)
  To: gdb-prs

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

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

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

--- Comment #5 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] 7+ messages in thread

end of thread, other threads:[~2024-04-17 10:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-02  6:37 [Bug testsuite/31592] New: [gdb/testsuite] gdb.dwarf2/dw2-epilogue-begin.exp drops epilogue_begin entry vries at gcc dot gnu.org
2024-04-02  6:38 ` [Bug testsuite/31592] " vries at gcc dot gnu.org
2024-04-02  7:22 ` vries at gcc dot gnu.org
2024-04-04 15:20 ` vries at gcc dot gnu.org
2024-04-04 19:17 ` blarsen at redhat dot com
2024-04-17 10:54 ` cvs-commit at gcc dot gnu.org
2024-04-17 10:55 ` 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).