-# Copyright 1988, 1990, 1991, 1992, 1994, 1997, 1999, 2000, 2002, 2003, 2004,
-# 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+# Copyright 1988-2015 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
# This file was written by Rob Savoye. (rob@cygnus.com)
-if $tracelevel then {
- strace $tracelevel
-}
-
+load_lib selftest-support.exp
# are we on a target board
if { [is_remote target] || ![isnative] } then {
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 ".*bfd_init ..;.*$gdb_prompt $" {
+ set description "next over bfd_init"
+ set command "next"
+ }
+ -re ".*notice_open_fds ..;.*$gdb_prompt $" {
+ set description "next over notice_open_fds"
+ set command "next"
+ }
+ -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 ".*quit_flag = 0.*$gdb_prompt $" {
+ -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"
}
set command "next"
}
-re ".*$gdb_prompt $" {
- fail "unknown source line after $description"
+ # If $description hasn't been set yet, it's likely the file
+ # has been edited but gdb hasn't been recompiled.
+ if [info exists description] {
+ fail "unknown source line (after $description)"
+ } else {
+ fail "unknown source line"
+ }
return
}
default {
global det_file
global decimal
global timeout
+ global INTERNAL_GDBFLAGS
# load yourself into the debugger
# This can take a relatively long time, particularly for testing where
return -1
}
+ # When GDB is built as a C++ program, disassemble shows the full
+ # prototype.
+ set cxx_main_args_re [string_to_regexp "(int, char**)"]
+
# disassemble yourself
gdb_test "x/10i main" \
- "x/10i.*main.*main.$decimal.*main.$decimal.*" \
+ "x/10i.*main.*main($cxx_main_args_re)?.$decimal.*main($cxx_main_args_re)?.$decimal.*" \
"Disassemble main"
# Set a breakpoint at 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"
- }
+ 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
set timeout 600
set description "run until breakpoint at captured_main"
- gdb_test_multiple "run -nw" "$description" {
+ gdb_test_multiple "run $INTERNAL_GDBFLAGS" "$description" {
-re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" {
pass "$description"
}
}
# start the "xgdb" process
- gdb_test_multiple "continue" "xgdb is at prompt" {
- -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)"
+ 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"
+
+ # 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"
-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"
- }
}
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]
+if {[is_remote host]} {
+ set xgdb x$tool
+} else {
+ set xgdb [standard_output_file x$tool]
+}
+
# Remove any old copy lying around.
-remote_file host delete x$tool
+remote_file host delete $xgdb
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";
+set file [remote_download host $GDB_FULLPATH $xgdb]
+set result [test_with_self $file]
+gdb_exit
+catch "remote_file host delete $file"
if {$result <0} then {
warning "Couldn't test self"