This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / auxv.exp
CommitLineData
d65308ae
RM
1# Test `info auxv' and related functionality.
2
3# Copyright 1992,1993,1994,1995,1996,1997,1998,1999,2000,2004
4# Free Software Foundation, Inc.
5
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.
10#
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.
15#
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.
19
20# Please email any bugs, comments, and/or additions to this file to:
21# bug-gdb@prep.ai.mit.edu
22
23# This file is based on corefile.exp which was written by Fred
24# Fish. (fnf@cygnus.com)
25
26if $tracelevel then {
27 strace $tracelevel
28}
29
30set prms_id 0
31set bug_id 0
32
33set testfile "auxv"
34set srcfile ${testfile}.c
35set binfile ${objdir}/${subdir}/${testfile}
36set corefile ${objdir}/${subdir}/${testfile}.corefile
37set gcorefile ${objdir}/${subdir}/${testfile}.gcore
38
39if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
78df6c56
JB
40 untested "couldn't compile ${srcdir}/${subdir}/${srcfile}"
41 return -1
d65308ae
RM
42}
43
44# Use a fresh directory to confine the native core dumps.
45# Make it the working directory for gdb and its child.
46set coredir "${objdir}/${subdir}/coredir.[getpid]"
47file mkdir $coredir
48set core_works [isnative]
49
50# Run GDB on the test program up to where it will dump core.
51
52gdb_exit
53gdb_start
54gdb_reinitialize_dir $srcdir/$subdir
55gdb_load ${binfile}
56gdb_test "set print sevenbit-strings" "" \
57 "set print sevenbit-strings; ${testfile}"
58gdb_test "set width 0" "" \
59 "set width 0; ${testfile}"
60
61if {$core_works} {
62 if {[gdb_test "cd $coredir" ".*Working directory .*" \
63 "cd to temporary directory for core dumps"]} {
64 set core_works 0
65 }
66}
67
68if { ![runto_main] } then {
69 gdb_suppress_tests;
70}
71set print_core_line [gdb_get_line_number "ABORT;"]
72gdb_test "tbreak $print_core_line"
73gdb_test continue ".*ABORT;.*"
74
75proc fetch_auxv {test} {
76 global gdb_prompt
77
78 set auxv_lines {}
79 set bad -1
80 if {[gdb_test_multiple "info auxv" $test {
81 -re "info auxv\[\r\n\]+" {
82 exp_continue
83 }
c1b5970d 84 -ex "The program has no auxiliary information now" {
d65308ae 85 set bad 1
f1ed375c 86 exp_continue
d65308ae 87 }
c1b5970d 88 -ex "Auxiliary vector is empty" {
d65308ae 89 set bad 1
f1ed375c 90 exp_continue
d65308ae 91 }
c1b5970d 92 -ex "No auxiliary vector found" {
d65308ae 93 set bad 1
f1ed375c 94 exp_continue
d65308ae
RM
95 }
96 -re "^\[0-9\]+\[ \t\]+(AT_\[^ \t\]+)\[^\r\n\]+\[\r\n\]+" {
97 lappend auxv_lines $expect_out(0,string)
98 exp_continue
99 }
100 -re "^\[0-9\]+\[ \t\]+\\?\\?\\?\[^\r\n\]+\[\r\n\]+" {
101 warning "Unrecognized tag value: $expect_out(0,string)"
102 set bad 1
103 lappend auxv_lines $expect_out(0,string)
104 exp_continue
105 }
f1ed375c
RM
106 -re ".*$gdb_prompt $" {
107 incr bad
d65308ae 108 }
c1b5970d
RM
109 -re "^\[^\r\n\]+\[\r\n\]+" {
110 if {!$bad} {
111 warning "Unrecognized output: $expect_out(0,string)"
112 set bad 1
113 }
114 exp_continue
115 }
d65308ae
RM
116 }] != 0} {
117 return {}
118 }
119
120 if {$bad} {
121 fail $test
122 return {}
123 }
124
125 pass $test
126 return $auxv_lines
127}
128
129set live_data [fetch_auxv "info auxv on live process"]
130
131# Now try gcore.
132set gcore_works 0
133set escapedfilename [string_to_regexp $gcorefile]
134gdb_test_multiple "gcore $gcorefile" "gcore" {
135 -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
136 pass "gcore"
137 set gcore_works 1
138 }
139 -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
140 unsupported "gcore"
141 }
142}
143
144# Let the program continue and die.
145gdb_test continue ".*Program received signal.*"
146gdb_test continue ".*Program terminated with signal.*"
147
148# Now collect the core dump it left.
149set test "generate native core dump"
150if {$core_works} {
151 # Find the
152 set names [glob -nocomplain -directory $coredir *core*]
153 if {[llength $names] == 1} {
154 set file [file join $coredir [lindex $names 0]]
155 remote_exec build "mv $file $corefile"
156 pass $test
157 } else {
158 set core_works 0
159 warning "can't generate a core file - core tests suppressed - check ulimit -c"
160 fail $test
161 }
162} else {
163 unsupported $test
164}
165remote_exec build "rm -rf $coredir"
166
167# Now we can examine the core files and check that their data matches what
168# we saw in the process. Note that the exact data can vary between runs,
169# so it's important that the native core dump file and the gcore-created dump
170# both be from the same run of the program as we examined live.
171
172proc do_core_test {works corefile test1 test2} {
173 if {! $works} {
174 unsupported $test1
175 unsupported $test2
176 } else {
177 gdb_test "core $corefile" "Core was generated by.*" \
178 "load core file for $test1" \
179 "A program is being debugged already.*" "y"
180 set core_data [fetch_auxv $test1]
181 global live_data
182 if {$core_data == $live_data} {
183 pass $test2
184 } else {
185 fail $test2
186 }
187 }
188}
189
190do_core_test $core_works $corefile \
191 "info auxv on native core dump" "matching auxv data from live and core"
192
193do_core_test $gcore_works $gcorefile \
194 "info auxv on gcore-created dump" "matching auxv data from live and gcore"
This page took 0.208449 seconds and 4 git commands to generate.