From: Simon Marchi Date: Fri, 19 Jan 2024 21:15:41 +0000 (+0000) Subject: gdb/testsuite: avoid duplicate test names in gdb.dwarf2/dw2-zero-range.exp (and more) X-Git-Tag: gdb-15-branchpoint~1172 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3a49585ad58fb11ec4e9a1d6adaaca47ddd84cd5;p=thirdparty%2Fbinutils-gdb.git gdb/testsuite: avoid duplicate test names in gdb.dwarf2/dw2-zero-range.exp (and more) Tom Tromey noticed that dw2-zero-range.exp reported a duplicate test name. This happens because have_index calls get_index_type with the default test name. Refactor the test to avoid this, while cleaning a few other things, the most important being: - factor out the relocated and unrelocated parts in their own procs - give different names to generated binaries in different variations, such that all binaries are left in the test output directory (this makes it easier to debug a specific variation) Change-Id: I7cdf7a344834852fbb035d7e0434559eab6b1e94 --- diff --git a/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp index 79ccd620b8b..59840b8d0e2 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp @@ -23,6 +23,67 @@ require dwarf2_support allow_shlib_tests standard_testfile .c -shlib.c -dw.S +# Test for presence of complaint, with the lib relocated. + +proc_with_prefix test_relocated { exec_path lib_path complaint_re readnow_p } { + clean_restart $exec_path + gdb_load_shlib $lib_path + + # Don't load the symbols for $lib_path during runto_main. + # Instead, we do this afterwards using "sharedlibrary $lib_path". + gdb_test_no_output "set auto-solib-add off" + + if { ![runto_main] } { + return + } + + # Test for presence of complaint. + with_complaints 1 { + set have_complaint 0 + gdb_test_multiple "maint with dwarf synchronous on -- sharedlibrary [file tail $lib_path]" "load shared library" { + -re -wrap $complaint_re { + set have_complaint 1 + } + -re -wrap "" { + } + } + + # The complaint won't be seen if an index is in use. + if {[have_index $lib_path] == ""} { + gdb_assert { $have_complaint } "complaint" + } + + if { ! $readnow_p } { + gdb_test "maint expand-symtabs $::srcfile2" $complaint_re \ + "complaint when expanding symtab" + } + } +} + +# Test for presence of complaint, with the lib unrelocated. + +proc_with_prefix test_unrelocated { exec_path lib_path complaint_re readnow_p } { + clean_restart + gdb_test_no_output "maint set dwarf synchronous on" + + with_complaints 1 { + gdb_load $lib_path + set have_complaint [regexp $complaint_re.* $::gdb_file_cmd_msg] + + # The complaint won't be seen if an index is in use. + if {[have_index $lib_path] == ""} { + gdb_assert { $have_complaint } "complaint" + } + + gdb_test_no_output "maint set dwarf synchronous off" + + if { ! $readnow_p } { + gdb_test "maint expand-symtabs $::srcfile2" $complaint_re \ + "complaint when expanding symtab" + } + } +} + # Test with both a .debug_ranges section (DWARF 4) and a .debug_rnglists # section (DWARF 5). @@ -86,83 +147,27 @@ foreach_with_prefix ranges_sect {ranges rnglists} { error "invalid ranges section kind" } - set lib1 [standard_output_file shr1.sl] - set lib_opts "nodebug" - - set sources [list ${srcdir}/${subdir}/$srcfile2 $asm_file] - if { [gdb_compile_shlib $sources ${lib1} $lib_opts] != "" } { + set lib_path [standard_output_file shr1-${ranges_sect}.sl] + set lib_sources [list ${srcdir}/${subdir}/$srcfile2 $asm_file] + if { [gdb_compile_shlib $lib_sources $lib_path {nodebug}] != "" } { untested "failed to compile" - return -1 + return } - set exec_opts [list debug shlib=${lib1}] - set sources ${srcdir}/${subdir}/${srcfile} - if { [gdb_compile $sources ${binfile} executable \ - $exec_opts] != ""} { + set exec_sources ${srcdir}/${subdir}/${srcfile} + set exec_path ${binfile}-${ranges_sect} + set exec_opts [list debug shlib=${lib_path}] + if { [gdb_compile $exec_sources $exec_path executable $exec_opts] != ""} { untested "failed to compile" - return -1 - } - - clean_restart $binfile - gdb_load_shlib $lib1 - - set readnow_p [readnow] - - # Don't load the symbols for $lib1 during runto_main. - # Instead, we do this afterwards using "sharedlibrary $lib1". - gdb_test_no_output "set auto-solib-add off" - - if { ![runto_main] } { - return -1 + return } set complaint_re ".debug_${ranges_sect} entry has start address of zero" - set re \ + set complaint_re \ "During symbol reading: $complaint_re \\\[in module \[^\r\n\]*\\\]" - # Test for presence of complaint, with lib1 relocated. - with_complaints 1 { - set test "Zero address complaint - relocated - psymtab" - set have_complaint 0 - gdb_test_multiple "maint with dwarf synchronous on -- sharedlibrary [file tail $lib1]" $test { - -re -wrap $re { - set have_complaint 1 - } - -re -wrap "" { - } - } - - # The complaint won't be seen if an index is in use. - if {[have_index $lib1] == ""} { - gdb_assert { $have_complaint } $test - } - } - - if { ! $readnow_p } { - with_complaints 1 { - gdb_test "maint expand-symtabs $srcfile2" $re \ - "Zero address complaint - relocated - symtab" - } - } - - clean_restart - # Test for presence of complaint, with lib1 unrelocated. - gdb_test_no_output "maint set dwarf synchronous on" - with_complaints 1 { - gdb_load $lib1 - set test "Zero address complaint - unrelocated - psymtab" - set have_complaint [regexp $re.* $gdb_file_cmd_msg] - # The complaint won't be seen if an index is in use. - if {[have_index $lib1] == ""} { - gdb_assert { $have_complaint } $test - } - } - gdb_test_no_output "maint set dwarf synchronous off" + set readnow_p [readnow] - if { ! $readnow_p } { - with_complaints 1 { - gdb_test "maint expand-symtabs $srcfile2" $re \ - "Zero address complaint - unrelocated - symtab" - } - } + test_relocated $exec_path $lib_path $complaint_re $readnow_p + test_unrelocated $exec_path $lib_path $complaint_re $readnow_p }