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

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

Issue 1914113002: [Findit] Enable project classifier and component classifier (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Address comments. Created 4 years, 7 months 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 re 5 import re
6 6
7 from crash.callstack import CallStack 7 from crash.callstack import CallStack
8 from crash.callstack_filters import FilterFramesBeforeSignature 8 from crash.callstack_filters import FilterFramesBeforeSignature
9 from crash.stacktrace import Stacktrace 9 from crash.stacktrace import Stacktrace
10 from crash.stacktrace_parser import StacktraceParser 10 from crash.stacktrace_parser import StacktraceParser
11 from crash.type_enums import CallStackFormatType 11 from crash.type_enums import CallStackFormatType
12 12
13 13
14 FRACAS_CALLSTACK_START_PATTERN = re.compile(r'CRASHED \[(.*) @ 0x(.*)\]') 14 FRACAS_CALLSTACK_START_PATTERN = re.compile(r'CRASHED \[(.*) @ 0x(.*)\]')
15 15
16 16
17 _INFINITY_PRIORITY = 1000
18
19
20 class FracasParser(StacktraceParser): 17 class FracasParser(StacktraceParser):
21 18
22 def Parse(self, stacktrace_string, deps, signature=None): 19 def Parse(self, stacktrace_string, deps, signature=None):
23 """Parse fracas stacktrace string into Stacktrace instance.""" 20 """Parse fracas stacktrace string into Stacktrace instance."""
24 stacktrace = Stacktrace() 21 stacktrace = Stacktrace()
25 callstack = CallStack(_INFINITY_PRIORITY) 22 callstack = CallStack(float('inf'))
26 23
27 for line in stacktrace_string.splitlines(): 24 for line in stacktrace_string.splitlines():
28 is_new_callstack, stack_priority, format_type = ( 25 is_new_callstack, stack_priority, format_type = (
29 self._IsStartOfNewCallStack(line)) 26 self._IsStartOfNewCallStack(line))
30 27
31 if is_new_callstack: 28 if is_new_callstack:
32 # If the callstack is not the initial one or empty, add it 29 # If the callstack is not the initial one or empty, add it
33 # to stacktrace. 30 # to stacktrace.
34 if callstack.priority != _INFINITY_PRIORITY and callstack: 31 if callstack.priority != float('inf') and callstack:
35 stacktrace.append(callstack) 32 stacktrace.append(callstack)
36 33
37 callstack = CallStack(stack_priority, format_type) 34 callstack = CallStack(stack_priority, format_type)
38 else: 35 else:
39 callstack.ParseLine(line, deps) 36 callstack.ParseLine(line, deps)
40 37
41 if callstack.priority != _INFINITY_PRIORITY and callstack: 38 if callstack.priority != float('inf') and callstack:
42 stacktrace.append(callstack) 39 stacktrace.append(callstack)
43 40
44 # Filter all the frames before signature frame. 41 # Filter all the frames before signature frame.
45 FilterFramesBeforeSignature(stacktrace.GetCrashStack(), signature) 42 FilterFramesBeforeSignature(stacktrace.GetCrashStack(), signature)
46 return stacktrace 43 return stacktrace
47 44
48 def _IsStartOfNewCallStack(self, line): 45 def _IsStartOfNewCallStack(self, line):
49 """Determine whether a line is a start of a callstack or not. 46 """Determine whether a line is a start of a callstack or not.
50 Returns a tuple - (is_new_callstack, stack_priority, format_type). 47 Returns a tuple - (is_new_callstack, stack_priority, format_type).
51 """ 48 """
52 if FRACAS_CALLSTACK_START_PATTERN.match(line): 49 if FRACAS_CALLSTACK_START_PATTERN.match(line):
53 #Fracas only provide magic signature stack (crash stack). 50 #Fracas only provide magic signature stack (crash stack).
54 return True, 0, CallStackFormatType.DEFAULT 51 return True, 0, CallStackFormatType.DEFAULT
55 52
56 return False, None, None 53 return False, None, None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698