From: Tom de Vries Date: Mon, 22 Nov 2021 08:14:15 +0000 (+0100) Subject: [gdb/testsuite] Support .debug_line v5 in dwarf assembler X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=44fda089397a;p=binutils-gdb.git [gdb/testsuite] Support .debug_line v5 in dwarf assembler The v5 section version for .debug_line has: - two new fields address_size and segment_selector_size - a different way to encode the directory and filename tables. Add support for this in the dwarf assembler. For now, make the v5 directory and filename tables work with the v4 type of specification in the test-cases by adding duplicate entries at position 0. This will need to be properly fixed with an intrusive fix that changes how directory and filename entries are specified in the test-cases, f.i: ... set diridx [include_dir "${srcdir}/${subdir}"] set fileidx [file_name "$srcfile" $diridx] ... Tested on x86_64-linux. --- diff --git a/gdb/testsuite/gdb.dwarf2/dw2-lines.exp b/gdb/testsuite/gdb.dwarf2/dw2-lines.exp index 5a5888a467e..27134af8f5d 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-lines.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-lines.exp @@ -154,3 +154,9 @@ for { set cv $cv_low } { $cv <= $cv_high } { incr cv } { } } } + +foreach cdw64 { 0 1 } { + foreach ldw64 { 0 1 } { + test 5 $cdw64 5 $ldw64 + } +} diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index d5451db90aa..b2a337238c3 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -2158,6 +2158,9 @@ namespace eval Dwarf { # default = 4 # addr_size n - the size of addresses in bytes: 4, 8, or default # default = default + # seg_sel_size n + # - the size of segment selector_size in bytes: + # default = 0 # # LABEL is the label of the current unit (which is probably # referenced by a DW_AT_stmt_list), or "" if there is no such @@ -2181,10 +2184,11 @@ namespace eval Dwarf { variable _line_header_finalized variable _line_saw_program variable _line_header_end_label + variable _line_unit_version # Establish the defaults. set is_64 0 - set _unit_version 4 + set _line_unit_version 4 set _unit_addr_size default set _line_saw_program 0 set _line_saw_file 0 @@ -2192,12 +2196,14 @@ namespace eval Dwarf { set _line_file_names {} set _line_header_finalized 0 set _default_is_stmt 1 + set _seg_sel_size 0 foreach { name value } $options { switch -exact -- $name { is_64 { set is_64 $value } - version { set _unit_version $value } + version { set _line_unit_version $value } addr_size { set _unit_addr_size $value } + seg_sel_size { set _seg_sel_size $value } default_is_stmt { set _default_is_stmt $value } default { error "unknown option $name" } } @@ -2234,7 +2240,13 @@ namespace eval Dwarf { define_label $unit_len_label - _op .2byte $_unit_version version + _op .2byte $_line_unit_version version + + if { $_line_unit_version >= 5 } { + _op .byte $_unit_addr_size "address_size" + # Hardcode to 0 for now. + _op .byte $_seg_sel_size "seg_sel_size" + } if {$is_64} { _op .8byte "$_line_header_end_label - $header_len_label" "header_length" @@ -2245,7 +2257,7 @@ namespace eval Dwarf { define_label $header_len_label _op .byte 1 "minimum_instruction_length" - if { $_unit_version >= 4 } { + if { $_line_unit_version >= 4 } { # Assume non-VLIW for now. _op .byte 1 "maximum_operations_per_instruction" } @@ -2293,7 +2305,54 @@ namespace eval Dwarf { variable _line_include_dirs variable _line_file_names - if { 1 } { + variable _line_unit_version + if { $_line_unit_version >= 5 } { + _op .byte 1 "directory_entry_format_count" + _op .uleb128 1 \ + "directory_entry_format (content type code: DW_LNCT_path)" + _op .uleb128 0x08 \ + "directory_entry_format (form: DW_FORM_string)" + + set nr_dirs [llength $_line_include_dirs] + # For entry 0. + set nr_dirs [expr $nr_dirs + 1] + _op .byte $nr_dirs "directory_count" + + # Entry 0. + set dirname [lindex $_line_include_dirs 0] + set _line_include_dirs \ + [concat [list $dirname] $_line_include_dirs] + + foreach dirname $_line_include_dirs { + _op .ascii [_quote $dirname] + } + + _op .byte 2 "file_name_entry_format_count" + _op .uleb128 1 \ + "file_name_entry_format (content type code: DW_LNCT_path)" + _op .uleb128 0x08 \ + "file_name_entry_format (form: DW_FORM_string)" + _op .uleb128 2 \ + "file_name_entry_format (content type code: DW_LNCT_directory_index)" + _op .uleb128 0x0f \ + "file_name_entry_format (form: DW_FORM_udata)" + + set nr_files [expr [llength $_line_file_names] / 2] + # For entry 0. + set nr_files [expr $nr_files + 1] + _op .byte $nr_files "file_names_count" + + # Entry 0. + set filename [lindex $_line_file_names 0] + set diridx [lindex $_line_file_names 1] + set _line_file_names \ + [concat [list $filename $diridx] $_line_file_names] + + foreach { filename diridx } $_line_file_names { + _op .ascii [_quote $filename] + _op .uleb128 $diridx + } + } else { foreach dirname $_line_include_dirs { _op .ascii [_quote $dirname] }