Re: [PATCH 2/6] gdb/testsuite/dwarf: convert _section proc to use parse_options

Tom Tromey
2025-11-19T15:54:13Z

>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:

I meant to send this last week but forgot.

Simon> - proc _section {name {flags ""} {type ""}} {
Simon> - if {$name == ".debug_str"} {
Simon> - # Hard-code this because it's always desirable.
Simon> - _emit " .section $name, \"MS\", %progbits, 1"
Simon> - } elseif {$flags == "" && $type == ""} {
Simon> - _emit " .section $name"
Simon> - } elseif {$type == ""} {
Simon> - _emit " .section $name, \"$flags\""
Simon> - } else {
Simon> - _emit " .section $name, \"$flags\", %$type"

This code ignores flags and type if name is .debug_str, but the
replacement code:

Simon> + if { $name == ".debug_str" } {
Simon> + # Hard-code this because it's always desirable.
Simon> + append directive ", \"MS\", %progbits, 1"
Simon> + }
Simon> +
Simon> + if { $flags != "" } {
Simon> + append directive ",\"$flags\""
Simon> + }
Simon> +
Simon> + if { $type != "" } {
Simon> + # Can't specify a type without flags.
Simon> + if { $flags == "" } {
Simon> + append directive ", \"\""
Simon> + }
Simon> +
Simon> + append directive ", %$type"
Simon> + }

... does not.

I think the old code was clearer in this regard. I didn't read forward
in the series to see if this restructuring helps newer code though.
Anyway this change should be addressed.

Tom