|
16 | 16 |
|
17 | 17 | # TODO(vlif): rename this file to collector.py. |
18 | 18 |
|
19 | | -from collections import namedtuple |
20 | 19 | import copy |
21 | 20 | import datetime |
22 | 21 | import inspect |
@@ -251,25 +250,19 @@ def Collect(self, top_frame): |
251 | 250 |
|
252 | 251 | while frame and (len(breakpoint_frames) < self.max_frames): |
253 | 252 | code = frame.f_code |
254 | | - function = code.co_name |
255 | | - frame_arguments = [] |
256 | | - frame_locals = [] |
257 | 253 | if len(breakpoint_frames) < self.max_expand_frames: |
258 | | - frame_capture = self.CaptureFrameLocals(frame) |
259 | | - frame_arguments = frame_capture.arguments |
260 | | - frame_locals = frame_capture.locals |
261 | | - if frame_capture.classname: |
262 | | - function = frame_capture.classname + '.' + code.co_name |
| 254 | + frame_arguments, frame_locals = self.CaptureFrameLocals(frame) |
| 255 | + else: |
| 256 | + frame_arguments = [] |
| 257 | + frame_locals = [] |
263 | 258 |
|
264 | 259 | breakpoint_frames.append({ |
265 | | - 'function': function, |
| 260 | + 'function': code.co_name, |
266 | 261 | 'location': { |
267 | 262 | 'path': NormalizePath(code.co_filename), |
268 | | - 'line': frame.f_lineno |
269 | | - }, |
| 263 | + 'line': frame.f_lineno}, |
270 | 264 | 'arguments': frame_arguments, |
271 | | - 'locals': frame_locals |
272 | | - }) |
| 265 | + 'locals': frame_locals}) |
273 | 266 | frame = frame.f_back |
274 | 267 |
|
275 | 268 | # Explore variables table in BFS fashion. The variables table will grow |
@@ -324,20 +317,11 @@ def CaptureFrameLocals(self, frame): |
324 | 317 | if frame.f_code.co_flags & inspect.CO_VARARGS: nargs += 1 |
325 | 318 | if frame.f_code.co_flags & inspect.CO_VARKEYWORDS: nargs += 1 |
326 | 319 |
|
327 | | - # Retrieve class name of function if we think it is a member function |
328 | | - # This functions under the assumption that member functions will name their |
329 | | - # first parameter argument 'self' but has some edge-cases. |
330 | | - if nargs >= 1 and 'self' == frame.f_code.co_varnames[0]: |
331 | | - frame_class = frame.f_locals['self'].__class__.__name__ |
332 | | - else: |
333 | | - frame_class = None |
334 | | - |
335 | 320 | frame_arguments = [] |
336 | 321 | for argname in frame.f_code.co_varnames[:nargs]: |
337 | 322 | if argname in variables: frame_arguments.append(variables.pop(argname)) |
338 | 323 |
|
339 | | - frame = namedtuple('frame', 'classname arguments locals') |
340 | | - return frame(frame_class, frame_arguments, list(variables.viewvalues())) |
| 324 | + return (frame_arguments, list(variables.viewvalues())) |
341 | 325 |
|
342 | 326 | def CaptureNamedVariable(self, name, value, depth, limits): |
343 | 327 | """Appends name to the product of CaptureVariable. |
|
0 commit comments