-# Copyright 1988, 1990, 1991, 1992, 1994, 1997, 1999, 2000, 2002,
-# 2003, 2004 Free Software Foundation, Inc.
+# Copyright 1988, 1990-1992, 1994, 1997, 1999-2000, 2002-2012 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 2 of the License, or
+# 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, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
+# 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] {
+if { [is_remote target] || ![isnative] } then {
return
}
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 {
+ gdb_test_multiple "list" "list" {
-re ".*context = data.*$gdb_prompt $" {
set description "step over context initialization"
set command "step"
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"
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"
+ -re ".*cmdarg_vec = NULL.*$gdb_prompt $" {
+ set description "step over cmdarg_vec initialization"
+ set command "step"
+ }
+ -re ".*pre_stat_chain = make_command_stats_cleanup.*$gdb_prompt $" {
+ set description "next over make_command_stats_cleanup and everything it calls"
set command "next"
}
-re ".*START_PROGRESS.*$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"
set description "next over textdomain PACKAGE"
set command "next"
}
- -re "\[0-9\]*\t\{\r\n$gdb_prompt $" {
+ -re ".*VEC_cleanup .cmdarg_s.*$gdb_prompt $" {
+ set description "next over cmdarg_s VEC_cleanup"
+ set command "next"
+ }
+ -re "\[0-9\]+\[\t \]+\{\r\n$gdb_prompt $" {
set description "step over initial brace"
set command "step"
}
set description "step over instream initialization"
set command "step"
}
- -re ".*getcwd .gdb_dirbuf, sizeof .gdb_dirbuf..;.*$gdb_prompt $" {
+ -re ".*getcwd .gdb_dirbuf, sizeof .gdb_dirbuf.*$gdb_prompt $" {
set description "next over getcwd"
set command "next"
}
- -re "\[ \t\]+\{\r\n$gdb_prompt $" {
- setup_xfail "mips-*-irix5*"
- fail "$description ended up at odd location"
+ -re ".*gdb_program_name = xstrdup.*$gdb_prompt $" {
+ set description "next over xstrdup"
+ 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
return
}
}
- send_gdb "$command\n"
- gdb_expect {
+ gdb_test_multiple "$command" "$description" {
-re ".*No such file or directory.\r\n$gdb_prompt $" {
fail "$description (no source available)"
}
-re ".*$gdb_prompt $" {
pass "$description"
}
- timeout {
- fail "$description (timeout)"
- }
}
}
}
set oldtimeout $timeout
set timeout 600
verbose "Timeout is now $timeout seconds" 2
- if {[gdb_load $executable] <0} then {
- set timeout $oldtimeout
- verbose "Timeout is now $timeout seconds" 2
- return -1
- }
+
+ 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.*" \
# 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'" "" \
+ 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"
+ gdb_test_no_output "set listsize 1" "set listsize to 1"
# run yourself
# It may take a very long time for the inferior gdb to start (lynx),
set timeout 600
set description "run until breakpoint at captured_main"
- send_gdb "run -nw\n"
- gdb_expect {
+ gdb_test_multiple "run -nw" "$description" {
-re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" {
pass "$description"
}
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 {
+ gdb_test_multiple "print version" "printed version" {
-re ".\[0-9\]+ = .\[0-9.\]+.*$gdb_prompt $" {
pass "printed version as string"
}
-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
set stepped_back 0
setup_xfail "alpha-*-*" "mips-*-*"
set description "step into xmalloc call"
- send_gdb "step\n"
- gdb_expect {
+ gdb_test_multiple "step" "$description" {
-re "ncmd = 0;.*$gdb_prompt $" {
set stepped_back 1
send_gdb "step\n"
-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 \[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" }
- -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)" }
- -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" }
+ if [target_info exists gdb,noinferiorio] {
+ # Maybe testing with a local extended-remote gdbserver. With
+ # no way to interact with inferior GDB, all we can do is let
+ # it run.
+ send_gdb "continue\n"
+ # Wait a bit while the inferior gdb gets to its prompt.
+ sleep 1
+ } else {
+ set test "xgdb is at prompt"
+ gdb_test_multiple "continue" $test {
+ -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 $test
+ }
+ }
+
+ # set xgdb prompt so we can tell which is which
+ gdb_test_multiple "set prompt (xgdb) " "Set xgdb_prompt" {
+ -re "\[(\]xgdb\[)\].*\[(\]xgdb\[)\] $" {
+ pass "Set xgdb prompt"
+ }
+ }
}
-
+
# kill the xgdb process
set description "send ^C to child process"
send_gdb "\003"
}
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)"
- }
- }
+ gdb_test "signal SIGINT" \
+ "Continuing with signal SIGINT.*" \
+ "$description"
# get a stack trace
#
# 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 {
+ gdb_test_multiple "backtrace" "$description" {
-re "#0.*(read|poll).*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" {
pass "$description"
}
setup_xfail "alpha*-*-osf*"
fail "$description"
}
- timeout {
- fail "$description (timeout)"
- }
}