]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Require address update for DW_LNE_end_sequence
authorTom de Vries <tdevries@suse.de>
Wed, 17 Apr 2024 10:55:00 +0000 (12:55 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 17 Apr 2024 10:55:00 +0000 (12:55 +0200)
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

gdb/testsuite/gdb.base/until-trailing-insns.exp
gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp
gdb/testsuite/gdb.dwarf2/dw2-disasm-over-non-stmt.exp
gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp
gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp
gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp
gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp
gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp
gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
gdb/testsuite/lib/dwarf.exp

index aed36814809f8fae8d7e02bce17afea1862bf244..baa5f1fa32c30e137ef4f87a72b149ab34b443e4 100644 (file)
@@ -147,9 +147,8 @@ Dwarf::assemble $asm_file {
            line [gdb_get_line_number "TAG: main return"]
            DW_LNS_negate_stmt
            DW_LNS_copy
+
            DW_LNE_set_address $main_end
-           line [expr [gdb_get_line_number "TAG: main return"] + 1]
-           DW_LNS_copy
            DW_LNE_end_sequence
        }
     }
index 71c5bf9014d20888244e3ff4774d96e511d7f3d2..63d83fb9416b906a28b95c0c74c15f1c07460cf2 100644 (file)
@@ -128,9 +128,12 @@ Dwarf::assemble $asm_file {
            DW_LNE_set_address [lindex $main_result 0]
            DW_LNS_advance_line 10
            DW_LNS_copy
+
            DW_LNS_advance_pc [lindex $main_result 1]
            DW_LNS_advance_line 19
            DW_LNS_copy
+
+           DW_LNS_advance_pc 0
            DW_LNE_end_sequence
        }
     }
@@ -144,9 +147,12 @@ Dwarf::assemble $asm_file {
            DW_LNE_set_address some_func
            DW_LNS_advance_line 5
            DW_LNS_copy
+
            DW_LNS_advance_pc 64
            DW_LNS_advance_line 8
            DW_LNS_copy
+
+           DW_LNS_advance_pc 0
            DW_LNE_end_sequence
        }
     }
index 425dd971333c213fd8676aed4133050324de9aea..aa84a20b09c14ece866ba05e77ae33e3ec4b16d0 100644 (file)
@@ -87,7 +87,6 @@ Dwarf::assemble $asm_file {
            DW_LNS_copy
 
            DW_LNE_set_address $main_end
-           DW_LNS_copy
            DW_LNE_end_sequence
        }
     }
index f646e23da621361cabe32d092cb31b9a7b0cac35..7ae14fa9b5a5805ed9fb52fc99e64373792826c9 100644 (file)
@@ -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
        }
     }
index 1ba346b97586fda02c9c1e72d3f8c8d06a4f5d45..b117c8910f050cb7088fd370f3e4d42b864022d1 100644 (file)
@@ -108,6 +108,8 @@ Dwarf::assemble $asm_file {
 
            DW_LNE_set_address line_label_3
            DW_LNS_copy
+
+           DW_LNE_set_address "$main_start + $main_len"
            DW_LNE_end_sequence
        }
     }
index 8d85464a82656982dbb049e31aaf091a1e3ce4e4..caa40861f87f9c1b5858228066ab451c88a3bfad 100644 (file)
@@ -72,6 +72,7 @@ Dwarf::assemble $asm_file {
            line [gdb_get_line_number "main end"]
            DW_LNS_copy
 
+           DW_LNE_set_address "$main_start + $main_len"
            DW_LNE_end_sequence
        }
     }
index 13e7c98dcf13f277f70a5e0cc106db30164d756e..1a3d53c2116263becbeefe049a7b80c995b77796 100644 (file)
@@ -79,24 +79,18 @@ Dwarf::assemble $asm_file {
            DW_LNS_advance_line 10
            DW_LNS_copy
            DW_LNS_advance_pc [lindex $main_func 1]
-           DW_LNS_advance_line 19
-           DW_LNS_copy
            DW_LNE_end_sequence
 
            DW_LNE_set_address [lindex $frame2_func 0]
            DW_LNS_advance_line 20
            DW_LNS_copy
            DW_LNS_advance_pc [lindex $frame2_func 1]
-           DW_LNS_advance_line 29
-           DW_LNS_copy
            DW_LNE_end_sequence
 
            DW_LNE_set_address [lindex $frame3_func 0]
            DW_LNS_advance_line 30
            DW_LNS_copy
            DW_LNS_advance_pc [lindex $frame3_func 1]
-           DW_LNS_advance_line 39
-           DW_LNS_copy
            DW_LNE_end_sequence
        }
     }
index ea69af44601b54316f73fb0347d3c287fda3e873..c952e82b335ec9078e77733146c36aea47d30edb 100644 (file)
@@ -133,9 +133,8 @@ proc do_test {suffix} {
                DW_LNE_set_address main_label2
                line [gdb_get_line_number "main return"]
                DW_LNS_copy
+
                DW_LNE_set_address $main_end
-               line [expr [gdb_get_line_number "main end"] + 1]
-               DW_LNS_copy
                DW_LNE_end_sequence
 
                DW_LNE_set_address $foo_start
@@ -150,25 +149,22 @@ proc do_test {suffix} {
                DW_LNE_set_address foo_label3
                line [gdb_get_line_number "foo end"]
                DW_LNS_copy
+
                DW_LNE_set_address $foo_end
-               DW_LNS_advance_line 1
-               DW_LNS_copy
                DW_LNE_end_sequence
 
                DW_LNE_set_address $bar_start
                line [gdb_get_line_number "bar end"]
                DW_LNS_copy
+
                DW_LNS_advance_pc $bar_len
-               DW_LNS_advance_line 1
-               DW_LNS_copy
                DW_LNE_end_sequence
 
                DW_LNE_set_address $baz_start
                line [gdb_get_line_number "baz end"]
                DW_LNS_copy
+
                DW_LNS_advance_pc $baz_len
-               DW_LNS_advance_line 1
-               DW_LNS_copy
                DW_LNE_end_sequence
 
                DW_LNE_set_address $foo_cold_start
@@ -180,9 +176,8 @@ proc do_test {suffix} {
                DW_LNE_set_address foo_cold_label2
                line [gdb_get_line_number "foo_cold end"]
                DW_LNS_copy
+
                DW_LNE_set_address $foo_cold_end
-               DW_LNS_advance_line 1
-               DW_LNS_copy
                DW_LNE_end_sequence
            }
        }
index d2ea91e2d3db3f450d75d89da942d280aa678937..567049adc873240245713a40244e579b67f2b539 100644 (file)
@@ -93,8 +93,6 @@ Dwarf::assemble $asm_file_1 {
            DW_LNS_copy
 
            DW_LNE_set_address $func_end
-           DW_LNS_advance_line 1
-           DW_LNS_copy
            DW_LNE_end_sequence
        }
     }
@@ -177,8 +175,6 @@ Dwarf::assemble $asm_file_2 {
            DW_LNS_copy
 
            DW_LNE_set_address $main_end
-           DW_LNS_advance_line 2
-           DW_LNS_copy
            DW_LNE_end_sequence
        }
     }
index ca597aaaa3ede00393609e7e7dc64a10767663c0..a1c0e7705b301fac18d84ae6607bf5044f527a60 100644 (file)
@@ -283,11 +283,11 @@ Dwarf::assemble ${asm_file} {
            DW_LNS_copy
            line [gdb_get_line_number "foo end" $libsrc]
            DW_LNS_copy
+
            DW_LNE_set_address $foo_end
-           DW_LNS_advance_line 1
-           DW_LNS_copy
            DW_LNE_end_sequence
 
+
            DW_LNE_set_address $bar_start
            line [gdb_get_line_number "bar prologue" $libsrc]
            DW_LNS_copy
@@ -296,9 +296,8 @@ Dwarf::assemble ${asm_file} {
            DW_LNS_copy
            line [gdb_get_line_number "bar end" $libsrc]
            DW_LNS_copy
+
            DW_LNE_set_address $bar_end
-           DW_LNS_advance_line 1
-           DW_LNS_copy
            DW_LNE_end_sequence
        }
     }
index d085f835f07fa8db1b18435a3fde33a6587ccc31..816440f975f229c672b6c9c019a546058892e42f 100644 (file)
@@ -2545,13 +2545,17 @@ namespace eval Dwarf {
        proc program { body } {
            variable _line_header_end_label
            variable _line
+           variable _line_address_update
 
 
            set _line 1
+           set _line_address_update 0
 
            _line_finalize_header
 
            proc DW_LNE_set_address {addr} {
+               variable _line_address_update
+               set _line_address_update 1
                _op .byte 0
                set start [new_label "set_address_start"]
                set end [new_label "set_address_end"]
@@ -2567,6 +2571,11 @@ namespace eval Dwarf {
            }
 
            proc DW_LNE_end_sequence {} {
+               variable _line_address_update
+               if { $_line_address_update == 0 } {
+                   error "Missing address update for end_sequence"
+               }
+               set _line_address_update 0
                variable _line
                _op .byte 0
                _op .uleb128 1
@@ -2591,6 +2600,8 @@ namespace eval Dwarf {
            }
 
            proc DW_LNS_copy {} {
+               variable _line_address_update
+               set _line_address_update 0
                _op .byte 1
            }
 
@@ -2607,6 +2618,8 @@ namespace eval Dwarf {
            }
 
            proc DW_LNS_advance_pc {offset} {
+               variable _line_address_update
+               set _line_address_update 1
                _op .byte 2
                _op .uleb128 ${offset}
            }