|
| 1 | +# Copyright (C) 2014 Free Software Foundation, Inc. |
| 2 | + |
| 3 | +# This program is free software; you can redistribute it and/or modify |
| 4 | +# it under the terms of the GNU General Public License as published by |
| 5 | +# the Free Software Foundation; either version 3 of the License, or |
| 6 | +# (at your option) any later version. |
| 7 | +# |
| 8 | +# This program is distributed in the hope that it will be useful, |
| 9 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | +# GNU General Public License for more details. |
| 12 | +# |
| 13 | +# You should have received a copy of the GNU General Public License |
| 14 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | + |
| 16 | +standard_testfile "normal.c" |
| 17 | + |
| 18 | +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } { |
| 19 | + return -1 |
| 20 | +} |
| 21 | + |
| 22 | +# Get the build-id of the file |
| 23 | +set build_id_debug_file [build_id_debug_filename_get $binfile] |
| 24 | +regsub -all ".debug$" $build_id_debug_file "" build_id_without_debug |
| 25 | + |
| 26 | +# Run to main |
| 27 | +if { ![runto_main] } { |
| 28 | + return -1 |
| 29 | +} |
| 30 | + |
| 31 | +# We first need to generate a corefile |
| 32 | +set escapedfilename [string_to_regexp [standard_output_file gcore.test]] |
| 33 | +set core_supported 0 |
| 34 | +gdb_test_multiple "gcore [standard_output_file gcore.test]" \ |
| 35 | + "save a corefile" \ |
| 36 | +{ |
| 37 | + -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" { |
| 38 | + pass "save a corefile" |
| 39 | + global core_supported |
| 40 | + set core_supported 1 |
| 41 | + } |
| 42 | + -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" { |
| 43 | + unsupported "save a corefile" |
| 44 | + global core_supported |
| 45 | + set core_supported 0 |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +if {!$core_supported} { |
| 50 | + return -1 |
| 51 | +} |
| 52 | + |
| 53 | +# Move the binfile to a temporary name |
| 54 | +remote_exec build "mv $binfile ${binfile}.old" |
| 55 | + |
| 56 | +# Reinitialize GDB and see if we get a yum/dnf warning |
| 57 | +gdb_exit |
| 58 | +gdb_start |
| 59 | +gdb_reinitialize_dir $srcdir/$subdir |
| 60 | + |
| 61 | +with_test_prefix "first run:" { |
| 62 | + gdb_test "set build-id-verbose 1" "" \ |
| 63 | + "set build-id-verbose" |
| 64 | + |
| 65 | + gdb_test "set debug-file-directory [file dirname [standard_output_file gcore.test]]" "" \ |
| 66 | + "set debug-file-directory" |
| 67 | + |
| 68 | + gdb_test "core-file [standard_output_file gcore.test]" \ |
| 69 | + "Missing separate debuginfo for the main executable file\r\nTry: (yum|dnf) --enablerepo='\\*debug\\*' install [standard_output_file $build_id_without_debug]\r\n.*" \ |
| 70 | + "test first yum/dnf warning" |
| 71 | +} |
| 72 | + |
| 73 | +# Now we define and create our .build-id |
| 74 | +file mkdir [file dirname [standard_output_file ${build_id_without_debug}]] |
| 75 | +# Cannot use "file link" (from TCL) because it requires the target file to |
| 76 | +# exist. |
| 77 | +remote_exec build "ln -s $binfile [standard_output_file ${build_id_without_debug}]" |
| 78 | + |
| 79 | +# Reinitialize GDB to get the second yum/dnf warning |
| 80 | +gdb_exit |
| 81 | +gdb_start |
| 82 | +gdb_reinitialize_dir $srcdir/$subdir |
| 83 | + |
| 84 | +with_test_prefix "second run:" { |
| 85 | + gdb_test "set build-id-verbose 1" "" \ |
| 86 | + "set build-id-verbose" |
| 87 | + |
| 88 | + gdb_test "set debug-file-directory [file dirname [standard_output_file gcore.test]]" "" \ |
| 89 | + "set debug-file-directory" |
| 90 | + |
| 91 | + gdb_test "core-file [standard_output_file gcore.test]" \ |
| 92 | + "Missing separate debuginfo for the main executable file\r\nTry: (yum|dnf) --enablerepo='\\*debug\\*' install $binfile\r\n.*" \ |
| 93 | + "test second yum/dnf warning" |
| 94 | +} |
| 95 | + |
| 96 | +# Leaving the link there will cause breakage in the next run. |
| 97 | +remote_exec build "rm -f [standard_output_file ${build_id_without_debug}]" |
0 commit comments