Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: appengine/findit/crash/stacktrace_parser.py

Issue 2593383002: [Predator] Move ``FilterStackBuffer`` from stack parser to ``AddFilteredStack`` of stacktrace buffe… (Closed)
Patch Set: . Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import math 5 import math
6 6
7 from crash.stacktrace import CallStackBuffer 7 from crash.stacktrace import CallStackBuffer
8 from crash.stacktrace import Stacktrace 8 from crash.stacktrace import Stacktrace
9 9
10 10
11 class StacktraceParser(object): 11 class StacktraceParser(object):
12 12
13 @staticmethod
14 def FilterStackBuffer(stack_buffer, filters):
15 """Builds stack buffer to keep all the Callstack inforamtion and metadata.
16
17 Filter stack buffers and cache all the metadata for later use in
18 ``BuildStackTrace``.
19
20 Args:
21 stack_buffer (CallStackBuffer): callstack buffer to be filtered.
22 filters (list): List of Filter objs, each Filter obj is callable and takes
23 stack_buffer as the only parameter.
24
25 Returns:
26 A new ``CallStackBuffer`` instance, None when all the frames of the
27 stack buffer are filtered.
28 """
29 # If the callstack is the initial one (infinte priority) or empty, return
30 # None.
31 if math.isinf(stack_buffer.priority) or not stack_buffer.frames:
32 return None
33
34 for stack_filter in filters:
35 stack_buffer = stack_filter(stack_buffer)
36 if not stack_buffer:
37 return None
38
39 return stack_buffer
40
41 def Parse(self, stacktrace_string, deps, signature=None, top_n_frames=None): 13 def Parse(self, stacktrace_string, deps, signature=None, top_n_frames=None):
42 """Parses stacktrace_string into ``Stacktrace`` instance. 14 """Parses stacktrace_string into ``Stacktrace`` instance.
43 15
44 Args: 16 Args:
45 stacktrace_string (str): Raw string to be parsed. 17 stacktrace_string (str): Raw string to be parsed.
46 deps (dict): Dict mapping repository path to ``Dependency`` instance, used 18 deps (dict): Dict mapping repository path to ``Dependency`` instance, used
47 to resolve dependency of frames. 19 to resolve dependency of frames.
48 signature (str): Signature is used to mark signature callstack, signature 20 signature (str): Signature is used to mark signature callstack, signature
49 callstack is the crash stack that causing the crash. 21 callstack is the crash stack that causing the crash.
50 top_n_frames (int): Number of top frames to be keep in a callstack. 22 top_n_frames (int): Number of top frames to be keep in a callstack.
51 """ 23 """
52 raise NotImplementedError() 24 raise NotImplementedError()
53 25
54 def _IsStartOfNewCallStack(self, line): 26 def _IsStartOfNewCallStack(self, line):
55 """Determines whether a line is the start of a new callstack or not.""" 27 """Determines whether a line is the start of a new callstack or not."""
56 raise NotImplementedError() 28 raise NotImplementedError()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698