gdb/testsuite/dwarf: use options for rnglists/loclists procs

Change how rnglists and loclists procs to align them with how procs for
aranges (and other things in the DWARF assembler) work.  Instead of
using "args" (variable number of parameters in TCL) and command-line
style option arguments, use one leading "option" parameters, used as a
kind of key/value dictionary of options parsed using `parse_options`.

Change-Id: I63e60d17ae16a020ce4d6de44baf3d152ea42a1a
This commit is contained in:
Simon Marchi
2021-08-30 11:20:59 -04:00
parent c5dfcc2188
commit 46a5b75b37
7 changed files with 46 additions and 75 deletions

View File

@ -81,8 +81,8 @@ foreach_with_prefix ranges_sect {ranges rnglists} {
}
}
rnglists {
table {
rnglists {} {
table {} {
rnglists_label: list_ {
start_end 0 1
}

View File

@ -87,17 +87,17 @@ foreach_with_prefix is_64 {false true} {
}
}
loclists -is-64 $is_64 {
loclists {is-64 $is_64} {
# This table is unused, but exists so that the used table is not at
# the beginning of the section.
table {
table {} {
list_ {
start_length 0x1000 0x1000 { DW_OP_addr 0x100000 }
}
}
# The lists in this table are accessed by index (DW_FORM_rnglistx).
table -post-header-label cu_table {
table {post-header-label cu_table} {
# This list is unused, but exists to offset the next ones.
list_ {
start_length 0x1000 0x1000 { DW_OP_addr 0x100000 }

View File

@ -165,10 +165,10 @@ foreach_with_prefix is_64 {false true} {
}
}
loclists -is-64 $is_64 {
loclists {is-64 $is_64} {
# The lists in this table are accessed by direct offset
# (DW_FORM_sec_offset).
table {
table {} {
foo_location_list: list_ {
start_length $func1_addr $func1_len {
DW_OP_constu 0x123456
@ -182,7 +182,7 @@ foreach_with_prefix is_64 {false true} {
}
}
table -post-header-label cu2_table {
table {post-header-label cu2_table} {
bar_location_list: list_ {
start_length $func3_addr $func3_len {
DW_OP_constu 0x345678
@ -196,7 +196,7 @@ foreach_with_prefix is_64 {false true} {
}
}
table -with-offset-array false {
table {with-offset-array false} {
baz_location_list: list_ {
start_length $func5_addr $func5_len {
DW_OP_constu 0x567890

View File

@ -78,17 +78,17 @@ foreach_with_prefix is_64 {false true} {
}
}
loclists -is-64 $is_64 {
loclists {is-64 $is_64} {
# This table is unused, but exists so that the used table is not at
# the beginning of the section.
table {
table {} {
list_ {
start_end 0x1000 0x2000 { DW_OP_addr 0x100000 }
}
}
# The lists in this table are accessed by index (DW_FORM_rnglistx).
table -post-header-label cu_table {
table {post-header-label cu_table} {
# This list is unused, but exists to offset the next ones.
list_ {
start_end 0x1000 0x2000 { DW_OP_addr 0x100000 }

View File

@ -63,17 +63,17 @@ foreach_with_prefix is_64 {false true} {
}
}
rnglists -is-64 $is_64 {
rnglists {is-64 $is_64} {
# This table is unused, but exists so that the used table is not at
# the beginning of the section.
table {
table {} {
list_ {
start_end 0x1000 0x2000
}
}
# The lists in this table are accessed by index (DW_FORM_rnglistx).
table -post-header-label cu_table {
table {post-header-label cu_table} {
# This list is unused, but exists to offset the next ones.
list_ {
start_end 0x2000 0x3000

View File

@ -90,10 +90,10 @@ foreach_with_prefix is_64 {false true} {
}
}
rnglists -is-64 $is_64 {
rnglists {is-64 $is_64} {
# The lists in this table are accessed by direct offset
# (DW_FORM_sec_offset).
table {
table {} {
# For the first CU.
cu1_range_list: list_ {
start_end 0x4000 0x5000
@ -105,7 +105,7 @@ foreach_with_prefix is_64 {false true} {
}
}
table -post-header-label cu2_table {
table {post-header-label cu2_table} {
# For the second CU.
cu2_range_list: list_ {
start_end 0x5000 0x6000
@ -117,7 +117,7 @@ foreach_with_prefix is_64 {false true} {
}
}
table -with-offset-array false {
table {with-offset-array false} {
# For the third CU.
cu3_range_list: list_ {
start_end 0x6000 0x7000

View File

@ -1543,27 +1543,18 @@ namespace eval Dwarf {
#
# The target address size is based on the current target's address size.
#
# There is one mandatory positional argument, BODY, which must be Tcl code
# that emits the content of the section. It is evaluated in the caller's
# context.
# BODY must be Tcl code that emits the content of the section. It is
# evaluated in the caller's context.
#
# The following option can be used:
#
# - -is-64 true|false: Whether to use 64-bit DWARF instead of 32-bit DWARF.
# The default is 32-bit.
# The `is-64 true|false` options tells whether to use 64-bit DWARF instead
# of 32-bit DWARF. The default is 32-bit.
proc rnglists { args } {
proc rnglists { options body } {
variable _debug_rnglists_addr_size
variable _debug_rnglists_offset_size
variable _debug_rnglists_is_64_dwarf
parse_args {{"is-64" "false"}}
if { [llength $args] != 1 } {
error "rnglists proc expects one positional argument (body)"
}
lassign $args body
parse_options {{"is-64" "false"}}
if [is_64_target] {
set _debug_rnglists_addr_size 8
@ -1603,34 +1594,29 @@ namespace eval Dwarf {
# This proc is meant to be used within proc rnglists' body. It is made
# available as `table` while inside proc rnglists' body.
#
# Accepts one positional argument, BODY. BODY may call the LIST_ procedure
# to generate rnglists.
# BODY must be Tcl code that emits the content of the table. It may call
# the LIST_ procedure to generate rnglists. It is evaluated in the
# caller's context.
#
# The -post-header-label option can be used to define a label just after
# The `post-header-label` option can be used to define a label just after
# the header of the table. This is the label that a DW_AT_rnglists_base
# attribute will usually refer to.
#
# The `-with-offset-array true|false` option can be used to control whether
# The `with-offset-array true|false` option can be used to control whether
# the headers of the location list tables have an array of offset. The
# default is true.
proc _rnglists_table { args } {
proc _rnglists_table { options body } {
variable _debug_rnglists_table_count
variable _debug_rnglists_addr_size
variable _debug_rnglists_offset_size
variable _debug_rnglists_is_64_dwarf
parse_args {
parse_options {
{post-header-label ""}
{with-offset-array true}
}
if { [llength $args] != 1 } {
error "table proc expects one positional argument (body)"
}
lassign $args body
# Count of lists in the table.
variable _debug_rnglists_list_count 0
@ -1743,27 +1729,18 @@ namespace eval Dwarf {
#
# The target address size is based on the current target's address size.
#
# There is one mandatory positional argument, BODY, which must be Tcl code
# that emits the content of the section. It is evaluated in the caller's
# context.
# BODY must be Tcl code that emits the content of the section. It is
# evaluated in the caller's context.
#
# The following option can be used:
#
# - -is-64 true|false: Whether to use 64-bit DWARF instead of 32-bit DWARF.
# The default is 32-bit.
# The `is-64 true|false` options tells whether to use 64-bit DWARF instead
# of 32-bit DWARF. The default is 32-bit.
proc loclists { args } {
proc loclists { options body } {
variable _debug_loclists_addr_size
variable _debug_loclists_offset_size
variable _debug_loclists_is_64_dwarf
parse_args {{"is-64" "false"}}
if { [llength $args] != 1 } {
error "loclists proc expects one positional argument (body)"
}
lassign $args body
parse_options {{"is-64" "false"}}
if [is_64_target] {
set _debug_loclists_addr_size 8
@ -1803,35 +1780,29 @@ namespace eval Dwarf {
# This proc is meant to be used within proc loclists' body. It is made
# available as `table` while inside proc rnglists' body.
#
# Accepts one position argument, BODY. BODY may call the LIST_
# procedure to generate loclists.
# BODY must be Tcl code that emits the content of the table. It may call
# the LIST_ procedure to generate rnglists. It is evaluated in the
# caller's context.
#
# The -post-header-label option can be used to define a label just after the
# header of the table. This is the label that a DW_AT_loclists_base
# The `post-header-label` option can be used to define a label just after
# the header of the table. This is the label that a DW_AT_loclists_base
# attribute will usually refer to.
#
# The `-with-offset-array true|false` option can be used to control
# The `with-offset-array true|false` option can be used to control
# whether the headers of the location list tables have an array of
# offset. The default is true.
proc _loclists_table { args } {
proc _loclists_table { options body } {
variable _debug_loclists_table_count
variable _debug_loclists_addr_size
variable _debug_loclists_offset_size
variable _debug_loclists_is_64_dwarf
parse_args {
parse_options {
{post-header-label ""}
{with-offset-array true}
}
if { [llength $args] != 1 } {
error "table proc expects one positional argument (body)"
}
lassign $args body
# Count of lists in the table.
variable _debug_loclists_list_count 0