]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/lib/prompt.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / lib / prompt.exp
1 # Copyright (C) 2011-2013 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 # Specialized subroutines for launching gdb and testing the very first prompt.
17
18
19 #
20 # start gdb -- start gdb running, prompt procedure
21 # this procedure differs from the default in that you must pass 'set height 0',
22 # and 'set width 0', yourself in GDBFLAGS, and it has a gdb_prompt_fail variable,
23 #
24 # uses pass if it sees $gdb_prompt, and fail if it sees $gdb_prompt_fail.
25 #
26 proc default_prompt_gdb_start { } {
27 global verbose
28 global GDB
29 global INTERNAL_GDBFLAGS GDBFLAGS
30 global gdb_prompt
31 global gdb_prompt_fail
32 global timeout
33 global gdb_spawn_id;
34
35 gdb_stop_suppressing_tests;
36
37 verbose "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS"
38
39 if [info exists gdb_spawn_id] {
40 return 0;
41 }
42
43 if ![is_remote host] {
44 if { [which $GDB] == 0 } then {
45 perror "$GDB does not exist."
46 exit 1
47 }
48 }
49 set res [remote_spawn host "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS [host_info gdb_opts]"];
50 if { $res < 0 || $res == "" } {
51 perror "Spawning $GDB failed."
52 return 1;
53 }
54 gdb_expect 360 {
55 -re ".*$gdb_prompt_fail.*$gdb_prompt_fail.*" {
56 fail "double prompted fail prompt"
57 }
58 -re ".*$gdb_prompt.*$gdb_prompt.*" {
59 fail "double prompted"
60 }
61 -re "\[\r\n\]$gdb_prompt_fail $" {
62 fail "GDB initializing first prompt"
63 }
64 -re "\[\r\n\]$gdb_prompt $" {
65 pass "GDB initializing first prompt"
66 }
67 -re "$gdb_prompt $" {
68 perror "GDB never initialized."
69 return -1
70 }
71 -re "$gdb_prompt_fail $" {
72 perror "GDB never initialized."
73 return -1
74 }
75 timeout {
76 perror "(timeout) GDB never initialized after 10 seconds."
77 remote_close host;
78 return -1
79 }
80 }
81 set gdb_spawn_id -1;
82 return 0;
83 }
84
85 #
86 # Overridable function. You can override this function in your
87 # baseboard file.
88 #
89 proc prompt_gdb_start { } {
90 default_prompt_gdb_start
91 }
92