]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.gdb/selftest.exp
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.gdb / selftest.exp
CommitLineData
e2882c85 1# Copyright 1988-2018 Free Software Foundation, Inc.
adf40b2e
JM
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
adf40b2e 6# (at your option) any later version.
e22f8b7c 7#
adf40b2e
JM
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
e22f8b7c 12#
adf40b2e 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
adf40b2e 15
adf40b2e
JM
16# This file was written by Rob Savoye. (rob@cygnus.com)
17
c95aea6b 18load_lib selftest-support.exp
adf40b2e 19
f25827c1 20proc test_with_self { } {
adf40b2e 21 global gdb_prompt
adf40b2e
JM
22 global decimal
23 global timeout
f25827c1 24 global inferior_spawn_id
3e3ffd2b 25
a37bfa30
PA
26 # When GDB is built as a C++ program, disassemble shows the full
27 # prototype.
28 set cxx_main_args_re [string_to_regexp "(int, char**)"]
29
adf40b2e
JM
30 # disassemble yourself
31 gdb_test "x/10i main" \
a37bfa30 32 "x/10i.*main.*main($cxx_main_args_re)?.$decimal.*main($cxx_main_args_re)?.$decimal.*" \
bb95117e 33 "disassemble main"
adf40b2e 34
adf40b2e
JM
35 # We'll need this when we send a ^C to GDB. Need to do it before we
36 # run the program and gdb starts saving and restoring tty states.
09dd9a69
PA
37 gdb_test "shell stty intr '^C'" ".*" \
38 "set interrupt character in test_with_self"
adf40b2e
JM
39
40 # FIXME: If we put this after the run to main, the first list
41 # command doesn't print the same line as the current line where
42 # gdb is stopped.
019ebafc 43 gdb_test_no_output "set listsize 1" "set listsize to 1"
adf40b2e 44
adf40b2e 45 # do we have a version number ?
a127f7b4 46 gdb_test_multiple "print version" "printed version" {
d4f3574e
SS
47 -re ".\[0-9\]+ = .\[0-9.\]+.*$gdb_prompt $" {
48 pass "printed version as string"
49 }
adf40b2e 50 -re ".\[0-9\]+ = +0x.*\[0-9.\]+.*$gdb_prompt $" {
d4f3574e 51 pass "printed version as pointer"
adf40b2e
JM
52 }
53 -re ".\[0-9\]+ = +.+ +0x.*\[0-9.\]+.*$gdb_prompt $" {
54 pass "printed version with cast"
55 }
adf40b2e
JM
56 }
57
adf40b2e 58 # start the "xgdb" process
c0b9f2c6 59 if [target_info exists gdb,noinferiorio] {
08280010
PA
60 # With no way to interact with the inferior GDB, all we can do
61 # is let it run.
c0b9f2c6
PA
62 send_gdb "continue\n"
63 # Wait a bit while the inferior gdb gets to its prompt.
64 sleep 1
65 } else {
66 set test "xgdb is at prompt"
67 gdb_test_multiple "continue" $test {
08280010 68 -i "$inferior_spawn_id"
c0b9f2c6
PA
69 -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 $" {
70 pass $test
71 }
a127f7b4 72 }
c0b9f2c6
PA
73
74 # set xgdb prompt so we can tell which is which
08280010
PA
75 send_inferior "set prompt (xgdb) \n"
76 set msg "Set xgdb_prompt"
77 gdb_test_multiple "" $msg {
78 -i "$inferior_spawn_id"
c0b9f2c6 79 -re "\[(\]xgdb\[)\].*\[(\]xgdb\[)\] $" {
08280010 80 pass $msg
c0b9f2c6 81 }
a127f7b4 82 }
adf40b2e 83 }
c0b9f2c6 84
adf40b2e 85 # kill the xgdb process
87a3a92c
SL
86 if ![target_info exists gdb,nointerrupts] {
87 set description "send ^C to child process"
88 send_gdb "\003"
31d765d3 89 # "Thread 1" is displayed iff Guile support is linked in.
87a3a92c 90 gdb_expect {
092127d7 91 -re "(Thread .*|Program) received signal SIGINT.*$gdb_prompt $" {
87a3a92c
SL
92 pass "$description"
93 }
94 -re ".*$gdb_prompt $" {
95 fail "$description"
96 }
97 timeout {
98 fail "$description (timeout)"
99 }
adf40b2e
JM
100 }
101 }
102
103 set description "send SIGINT signal to child process"
5836a818
PP
104 gdb_test "signal SIGINT" \
105 "Continuing with signal SIGINT.*" \
106 "$description"
31d765d3
JK
107
108 # Switch back to the GDB thread if Guile support is linked in.
109 # "signal SIGINT" could also switch the current thread.
110 gdb_test "thread 1" {\[Switching to thread 1 .*\].*}
adf40b2e
JM
111
112 # get a stack trace
113 #
114 # This fails on some linux systems for unknown reasons. On the
115 # systems where it fails, sometimes it works fine when run manually.
116 # The testsuite failures may not be limited to just aout systems.
634d57ec 117 setup_xfail "i*86-pc-linuxaout-gnu"
adf40b2e 118 set description "backtrace through signal handler"
a127f7b4 119 gdb_test_multiple "backtrace" "$description" {
92806416 120 -re "#0.*(read|poll).*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" {
adf40b2e
JM
121 pass "$description"
122 }
adf40b2e
JM
123 }
124
adf40b2e
JM
125 # Restart gdb in case next test expects it to be started already.
126 return 0
127}
128
f25827c1 129do_self_tests captured_main test_with_self