aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib/dwarf.exp
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2021-02-02 10:40:53 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2021-02-02 10:42:12 -0500
commit9307efbe9eb58fb041d09b1e35cffd377d20e708 (patch)
tree4d059caa8700fb10faf6b8703d5c99a544b871b5 /gdb/testsuite/lib/dwarf.exp
parente57933dc9cda3292f0baadbf80ff07d398566abb (diff)
downloadgdb-9307efbe9eb58fb041d09b1e35cffd377d20e708.zip
gdb-9307efbe9eb58fb041d09b1e35cffd377d20e708.tar.gz
gdb-9307efbe9eb58fb041d09b1e35cffd377d20e708.tar.bz2
gdb/testsuite: add test for .debug_{rng,loc}lists section without offset array
It is possible for the tables in the .debug_{rng,loc}lists sections to not have an array of offsets. In that case, the offset_entry_count field of the header is 0. The forms DW_FORM_{rng,loc}listx (reference by index) can't be used with that table. Instead, the DW_FORM_sec_offset form, which references a {rng,loc}list by direct offset in the section, must be used. From what I saw, this is what GCC currently produces. Add tests for this case. I didn't see any bug related to this, I just think that it would be nice to have coverage for this. A new `-with-offset-array` option is added to the `table` procs, used when generating {rng,loc}lists, to decide whether to generate the offset array. gdb/testsuite/ChangeLog: * lib/dwarf.exp (rnglists): Add -no-offset-array option to table proc. * gdb.dwarf2/rnglists-sec-offset.exp: Add test for .debug_rnglists table without offset array. * gdb.dwarf2/loclists-sec-offset.exp: Add test for .debug_loclists table without offset array. Change-Id: I8e34a7bf68c9682215ffbbf66600da5b7db91ef7
Diffstat (limited to 'gdb/testsuite/lib/dwarf.exp')
-rw-r--r--gdb/testsuite/lib/dwarf.exp48
1 files changed, 38 insertions, 10 deletions
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index b444ef3..10fd88f 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -1392,6 +1392,10 @@ namespace eval Dwarf {
# 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 headers of the location list tables have an array of
+ # offset. The default is true.
proc table { args } {
variable _debug_rnglists_table_count
@@ -1399,7 +1403,10 @@ namespace eval Dwarf {
variable _debug_rnglists_offset_size
variable _debug_rnglists_is_64_dwarf
- parse_args {{post-header-label ""}}
+ parse_args {
+ {post-header-label ""}
+ {with-offset-array true}
+ }
if { [llength $args] != 1 } {
error "table proc expects one positional argument (body)"
@@ -1477,7 +1484,12 @@ namespace eval Dwarf {
_op .2byte 5 "dwarf version"
_op .byte $_debug_rnglists_addr_size "address size"
_op .byte 0 "segment selector size"
- _op .4byte "$_debug_rnglists_list_count" "offset entry count"
+
+ if { ${with-offset-array} } {
+ _op .4byte "$_debug_rnglists_list_count" "offset entry count"
+ } else {
+ _op .4byte 0 "offset entry count"
+ }
define_label $post_header_label
@@ -1487,9 +1499,11 @@ namespace eval Dwarf {
}
# Emit the offset array.
- for {set list_idx 0} {$list_idx < $_debug_rnglists_list_count} {incr list_idx} {
- set list_label [_compute_list_label $list_idx]
- _op .${_debug_rnglists_offset_size}byte "$list_label - $post_header_label" "offset of list $list_idx"
+ if { ${with-offset-array} } {
+ for {set list_idx 0} {$list_idx < $_debug_rnglists_list_count} {incr list_idx} {
+ set list_label [_compute_list_label $list_idx]
+ _op .${_debug_rnglists_offset_size}byte "$list_label - $post_header_label" "offset of list $list_idx"
+ }
}
# Emit the actual list data.
@@ -1565,6 +1579,10 @@ namespace eval Dwarf {
# 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
+ # whether the headers of the location list tables have an array of
+ # offset. The default is true.
proc table { args } {
variable _debug_loclists_table_count
@@ -1572,7 +1590,10 @@ namespace eval Dwarf {
variable _debug_loclists_offset_size
variable _debug_loclists_is_64_dwarf
- parse_args {{post-header-label ""}}
+ parse_args {
+ {post-header-label ""}
+ {with-offset-array true}
+ }
if { [llength $args] != 1 } {
error "table proc expects one positional argument (body)"
@@ -1672,7 +1693,12 @@ namespace eval Dwarf {
_op .2byte 5 "DWARF version"
_op .byte $_debug_loclists_addr_size "address size"
_op .byte 0 "segment selector size"
- _op .4byte $_debug_loclists_list_count "offset entry count"
+
+ if { ${with-offset-array} } {
+ _op .4byte "$_debug_loclists_list_count" "offset entry count"
+ } else {
+ _op .4byte 0 "offset entry count"
+ }
define_label $post_header_label
@@ -1682,9 +1708,11 @@ namespace eval Dwarf {
}
# Emit the offset array.
- for {set list_idx 0} {$list_idx < $_debug_loclists_list_count} {incr list_idx} {
- set list_label [_compute_list_label $list_idx]
- _op .${_debug_loclists_offset_size}byte "$list_label - $post_header_label" "offset of list $list_idx"
+ if { ${with-offset-array} } {
+ for {set list_idx 0} {$list_idx < $_debug_loclists_list_count} {incr list_idx} {
+ set list_label [_compute_list_label $list_idx]
+ _op .${_debug_loclists_offset_size}byte "$list_label - $post_header_label" "offset of list $list_idx"
+ }
}
# Emit the actual list data.