public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 2/4] [gdb/testsuite] Require address update for DW_LNS_copy
Date: Mon,  8 Apr 2024 14:04:43 +0200	[thread overview]
Message-ID: <20240408120445.12544-2-tdevries@suse.de> (raw)
In-Reply-To: <20240408120445.12544-1-tdevries@suse.de>

No address update before a DW_LNS_copy might mean an incorrect dwarf
assembly test-case.

Try to catch such incorrect dwarf assembly test-cases by:
- requiring an explicit address update for each DW_LNS_copy, and
- handling the cases where an update is indeed not needed, by adding
  "DW_LNS_advance_pc 0".

Tested on aarch64-linux.
---
 gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp          | 1 +
 gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp          | 1 +
 gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp          | 1 +
 gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp        | 3 +++
 gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl         | 1 +
 gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp | 6 ++++++
 gdb/testsuite/lib/dwarf.exp                               | 3 +++
 7 files changed, 16 insertions(+)

diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
index 5268e7815ad..6d12e968f41 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
@@ -129,6 +129,7 @@ proc do_test { start_label func_name tag } {
 		DW_LNS_advance_line 1
 		DW_LNS_copy
 
+		DW_LNS_advance_pc 0
 		DW_LNS_advance_line -4
 		DW_LNS_set_file 1
 		DW_LNS_negate_stmt
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
index d3a1fd38ed2..6a5f7d6dd76 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
@@ -119,6 +119,7 @@ Dwarf::assemble $asm_file {
 	    DW_LNS_advance_line 1
 	    DW_LNS_copy
 
+	    DW_LNS_advance_pc 0
 	    DW_LNS_advance_line -4
 	    DW_LNS_set_file 1
 	    DW_LNS_negate_stmt
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
index 66d9f645cf3..b3db154db25 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
@@ -108,6 +108,7 @@ Dwarf::assemble $asm_file {
 	    DW_LNS_advance_line 1
 	    DW_LNS_copy
 
+	    DW_LNS_advance_pc 0
 	    DW_LNS_advance_line -4
 	    DW_LNS_set_file 1
 	    DW_LNS_negate_stmt
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
index b117c8910f0..ed7166983d5 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
@@ -91,13 +91,16 @@ Dwarf::assemble $asm_file {
 	    line $f1_l1
 	    DW_LNS_copy
 
+	    DW_LNS_advance_pc 0
 	    line ${f1_l2}
 	    DW_LNS_copy
 
+	    DW_LNS_advance_pc 0
 	    DW_LNS_set_file 2
 	    line ${f2_l1}
 	    DW_LNS_copy
 
+	    DW_LNS_advance_pc 0
 	    DW_LNS_negate_stmt
 	    DW_LNS_copy
 
diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl b/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl
index 4f59c9b2639..968378620a0 100644
--- a/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl
+++ b/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl
@@ -96,6 +96,7 @@ Dwarf::assemble $asm_file {
 	    DW_LNS_advance_line 1
 	    DW_LNS_copy
 
+	    DW_LNS_advance_pc 0
 	    DW_LNS_advance_line -4
 	    DW_LNS_negate_stmt
 	    DW_LNS_copy
diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
index a1c0e7705b3..2001b28989f 100644
--- a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
+++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
@@ -278,9 +278,12 @@ Dwarf::assemble ${asm_file} {
 	    DW_LNE_set_address $foo_start
 	    line [gdb_get_line_number "foo prologue" $libsrc]
 	    DW_LNS_copy
+
 	    DW_LNE_set_address foo_label
 	    line [gdb_get_line_number "foo return" $libsrc]
 	    DW_LNS_copy
+
+	    DW_LNS_advance_pc 0
 	    line [gdb_get_line_number "foo end" $libsrc]
 	    DW_LNS_copy
 
@@ -291,9 +294,12 @@ Dwarf::assemble ${asm_file} {
 	    DW_LNE_set_address $bar_start
 	    line [gdb_get_line_number "bar prologue" $libsrc]
 	    DW_LNS_copy
+
 	    DW_LNE_set_address bar_label
 	    line [gdb_get_line_number "bar return" $libsrc]
 	    DW_LNS_copy
+
+	    DW_LNS_advance_pc 0
 	    line [gdb_get_line_number "bar end" $libsrc]
 	    DW_LNS_copy
 
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 816440f975f..254f88f1055 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -2601,6 +2601,9 @@ namespace eval Dwarf {
 
 	    proc DW_LNS_copy {} {
 		variable _line_address_update
+		if { $_line_address_update == 0 } {
+		    error "Missing address update for copy"
+		}
 		set _line_address_update 0
 		_op .byte 1
 	    }
-- 
2.35.3


  reply	other threads:[~2024-04-08 12:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08 12:04 [PATCH v2 1/4] [gdb/testsuite] Require address update for DW_LNE_end_sequence Tom de Vries
2024-04-08 12:04 ` Tom de Vries [this message]
2024-04-08 12:04 ` [PATCH v2 3/4] [gdb/testsuite] Fix end_sequence addresses Tom de Vries
2024-04-24 17:45   ` Carl Love
2024-04-24 18:07     ` Carl Love
2024-04-24 18:28     ` Carl Love
2024-04-24 21:07       ` Tom de Vries
2024-04-25 17:05         ` Carl Love
2024-04-25 20:46           ` Tom de Vries
2024-04-08 12:04 ` [PATCH v2 4/4] [gdb/testsuite] Require DW_LNE_end_sequence Tom de Vries
2024-04-17 10:58 ` [PATCH v2 1/4] [gdb/testsuite] Require address update for DW_LNE_end_sequence Tom de Vries

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=20240408120445.12544-2-tdevries@suse.de \
    --to=tdevries@suse.de \
    --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).