1 # Test `info auxv' and related functionality.
3 # Copyright 1992,1993,1994,1995,1996,1997,1998,1999,2000,2004,2007
4 # Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # Please email any bugs, comments, and/or additions to this file to:
20 # bug-gdb@prep.ai.mit.edu
22 # This file is based on corefile.exp which was written by Fred
23 # Fish. (fnf@cygnus.com)
25 if { ! [istarget "*-*-linux*"] && ! [istarget "*-*-solaris*"] } {
26 verbose "Skipping auxv.exp because of lack of support."
38 set srcfile ${testfile}.c
39 set binfile ${objdir}/${subdir}/${testfile}
40 set corefile ${objdir}/${subdir}/${testfile}.corefile
41 set gcorefile ${objdir}/${subdir}/${testfile}.gcore
43 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
44 untested "couldn't compile ${srcdir}/${subdir}/${srcfile}"
48 # Use a fresh directory to confine the native core dumps.
49 # Make it the working directory for gdb and its child.
50 set coredir "${objdir}/${subdir}/coredir.[getpid]"
52 set core_works [expr [isnative] && ! [is_remote target]]
54 # Run GDB on the test program up to where it will dump core.
58 gdb_reinitialize_dir $srcdir/$subdir
60 gdb_test "set print sevenbit-strings" "" \
61 "set print sevenbit-strings; ${testfile}"
62 gdb_test "set width 0" "" \
63 "set width 0; ${testfile}"
66 if {[gdb_test "cd $coredir" ".*Working directory .*" \
67 "cd to temporary directory for core dumps"]} {
72 if { ![runto_main] } then {
75 set print_core_line [gdb_get_line_number "ABORT;"]
76 gdb_test "tbreak $print_core_line"
77 gdb_test continue ".*ABORT;.*"
79 proc fetch_auxv {test} {
84 if {[gdb_test_multiple "info auxv" $test {
85 -re "info auxv\[\r\n\]+" {
88 -ex "The program has no auxiliary information now" {
92 -ex "Auxiliary vector is empty" {
96 -ex "No auxiliary vector found" {
100 -re "^\[0-9\]+\[ \t\]+(AT_\[^ \t\]+)\[^\r\n\]+\[\r\n\]+" {
101 lappend auxv_lines $expect_out(0,string)
104 -re "^\[0-9\]+\[ \t\]+\\?\\?\\?\[^\r\n\]+\[\r\n\]+" {
105 warning "Unrecognized tag value: $expect_out(0,string)"
107 lappend auxv_lines $expect_out(0,string)
110 -re ".*$gdb_prompt $" {
113 -re "^\[^\r\n\]+\[\r\n\]+" {
115 warning "Unrecognized output: $expect_out(0,string)"
133 set live_data [fetch_auxv "info auxv on live process"]
137 set escapedfilename [string_to_regexp $gcorefile]
138 gdb_test_multiple "gcore $gcorefile" "gcore" {
139 -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
143 -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
146 -re "Undefined command: .*\[\r\n\]+$gdb_prompt $" {
151 # Let the program continue and die.
152 gdb_test continue ".*Program received signal.*"
153 gdb_test continue ".*Program terminated with signal.*"
155 # Now collect the core dump it left.
156 set test "generate native core dump"
159 set names [glob -nocomplain -directory $coredir *core*]
160 if {[llength $names] == 1} {
161 set file [file join $coredir [lindex $names 0]]
162 remote_exec build "mv $file $corefile"
166 warning "can't generate a core file - core tests suppressed - check ulimit -c"
172 remote_exec build "rm -rf $coredir"
174 # Now we can examine the core files and check that their data matches what
175 # we saw in the process. Note that the exact data can vary between runs,
176 # so it's important that the native core dump file and the gcore-created dump
177 # both be from the same run of the program as we examined live.
179 proc do_core_test {works corefile test1 test2} {
184 gdb_test "core $corefile" "Core was generated by.*" \
185 "load core file for $test1" \
186 "A program is being debugged already.*" "y"
187 set core_data [fetch_auxv $test1]
189 if {$core_data == $live_data} {
197 do_core_test $core_works $corefile \
198 "info auxv on native core dump" "matching auxv data from live and core"
200 do_core_test $gcore_works $gcorefile \
201 "info auxv on gcore-created dump" "matching auxv data from live and gcore"