17"""GDB commands for working with frame-filters."""
26 """Prefix command for 'set' frame-filter related operations."""
29 super(SetFilterPrefixCmd, self).
__init__(
30 "set frame-filter", gdb.COMMAND_OBSCURE, gdb.COMPLETE_NONE,
True
35 """Prefix command for 'show' frame-filter related operations."""
38 super(ShowFilterPrefixCmd, self).
__init__(
39 "show frame-filter", gdb.COMMAND_OBSCURE, gdb.COMPLETE_NONE,
True
44 """List all registered Python frame-filters.
46 Usage: info frame-filters"""
49 super(InfoFrameFilter, self).
__init__(
"info frame-filter", gdb.COMMAND_DATA)
53 """Return "Yes" if filter is enabled, otherwise "No"."""
60 sorted_frame_filters = sorted(
61 frame_filters.items(),
66 if len(sorted_frame_filters) == 0:
70 print(
" Priority Enabled Name")
71 for frame_filter
in sorted_frame_filters:
72 name = frame_filter[0]
75 enabled =
"{:<7}".format(
78 print(
" %s %s %s" % (priority, enabled, name))
81 print(
" Error printing filter '" + name +
"': " + str(e))
91 "progspace %s frame-filters:" % cp.filename, cp.frame_filters,
True
96 "objfile %s frame-filters:" % objfile.filename,
97 objfile.frame_filters,
102 print(
"No frame filters.")
109 """Internal worker function to take an argument from
110 enable/disable and return a tuple of arguments.
113 cmd_name: Name of the command invoking this function.
114 args: The argument as a string.
117 A tuple containing the dictionary, and the argument, or just
118 the dictionary in the case of "all".
121 argv = gdb.string_to_argv(arg)
124 raise gdb.GdbError(cmd_name +
" requires an argument")
128 cmd_name +
": with 'all' " "you may not specify a filter."
131 raise gdb.GdbError(cmd_name +
" takes exactly two arguments.")
137 """Worker for enabling/disabling frame_filters.
140 command_type: A tuple with the first element being the
141 frame filter dictionary, and the second being
142 the frame filter name.
143 flag: True for Enable, False for Disable.
146 list_op = command_tuple[0]
153 frame_filter = command_tuple[1]
155 ff = op_list[frame_filter]
157 msg =
"frame-filter '" + str(frame_filter) +
"' not found."
158 raise gdb.GdbError(msg)
164 """Worker for frame filter dictionary name completion.
167 text: The full text of the command line.
168 word: The most recent word of the command line.
169 all_flag: Whether to include the word "all" in completion.
172 A list of suggested frame filter dictionary name completions
173 from text/word analysis. This list can be empty when there
174 are no suggestions for completion.
177 filter_locations = [
"all",
"global",
"progspace"]
179 filter_locations = [
"global",
"progspace"]
181 filter_locations.append(objfile.filename)
187 return filter_locations
190 flist = filter(
lambda x, y=text: x.startswith(y), filter_locations)
194 flist[0] = flist[0][len(text) - len(word) :]
202 """Worker for frame filter name completion.
206 word: The most recent word of the command line.
208 printer_dict: The frame filter dictionary to search for frame
209 filter name completions.
211 Returns: A list of suggested frame filter name completions
212 from word analysis of the frame filter dictionary. This list
213 can be empty when there are no suggestions for completion.
216 printer_keys = printer_dict.keys()
220 flist = filter(
lambda x, y=word: x.startswith(y), printer_keys)
225 """GDB command to enable the specified frame-filter.
227 Usage: enable frame-filter DICTIONARY [NAME]
229 DICTIONARY is the name of the frame filter dictionary on which to
230 operate. If dictionary is set to "all", perform operations on all
231 dictionaries. Named dictionaries are: "global" for the global
232 frame filter dictionary, "progspace" for the program space's frame
233 filter dictionary. If either all, or the two named dictionaries
234 are not specified, the dictionary name is assumed to be the name
235 of an "objfile" -- a shared library or an executable.
237 NAME matches the name of the frame-filter to operate on."""
240 super(EnableFrameFilter, self).
__init__(
"enable frame-filter", gdb.COMMAND_DATA)
243 """Completion function for both frame filter dictionary, and
244 frame filter name."""
245 if text.count(
" ") == 0:
257 """GDB command to disable the specified frame-filter.
259 Usage: disable frame-filter DICTIONARY [NAME]
261 DICTIONARY is the name of the frame filter dictionary on which to
262 operate. If dictionary is set to "all", perform operations on all
263 dictionaries. Named dictionaries are: "global" for the global
264 frame filter dictionary, "progspace" for the program space's frame
265 filter dictionary. If either all, or the two named dictionaries
266 are not specified, the dictionary name is assumed to be the name
267 of an "objfile" -- a shared library or an executable.
269 NAME matches the name of the frame-filter to operate on."""
272 super(DisableFrameFilter, self).
__init__(
273 "disable frame-filter", gdb.COMMAND_DATA
277 """Completion function for both frame filter dictionary, and
278 frame filter name."""
279 if text.count(
" ") == 0:
291 """GDB command to set the priority of the specified frame-filter.
293 Usage: set frame-filter priority DICTIONARY NAME PRIORITY
295 DICTIONARY is the name of the frame filter dictionary on which to
296 operate. Named dictionaries are: "global" for the global frame
297 filter dictionary, "progspace" for the program space's framefilter
298 dictionary. If either of these two are not specified, the
299 dictionary name is assumed to be the name of an "objfile" -- a
300 shared library or an executable.
302 NAME matches the name of the frame filter to operate on.
304 PRIORITY is the an integer to assign the new priority to the frame
308 super(SetFrameFilterPriority, self).
__init__(
309 "set frame-filter " "priority", gdb.COMMAND_DATA
313 """Internal worker to parse a priority from a tuple.
316 arg: Tuple which contains the arguments from the command.
319 A tuple containing the dictionary, name and priority from
323 gdb.GdbError: An error parsing the arguments.
326 argv = gdb.string_to_argv(arg)
329 print(
"set frame-filter priority " "takes exactly three arguments.")
335 """Internal worker for setting priority of frame-filters, by
336 parsing a tuple and calling _set_priority with the parsed
340 command_tuple: Tuple which contains the arguments from the
344 list_op = command_tuple[0]
345 frame_filter = command_tuple[1]
349 priority = int(command_tuple[2])
354 ff = op_list[frame_filter]
356 msg =
"frame-filter '" + str(frame_filter) +
"' not found."
357 raise gdb.GdbError(msg)
362 """Completion function for both frame filter dictionary, and
363 frame filter name."""
364 if text.count(
" ") == 0:
372 if command_tuple
is not None:
377 """GDB command to show the priority of the specified frame-filter.
379 Usage: show frame-filter priority DICTIONARY NAME
381 DICTIONARY is the name of the frame filter dictionary on which to
382 operate. Named dictionaries are: "global" for the global frame
383 filter dictionary, "progspace" for the program space's framefilter
384 dictionary. If either of these two are not specified, the
385 dictionary name is assumed to be the name of an "objfile" -- a
386 shared library or an executable.
388 NAME matches the name of the frame-filter to operate on."""
391 super(ShowFrameFilterPriority, self).
__init__(
392 "show frame-filter " "priority", gdb.COMMAND_DATA
396 """Internal worker to parse a dictionary and name from a
400 arg: Tuple which contains the arguments from the command.
403 A tuple containing the dictionary, and frame filter name.
406 gdb.GdbError: An error parsing the arguments.
409 argv = gdb.string_to_argv(arg)
412 print(
"show frame-filter priority " "takes exactly two arguments.")
418 """Worker for retrieving the priority of frame_filters.
421 frame_filters: Name of frame filter dictionary.
422 name: object to select printers.
425 The priority of the frame filter.
428 gdb.GdbError: A frame filter cannot be found.
436 msg =
"frame-filter '" + str(name) +
"' not found."
437 raise gdb.GdbError(msg)
442 """Completion function for both frame filter dictionary, and
443 frame filter name."""
445 if text.count(
" ") == 0:
448 printer_list = frame._return_list(text.split()[0].rstrip())
453 if command_tuple
is None:
455 filter_name = command_tuple[1]
456 list_name = command_tuple[0]
460 e = sys.exc_info()[1]
461 print(
"Error printing filter priority for '" + name +
"':" + str(e))
464 "Priority of filter '"
invoke(self, arg, from_tty)
complete(self, text, word)
complete(self, text, word)
invoke(self, arg, from_tty)
invoke(self, arg, from_tty)
print_list(self, title, frame_filters, blank_line)
_set_filter_priority(self, command_tuple)
complete(self, text, word)
invoke(self, arg, from_tty)
_parse_pri_arg(self, arg)
invoke(self, arg, from_tty)
complete(self, text, word)
_parse_pri_arg(self, arg)
get_filter_priority(self, frame_filters, name)
_complete_frame_filter_name(word, printer_dict)
_complete_frame_filter_list(text, word, all_flag)
_do_enable_frame_filter(command_tuple, flag)
_enable_parse_arg(cmd_name, arg)
set_enabled(filter_item, state)
set_priority(filter_item, priority)
get_priority(filter_item)