aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/py-completion.py
blob: abec06921c0e24fd5f6b17d3b82d58c81768a163 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# Copyright (C) 2014-2023 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/>.

# This testcase tests PR python/16699

import gdb


class CompleteFileInit(gdb.Command):
    def __init__(self):
        gdb.Command.__init__(
            self, "completefileinit", gdb.COMMAND_USER, gdb.COMPLETE_FILENAME
        )

    def invoke(self, argument, from_tty):
        raise gdb.GdbError("not implemented")


class CompleteFileMethod(gdb.Command):
    def __init__(self):
        gdb.Command.__init__(self, "completefilemethod", gdb.COMMAND_USER)

    def invoke(self, argument, from_tty):
        raise gdb.GdbError("not implemented")

    def complete(self, text, word):
        return gdb.COMPLETE_FILENAME


class CompleteFileCommandCond(gdb.Command):
    def __init__(self):
        gdb.Command.__init__(self, "completefilecommandcond", gdb.COMMAND_USER)

    def invoke(self, argument, from_tty):
        raise gdb.GdbError("not implemented")

    def complete(self, text, word):
        # This is a test made to know if the command
        # completion still works fine.  When the user asks to
        # complete something like "completefilecommandcond
        # /path/to/py-completion-t", it should not complete to
        # "/path/to/py-completion-test/", but instead just
        # wait for input.
        if "py-completion-t" in text:
            return gdb.COMPLETE_COMMAND
        else:
            return gdb.COMPLETE_FILENAME


class CompleteLimit1(gdb.Command):
    def __init__(self):
        gdb.Command.__init__(self, "completelimit1", gdb.COMMAND_USER)

    def invoke(self, argument, from_tty):
        raise gdb.GdbError("not implemented")

    def complete(self, text, word):
        return ["cl11", "cl12", "cl13"]


class CompleteLimit2(gdb.Command):
    def __init__(self):
        gdb.Command.__init__(self, "completelimit2", gdb.COMMAND_USER)

    def invoke(self, argument, from_tty):
        raise gdb.GdbError("not implemented")

    def complete(self, text, word):
        return [
            "cl21",
            "cl23",
            "cl25",
            "cl27",
            "cl29",
            "cl22",
            "cl24",
            "cl26",
            "cl28",
            "cl210",
        ]


class CompleteLimit3(gdb.Command):
    def __init__(self):
        gdb.Command.__init__(self, "completelimit3", gdb.COMMAND_USER)

    def invoke(self, argument, from_tty):
        raise gdb.GdbError("not implemented")

    def complete(self, text, word):
        return [
            "cl31",
            "cl33",
            "cl35",
            "cl37",
            "cl39",
            "cl32",
            "cl34",
            "cl36",
            "cl38",
            "cl310",
        ]


class CompleteLimit4(gdb.Command):
    def __init__(self):
        gdb.Command.__init__(self, "completelimit4", gdb.COMMAND_USER)

    def invoke(self, argument, from_tty):
        raise gdb.GdbError("not implemented")

    def complete(self, text, word):
        return [
            "cl41",
            "cl43",
            "cl45",
            "cl47",
            "cl49",
            "cl42",
            "cl44",
            "cl46",
            "cl48",
            "cl410",
        ]


class CompleteLimit5(gdb.Command):
    def __init__(self):
        gdb.Command.__init__(self, "completelimit5", gdb.COMMAND_USER)

    def invoke(self, argument, from_tty):
        raise gdb.GdbError("not implemented")

    def complete(self, text, word):
        return [
            "cl51",
            "cl53",
            "cl55",
            "cl57",
            "cl59",
            "cl52",
            "cl54",
            "cl56",
            "cl58",
            "cl510",
        ]


class CompleteLimit6(gdb.Command):
    def __init__(self):
        gdb.Command.__init__(self, "completelimit6", gdb.COMMAND_USER)

    def invoke(self, argument, from_tty):
        raise gdb.GdbError("not implemented")

    def complete(self, text, word):
        return [
            "cl61",
            "cl63",
            "cl65",
            "cl67",
            "cl69",
            "cl62",
            "cl64",
            "cl66",
            "cl68",
            "cl610",
        ]


class CompleteLimit7(gdb.Command):
    def __init__(self):
        gdb.Command.__init__(self, "completelimit7", gdb.COMMAND_USER)

    def invoke(self, argument, from_tty):
        raise gdb.GdbError("not implemented")

    def complete(self, text, word):
        return [
            "cl71",
            "cl73",
            "cl75",
            "cl77",
            "cl79",
            "cl72",
            "cl74",
            "cl76",
            "cl78",
            "cl710",
        ]


CompleteFileInit()
CompleteFileMethod()
CompleteFileCommandCond()
CompleteLimit1()
CompleteLimit2()
CompleteLimit3()
CompleteLimit4()
CompleteLimit5()
CompleteLimit6()
CompleteLimit7()