keywords.exp revision 1.1.1.2
1# Copyright 2015-2016 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 keyword parsing in the linespec parser. 17 18standard_testfile 19set exefile $testfile 20 21if {[prepare_for_testing $testfile $exefile $srcfile {debug}]} { 22 return -1 23} 24 25if ![runto_main] { 26 fail "Can't run to main" 27 return 0 28} 29 30# Turn off pending breakpoints to facilitate testing errors. 31gdb_test_no_output "set breakpoint pending off" 32 33# The linespec lexer ignores the language setting when lexing 34# keywords. 35gdb_test "break if" "Function \"if\" not defined." 36gdb_breakpoint "thread" "message" 37gdb_breakpoint "task" "message" 38 39# The lexer should prune any trailing whitesapce, so the expected 40# outcome of the following tests should be the same as the previous 41# tests. 42with_test_prefix "trailing whitespace" { 43 gdb_test "break if " "Function \"if\" not defined." 44 gdb_breakpoint "thread " "message" 45 gdb_breakpoint "task " "message" 46} 47 48# With a single keyword specified first in the location, 49# we assume we have a NULL location, i.e., the actual location 50# of the event is the current default location. 51# 52# break if XX --> okay if XX is a valid expression 53# (the lexer cannot know whether the expression is valid or not) 54# break {thread,task} NUMBER --> invalid thread/task 55# break {thread,task} STUFF --> "junk" after keyword (STUFF is not numeric) 56gdb_test "break thread 123" "Unknown thread 123\\." 57gdb_test "break thread foo" "Invalid thread ID: foo" 58gdb_test "break task 123" "Unknown task 123\\." 59gdb_test "break task foo" "Junk after task keyword\\." 60gdb_breakpoint "thread if 0" "message" 61 62# These are also NULL locations, but using a subsequent keyword 63# as the "junk". 64gdb_test "break thread thread" "Invalid thread ID: thread" 65gdb_test "break thread task" "Invalid thread ID: task" 66gdb_test "break thread if" "Invalid thread ID: if" 67gdb_test "break task task" "Junk after task keyword\\." 68gdb_test "break task thread" "Junk after task keyword\\." 69gdb_test "break task if" "Junk after task keyword\\." 70 71# Test locations containing keyword followed by keyword. 72gdb_test "break thread thread 123" "Unknown thread 123\\." 73gdb_test "break task task 123" "Unknown task 123\\." 74 75# Test NULL location with valid conditional containing a keyword. 76gdb_breakpoint "thread if thread == 0" 77gdb_breakpoint "task if task == 0" 78