Re: [PATCH 10/13] gdb/testsuite: add .debug_loclists tests

Zoran Zaric via Gdb-patches
2021-01-28T16:52:57Z

> From: Simon Marchi <simon.marchi@efficios.com>
>
> Add tests for the various issues fixed in the previous patches.
>
> Add a new "loclists" procedure to the DWARF assembler, to allow
> generating .debug_loclists sections.
>

Thank you for this contribution.

Having a loclists support in DWARF assembler gives us so considerable
testing flexibility and decouples the gdb testing even more from what
compiler is expected to generate.

The only thing missing now (at least in my mind) is the CFI support but
that is a big project for the future.

> +
> + proc loclists { args } {
> + 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
> +
> + if [is_64_target] {
> + set _debug_loclists_addr_size 8
> + } else {
> + set _debug_loclists_addr_size 4
> + }
> +
> + if { ${is-64} } {
> + set _debug_loclists_offset_size 8
> + set _debug_loclists_is_64_dwarf true
> + } else {
> + set _debug_loclists_offset_size 4
> + set _debug_loclists_is_64_dwarf false
> + }
> +
> + _section ".debug_loclists"
> +
> + # Count of tables in the section.
> + variable _debug_loclists_table_count 0
> +
> + # Compute the label name for list at index LIST_IDX, for the current
> + # table.
> +
> + proc _compute_list_label { list_idx } {
> + variable _debug_loclists_table_count
> +
> + return ".Lloclists_table_${_debug_loclists_table_count}_list_${list_idx}"
> + }
> +
> + # Generate one table (header + offset array + location lists).
> + #
> + # Accepts one position argument, BODY. BODY may call the LIST_
> + # procedure to generate loclists.
> + #
> + # 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.
> +
> + proc table { args } {
> + variable _debug_loclists_table_count
> + variable _debug_loclists_addr_size
> + variable _debug_loclists_offset_size
> + variable _debug_loclists_is_64_dwarf
> +
> + parse_args {{post-header-label ""}}
> +
> + if { [llength $args] != 1 } {
> + error "table proc expects one positional argument (body)"
> + }
> +
> + lassign $args body
> +
> + # Generate one location list.
> + #
> + # BODY may call the various procs defined below to generate list
> + # entries. They correspond to the location list entry kinds
> + # described in section 2.6.2 of the DWARF 5 spec.
> + #
> + # To define a label pointing to the beginning of the list, use
> + # the conventional way of declaring and defining labels:
> + #
> + # declare_labels the_list
> + #
> + # the_list: list_ {
> + # ...
> + # }
> +
> + proc list_ { body } {
> + variable _debug_loclists_list_count
> +

I guess that the table and list procedures from loclist and ranglist
support couldn't be commonized in some way?

They do seem considerably different.

Zoran