annota-input-while-running.exp revision 1.1
1# Copyright 1999-2015 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# Test that annotations support doesn't leave GDB's terminal settings 17# into effect when we run a foreground command. 18 19if [is_remote target] then { 20 # We cannot use runto_main because of the different prompt we get 21 # when using annotation level 2. 22 return 0 23} 24 25standard_testfile 26 27if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug] == -1} { 28 return -1 29} 30 31# Break at main 32 33gdb_test "break main" \ 34 "Breakpoint.*at.* file .*$srcfile.*\\." \ 35 "breakpoint main" 36 37# NOTE: this prompt is OK only when the annotation level is > 1 38# NOTE: When this prompt is in use the gdb_test procedure cannot be 39# used because it assumes that the last char after the gdb_prompt is a 40# white space. This is not true with this annotated prompt. So we 41# must use the gdb_annota_test replacement below, or 42# gdb_test_multiple. 43 44set old_gdb_prompt $gdb_prompt 45set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n" 46 47# Like gdb_test, but cope with the annotation prompt. 48proc gdb_annota_test {command pattern message} { 49 global gdb_prompt 50 51 gdb_test_multiple $command $message { 52 -re "$pattern$gdb_prompt$" { 53 pass "$message" 54 } 55 -re "$gdb_prompt$" { 56 fail "$message" 57 } 58 } 59} 60 61# Set the annotation level to 2. 62 63set test "annotation set at level 2" 64gdb_annota_test "set annotate 2" ".*" "annotation set at level 2" 65 66# Run to main. 67 68gdb_annota_test "run" \ 69 "\r\n\032\032post-prompt.*\r\n\r\n\032\032stopped.*" \ 70 "run until main breakpoint" 71 72set test "delete breakpoints" 73gdb_test_multiple "delete" $test { 74 -re "Delete all breakpoints. .y or n." { 75 send_gdb "y\n" 76 exp_continue 77 } 78 -re "$gdb_prompt$" { 79 pass $test 80 } 81} 82 83# Set the target running, and then type something. GDB used to have a 84# bug where it'd be accepting input even though the target was 85# supposedly resumed in the foreground. This ultimately resulted in 86# readline aborting. 87 88set linenum [gdb_get_line_number "set break here"] 89 90gdb_annota_test "break $linenum" \ 91 "Breakpoint .*$srcfile, line .*" \ 92 "break after sleep" 93 94# Continue, and wait a bit to make sure the inferior really starts 95# running. Wait less than much the program sleeps, which is 5 96# seconds, though. 97set saw_continuing 0 98set test "continue" 99gdb_test_multiple $test $test { 100 -timeout 2 101 -re "Continuing\\." { 102 set saw_continuing 1 103 exp_continue 104 } 105 timeout { 106 gdb_assert $saw_continuing $test 107 } 108} 109 110# Type something. 111send_gdb "print 1\n" 112 113# Poor buggy GDB would crash before the breakpoint was hit. 114set test "breakpoint hit" 115gdb_test_multiple "" $test { 116 -re "stopped\r\n$gdb_prompt" { 117 pass $test 118 } 119} 120 121set test "print command result" 122gdb_test_multiple "" $test { 123 -re "\r\n1\r\n\r\n\032\032value-history-end\r\n$gdb_prompt" { 124 pass $test 125 } 126} 127 128# Restore the original prompt for the rest of the testsuite. 129 130set gdb_prompt $old_gdb_prompt 131