1 # Test `info auxv' and related functionality.
3 # Copyright 1992,1993,1994,1995,1996,1997,1998,1999,2000,2004
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 2 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, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 # Please email any bugs, comments, and/or additions to this file to:
21 # bug-gdb@prep.ai.mit.edu
23 # This file is based on corefile.exp which was written by Fred
24 # Fish. (fnf@cygnus.com)
26 if { ! [istarget "*-*-linux*"] && ! [istarget "*-*-solaris*"] } {
27 verbose "Skipping auxv.exp because of lack of support."
39 set srcfile ${testfile}.c
40 set binfile ${objdir}/${subdir}/${testfile}
41 set corefile ${objdir}/${subdir}/${testfile}.corefile
42 set gcorefile ${objdir}/${subdir}/${testfile}.gcore
44 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
45 untested "couldn't compile ${srcdir}/${subdir}/${srcfile}"
49 # Use a fresh directory to confine the native core dumps.
50 # Make it the working directory for gdb and its child.
51 set coredir "${objdir}/${subdir}/coredir.[getpid]"
53 set core_works [isnative]
55 # Run GDB on the test program up to where it will dump core.
59 gdb_reinitialize_dir $srcdir/$subdir
61 gdb_test "set print sevenbit-strings" "" \
62 "set print sevenbit-strings; ${testfile}"
63 gdb_test "set width 0" "" \
64 "set width 0; ${testfile}"
67 if {[gdb_test "cd $coredir" ".*Working directory .*" \
68 "cd to temporary directory for core dumps"]} {
73 if { ![runto_main] } then {
76 set print_core_line [gdb_get_line_number "ABORT;"]
77 gdb_test "tbreak $print_core_line"
78 gdb_test continue ".*ABORT;.*"
80 proc fetch_auxv {test} {
85 if {[gdb_test_multiple "info auxv" $test {
86 -re "info auxv\[\r\n\]+" {
89 -ex "The program has no auxiliary information now" {
93 -ex "Auxiliary vector is empty" {
97 -ex "No auxiliary vector found" {
101 -re "^\[0-9\]+\[ \t\]+(AT_\[^ \t\]+)\[^\r\n\]+\[\r\n\]+" {
102 lappend auxv_lines $expect_out(0,string)
105 -re "^\[0-9\]+\[ \t\]+\\?\\?\\?\[^\r\n\]+\[\r\n\]+" {
106 warning "Unrecognized tag value: $expect_out(0,string)"
108 lappend auxv_lines $expect_out(0,string)
111 -re ".*$gdb_prompt $" {
114 -re "^\[^\r\n\]+\[\r\n\]+" {
116 warning "Unrecognized output: $expect_out(0,string)"
134 set live_data [fetch_auxv "info auxv on live process"]
138 set escapedfilename [string_to_regexp $gcorefile]
139 gdb_test_multiple "gcore $gcorefile" "gcore" {
140 -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
144 -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
147 -re "Undefined command: .*\[\r\n\]+$gdb_prompt $" {
152 # Let the program continue and die.
153 gdb_test continue ".*Program received signal.*"
154 gdb_test continue ".*Program terminated with signal.*"
156 # Now collect the core dump it left.
157 set test "generate native core dump"
160 set names [glob -nocomplain -directory $coredir *core*]
161 if {[llength $names] == 1} {
162 set file [file join $coredir [lindex $names 0]]
163 remote_exec build "mv $file $corefile"
167 warning "can't generate a core file - core tests suppressed - check ulimit -c"
173 remote_exec build "rm -rf $coredir"
175 # Now we can examine the core files and check that their data matches what
176 # we saw in the process. Note that the exact data can vary between runs,
177 # so it's important that the native core dump file and the gcore-created dump
178 # both be from the same run of the program as we examined live.
180 proc do_core_test {works corefile test1 test2} {
185 gdb_test "core $corefile" "Core was generated by.*" \
186 "load core file for $test1" \
187 "A program is being debugged already.*" "y"
188 set core_data [fetch_auxv $test1]
190 if {$core_data == $live_data} {
198 do_core_test $core_works $corefile \
199 "info auxv on native core dump" "matching auxv data from live and core"
201 do_core_test $gcore_works $gcorefile \
202 "info auxv on gcore-created dump" "matching auxv data from live and gcore"