URL
https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk
Subversion Repositories openrisc_2011-10-31
Compare Revisions
- This comparison shows the changes necessary to convert path
/openrisc/tags/gdb/gdb-6.8/gdb-6.8.openrisc-2.1/gdb/testsuite/gdb.gdb
- from Rev 24 to Rev 33
- ↔ Reverse comparison
Rev 24 → Rev 33
/observer.exp
0,0 → 1,272
# Copyright 2003, 2004, 2007, 2008 Free Software Foundation, Inc. |
|
# This program is free software; you can redistribute it and/or modify |
# it under the terms of the GNU General Public License as published by |
# the Free Software Foundation; either version 3 of the License, or |
# (at your option) any later version. |
# |
# This program is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# GNU General Public License for more details. |
# |
# You should have received a copy of the GNU General Public License |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
# This file was written by Joel Brobecker (brobecker@gnat.com), derived |
# from xfullpath.exp. |
|
if $tracelevel then { |
strace $tracelevel |
} |
|
set prms_id 0 |
set bug_id 0 |
|
# are we on a target board |
if { [is_remote target] || ![isnative] } then { |
return |
} |
|
proc setup_test { executable } { |
global gdb_prompt |
global timeout |
|
# load yourself into the debugger |
# This can take a relatively long time, particularly for testing where |
# the executable is being accessed over a network, or where gdb does not |
# support partial symbols for a particular target and has to load the |
# entire symbol table. Set the timeout to 10 minutes, which should be |
# adequate for most environments (it *has* timed out with 5 min on a |
# SPARCstation SLC under moderate load, so this isn't unreasonable). |
# After gdb is started, set the timeout to 30 seconds for the duration |
# of this test, and then back to the original value. |
|
set oldtimeout $timeout |
set timeout 600 |
verbose "Timeout is now $timeout seconds" 2 |
|
global gdb_file_cmd_debug_info |
set gdb_file_cmd_debug_info "unset" |
|
set result [gdb_load $executable] |
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
|
if { $result != 0 } then { |
return -1 |
} |
|
if { $gdb_file_cmd_debug_info != "debug" } then { |
untested "No debug information, skipping testcase." |
return -1 |
} |
|
# Set a breakpoint at main |
gdb_test "break captured_main" \ |
"Breakpoint.*at.* file.*, line.*" \ |
"breakpoint in captured_main" |
|
# run yourself |
# It may take a very long time for the inferior gdb to start (lynx), |
# so we bump it back up for the duration of this command. |
set timeout 600 |
|
set description "run until breakpoint at captured_main" |
gdb_test_multiple "run -nw" "$description" { |
-re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" { |
pass "$description" |
} |
-re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.*$gdb_prompt $" { |
xfail "$description (line numbers scrambled?)" |
} |
-re "vfork: No more processes.*$gdb_prompt $" { |
fail "$description (out of virtual memory)" |
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
return -1 |
} |
-re ".*$gdb_prompt $" { |
fail "$description" |
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
return -1 |
} |
} |
|
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
|
return 0 |
} |
|
proc attach_first_observer { message } { |
gdb_test "set \$first_obs = observer_attach_normal_stop (&observer_test_first_notification_function)" \ |
"" "$message; attach first observer" |
} |
|
proc attach_second_observer { message } { |
gdb_test "set \$second_obs = observer_attach_normal_stop (&observer_test_second_notification_function)" \ |
"" "$message; attach second observer" |
} |
|
proc attach_third_observer { message } { |
gdb_test "set \$third_obs = observer_attach_normal_stop (&observer_test_third_notification_function)" \ |
"" "$message; attach third observer" |
} |
|
proc detach_first_observer { message } { |
gdb_test "call observer_detach_normal_stop (\$first_obs)" \ |
"" "$message; detach first observer" |
} |
|
proc detach_second_observer { message } { |
gdb_test "call observer_detach_normal_stop (\$second_obs)" \ |
"" "$message; detach second observer" |
} |
|
proc detach_third_observer { message } { |
gdb_test "call observer_detach_normal_stop (\$third_obs)" \ |
"" "$message; detach third observer" |
} |
|
proc check_counters { first second third message } { |
gdb_test "print observer_test_first_observer" \ |
".\[0-9\]+ =.*$first" \ |
"$message; check first observer counter value" |
gdb_test "print observer_test_second_observer" \ |
".\[0-9\]+ =.*$second" \ |
"$message; check second observer counter value" |
gdb_test "print observer_test_third_observer" \ |
".\[0-9\]+ =.*$third" \ |
"$message; check third observer counter value" |
} |
|
proc reset_counters { message } { |
gdb_test "set variable observer_test_first_observer = 0" "" \ |
"$message; reset first observer counter" |
gdb_test "set variable observer_test_second_observer = 0" "" \ |
"$message; reset second observer counter" |
gdb_test "set variable observer_test_third_observer = 0" "" \ |
"$message; reset third observer counter" |
} |
|
proc test_normal_stop_notifications { first second third message args } { |
# Do any initialization |
for {set i 0} {$i < [llength $args]} {incr i} { |
[lindex $args $i] $message |
} |
reset_counters $message |
# Call observer_notify_normal_stop. Note that this procedure |
# takes one argument, but this argument is ignored by the observer |
# callbacks we have installed. So we just pass an arbitrary value. |
gdb_test "call observer_notify_normal_stop (0)" "" \ |
"$message; sending notification" |
check_counters $first $second $third $message |
} |
|
proc test_observer_normal_stop { executable } { |
|
set setup_result [setup_test $executable] |
if {$setup_result <0} then { |
return -1 |
} |
|
# First, try sending a notification without any observer attached. |
test_normal_stop_notifications 0 0 0 "no observer attached" |
|
# Now, attach one observer, and send a notification. |
test_normal_stop_notifications 0 1 0 "second observer attached" \ |
attach_second_observer |
|
# Remove the observer, and send a notification. |
test_normal_stop_notifications 0 0 0 "second observer detached" \ |
detach_second_observer |
|
# With a new observer. |
test_normal_stop_notifications 1 0 0 "1st observer added" \ |
attach_first_observer |
|
# With 2 observers. |
test_normal_stop_notifications 1 1 0 "2nd observer added" \ |
attach_second_observer |
|
# With 3 observers. |
test_normal_stop_notifications 1 1 1 "3rd observer added" \ |
attach_third_observer |
|
# Remove middle observer. |
test_normal_stop_notifications 1 0 1 "2nd observer removed" \ |
detach_second_observer |
|
# Remove first observer. |
test_normal_stop_notifications 0 0 1 "1st observer removed" \ |
detach_first_observer |
|
# Remove last observer. |
test_normal_stop_notifications 0 0 0 "3rd observer removed" \ |
detach_third_observer |
|
# Go back to 3 observers, and remove them in a different order... |
test_normal_stop_notifications 1 1 1 "three observers added" \ |
attach_first_observer \ |
attach_second_observer \ |
attach_third_observer |
|
# Remove the third observer. |
test_normal_stop_notifications 1 1 0 "third observer removed" \ |
detach_third_observer |
|
# Remove the second observer. |
test_normal_stop_notifications 1 0 0 "second observer removed" \ |
detach_second_observer |
|
# Remove the first observer, no more observers. |
test_normal_stop_notifications 0 0 0 "first observer removed" \ |
detach_first_observer |
|
return 0 |
} |
|
# Find a pathname to a file that we would execute if the shell was asked |
# to run $arg using the current PATH. |
|
proc find_gdb { arg } { |
|
# If the arg directly specifies an existing executable file, then |
# simply use it. |
|
if [file executable $arg] then { |
return $arg |
} |
|
set result [which $arg] |
if [string match "/" [ string range $result 0 0 ]] then { |
return $result |
} |
|
# If everything fails, just return the unqualified pathname as default |
# and hope for best. |
|
return $arg |
} |
|
# Run the test with self. |
# Copy the file executable file in case this OS doesn't like to edit its own |
# text space. |
|
set GDB_FULLPATH [find_gdb $GDB] |
|
# Remove any old copy lying around. |
remote_file host delete x$tool |
|
gdb_start |
set file [remote_download host $GDB_FULLPATH x$tool] |
set result [test_observer_normal_stop $file]; |
gdb_exit; |
catch "remote_file host delete $file"; |
|
if {$result <0} then { |
warning "Couldn't test self" |
return -1 |
} |
/xfullpath.exp
0,0 → 1,193
# Copyright 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. |
|
# This program is free software; you can redistribute it and/or modify |
# it under the terms of the GNU General Public License as published by |
# the Free Software Foundation; either version 3 of the License, or |
# (at your option) any later version. |
# |
# This program is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# GNU General Public License for more details. |
# |
# You should have received a copy of the GNU General Public License |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
# This file was written by Joel Brobecker. (brobecker@gnat.com), derived |
# from selftest.exp, written by Rob Savoye. |
|
if $tracelevel then { |
strace $tracelevel |
} |
|
set prms_id 0 |
set bug_id 0 |
|
# are we on a target board |
if { [is_remote target] || ![isnative] } then { |
return |
} |
|
proc setup_test { executable } { |
global gdb_prompt |
global timeout |
|
# load yourself into the debugger |
# This can take a relatively long time, particularly for testing where |
# the executable is being accessed over a network, or where gdb does not |
# support partial symbols for a particular target and has to load the |
# entire symbol table. Set the timeout to 10 minutes, which should be |
# adequate for most environments (it *has* timed out with 5 min on a |
# SPARCstation SLC under moderate load, so this isn't unreasonable). |
# After gdb is started, set the timeout to 30 seconds for the duration |
# of this test, and then back to the original value. |
|
set oldtimeout $timeout |
set timeout 600 |
verbose "Timeout is now $timeout seconds" 2 |
|
global gdb_file_cmd_debug_info |
set gdb_file_cmd_debug_info "unset" |
|
set result [gdb_load $executable] |
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
|
if { $result != 0 } then { |
return -1 |
} |
|
if { $gdb_file_cmd_debug_info != "debug" } then { |
untested "No debug information, skipping testcase." |
return -1 |
} |
|
# Set a breakpoint at main |
gdb_test "break captured_main" \ |
"Breakpoint.*at.* file.*, line.*" \ |
"breakpoint in captured_main" |
|
# run yourself |
# It may take a very long time for the inferior gdb to start (lynx), |
# so we bump it back up for the duration of this command. |
set timeout 600 |
|
set description "run until breakpoint at captured_main" |
send_gdb "run -nw\n" |
gdb_expect { |
-re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" { |
pass "$description" |
} |
-re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.*$gdb_prompt $" { |
xfail "$description (line numbers scrambled?)" |
} |
-re "vfork: No more processes.*$gdb_prompt $" { |
fail "$description (out of virtual memory)" |
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
return -1 |
} |
-re ".*$gdb_prompt $" { |
fail "$description" |
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
return -1 |
} |
timeout { |
fail "$description (timeout)" |
} |
} |
|
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
|
return 0 |
} |
|
proc test_with_self { executable } { |
|
set setup_result [setup_test $executable] |
if {$setup_result <0} then { |
return -1 |
} |
|
# A file which contains a directory prefix |
gdb_test "print xfullpath (\"./xfullpath.exp\")" \ |
".\[0-9\]+ =.*\".*/xfullpath.exp\"" \ |
"A filename with ./ as the directory prefix" |
|
# A file which contains a directory prefix |
gdb_test "print xfullpath (\"../../defs.h\")" \ |
".\[0-9\]+ =.*\".*/defs.h\"" \ |
"A filename with ../ in the directory prefix" |
|
# A one-character filename |
gdb_test "print xfullpath (\"./a\")" \ |
".\[0-9\]+ =.*\".*/a\"" \ |
"A one-char filename in the current directory" |
|
# A file in the root directory |
gdb_test "print xfullpath (\"/root_file_which_should_exist\")" \ |
".\[0-9\]+ =.*\"/root_file_which_should_exist\"" \ |
"A filename in the root directory" |
|
# A file which does not have a directory prefix |
gdb_test "print xfullpath (\"xfullpath.exp\")" \ |
".\[0-9\]+ =.*\"xfullpath.exp\"" \ |
"A filename without any directory prefix" |
|
# A one-char filename without any directory prefix |
gdb_test "print xfullpath (\"a\")" \ |
".\[0-9\]+ =.*\"a\"" \ |
"A one-char filename without any directory prefix" |
|
# An empty filename |
gdb_test "print xfullpath (\"\")" \ |
".\[0-9\]+ =.*\"\"" \ |
"An empty filename" |
|
return 0 |
} |
|
# Find a pathname to a file that we would execute if the shell was asked |
# to run $arg using the current PATH. |
|
proc find_gdb { arg } { |
|
# If the arg directly specifies an existing executable file, then |
# simply use it. |
|
if [file executable $arg] then { |
return $arg |
} |
|
set result [which $arg] |
if [string match "/" [ string range $result 0 0 ]] then { |
return $result |
} |
|
# If everything fails, just return the unqualified pathname as default |
# and hope for best. |
|
return $arg |
} |
|
# Run the test with self. |
# Copy the file executable file in case this OS doesn't like to edit its own |
# text space. |
|
set GDB_FULLPATH [find_gdb $GDB] |
|
# Remove any old copy lying around. |
remote_file host delete x$tool |
|
gdb_start |
set file [remote_download host $GDB_FULLPATH x$tool] |
set result [test_with_self $file]; |
gdb_exit; |
catch "remote_file host delete $file"; |
|
if {$result <0} then { |
warning "Couldn't test self" |
return -1 |
} |
/complaints.exp
0,0 → 1,322
# Copyright 2002, 2004, 2007, 2008 Free Software Foundation, Inc. |
|
# This program is free software; you can redistribute it and/or modify |
# it under the terms of the GNU General Public License as published by |
# the Free Software Foundation; either version 3 of the License, or |
# (at your option) any later version. |
# |
# This program is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# GNU General Public License for more details. |
# |
# You should have received a copy of the GNU General Public License |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
# This file was written by Andrew Cagney (cagney at redhat dot com), |
# derived from xfullpath.exp (written by Joel Brobecker), derived from |
# selftest.exp (written by Rob Savoye). |
|
if $tracelevel then { |
strace $tracelevel |
} |
|
set prms_id 0 |
set bug_id 0 |
|
# are we on a target board |
if { [is_remote target] || ![isnative] } then { |
return |
} |
|
proc setup_test { executable } { |
global gdb_prompt |
global timeout |
|
# load yourself into the debugger |
# This can take a relatively long time, particularly for testing where |
# the executable is being accessed over a network, or where gdb does not |
# support partial symbols for a particular target and has to load the |
# entire symbol table. Set the timeout to 10 minutes, which should be |
# adequate for most environments (it *has* timed out with 5 min on a |
# SPARCstation SLC under moderate load, so this isn't unreasonable). |
# After gdb is started, set the timeout to 30 seconds for the duration |
# of this test, and then back to the original value. |
|
set oldtimeout $timeout |
set timeout 600 |
verbose "Timeout is now $timeout seconds" 2 |
|
global gdb_file_cmd_debug_info |
set gdb_file_cmd_debug_info "unset" |
|
set result [gdb_load $executable] |
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
|
if { $result != 0 } then { |
return -1 |
} |
|
if { $gdb_file_cmd_debug_info != "debug" } then { |
untested "No debug information, skipping testcase." |
return -1 |
} |
|
# Set a breakpoint at main |
gdb_test "break captured_command_loop" \ |
"Breakpoint.*at.* file.*, line.*" \ |
"breakpoint in captured_command_loop" |
|
# run yourself |
# It may take a very long time for the inferior gdb to start (lynx), |
# so we bump it back up for the duration of this command. |
set timeout 600 |
|
set description "run until breakpoint at captured_command_loop" |
send_gdb "run -nw\n" |
gdb_expect { |
-re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.* at .*main.c:.*$gdb_prompt $" { |
pass "$description" |
} |
-re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.*$gdb_prompt $" { |
xfail "$description (line numbers scrambled?)" |
} |
-re "vfork: No more processes.*$gdb_prompt $" { |
fail "$description (out of virtual memory)" |
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
return -1 |
} |
-re ".*$gdb_prompt $" { |
fail "$description" |
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
return -1 |
} |
timeout { |
fail "$description (timeout)" |
} |
} |
|
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
|
return 0 |
} |
|
proc test_initial_complaints { } { |
|
global gdb_prompt |
|
# Unsupress complaints |
gdb_test "set stop_whining = 2" |
|
# Prime the system |
gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \ |
"During symbol reading, Register a complaint." |
|
# Check that the complaint was inserted and where |
gdb_test "print symfile_complaints->root->fmt" \ |
".\[0-9\]+ =.*\"Register a complaint\"" |
|
# Re-issue the first message #1 |
gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \ |
"During symbol reading, Register a complaint." |
|
# Check that there is only one thing in the list |
gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \ |
".\[0-9\]+ = 1" "list has one entry" |
|
# Add a second complaint, expect it |
gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \ |
"During symbol reading, Testing. Testing. Testing.." |
|
return 0 |
} |
|
proc test_serial_complaints { } { |
|
global gdb_prompt |
|
gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start" |
|
# Prime the system |
send_gdb "call complaint (&symfile_complaints, \"serial line 1\")\n" |
gdb_expect { |
-re "During symbol reading...serial line 1...$gdb_prompt " { |
pass "serial line 1" |
} |
"$gdb_prompt" { |
fail "serial line 1" |
} |
timeout { |
fail "serial line 1 (timeout)" |
} |
} |
|
# Add a second complaint, expect it |
send_gdb "call complaint (&symfile_complaints, \"serial line 2\")\n" |
gdb_expect { |
-re "serial line 2...$gdb_prompt " { |
pass "serial line 2" |
} |
"$gdb_prompt" { |
fail "serial line 2" |
} |
timeout { |
fail "serial line 2 (timeout)" |
} |
} |
|
send_gdb "call clear_complaints (&symfile_complaints, 1, 0)\n" |
gdb_expect { |
-re "\r\n\r\n$gdb_prompt " { |
pass "serial end" |
} |
"$gdb_prompt" { |
fail "serial end" |
} |
timeout { |
fail "serial end (timeout)" |
} |
} |
|
return 0 |
} |
|
# For short complaints, all are the same |
|
proc test_short_complaints { } { |
|
global gdb_prompt |
|
gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start" |
|
# Prime the system |
send_gdb "call complaint (&symfile_complaints, \"short line 1\")\n" |
gdb_expect { |
-re "short line 1...$gdb_prompt " { |
pass "short line 1" |
} |
"$gdb_prompt" { |
fail "short line 1" |
} |
timeout { |
fail "short line 1 (timeout)" |
} |
} |
|
# Add a second complaint, expect it |
send_gdb "call complaint (&symfile_complaints, \"short line 2\")\n" |
gdb_expect { |
-re "short line 2...$gdb_prompt " { |
pass "short line 2" |
} |
"$gdb_prompt" { |
fail "short line 2" |
} |
timeout { |
fail "short line 2 (timeout)" |
} |
} |
|
send_gdb "call clear_complaints (&symfile_complaints, 1, 0)\n" |
gdb_expect { |
-re "\r\n\r\n$gdb_prompt " { |
pass "short end" |
} |
"$gdb_prompt" { |
fail "short end" |
} |
timeout { |
fail "short end (timeout)" |
} |
} |
|
return 0 |
} |
|
# Check that nothing comes out when there haven't been any real |
# complaints. Note that each test is really checking the previous |
# command. |
|
proc test_empty_complaint { cmd msg } { |
global gdb_prompt |
send_gdb $cmd |
gdb_expect { |
-re "\r\n\r\n$gdb_prompt " { |
fail $msg |
} |
"\r\n$gdb_prompt" { |
pass $msg |
} |
timeout { |
fail "$msg (timeout)" |
} |
} |
|
} |
|
proc test_empty_complaints { } { |
|
test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)\n" \ |
"empty non-verbose non-noisy clear" |
test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)\n" \ |
"empty verbose non-noisy clear" |
test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)\n" \ |
"empty verbose noisy clear" |
test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)\n" \ |
"empty non-verbose noisy clear" |
|
return 0 |
} |
|
# Find a pathname to a file that we would execute if the shell was asked |
# to run $arg using the current PATH. |
|
proc find_gdb { arg } { |
|
# If the arg directly specifies an existing executable file, then |
# simply use it. |
|
if [file executable $arg] then { |
return $arg |
} |
|
set result [which $arg] |
if [string match "/" [ string range $result 0 0 ]] then { |
return $result |
} |
|
# If everything fails, just return the unqualified pathname as default |
# and hope for best. |
|
return $arg |
} |
|
# Run the test with self. |
# Copy the file executable file in case this OS doesn't like to edit its own |
# text space. |
|
set GDB_FULLPATH [find_gdb $GDB] |
|
# Remove any old copy lying around. |
remote_file host delete x$tool |
|
gdb_start |
|
set file [remote_download host $GDB_FULLPATH x$tool] |
|
set setup_result [setup_test $file ] |
if {$setup_result <0} then { |
return -1 |
} |
|
test_initial_complaints |
test_serial_complaints |
test_short_complaints |
test_empty_complaints |
|
gdb_exit; |
catch "remote_file host delete $file"; |
/selftest.exp
0,0 → 1,558
# Copyright 1988, 1990, 1991, 1992, 1994, 1997, 1999, 2000, 2002, 2003, 2004, |
# 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
|
# This program is free software; you can redistribute it and/or modify |
# it under the terms of the GNU General Public License as published by |
# the Free Software Foundation; either version 3 of the License, or |
# (at your option) any later version. |
# |
# This program is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# GNU General Public License for more details. |
# |
# You should have received a copy of the GNU General Public License |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
# This file was written by Rob Savoye. (rob@cygnus.com) |
|
if $tracelevel then { |
strace $tracelevel |
} |
|
set prms_id 0 |
set bug_id 0 |
|
# are we on a target board |
if { [is_remote target] || ![isnative] } then { |
return |
} |
|
# Not all of the lines of code near the start of main are executed for |
# every machine. Also, optimization may reorder some of the lines. |
# So all we do is try to step or next over everything until we get |
# to a line that we know is always executed. |
|
proc do_steps_and_nexts {} { |
global gdb_prompt |
global srcdir |
|
gdb_reinitialize_dir $srcdir/.. |
|
set unlikely_line 0 |
for {set count 0} {$count < 32} {incr count} { |
send_gdb "list\n" |
# NOTE: carlton/2002-12-11: The "initial brace" and |
# "current_directory initialization" possibilities happen to |
# me with GCC 3.1 on i686-pc-linux-gnu when I compile with |
# optimization. |
gdb_expect { |
-re ".*context = data.*$gdb_prompt $" { |
set description "step over context initialization" |
set command "step" |
} |
-re ".*argc = context->argc.*$gdb_prompt $" { |
set description "step over argc initialization" |
set command "step" |
} |
-re ".*argv = context->argv.*$gdb_prompt $" { |
set description "step over argv initialization" |
set command "step" |
} |
-re ".*quiet = 0.*$gdb_prompt $" { |
set description "step over quiet initialization" |
set command "step" |
} |
-re ".*batch = 0.*$gdb_prompt $" { |
set description "step over batch initialization" |
set command "step" |
} |
-re ".*symarg = NULL.*$gdb_prompt $" { |
set description "step over symarg initialization" |
set command "step" |
} |
-re ".*execarg = NULL.*$gdb_prompt $" { |
set description "step over execarg initialization" |
set command "step" |
} |
-re ".*pidarg = NULL.*$gdb_prompt $" { |
set description "step over pidarg initialization" |
set command "step" |
} |
-re ".*corearg = NULL.*$gdb_prompt $" { |
set description "step over corearg initialization" |
set command "step" |
} |
-re ".*pid_or_core_arg = NULL.*$gdb_prompt $" { |
set description "step over pid_or_core_arg initialization" |
set command "step" |
} |
-re ".*cdarg = NULL.*$gdb_prompt $" { |
set description "step over cdarg initialization" |
set command "step" |
} |
-re ".*ttyarg = NULL.*$gdb_prompt $" { |
set description "step over ttyarg initialization" |
set command "step" |
} |
-re ".*time_at_startup = get_run_time.*$gdb_prompt $" { |
set description "next over get_run_time and everything it calls" |
set command "next" |
} |
-re ".*START_PROGRESS.*$gdb_prompt $" { |
# Note: ezannoni/2004/02/17: This check should be |
# removed, since as of today that source line is not |
# in gdb anymore. |
set description "next over START_PROGRESS and everything it calls" |
set command "next" |
} |
-re ".*mac_init.*$gdb_prompt $" { |
set description "next over mac_init and everything it calls" |
set command "next" |
} |
-re ".*init_malloc.*$gdb_prompt $" { |
# gdb 6.2.X is the last gdb which called init_malloc |
set description "next over init_malloc and everything it calls" |
set command "next" |
} |
-re ".*lim_at_start.*$gdb_prompt $" { |
set description "next over lim_at_start initialization" |
set command "next" |
} |
-re ".*count . 0x3.*$gdb_prompt $" { |
set description "next over conditional stack alignment code 1" |
set command "next" |
} |
-re ".*if .i != 0.*$gdb_prompt $" { |
set description "next over conditional stack alignment code 2" |
set command "next" |
} |
-re ".*alloca .i - 4.*$gdb_prompt $" { |
set description "next over conditional stack alignment alloca" |
set command "next" |
} |
-re ".*cmdsize = 1.*$gdb_prompt $" { |
set description "step over cmdsize initialization" |
set command "next" |
} |
-re ".*cmdarg = .* xmalloc.*$gdb_prompt $" { |
set description "next over cmdarg initialization via xmalloc" |
set command "next" |
} |
-re ".*ncmd = 0.*$gdb_prompt $" { |
set description "next over ncmd initialization" |
set command "next" |
} |
-re ".*dirsize = 1.*$gdb_prompt $" { |
set description "next over dirsize initialization" |
set command "next" |
} |
-re ".*dirarg = .* xmalloc.*$gdb_prompt $" { |
return |
} |
-re ".*setlocale .LC_MESSAGES,.*$gdb_prompt $" { |
set description "next over setlocale LC_MESSAGES" |
set command "next" |
} |
-re ".*setlocale .LC_CTYPE,.*$gdb_prompt $" { |
set description "next over setlocale LC_CTYPE" |
set command "next" |
} |
-re ".*bindtextdomain .PACKAGE, LOCALEDIR.;.*$gdb_prompt $" { |
set description "next over bindtextdomain" |
set command "next" |
} |
-re ".*textdomain .PACKAGE.;.*$gdb_prompt $" { |
set description "next over textdomain PACKAGE" |
set command "next" |
} |
-re "\[0-9\]+\[\t \]+\{\r\n$gdb_prompt $" { |
set description "step over initial brace" |
set command "step" |
} |
-re ".*current_directory = gdb_dirbuf.*$gdb_prompt $" { |
set description "step over current_directory initialization" |
set command "step" |
} |
-re ".*gdb_sysroot = .*$gdb_prompt $" { |
# NOTE: carlton/2003-01-15: More optimization reordering, |
# observed on GCC 3.1. |
set description "step over gdb_sysroot initialization" |
set command "step" |
} |
-re ".*ndir = 0.*$gdb_prompt $" { |
set description "step over ndir initialization" |
set command "step" |
} |
-re ".*instream = stdin.*$gdb_prompt $" { |
set description "step over instream initialization" |
set command "step" |
} |
-re ".*getcwd .gdb_dirbuf, sizeof .gdb_dirbuf..;.*$gdb_prompt $" { |
set description "next over getcwd" |
set command "next" |
} |
-re ".*quit_flag = 0.*$gdb_prompt $" { |
set description "step over quit_flag initialization" |
set command "step" |
} |
-re ".*gdb_stdout = stdio_fileopen .stdout.;.*$gdb_prompt $" { |
set description "step over gdb_stdout initialization" |
set command "step" |
} |
-re ".*gdb_stderr = stdio_fileopen .stderr.;.*$gdb_prompt $" { |
set description "step over gdb_stderr initialization" |
set command "step" |
} |
-re ".*main.c.*No such file or directory.*$gdb_prompt $" { |
setup_xfail "rs6000-*-aix3*" |
fail "must be able to list source lines" |
return |
} |
-re ".*interpreter_p = xstrdup.*$gdb_prompt $" { |
if { $unlikely_line == 0 } { |
# This is a GCC optimization bug; a constant has been |
# associated with the wrong line number. |
setup_xfail "*-*-*" gcc/26475 |
fail "$description (unlikely line from gcc)" |
set unlikely_line 1 |
} |
set description "next over xstrdup" |
set command "next" |
} |
-re ".*$gdb_prompt $" { |
fail "unknown source line after $description" |
return |
} |
default { |
fail "unknown source line near main" |
return |
} |
} |
send_gdb "$command\n" |
gdb_expect { |
-re ".*No such file or directory.\r\n$gdb_prompt $" { |
fail "$description (no source available)" |
} |
-re ".*A file or directory .* does not exist..\r\n$gdb_prompt $" { |
fail "$description (no source available)" |
} |
-re ".*$gdb_prompt $" { |
pass "$description" |
} |
timeout { |
fail "$description (timeout)" |
} |
} |
} |
} |
|
proc test_with_self { executable } { |
global gdb_prompt |
global tool |
global det_file |
global decimal |
global timeout |
|
# load yourself into the debugger |
# This can take a relatively long time, particularly for testing where |
# the executable is being accessed over a network, or where gdb does not |
# support partial symbols for a particular target and has to load the |
# entire symbol table. Set the timeout to 10 minutes, which should be |
# adequate for most environments (it *has* timed out with 5 min on a |
# SPARCstation SLC under moderate load, so this isn't unreasonable). |
# After gdb is started, set the timeout to 30 seconds for the duration |
# of this test, and then back to the original value. |
|
set oldtimeout $timeout |
set timeout 600 |
verbose "Timeout is now $timeout seconds" 2 |
|
global gdb_file_cmd_debug_info |
set gdb_file_cmd_debug_info "unset" |
|
set result [gdb_load $executable] |
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
|
if { $result != 0 } then { |
return -1 |
} |
|
if { $gdb_file_cmd_debug_info != "debug" } then { |
untested "No debug information, skipping testcase." |
return -1 |
} |
|
# disassemble yourself |
gdb_test "x/10i main" \ |
"x/10i.*main.*main.$decimal.*main.$decimal.*" \ |
"Disassemble main" |
|
# Set a breakpoint at main |
gdb_test "break captured_main" \ |
"Breakpoint.*at.* file.*, line.*" \ |
"breakpoint in captured_main" |
|
# We'll need this when we send a ^C to GDB. Need to do it before we |
# run the program and gdb starts saving and restoring tty states. |
# On Ultrix, we don't need it and it is really slow (because shell_escape |
# doesn't use vfork). |
if ![istarget "*-*-ultrix*"] then { |
gdb_test "shell stty intr '^C'" "" \ |
"set interrupt character in test_with_self" |
} |
|
# FIXME: If we put this after the run to main, the first list |
# command doesn't print the same line as the current line where |
# gdb is stopped. |
gdb_test "set listsize 1" "" "set listsize to 1" |
|
# run yourself |
# It may take a very long time for the inferior gdb to start (lynx), |
# so we bump it back up for the duration of this command. |
set timeout 600 |
|
set description "run until breakpoint at captured_main" |
send_gdb "run -nw\n" |
gdb_expect { |
-re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" { |
pass "$description" |
} |
-re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.*$gdb_prompt $" { |
xfail "$description (line numbers scrambled?)" |
} |
-re "vfork: No more processes.*$gdb_prompt $" { |
fail "$description (out of virtual memory)" |
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
return -1 |
} |
-re ".*$gdb_prompt $" { |
fail "$description" |
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
return -1 |
} |
timeout { |
fail "$description (timeout)" |
} |
} |
|
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
|
# do we have a version number ? |
send_gdb "print version\n" |
gdb_expect { |
-re ".\[0-9\]+ = .\[0-9.\]+.*$gdb_prompt $" { |
pass "printed version as string" |
} |
-re ".\[0-9\]+ = +0x.*\[0-9.\]+.*$gdb_prompt $" { |
pass "printed version as pointer" |
} |
-re ".\[0-9\]+ = +.+ +0x.*\[0-9.\]+.*$gdb_prompt $" { |
pass "printed version with cast" |
} |
-re ".*$gdb_prompt $" { fail "printed version" } |
timeout { fail "(timeout) printed version" } |
} |
|
do_steps_and_nexts |
|
gdb_test "print \"foo\"" ".\[0-9\]+ = \"foo\"" "print a string" |
|
# do_steps_and_nexts left us ready to execute an xmalloc call, |
# so give that a try. |
# If we don't actually enter the xmalloc call when we give a |
# step command that seems like a genuine bug. It seems to happen |
# on most RISC processors. |
# NOTE drow/2003-06-22: However, if we step back to the preceding two |
# lines, just keep stepping until we enter. |
set stepped_back 0 |
setup_xfail "alpha-*-*" "mips-*-*" |
set description "step into xmalloc call" |
send_gdb "step\n" |
gdb_expect { |
-re "ncmd = 0;.*$gdb_prompt $" { |
set stepped_back 1 |
send_gdb "step\n" |
exp_continue |
} |
-re ".*cmdarg = .* xmalloc.*$gdb_prompt $" { |
set stepped_back 1 |
send_gdb "step\n" |
exp_continue |
} |
-re "dirsize = 1;.*$gdb_prompt $" { |
set stepped_back 1 |
send_gdb "step\n" |
exp_continue |
} |
-re ".*dirarg = .* xmalloc.*$gdb_prompt $" { |
if { $stepped_back == 1 } { |
send_gdb "step\n" |
exp_continue |
} else { |
fail "$description" |
} |
} |
-re "xmalloc.*size=.*at.*utils.c.*$gdb_prompt $" { |
pass "$description" |
} |
-re ".*No such file or directory.\r\n$gdb_prompt $" { |
pass "$description (no source available)" |
} |
-re "A file or directory .* does not exist..\r\n$gdb_prompt $" { |
pass "$description (no source available)" |
} |
-re ".*$gdb_prompt $" { |
fail "$description" |
} |
timeout { |
fail "$description (timeout)" |
} |
} |
|
# start the "xgdb" process |
send_gdb "continue\n" |
gdb_expect { |
-re "GNU gdb \[0-9\.\]*.* |
Copyright \\(C\\) \[0-9\]* Free Software Foundation, Inc.* |
License GPLv3\\+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.* |
This is free software: you are free to change and redistribute it.* |
There is NO WARRANTY, to the extent permitted by law. Type \"show copying\".* |
and \"show warranty\" for details.* |
This GDB was configured as .*$gdb_prompt $"\ |
{ pass "xgdb is at prompt" } |
-re "GNU gdb \[0-9\.\]*.* |
Copyright \\(C\\) \[0-9\]* Free Software Foundation, Inc.* |
GDB is free software, covered by the GNU General Public License, and you are.* |
welcome to change it and/or distribute copies of it under certain conditions.* |
Type \"show copying\" to see the conditions.* |
There is absolutely no warranty for GDB. Type \"show warranty\" for details.* |
This GDB was configured as .*$gdb_prompt $"\ |
{ pass "xgdb is at prompt (obsolescent gdb 2)" } |
-re "GDB is free software and you are welcome to distribute copies of it.* |
under certain conditions; type \"show copying\" to see the conditions..* |
There is absolutely no warranty for GDB; type \"show warranty\" for details..* |
GDB.*Copyright \[0-9\]+ Free Software Foundation, Inc..*$gdb_prompt $"\ |
{ pass "xgdb is at prompt (obsolescent gdb 1)" } |
-re ".*$gdb_prompt $" { fail "xgdb is at prompt" } |
timeout { fail "(timeout) xgdb is at prompt" } |
} |
|
# set xgdb prompt so we can tell which is which |
send_gdb "set prompt (xgdb) \n" |
gdb_expect { |
-re "\[(\]xgdb\[)\].*\[(\]xgdb\[)\] $" { pass "Set xgdb prompt" } |
-re ".*$gdb_prompt $" { fail "Set xgdb prompt" } |
default { fail "(timeout) Set xgdb prompt" } |
} |
|
# kill the xgdb process |
set description "send ^C to child process" |
send_gdb "\003" |
gdb_expect { |
-re "Program received signal SIGINT.*$gdb_prompt $" { |
pass "$description" |
} |
-re ".*$gdb_prompt $" { |
fail "$description" |
} |
timeout { |
fail "$description (timeout)" |
} |
} |
|
set description "send SIGINT signal to child process" |
send_gdb "signal SIGINT\n" |
gdb_expect { |
-re "Continuing with signal SIGINT.*$gdb_prompt $" { |
pass "$description" |
} |
-re ".*$gdb_prompt $" { |
fail "$description" |
} |
timeout { |
fail "$description (timeout)" |
} |
} |
|
# get a stack trace |
# |
# This fails on some linux systems for unknown reasons. On the |
# systems where it fails, sometimes it works fine when run manually. |
# The testsuite failures may not be limited to just aout systems. |
setup_xfail "i*86-pc-linuxaout-gnu" |
set description "backtrace through signal handler" |
send_gdb "backtrace\n" |
gdb_expect { |
-re "#0.*(read|poll).*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" { |
pass "$description" |
} |
-re ".*$gdb_prompt $" { |
# On the alpha, we hit the infamous problem about gdb |
# being unable to get the frame pointer (mentioned in |
# gdb/README). As it is intermittent, there is no way to |
# XFAIL it which will give us an XPASS if the problem goes |
# away. |
setup_xfail "alpha*-*-osf*" |
fail "$description" |
} |
timeout { |
fail "$description (timeout)" |
} |
} |
|
|
# Set the timeout back to the value it had when we were called. |
set timeout $oldtimeout |
verbose "Timeout is now $timeout seconds" 2 |
|
# Restart gdb in case next test expects it to be started already. |
return 0 |
} |
|
# Find a pathname to a file that we would execute if the shell was asked |
# to run $arg using the current PATH. |
|
proc find_gdb { arg } { |
|
# If the arg directly specifies an existing executable file, then |
# simply use it. |
|
if [file executable $arg] then { |
return $arg |
} |
|
set result [which $arg] |
if [string match "/" [ string range $result 0 0 ]] then { |
return $result |
} |
|
# If everything fails, just return the unqualified pathname as default |
# and hope for best. |
|
return $arg |
} |
|
# Run the test with self. |
# Copy the file executable file in case this OS doesn't like to edit its own |
# text space. |
|
set GDB_FULLPATH [find_gdb $GDB] |
|
# Remove any old copy lying around. |
remote_file host delete x$tool |
|
gdb_start |
set file [remote_download host $GDB_FULLPATH x$tool] |
set result [test_with_self $file]; |
gdb_exit; |
catch "remote_file host delete $file"; |
|
if {$result <0} then { |
warning "Couldn't test self" |
return -1 |
} |