From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 8E3E43858D1E; Mon, 18 Apr 2022 20:59:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E3E43858D1E Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite/dwarf: don't automatically add directory and file entry for DWARF 5 X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 56325e2ba62af99ff47c38679951115cbf5c6ba0 X-Git-Newrev: 9a0de6abdd1af5a4eaafb44d7cda6ad60a4b6485 Message-Id: <20220418205921.8E3E43858D1E@sourceware.org> Date: Mon, 18 Apr 2022 20:59:21 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Apr 2022 20:59:21 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D9a0de6abdd1a= f5a4eaafb44d7cda6ad60a4b6485 commit 9a0de6abdd1af5a4eaafb44d7cda6ad60a4b6485 Author: Simon Marchi Date: Wed Apr 6 21:51:56 2022 -0400 gdb/testsuite/dwarf: don't automatically add directory and file entry f= or DWARF 5 =20 To support DWARF 5 in the DWARF assembler line tables, we currently copy the first user-provided directory and the first user-provided files and make them elements at indices 0 in the directory and file name tables. That was a sufficient behavior at the time (see commit 44fda089397a ("[gdb/testsuite] Support .debug_line v5 in dwarf assembler")), but in the following patches, I would need to have finer grained control on what is generated exactly. For example, I'd like to generate a DWARF 5= line table with just a single file and a single directory. =20 Get rid of this behavior, and implement what is suggested in 44fda089397a: make include_dir return the directory index that can be used to refer to that directory entry (based on the DWARF version), and use it afterwards. =20 Adjust dw2-lines.exp and dw2-prologue-end.exp accordingly. Their produ= ced DWARF5 binaries will change a bit, in that they will now have a single directory and file, where they had two before. But it doesn't change the expected GDB behavior. =20 Change-Id: I5459b16ac9b7f28c34c9693c35c9afd2ebb3aa3b Diff: --- gdb/testsuite/gdb.dwarf2/dw2-lines.exp | 9 ++++++-- gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp | 5 ++-- gdb/testsuite/lib/dwarf.exp | 33 +++++++++++++++--------= ---- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/gdb/testsuite/gdb.dwarf2/dw2-lines.exp b/gdb/testsuite/gdb.dwa= rf2/dw2-lines.exp index 3cbbd28fd48..b24eec0c8d2 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-lines.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-lines.exp @@ -79,10 +79,15 @@ proc test_1 { _cv _cdw64 _lv _ldw64 {_string_form ""}} { } =20 lines [list version $lv is_64 $ldw64 string_form $string_form] Llines { - include_dir "${srcdir}/${subdir}" - file_name "$srcfile" 1 + set diridx [include_dir "${srcdir}/${subdir}"] + file_name "$srcfile" $diridx =20 program { + # If using DWARF 5, we want to refer to file 0, but the LNP + # state machine is still initialized with file 1. So we need + # to set the current file explicitly. + DW_LNS_set_file $diridx + DW_LNE_set_address bar_label line [line_for bar_label] DW_LNS_copy diff --git a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp b/gdb/testsuite/= gdb.dwarf2/dw2-prologue-end.exp index 7fd1bd78132..9ce97fc1f26 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp @@ -48,10 +48,11 @@ Dwarf::assemble $asm_file { } =20 lines {version 5} lines_label { - include_dir "${srcdir}/${subdir}" - file_name "$srcfile" 1 + set diridx [include_dir "${srcdir}/${subdir}"] + file_name "$srcfile" $diridx =20 program { + DW_LNS_set_file $diridx DW_LNE_set_address $main_start line [gdb_get_line_number "main prologue"] DW_LNS_copy diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index 9c92115fd00..55e97c33a6e 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -2277,14 +2277,32 @@ namespace eval Dwarf { _op .byte 1 "standard opcode 9" _op .byte 0 "standard opcode 10" =20 + # Add a directory entry to the line table header's directory table. + # + # Return the index by which this entry can be referred to. proc include_dir {dirname} { variable _line_include_dirs lappend _line_include_dirs $dirname + + if { $Dwarf::_line_unit_version >=3D 5 } { + return [expr [llength $_line_include_dirs] - 1] + } else { + return [llength $_line_include_dirs] + } } =20 + # Add a file name entry to the line table header's file names table. + # + # Return the index by which this entry can be referred to. proc file_name {filename diridx} { variable _line_file_names lappend _line_file_names $filename $diridx + + if { $Dwarf::_line_unit_version >=3D 5 } { + return [expr [llength $_line_file_names] - 1] + } else { + return [llength $_line_file_names] + } } =20 proc _line_finalize_header {} { @@ -2316,15 +2334,8 @@ namespace eval Dwarf { } =20 set nr_dirs [llength $_line_include_dirs] - # For entry 0. - set nr_dirs [expr $nr_dirs + 1] _op .byte $nr_dirs "directory_count" =20 - # Entry 0. - set dirname [lindex $_line_include_dirs 0] - set _line_include_dirs \ - [concat [list $dirname] $_line_include_dirs] - foreach dirname $_line_include_dirs { switch $_line_string_form { string { @@ -2360,16 +2371,8 @@ namespace eval Dwarf { "file_name_entry_format (form: DW_FORM_udata)" =20 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" =20 - # 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 { switch $_line_string_form { string {