From: Simon Marchi Date: Fri, 21 Nov 2025 20:14:00 +0000 (-0500) Subject: gdb/testsuite/dwarf: convert _section proc to use parse_options X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=025bf7eaf79b40ebc616c5593c1a2b067d8ba95a;p=thirdparty%2Fbinutils-gdb.git gdb/testsuite/dwarf: convert _section proc to use parse_options New in v2: return early if the section is .debug_str 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 Approved-By: Andrew Burgess --- diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index cedc12aed57..a0da797ca3f 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -1074,17 +1074,34 @@ namespace eval Dwarf { } } - proc _section {name {flags ""} {type ""}} { - if {$name == ".debug_str"} { + proc _section {name {options {}}} { + parse_options { + { 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" + _emit " .section .debug_str, \"MS\", %progbits, 1" + return + } + + set directive ".section $name" + + 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. @@ -3176,7 +3193,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 @@ -3610,7 +3630,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}