xref: /netbsd-src/external/gpl3/gdb/dist/gdb/testsuite/gdb.python/py-completion.py (revision 53b02e147d4ed531c0d2a5ca9b3e8026ba3e99b5)
1# Copyright (C) 2014-2020 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# This testcase tests PR python/16699
17
18import gdb
19
20class CompleteFileInit(gdb.Command):
21	def __init__(self):
22		gdb.Command.__init__(self,'completefileinit',gdb.COMMAND_USER,gdb.COMPLETE_FILENAME)
23
24	def invoke(self,argument,from_tty):
25		raise gdb.GdbError('not implemented')
26
27class CompleteFileMethod(gdb.Command):
28	def __init__(self):
29		gdb.Command.__init__(self,'completefilemethod',gdb.COMMAND_USER)
30
31	def invoke(self,argument,from_tty):
32		raise gdb.GdbError('not implemented')
33
34	def complete(self,text,word):
35		return gdb.COMPLETE_FILENAME
36
37class CompleteFileCommandCond(gdb.Command):
38	def __init__(self):
39		gdb.Command.__init__(self,'completefilecommandcond',gdb.COMMAND_USER)
40
41	def invoke(self,argument,from_tty):
42		raise gdb.GdbError('not implemented')
43
44	def complete(self,text,word):
45		# This is a test made to know if the command
46		# completion still works fine.  When the user asks to
47		# complete something like "completefilecommandcond
48		# /path/to/py-completion-t", it should not complete to
49		# "/path/to/py-completion-test/", but instead just
50		# wait for input.
51		if "py-completion-t" in text:
52			return gdb.COMPLETE_COMMAND
53		else:
54			return gdb.COMPLETE_FILENAME
55
56class CompleteLimit1(gdb.Command):
57	def __init__(self):
58		gdb.Command.__init__(self,'completelimit1',gdb.COMMAND_USER)
59
60	def invoke(self,argument,from_tty):
61		raise gdb.GdbError('not implemented')
62
63	def complete(self,text,word):
64                return ["cl11", "cl12", "cl13"]
65
66class CompleteLimit2(gdb.Command):
67	def __init__(self):
68		gdb.Command.__init__(self,'completelimit2',
69                                     gdb.COMMAND_USER)
70
71	def invoke(self,argument,from_tty):
72		raise gdb.GdbError('not implemented')
73
74	def complete(self,text,word):
75		return ["cl21", "cl23", "cl25", "cl27", "cl29",
76                        "cl22", "cl24", "cl26", "cl28", "cl210"]
77
78class CompleteLimit3(gdb.Command):
79	def __init__(self):
80		gdb.Command.__init__(self,'completelimit3',
81                                     gdb.COMMAND_USER)
82
83	def invoke(self,argument,from_tty):
84		raise gdb.GdbError('not implemented')
85
86	def complete(self,text,word):
87		return ["cl31", "cl33", "cl35", "cl37", "cl39",
88                        "cl32", "cl34", "cl36", "cl38", "cl310"]
89
90class CompleteLimit4(gdb.Command):
91	def __init__(self):
92		gdb.Command.__init__(self,'completelimit4',
93                                     gdb.COMMAND_USER)
94
95	def invoke(self,argument,from_tty):
96		raise gdb.GdbError('not implemented')
97
98	def complete(self,text,word):
99		return ["cl41", "cl43", "cl45", "cl47", "cl49",
100                        "cl42", "cl44", "cl46", "cl48", "cl410"]
101
102class CompleteLimit5(gdb.Command):
103	def __init__(self):
104		gdb.Command.__init__(self,'completelimit5',
105                                     gdb.COMMAND_USER)
106
107	def invoke(self,argument,from_tty):
108		raise gdb.GdbError('not implemented')
109
110	def complete(self,text,word):
111		return ["cl51", "cl53", "cl55", "cl57", "cl59",
112                        "cl52", "cl54", "cl56", "cl58", "cl510"]
113
114class CompleteLimit6(gdb.Command):
115	def __init__(self):
116		gdb.Command.__init__(self,'completelimit6',
117                                     gdb.COMMAND_USER)
118
119	def invoke(self,argument,from_tty):
120		raise gdb.GdbError('not implemented')
121
122	def complete(self,text,word):
123		return ["cl61", "cl63", "cl65", "cl67", "cl69",
124                        "cl62", "cl64", "cl66", "cl68", "cl610"]
125
126class CompleteLimit7(gdb.Command):
127	def __init__(self):
128		gdb.Command.__init__(self,'completelimit7',
129                                     gdb.COMMAND_USER)
130
131	def invoke(self,argument,from_tty):
132		raise gdb.GdbError('not implemented')
133
134	def complete(self,text,word):
135		return ["cl71", "cl73", "cl75", "cl77", "cl79",
136                        "cl72", "cl74", "cl76", "cl78", "cl710"]
137
138CompleteFileInit()
139CompleteFileMethod()
140CompleteFileCommandCond()
141CompleteLimit1()
142CompleteLimit2()
143CompleteLimit3()
144CompleteLimit4()
145CompleteLimit5()
146CompleteLimit6()
147CompleteLimit7()
148