17 """Internal functions for working with frame-filters."""
26 """ Internal worker function to return the frame-filter's priority
27 from a frame filter object. This is a fail free function as it is
28 used in sorting and filtering. If a badly implemented frame
29 filter does not implement the priority attribute, return zero
30 (otherwise sorting/filtering will fail and prevent other frame
31 filters from executing).
34 filter_item: An object conforming to the frame filter
38 The priority of the frame filter from the "priority"
43 return getattr(filter_item,
"priority", 0)
46 """ Internal worker function to set the frame-filter's priority.
49 filter_item: An object conforming to the frame filter
51 priority: The priority to assign as an integer.
54 filter_item.priority = priority
57 """ Internal worker function to return a filter's enabled state
58 from a frame filter object. This is a fail free function as it is
59 used in sorting and filtering. If a badly implemented frame
60 filter does not implement the enabled attribute, return False
61 (otherwise sorting/filtering will fail and prevent other frame
62 filters from executing).
65 filter_item: An object conforming to the frame filter
69 The enabled state of the frame filter from the "enabled"
76 return getattr(filter_item,
"enabled",
False)
79 """ Internal Worker function to set the frame-filter's enabled
83 filter_item: An object conforming to the frame filter
85 state: True or False, depending on desired state.
88 filter_item.enabled = state
91 """ Internal Worker function to return the frame filter
92 dictionary, depending on the name supplied as an argument. If the
93 name is not "all", "global" or "progspace", it is assumed to name
97 name: The name of the list, as specified by GDB user commands.
100 A dictionary object for a single specified dictionary, or a
101 list containing all the items for "all"
104 gdb.GdbError: A dictionary of that name cannot be found.
113 glob = gdb.frame_filters.values()
114 prog = gdb.current_progspace().frame_filters.values()
115 return_iter = itertools.chain(glob, prog)
116 for objfile
in gdb.objfiles():
117 return_iter = itertools.chain(return_iter, objfile.frame_filters.values())
122 return gdb.frame_filters
124 if name ==
"progspace":
125 cp = gdb.current_progspace()
126 return cp.frame_filters
128 for objfile
in gdb.objfiles():
129 if name == objfile.filename:
130 return objfile.frame_filters
132 msg =
"Cannot find frame-filter dictionary for '" + name +
"'"
133 raise gdb.GdbError(msg)
136 """ Internal Worker function to merge all known frame-filter
137 lists, prune any filters with the state set to "disabled", and
138 sort the list on the frame-filter's "priority" attribute.
141 sorted_list: A sorted, pruned list of frame filters to
146 sorted_frame_filters = sorted(all_filters, key = get_priority,
149 sorted_frame_filters = filter(get_enabled,
150 sorted_frame_filters)
152 return sorted_frame_filters
155 """ Internal function called from GDB that will execute the chain
156 of frame filters. Each filter is executed in priority order.
157 After the execution completes, slice the iterator to frame_low -
161 frame: The initial frame.
163 frame_low: The low range of the slice. If this is a negative
164 integer then it indicates a backward slice (ie bt -4) which
165 counts backward from the last frame in the backtrace.
167 frame_high: The high range of the slice. If this is -1 then
168 it indicates all frames until the end of the stack from
172 frame_iterator: The sliced iterator after all frame
173 filters have had a change to execute, or None if no frame
174 filters are registered.
182 if len(sorted_list) == 0:
190 if hasattr(itertools,
"imap"):
191 frame_iterator = itertools.imap(FrameDecorator, frame_iterator)
193 frame_iterator = map(FrameDecorator, frame_iterator)
195 for ff
in sorted_list:
196 frame_iterator = ff.filter(frame_iterator)
203 slice_length = abs(frame_low)
206 sliced = collections.deque()
208 for frame_item
in frame_iterator:
209 if count >= slice_length:
212 sliced.append(frame_item)
224 frame_high = frame_high + 1;
226 sliced = itertools.islice(frame_iterator, frame_low, frame_high)
def set_enabled(filter_item, state)
def set_priority(filter_item, priority)
def execute_frame_filters(frame, frame_low, frame_high)
def get_enabled(filter_item)
def get_priority(filter_item)
const ULONGEST const LONGEST len