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

Side by Side Diff: appengine/findit/crash/callstack.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 import parse_util 7 from crash import parse_util
8 from crash.type_enums import CallStackFormatType 8 from crash.type_enums import CallStackFormatType
9 9
10 # Used to parse a line into StackFrame of a Callstack. 10 # Used to parse a line into StackFrame of a Callstack.
(...skipping 11 matching lines...) Expand all
22 22
23 23
24 class StackFrame(object): 24 class StackFrame(object):
25 """Represents a frame in a stacktrace. 25 """Represents a frame in a stacktrace.
26 26
27 Attributes: 27 Attributes:
28 index (int): Index shown in the stacktrace if a stackframe line looks like 28 index (int): Index shown in the stacktrace if a stackframe line looks like
29 this - '#0 ...', else use the index in the callstack list. 29 this - '#0 ...', else use the index in the callstack list.
30 dep_path (str): Path of the dep this frame represents, for example, 30 dep_path (str): Path of the dep this frame represents, for example,
31 'src/', 'src/v8', 'src/skia'...etc. 31 'src/', 'src/v8', 'src/skia'...etc.
32 component (str): Component of this frame, for example, 'Blink>API'.
33 function (str): Function that caused the crash. 32 function (str): Function that caused the crash.
34 file_path (str): Path of the crashed file. 33 file_path (str): Normalized path of the crashed file, with parts dep_path
34 and parts before it stripped.
35 raw_file_path (str): Normalized original path of the crashed file.
stgao 2016/05/17 21:40:57 Maybe give two examples here for the file paths?
Sharu Jiang 2016/05/20 23:16:32 Done.
35 crashed_line_numbers (list): Line numbers of the file that caused the crash. 36 crashed_line_numbers (list): Line numbers of the file that caused the crash.
36 """ 37 """
37 def __init__(self, index, dep_path, component, 38 def __init__(self, index, dep_path, function,
38 function, file_path, crashed_line_numbers): 39 file_path, raw_file_path, crashed_line_numbers):
39 self.index = index 40 self.index = index
40 self.dep_path = dep_path 41 self.dep_path = dep_path
41 self.component = component
42 self.function = function 42 self.function = function
43 self.file_path = file_path 43 self.file_path = file_path
44 self.raw_file_path = raw_file_path
44 self.crashed_line_numbers = crashed_line_numbers 45 self.crashed_line_numbers = crashed_line_numbers
45 46
46 def ToString(self): 47 def ToString(self):
47 frame_str = '#%d in %s @ %s' % (self.index, self.function, self.file_path) 48 frame_str = '#%d in %s @ %s' % (self.index, self.function, self.file_path)
48 if self.crashed_line_numbers: 49 if self.crashed_line_numbers:
49 frame_str += ':%d' % self.crashed_line_numbers[0] 50 frame_str += ':%d' % self.crashed_line_numbers[0]
50 51
51 # For example, if crashed_line_numbers is [61], returns '... f.cc:61', 52 # For example, if crashed_line_numbers is [61], returns '... f.cc:61',
52 # if is [61, 62], returns '... f.cc:61:1' 53 # if is [61, 62], returns '... f.cc:61:1'
53 if len(self.crashed_line_numbers) > 1: 54 if len(self.crashed_line_numbers) > 1:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 parsed.""" 90 parsed."""
90 line = line.strip() 91 line = line.strip()
91 line_pattern = CALLSTACK_FORMAT_TO_PATTERN[self.format_type] 92 line_pattern = CALLSTACK_FORMAT_TO_PATTERN[self.format_type]
92 93
93 if self.format_type == CallStackFormatType.JAVA: 94 if self.format_type == CallStackFormatType.JAVA:
94 match = line_pattern.match(line) 95 match = line_pattern.match(line)
95 if not match: 96 if not match:
96 return 97 return
97 98
98 function = match.group(1) 99 function = match.group(1)
99 file_path = parse_util.GetFullPathForJavaFrame(function) 100 raw_file_path = parse_util.GetFullPathForJavaFrame(function)
100 crashed_line_numbers = [int(match.group(3))] 101 crashed_line_numbers = [int(match.group(3))]
101 102
102 elif self.format_type == CallStackFormatType.SYZYASAN: 103 elif self.format_type == CallStackFormatType.SYZYASAN:
103 match = line_pattern.match(line) 104 match = line_pattern.match(line)
104 if not match: 105 if not match:
105 return 106 return
106 107
107 function = match.group(2).strip() 108 function = match.group(2).strip()
108 file_path = match.group(5) 109 raw_file_path = match.group(5)
109 crashed_line_numbers = [int(match.group(6))] 110 crashed_line_numbers = [int(match.group(6))]
110 111
111 else: 112 else:
112 line_parts = line.split() 113 line_parts = line.split()
113 if not line_parts or not line_parts[0].startswith('#'): 114 if not line_parts or not line_parts[0].startswith('#'):
114 return 115 return
115 116
116 match = line_pattern.match(line_parts[-1]) 117 match = line_pattern.match(line_parts[-1])
117 if not match: 118 if not match:
118 return 119 return
119 120
120 function = ' '.join(line_parts[3:-1]) 121 function = ' '.join(line_parts[3:-1])
121 file_path = match.group(1) 122 raw_file_path = match.group(1)
122 crashed_line_numbers = parse_util.GetCrashedLineRange( 123 crashed_line_numbers = parse_util.GetCrashedLineRange(
123 match.group(2) + (match.group(3) if match.group(3) else '')) 124 match.group(2) + (match.group(3) if match.group(3) else ''))
124 125
125 # Normalize the file path so that it can be compared to repository path. 126 # Normalize the file path so that it can be compared to repository path.
126 dep_path, file_path = parse_util.GetDepPathAndNormalizedFilePath( 127 dep_path, file_path = parse_util.GetDepPathAndNormalizedFilePath(
127 file_path, deps) 128 raw_file_path, deps)
128
129 #TODO(katesonia): Enable component classifier later.
130 component = ''
131 129
132 # If we have the common stack frame index pattern, then use it 130 # If we have the common stack frame index pattern, then use it
133 # since it is more reliable. 131 # since it is more reliable.
134 index_match = FRAME_INDEX_PATTERN.match(line) 132 index_match = FRAME_INDEX_PATTERN.match(line)
135 if index_match: 133 if index_match:
136 stack_frame_index = int(index_match.group(1)) 134 stack_frame_index = int(index_match.group(1))
137 else: 135 else:
138 stack_frame_index = len(self) 136 stack_frame_index = len(self)
139 137
140 self.append(StackFrame(stack_frame_index, dep_path, component, 138 self.append(StackFrame(stack_frame_index, dep_path, function,
141 function, file_path, crashed_line_numbers)) 139 file_path, raw_file_path, crashed_line_numbers))
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/crash/callstack_filters.py » ('j') | appengine/findit/crash/classifier.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698