1 # Copyright (C) 2011-2022 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Specialized subroutines for launching gdb and testing the very first prompt.
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,
24 # uses pass if it sees $gdb_prompt, and fail if it sees $gdb_prompt_fail.
26 proc default_prompt_gdb_start { } {
28 global INTERNAL_GDBFLAGS GDBFLAGS
30 global gdb_prompt_fail
34 verbose "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS"
36 if [info exists gdb_spawn_id] {
40 if ![is_remote host] {
41 if {[which $GDB] == 0} {
42 perror "$GDB does not exist."
46 set res [remote_spawn host "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS [host_info gdb_opts]"]
47 if { $res < 0 || $res == "" } {
48 perror "Spawning $GDB failed."
52 -re ".*$gdb_prompt_fail.*$gdb_prompt_fail.*" {
53 fail "double prompted fail prompt"
55 -re ".*$gdb_prompt.*$gdb_prompt.*" {
56 fail "double prompted"
58 -re "\[\r\n\]$gdb_prompt_fail $" {
59 fail "GDB initializing first prompt"
61 -re "\[\r\n\]$gdb_prompt $" {
62 pass "GDB initializing first prompt"
65 perror "GDB never initialized."
68 -re "$gdb_prompt_fail $" {
69 perror "GDB never initialized."
73 perror "(timeout) GDB never initialized after 10 seconds."
83 # Overridable function. You can override this function in your
86 proc prompt_gdb_start { } {
87 default_prompt_gdb_start