1 # Copyright 2019-2021 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Test whether GDB's gcore/generate-core-file command can dump memory
17 # mappings with ELF headers, containing a build-id note.
19 # Due to the fact that we don't have an easy way to process a corefile
20 # and look for specific notes using GDB/dejagnu, we rely on an
21 # external tool, eu-unstrip, to verify if the corefile contains
24 standard_testfile "normal.c"
26 # This test is Linux x86_64 only.
27 if { ![istarget *-*-linux*] } {
28 untested "$testfile.exp"
31 if { ![istarget "x86_64-*-*"] || ![is_lp64_target] } {
32 untested "$testfile.exp"
36 if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
40 if { ![runto_main] } {
41 untested "could not run to main"
45 # First we need to generate a corefile.
46 set corefilename "[standard_output_file gcore.test]"
47 if { ![gdb_gcore_cmd "$corefilename" "save corefile"] } {
48 verbose -log "Could not save corefile"
49 untested "$testfile.exp"
53 # Determine if GDB dumped the mapping containing the build-id. This
54 # is done by invoking an external program (eu-unstrip).
55 if { [catch "exec [gdb_find_eu-unstrip] -n --core $corefilename" output] == 0 } {
56 set line [lindex [split $output "\n"] 0]
57 set test "gcore dumped mapping with build-id"
59 verbose -log "First line of eu-unstrip: $line"
61 set binfile_re (?:[string_to_regexp $binfile]|\\\[(?:exe|pie)\\\])
62 if { [regexp "^${hex}\\+${hex} \[a-f0-9\]+@${hex}.*$binfile_re$" $line] } {
68 verbose -log "Could not execute eu-unstrip program"
69 untested "$testfile.exp"