[binutils-gdb] test: basename filenames in dwarf2 frame checks
Bratislav Filipovic via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9c5a32d82cd223768c873bfd613418168f623b02 commit 9c5a32d82cd223768c873bfd613418168f623b02 Author: Bratislav Filipovic <[email protected]> Date: Tue Mar 17 21:25:17 2026 +0530 test: basename filenames in dwarf2 frame checks Some gdb.dwarf2 tests match the output of commands like frame and expect to see locations printed as fission-base.c:LINE (no directory prefix). When the test programs are built with clang as CC_FOR_TARGET, GDB can print an absolute source path instead, causing FAILs. For example, with clang: (gdb) PASS: gdb.dwarf2/fission-base.exp: ptype func (gdb) frame #0 main () at /path/to/gdb/testsuite/fission-base.c:27 27 return func (-1); (gdb) FAIL: gdb.dwarf2/fission-base.exp: frame in main With gcc: (gdb) PASS: gdb.dwarf2/fission-base.exp: ptype func (gdb) frame #0 main () at fission-base.c:27 27 return func (-1); (gdb) PASS: gdb.dwarf2/fission-base.exp: frame in main The difference comes from the DWARF line table contents. With clang, the .debug_line directory table can contain an absolute directory that the file table entries reference: The Directory Table: 0 /path/to/gdb/testsuite The File Name Table: 0 Dir=0 Name=fission-base.c 1 Dir=0 Name=fission-base.c Whereas with gcc the directory table is empty and only the bare filename is present: The Directory Table is empty. The File Name Table: 1 Name=fission-base.c This difference reflects toolchain/assembler behavior in how .file/.loc are translated into .debug_line and is orthogonal to what these tests aim to validate. Force set filename-display basename in the affected tests so the output is stable across toolchains. Test: gdb.dwarf2/fission-base.exp (CC_FOR_TARGET=clang, gcc) Test: gdb.dwarf2/dw2-undefined-ret-addr.exp (CC_FOR_TARGET=clang, gcc) Approved-By: Andrew Burgess <[email protected]> Diff: --- gdb/testsuite/gdb.dwarf2/dw2-undefined-ret-addr.exp | 5 +++++ gdb/testsuite/gdb.dwarf2/fission-base.exp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/gdb/testsuite/gdb.dwarf2/dw2-undefined-ret-addr.exp b/gdb/testsuite/gdb.dwarf2/dw2-undefined-ret-addr.exp index 32ddaf4a605..88765d4f513 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-undefined-ret-addr.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-undefined-ret-addr.exp @@ -30,6 +30,11 @@ if {![runto "stop_frame"]} { return -1 } +# If test is compiled with clang, GDB would display absolute path. +# This command keeps output consistent across toolchains. + +gdb_test_no_output "set filename-display basename" + # stop_frame should be the outermost frame. # Check that backtrace shows only frame #0. diff --git a/gdb/testsuite/gdb.dwarf2/fission-base.exp b/gdb/testsuite/gdb.dwarf2/fission-base.exp index 035fe73104f..d1abf6c9eb7 100644 --- a/gdb/testsuite/gdb.dwarf2/fission-base.exp +++ b/gdb/testsuite/gdb.dwarf2/fission-base.exp @@ -46,6 +46,11 @@ if {![runto_main]} { gdb_test "ptype main" "type = int \\(\\)" gdb_test "ptype func" "type = int \\(int\\)" +# If test is compiled with clang, GDB would display absolute path. +# This command keeps output consistent across toolchains. + +gdb_test_no_output "set filename-display basename" + gdb_test "frame" "#0 *main \\(\\) at $testfile\\.c:$decimal.*" \ "frame in main"