aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.dwarf2
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2023-11-01 00:33:12 +0100
committerTom de Vries <tdevries@suse.de>2023-11-01 00:33:12 +0100
commita833790a626d9620319d0ca6aee23daa584d445c (patch)
tree25a3a0f829e12317b39a580c803c8ae663c36764 /gdb/testsuite/gdb.dwarf2
parent98ef1d81d6a3970f07e98216f31c89ec77997095 (diff)
downloadgdb-a833790a626d9620319d0ca6aee23daa584d445c.zip
gdb-a833790a626d9620319d0ca6aee23daa584d445c.tar.gz
gdb-a833790a626d9620319d0ca6aee23daa584d445c.tar.bz2
[gdb/symtab] Work around gas PR28629
When running test-case gdb.tui/tui-layout-asm-short-prog.exp on AlmaLinux 9.2 ppc64le, I run into: ... FAIL: gdb.tui/tui-layout-asm-short-prog.exp: check asm box contents ... The problem is that we get: ... 7 [ No Assembly Available ] ... because tui_get_begin_asm_address doesn't succeed. In more detail, tui_get_begin_asm_address calls: ... find_line_pc (sal.symtab, sal.line, &addr); ... with: ... (gdb) p *sal.symtab $5 = {next = 0x130393c0, m_compunit = 0x130392f0, m_linetable = 0x0, filename = "tui-layout-asm-short-prog.S", filename_for_id = "$gdb/build/gdb/testsuite/tui-layout-asm-short-prog.S", m_language = language_asm, fullname = 0x0} (gdb) p sal.line $6 = 1 ... The problem is the filename_for_id which is the source file prefixed with the compilation dir rather than the source dir. This is due to faulty debug info generated by gas, PR28629: ... <1a> DW_AT_name : tui-layout-asm-short-prog.S <1e> DW_AT_comp_dir : $gdb/build/gdb/testsuite <22> DW_AT_producer : GNU AS 2.35.2 ... The DW_AT_name is relative, and it's relative to the DW_AT_comp_dir entry, making the effective name $gdb/build/gdb/testsuite/tui-layout-asm-short-prog.S. The bug is fixed starting version 2.38, where we get instead: ... <1a> DW_AT_name : $gdb/src/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.S <1e> DW_AT_comp_dir : $gdb/build/gdb/testsuite <22> DW_AT_producer : GNU AS 2.38 ... Work around the faulty debug info by constructing the filename_for_id using the second directory from the directory table in the .debug_line header: ... The Directory Table (offset 0x22, lines 2, columns 1): Entry Name 0 $gdb/build/gdb/testsuite 1 $gdb/src/gdb/testsuite/gdb.tui ... Note that the used gas contains a backport of commit 3417bfca676 ("GAS: DWARF-5: Ensure that the 0'th entry in the directory table contains the current working directory."), because directory 0 is correct. With the unpatched 2.35.2 release the directory 0 entry is incorrect: it's a copy of entry 1. Add a dwarf assembly test-case that reflects the debug info as generated by unpatched gas 2.35.2. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/testsuite/gdb.dwarf2')
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp92
1 files changed, 92 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp b/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp
new file mode 100644
index 0000000..ca2b10f
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp
@@ -0,0 +1,92 @@
+# Copyright 2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test line number information in various configurations.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+require dwarf2_support
+
+standard_testfile dw2-lines.c -dw2.S
+
+with_shared_gdb {
+ set func_info_vars [get_func_info bar]
+}
+
+# Helper function.
+proc line_for { l } {
+ global srcfile
+ set line [gdb_get_line_number "$l:" $srcfile]
+ return [expr $line + 1]
+}
+
+set asm_file [standard_output_file $srcfile2]
+Dwarf::assemble $asm_file {
+ declare_labels Llines
+ global srcdir subdir srcfile objdir
+ global func_info_vars
+ foreach var $func_info_vars {
+ global $var
+ }
+
+ cu { version 5 } {
+ compile_unit {
+ {language @DW_LANG_Mips_Assembler}
+ {name $srcfile}
+ {comp_dir $objdir}
+ {stmt_list $Llines DW_FORM_sec_offset}
+ {producer "GNU AS 2.35.2"}
+ } {
+ subprogram {
+ {external 1 flag}
+ {name bar}
+ {low_pc $bar_start addr}
+ {high_pc "$bar_start + $bar_len" addr}
+ }
+ }
+ }
+
+ lines [list version 5] Llines {
+ set diridx1 [include_dir "${srcdir}/${subdir}"]
+ set diridx2 [include_dir "${srcdir}/${subdir}"]
+ file_name "$srcfile" $diridx1
+ file_name "$srcfile" $diridx2
+
+ program {
+ DW_LNE_set_address bar_label
+ line [line_for bar_label]
+ DW_LNS_copy
+
+ DW_LNE_set_address bar_label_2
+ DW_LNE_end_sequence
+ }
+ }
+}
+
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+ [list $srcfile $asm_file] {nodebug}] } {
+ return -1
+}
+
+gdb_test_no_output "set debug symtab-create 1"
+gdb_test_multiple "ptype bar" "" {
+ -re -wrap "$objdir.*" {
+ fail $gdb_test_name
+ }
+ -re -wrap "" {
+ pass $gdb_test_name
+ }
+}