Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / lib / prompt.exp
CommitLineData
88b9d363 1# Copyright (C) 2011-2022 Free Software Foundation, Inc.
7d8e6458 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#
26proc default_prompt_gdb_start { } {
7d8e6458 27 global GDB
28 global INTERNAL_GDBFLAGS GDBFLAGS
29 global gdb_prompt
30 global gdb_prompt_fail
31 global timeout
4ec70201 32 global gdb_spawn_id
7d8e6458 33
7d8e6458 34 verbose "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS"
35
36 if [info exists gdb_spawn_id] {
ae59b1da 37 return 0
7d8e6458 38 }
39
40 if ![is_remote host] {
41 if { [which $GDB] == 0 } then {
42 perror "$GDB does not exist."
43 exit 1
44 }
45 }
4ec70201 46 set res [remote_spawn host "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS [host_info gdb_opts]"]
7d8e6458 47 if { $res < 0 || $res == "" } {
48 perror "Spawning $GDB failed."
ae59b1da 49 return 1
7d8e6458 50 }
51 gdb_expect 360 {
52 -re ".*$gdb_prompt_fail.*$gdb_prompt_fail.*" {
53 fail "double prompted fail prompt"
54 }
55 -re ".*$gdb_prompt.*$gdb_prompt.*" {
56 fail "double prompted"
57 }
58 -re "\[\r\n\]$gdb_prompt_fail $" {
59 fail "GDB initializing first prompt"
60 }
61 -re "\[\r\n\]$gdb_prompt $" {
62 pass "GDB initializing first prompt"
63 }
64 -re "$gdb_prompt $" {
65 perror "GDB never initialized."
66 return -1
67 }
68 -re "$gdb_prompt_fail $" {
69 perror "GDB never initialized."
70 return -1
71 }
72 timeout {
73 perror "(timeout) GDB never initialized after 10 seconds."
4ec70201 74 remote_close host
7d8e6458 75 return -1
76 }
77 }
717cf30c 78 set gdb_spawn_id $res
ae59b1da 79 return 0
7d8e6458 80}
81
82#
83# Overridable function. You can override this function in your
84# baseboard file.
85#
86proc prompt_gdb_start { } {
87 default_prompt_gdb_start
88}
89
This page took 1.226888 seconds and 4 git commands to generate.