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

Unified Diff: appengine/findit/crash/stacktrace.py

Issue 2593383002: [Predator] Move ``FilterStackBuffer`` from stack parser to ``AddFilteredStack`` of stacktrace buffe… (Closed)
Patch Set: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/crash/chromecrash_parser.py ('k') | appengine/findit/crash/test/callstack_filters_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/crash/stacktrace.py
diff --git a/appengine/findit/crash/stacktrace.py b/appengine/findit/crash/stacktrace.py
index 4db6faf2f798d0bfe8188ef56e8e13cabd6932f3..7c2e95b6ee400d2d7ebaafc72d67a2bf2aa1e599 100644
--- a/appengine/findit/crash/stacktrace.py
+++ b/appengine/findit/crash/stacktrace.py
@@ -5,6 +5,7 @@
from collections import namedtuple
import copy
import logging
+import math
import re
from crash import parse_util
@@ -309,18 +310,19 @@ class Stacktrace(namedtuple('Stacktrace', ['stacks', 'crash_stack'])):
class StacktraceBuffer(object):
"""A Mutable type to simplify constructing ``Stacktrace`` objects.
- The class can be converted to immutable stacktrace.
- using ``ToStacktrace``.
+ The class can be converted to immutable stacktrace using ``ToStacktrace``.
Note, to make this class fully mutable, it should contain CallStackBuffer
list instead of CallStack list.
"""
- def __init__(self, stacks=None, signature=None):
+ def __init__(self, stacks=None, signature=None, filters=None):
"""Initialize StacktraceBuffer instance.
Args:
stacks (list of CallStackBuffer): CallStackBuffer objects to
build stacktrace.
- signature (str): signagure is used to determine the crash stack.
+ signature (str): The signature is used to determine the crash stack.
+ filters (list of CallStackFilters): List of ``CallStackFilter`` instances,
+ which filter frames if necessary.
"""
self.stacks = stacks or []
if signature:
@@ -332,11 +334,27 @@ class StacktraceBuffer(object):
else:
self.signature_parts = None
+ self.filters = filters
+
def __nonzero__(self):
"""Returns whether this trace buffer is empty."""
return bool(self.stacks)
__bool__ = __nonzero__
+ def AddFilteredStack(self, stack_buffer):
+ """Filters stack_buffer and add it to stacks if it's not empty."""
+ # If the callstack is the initial one (infinte priority) or empty, return
+ # None.
+ if math.isinf(stack_buffer.priority) or not stack_buffer.frames:
+ return
+
+ for stack_filter in self.filters or []:
+ stack_buffer = stack_filter(stack_buffer)
+ if not stack_buffer:
+ return
+
+ self.stacks.append(stack_buffer)
+
def ToStacktrace(self):
"""Converts to ``Stacktrace`` object."""
if not self:
« no previous file with comments | « appengine/findit/crash/chromecrash_parser.py ('k') | appengine/findit/crash/test/callstack_filters_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698