17 """GDB commands for working with frame-filters."""
29 """Prefix command for 'set' frame-filter related operations."""
32 super(SetFilterPrefixCmd, self).
__init__(
"set frame-filter",
34 gdb.COMPLETE_NONE,
True)
37 """Prefix command for 'show' frame-filter related operations."""
39 super(ShowFilterPrefixCmd, self).
__init__(
"show frame-filter",
41 gdb.COMPLETE_NONE,
True)
43 """List all registered Python frame-filters.
45 Usage: info frame-filters
49 super(InfoFrameFilter, self).
__init__(
"info frame-filter",
53 """Return "Yes" if filter is enabled, otherwise "No"."""
60 """ Internal worker function to list and print frame filters
64 frame_filters: The name of the dictionary, as
65 specified by GDB user commands.
68 sorted_frame_filters = sorted(frame_filters.items(),
72 if len(sorted_frame_filters) == 0:
73 print(
" No frame filters registered.")
75 print(
" Priority Enabled Name")
76 for frame_filter
in sorted_frame_filters:
77 name = frame_filter[0]
79 priority =
'{:<8}'.format(
81 enabled =
'{:<7}'.format(
85 print(
" Error printing filter '"+name+
"': "+str(e))
87 print(
" %s %s %s" % (priority, enabled, name))
96 self.
print_list(
"global frame-filters:", gdb.frame_filters,
True)
98 cp = gdb.current_progspace()
99 self.
print_list(
"progspace %s frame-filters:" % cp.filename,
100 cp.frame_filters,
True)
102 for objfile
in gdb.objfiles():
103 self.
print_list(
"objfile %s frame-filters:" % objfile.filename,
104 objfile.frame_filters,
False)
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);
123 if argv[0] ==
"all" and argc > 1:
124 raise gdb.GdbError(cmd_name +
": with 'all' " \
125 "you may not specify a filter.")
127 if argv[0] !=
"all" and argc != 2:
128 raise gdb.GdbError(cmd_name +
" takes exactly two arguments.")
133 """Worker for enabling/disabling frame_filters.
136 command_type: A tuple with the first element being the
137 frame filter dictionary, and the second being
138 the frame filter name.
139 flag: True for Enable, False for Disable.
142 list_op = command_tuple[0]
149 frame_filter = command_tuple[1]
151 ff = op_list[frame_filter]
153 msg =
"frame-filter '" + str(name) +
"' not found."
154 raise gdb.GdbError(msg)
159 """Worker for frame filter dictionary name completion.
162 text: The full text of the command line.
163 word: The most recent word of the command line.
164 all_flag: Whether to include the word "all" in completion.
167 A list of suggested frame filter dictionary name completions
168 from text/word analysis. This list can be empty when there
169 are no suggestions for completion.
172 filter_locations = [
"all",
"global",
"progspace"]
174 filter_locations = [
"global",
"progspace"]
175 for objfile
in gdb.objfiles():
176 filter_locations.append(objfile.filename)
182 return filter_locations
185 flist = filter(
lambda x,y=text:x.startswith(y), filter_locations)
189 flist[0] = flist[0][
len(text)-
len(word):]
196 """Worker for frame filter name completion.
200 word: The most recent word of the command line.
202 printer_dict: The frame filter dictionary to search for frame
203 filter name completions.
205 Returns: A list of suggested frame filter name completions
206 from word analysis of the frame filter dictionary. This list
207 can be empty when there are no suggestions for completion.
210 printer_keys = printer_dict.keys()
214 flist = filter(
lambda x,y=word:x.startswith(y), printer_keys)
218 """GDB command to disable the specified frame-filter.
220 Usage: enable frame-filter enable DICTIONARY [NAME]
222 DICTIONARY is the name of the frame filter dictionary on which to
223 operate. If dictionary is set to "all", perform operations on all
224 dictionaries. Named dictionaries are: "global" for the global
225 frame filter dictionary, "progspace" for the program space's frame
226 filter dictionary. If either all, or the two named dictionaries
227 are not specified, the dictionary name is assumed to be the name
228 of the object-file name.
230 NAME matches the name of the frame-filter to operate on. If
231 DICTIONARY is "all", NAME is ignored.
234 super(EnableFrameFilter, self).
__init__(
"enable frame-filter",
237 """Completion function for both frame filter dictionary, and
238 frame filter name."""
239 if text.count(
" ") == 0:
251 """GDB command to disable the specified frame-filter.
253 Usage: disable frame-filter disable DICTIONARY [NAME]
255 DICTIONARY is the name of the frame filter dictionary on which to
256 operate. If dictionary is set to "all", perform operations on all
257 dictionaries. Named dictionaries are: "global" for the global
258 frame filter dictionary, "progspace" for the program space's frame
259 filter dictionary. If either all, or the two named dictionaries
260 are not specified, the dictionary name is assumed to be the name
261 of the object-file name.
263 NAME matches the name of the frame-filter to operate on. If
264 DICTIONARY is "all", NAME is ignored.
267 super(DisableFrameFilter, self).
__init__(
"disable frame-filter",
271 """Completion function for both frame filter dictionary, and
272 frame filter name."""
273 if text.count(
" ") == 0:
284 """GDB command to set the priority of the specified frame-filter.
286 Usage: set frame-filter priority DICTIONARY NAME PRIORITY
288 DICTIONARY is the name of the frame filter dictionary on which to
289 operate. Named dictionaries are: "global" for the global frame
290 filter dictionary, "progspace" for the program space's framefilter
291 dictionary. If either of these two are not specified, the
292 dictionary name is assumed to be the name of the object-file name.
294 NAME matches the name of the frame filter to operate on.
296 PRIORITY is the an integer to assign the new priority to the frame
301 super(SetFrameFilterPriority, self).
__init__(
"set frame-filter " \
306 """Internal worker to parse a priority from a tuple.
309 arg: Tuple which contains the arguments from the command.
312 A tuple containing the dictionary, name and priority from
316 gdb.GdbError: An error parsing the arguments.
319 argv = gdb.string_to_argv(arg);
322 print(
"set frame-filter priority " \
323 "takes exactly three arguments.")
329 """Internal worker for setting priority of frame-filters, by
330 parsing a tuple and calling _set_priority with the parsed
334 command_tuple: Tuple which contains the arguments from the
338 list_op = command_tuple[0]
339 frame_filter = command_tuple[1]
343 priority =
int(command_tuple[2])
348 ff = op_list[frame_filter]
350 msg =
"frame-filter '" + str(name) +
"' not found."
351 raise gdb.GdbError(msg)
356 """Completion function for both frame filter dictionary, and
357 frame filter name."""
358 if text.count(
" ") == 0:
366 if command_tuple !=
None:
370 """GDB command to show the priority of the specified frame-filter.
372 Usage: show frame-filter priority DICTIONARY NAME
374 DICTIONARY is the name of the frame filter dictionary on which to
375 operate. Named dictionaries are: "global" for the global frame
376 filter dictionary, "progspace" for the program space's framefilter
377 dictionary. If either of these two are not specified, the
378 dictionary name is assumed to be the name of the object-file name.
380 NAME matches the name of the frame-filter to operate on.
384 super(ShowFrameFilterPriority, self).
__init__(
"show frame-filter " \
389 """Internal worker to parse a dictionary and name from a
393 arg: Tuple which contains the arguments from the command.
396 A tuple containing the dictionary, and frame filter name.
399 gdb.GdbError: An error parsing the arguments.
402 argv = gdb.string_to_argv(arg);
405 print(
"show frame-filter priority " \
406 "takes exactly two arguments.")
412 """Worker for retrieving the priority of frame_filters.
415 frame_filters: Name of frame filter dictionary.
416 name: object to select printers.
419 The priority of the frame filter.
422 gdb.GdbError: A frame filter cannot be found.
430 msg =
"frame-filter '" + str(name) +
"' not found."
431 raise gdb.GdbError(msg)
436 """Completion function for both frame filter dictionary, and
437 frame filter name."""
439 if text.count(
" ") == 0:
442 printer_list = frame._return_list(text.split()[0].rstrip())
447 if command_tuple ==
None:
449 filter_name = command_tuple[1]
450 list_name = command_tuple[0]
454 e = sys.exc_info()[1]
455 print(
"Error printing filter priority for '"+name+
"':"+str(e))
457 print(
"Priority of filter '" + filter_name +
"' in list '" \
458 + list_name +
"' is: " + str(priority))
def invoke(self, arg, from_tty)
def complete(self, text, word)
def list_frame_filters(self, frame_filters)
def complete(self, text, word)
def invoke(self, arg, from_tty)
def complete(self, text, word)
def complete(self, text, word)
def set_enabled(filter_item, state)
def get_filter_priority(self, frame_filters, name)
def _complete_frame_filter_name(word, printer_dict)
def set_priority(filter_item, priority)
def _parse_pri_arg(self, arg)
def enabled_string(state)
def invoke(self, arg, from_tty)
def invoke(self, arg, from_tty)
def invoke(self, arg, from_tty)
const char const char int
def _set_filter_priority(self, command_tuple)
def print_list(self, title, filter_list, blank_line)
def _enable_parse_arg(cmd_name, arg)
def _do_enable_frame_filter(command_tuple, flag)
def get_enabled(filter_item)
def _complete_frame_filter_list(text, word, all_flag)
def get_priority(filter_item)
def _parse_pri_arg(self, arg)
const ULONGEST const LONGEST len