blob: 93bdcc9fc64d5312286462e8a0c922b46658ed70 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# Copyright 2015-2020 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Test keyword parsing in the linespec parser.
standard_testfile
set exefile $testfile
if {[prepare_for_testing "failed to prepare" $exefile $srcfile {debug}]} {
return -1
}
if ![runto_main] {
fail "can't run to main"
return 0
}
# Turn off pending breakpoints to facilitate testing errors.
gdb_test_no_output "set breakpoint pending off"
# The linespec lexer ignores the language setting when lexing
# keywords.
gdb_test "break if" "Function \"if\" not defined."
gdb_breakpoint "thread" "message"
gdb_breakpoint "task" "message"
# The lexer should prune any trailing whitesapce, so the expected
# outcome of the following tests should be the same as the previous
# tests.
with_test_prefix "trailing whitespace" {
gdb_test "break if " "Function \"if\" not defined."
gdb_breakpoint "thread " "message"
gdb_breakpoint "task " "message"
}
# With a single keyword specified first in the location,
# we assume we have a NULL location, i.e., the actual location
# of the event is the current default location.
#
# break if XX --> okay if XX is a valid expression
# (the lexer cannot know whether the expression is valid or not)
# break {thread,task} NUMBER --> invalid thread/task
# break {thread,task} STUFF --> "junk" after keyword (STUFF is not numeric)
gdb_test "break thread 123" "Unknown thread 123\\."
gdb_test "break thread foo" "Invalid thread ID: foo"
gdb_test "break task 123" "Unknown task 123\\."
gdb_test "break task foo" "Junk after task keyword\\."
gdb_breakpoint "thread if 0" "message"
# These are also NULL locations, but using a subsequent keyword
# as the "junk".
gdb_test "break thread thread" "Invalid thread ID: thread"
gdb_test "break thread task" "Invalid thread ID: task"
gdb_test "break thread if" "Invalid thread ID: if"
gdb_test "break task task" "Junk after task keyword\\."
gdb_test "break task thread" "Junk after task keyword\\."
gdb_test "break task if" "Junk after task keyword\\."
# Test locations containing keyword followed by keyword.
gdb_test "break thread thread 123" "Unknown thread 123\\."
gdb_test "break task task 123" "Unknown task 123\\."
# Test NULL location with valid conditional containing a keyword.
gdb_breakpoint "thread if thread == 0"
gdb_breakpoint "task if task == 0"
|