1 # Copyright
2019-2023 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 require is_x86_64_m64_target
33 if { [prepare_for_testing
"failed to prepare" $testfile $srcfile debug] } {
37 if { ![runto_main
] } {
41 # First we need to generate a corefile.
42 set corefilename
"[standard_output_file gcore.test]"
43 if { ![gdb_gcore_cmd
"$corefilename" "save corefile"] } {
44 verbose
-log "Could not save corefile"
45 untested
"$testfile.exp"
49 # Determine
if GDB dumped the mapping containing the build
-id. This
50 # is done by invoking an external
program (eu
-unstrip
).
51 if { [catch
"exec [gdb_find_eu-unstrip] -n --core $corefilename" output] == 0 } {
52 set line
[lindex
[split $output
"\n"] 0]
53 set test
"gcore dumped mapping with build-id"
55 verbose
-log "First line of eu-unstrip: $line"
57 set binfile_re
(?
:[string_to_regexp $binfile
]|
\\\
[(?
:exe|pie
)\\\
])
58 if { [regexp
"^${hex}\\+${hex} \[a-f0-9\]+@${hex}.*$binfile_re$" $line] } {
64 verbose
-log "Could not execute eu-unstrip program"
65 untested
"$testfile.exp"