Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 2/6] gdb/testsuite/dwarf: convert _section proc to use parse_options
Date: Fri,  7 Nov 2025 16:10:13 -0500	[thread overview]
Message-ID: <20251107211041.520697-3-simon.marchi@efficios.com> (raw)
In-Reply-To: <20251107211041.520697-1-simon.marchi@efficios.com>

From: Simon Marchi <simon.marchi@polymtl.ca>

The following patch will add more options to the _section proc, so
convert it to use options, to be more user-friendly.

Change-Id: I971e4e10e55d63af2a5e29dc5e1d00f368b3ecaa
---
 gdb/testsuite/lib/dwarf.exp | 45 +++++++++++++++++++++++++++----------
 1 file changed, 33 insertions(+), 12 deletions(-)

diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 919e2e05687f..5536b7656b8c 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -1071,17 +1071,33 @@ namespace eval Dwarf {
 	}
     }
 
-    proc _section {name {flags ""} {type ""}} {
-	if {$name == ".debug_str"} {
-	    # Hard-code this because it's always desirable.
-	    _emit "        .section $name, \"MS\", %progbits, 1"
-	} elseif {$flags == "" && $type == ""} {
-	    _emit "        .section $name"
-	} elseif {$type == ""} {
-	    _emit "        .section $name, \"$flags\""
-	} else {
-	    _emit "        .section $name, \"$flags\", %$type"
+    proc _section {name {options {}}} {
+	parse_options {
+	    { flags "" }
+	    { type "" }
 	}
+
+	set directive ".section $name"
+
+	if { $name == ".debug_str" } {
+	    # Hard-code this because it's always desirable.
+	    append directive ", \"MS\", %progbits, 1"
+	}
+
+	if { $flags != "" } {
+	    append directive ",\"$flags\""
+	}
+
+	if { $type != "" } {
+	    # Can't specify a type without flags.
+ 	    if { $flags == "" } {
+		append directive ", \"\""
+	    }
+
+	    append directive ", %$type"
+	}
+
+	_emit "        $directive"
     }
 
     # SECTION_SPEC is a list of arguments to _section.
@@ -3173,7 +3189,10 @@ namespace eval Dwarf {
 
     # Emit a note section holding the given build-id.
     proc build_id {buildid} {
-	_defer_output {.note.gnu.build-id a note} {
+	_defer_output {.note.gnu.build-id {
+			   flags a
+			   type note
+		       }} {
 	    # From elf/common.h.
 	    set NT_GNU_BUILD_ID 3
 
@@ -3607,7 +3626,9 @@ namespace eval Dwarf {
 
 	_write_deferred_output
 
-	_section .note.GNU-stack "" progbits
+	_section .note.GNU-stack {
+	    type progbits
+	}
 
 	if { $file_id == "" } {
 	    catch {close $_output_file}
-- 
2.51.2


  parent reply	other threads:[~2025-11-07 21:11 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-07 21:10 [PATCH 0/6] Type unit + split DWARF fixes (PR 33307) Simon Marchi
2025-11-07 21:10 ` [PATCH 1/6] gdb/testsuite/dwarf: use single abbrev table in .dwo files Simon Marchi
2025-11-10 20:14   ` Simon Marchi
2025-11-18 13:32     ` Andrew Burgess
2025-11-18 16:50       ` Simon Marchi
2025-11-18 16:55   ` Andrew Burgess
2025-11-18 17:20     ` Simon Marchi
2025-11-19 16:05       ` Tom Tromey
2025-11-19 20:21         ` Simon Marchi
2025-11-07 21:10 ` Simon Marchi [this message]
2025-11-19 10:59   ` [PATCH 2/6] gdb/testsuite/dwarf: convert _section proc to use parse_options Andrew Burgess
2025-11-19 15:53   ` Tom Tromey
2025-11-19 20:40     ` Simon Marchi
2025-11-19 21:03       ` Tom Tromey
2025-11-07 21:10 ` [PATCH 3/6] gdb/testsuite/dwarf: emit type unit sections as COMDAT Simon Marchi
2025-11-19 11:43   ` Andrew Burgess
2025-11-07 21:10 ` [PATCH 4/6] gdb/dwarf: when in dwarf2_cu, read addr_size from dwarf2_cu::header Simon Marchi
2025-11-19 14:30   ` Andrew Burgess
2025-11-19 20:46     ` Simon Marchi
2025-11-19 16:11   ` Tom Tromey
2025-11-19 20:51     ` Simon Marchi
2025-11-07 21:10 ` [PATCH 5/6] gdb/dwarf: store addr/offset/ref_addr sizes in dwarf2_per_cu Simon Marchi
2025-11-19 14:42   ` Andrew Burgess
2025-11-19 16:14   ` Tom Tromey
2025-11-21 19:54     ` Simon Marchi
2025-11-21 21:25       ` Tom Tromey
2025-11-07 21:10 ` [PATCH 6/6] gdb/dwarf: use dwarf2_per_cu::ref_addr_size in one spot Simon Marchi
2025-11-19 14:44   ` Andrew Burgess

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=20251107211041.520697-3-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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