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

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: Rebase 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
« no previous file with comments | « no previous file | appengine/findit/crash/classifier.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, for example, api.cc.
35 raw_file_path (str): Normalized original path of the crashed file,
36 for example, /b/build/slave/mac64/build/src/v8/src/heap/
37 incremental-marking-job.cc.
35 crashed_line_numbers (list): Line numbers of the file that caused the crash. 38 crashed_line_numbers (list): Line numbers of the file that caused the crash.
36 """ 39 """
37 def __init__(self, index, dep_path, component, 40 def __init__(self, index, dep_path, function,
38 function, file_path, crashed_line_numbers): 41 file_path, raw_file_path, crashed_line_numbers):
39 self.index = index 42 self.index = index
40 self.dep_path = dep_path 43 self.dep_path = dep_path
41 self.component = component
42 self.function = function 44 self.function = function
43 self.file_path = file_path 45 self.file_path = file_path
46 self.raw_file_path = raw_file_path
44 self.crashed_line_numbers = crashed_line_numbers 47 self.crashed_line_numbers = crashed_line_numbers
45 48
46 def ToString(self): 49 def ToString(self):
47 frame_str = '#%d in %s @ %s' % (self.index, self.function, self.file_path) 50 frame_str = '#%d in %s @ %s' % (self.index, self.function, self.file_path)
48 if self.crashed_line_numbers: 51 if self.crashed_line_numbers:
49 frame_str += ':%d' % self.crashed_line_numbers[0] 52 frame_str += ':%d' % self.crashed_line_numbers[0]
50 53
51 # For example, if crashed_line_numbers is [61], returns '... f.cc:61', 54 # For example, if crashed_line_numbers is [61], returns '... f.cc:61',
52 # if is [61, 62], returns '... f.cc:61:1' 55 # if is [61, 62], returns '... f.cc:61:1'
53 if len(self.crashed_line_numbers) > 1: 56 if len(self.crashed_line_numbers) > 1:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 parsed.""" 94 parsed."""
92 line = line.strip() 95 line = line.strip()
93 line_pattern = CALLSTACK_FORMAT_TO_PATTERN[self.format_type] 96 line_pattern = CALLSTACK_FORMAT_TO_PATTERN[self.format_type]
94 97
95 if self.format_type == CallStackFormatType.JAVA: 98 if self.format_type == CallStackFormatType.JAVA:
96 match = line_pattern.match(line) 99 match = line_pattern.match(line)
97 if not match: 100 if not match:
98 return 101 return
99 102
100 function = match.group(1) 103 function = match.group(1)
101 file_path = parse_util.GetFullPathForJavaFrame(function) 104 raw_file_path = parse_util.GetFullPathForJavaFrame(function)
102 crashed_line_numbers = [int(match.group(3))] 105 crashed_line_numbers = [int(match.group(3))]
103 106
104 elif self.format_type == CallStackFormatType.SYZYASAN: 107 elif self.format_type == CallStackFormatType.SYZYASAN:
105 match = line_pattern.match(line) 108 match = line_pattern.match(line)
106 if not match: 109 if not match:
107 return 110 return
108 111
109 function = match.group(2).strip() 112 function = match.group(2).strip()
110 file_path = match.group(5) 113 raw_file_path = match.group(5)
111 crashed_line_numbers = [int(match.group(6))] 114 crashed_line_numbers = [int(match.group(6))]
112 115
113 else: 116 else:
114 line_parts = line.split() 117 line_parts = line.split()
115 if not line_parts or not line_parts[0].startswith('#'): 118 if not line_parts or not line_parts[0].startswith('#'):
116 return 119 return
117 120
118 match = line_pattern.match(line_parts[-1]) 121 match = line_pattern.match(line_parts[-1])
119 if not match: 122 if not match:
120 return 123 return
121 124
122 function = ' '.join(line_parts[3:-1]) 125 function = ' '.join(line_parts[3:-1])
123 file_path = match.group(1) 126 raw_file_path = match.group(1)
124 crashed_line_numbers = parse_util.GetCrashedLineRange( 127 crashed_line_numbers = parse_util.GetCrashedLineRange(
125 match.group(2) + (match.group(3) if match.group(3) else '')) 128 match.group(2) + (match.group(3) if match.group(3) else ''))
126 129
127 # Normalize the file path so that it can be compared to repository path. 130 # Normalize the file path so that it can be compared to repository path.
128 dep_path, file_path = parse_util.GetDepPathAndNormalizedFilePath( 131 dep_path, file_path = parse_util.GetDepPathAndNormalizedFilePath(
129 file_path, deps) 132 raw_file_path, deps)
130
131 #TODO(katesonia): Enable component classifier later.
132 component = ''
133 133
134 # If we have the common stack frame index pattern, then use it 134 # If we have the common stack frame index pattern, then use it
135 # since it is more reliable. 135 # since it is more reliable.
136 index_match = FRAME_INDEX_PATTERN.match(line) 136 index_match = FRAME_INDEX_PATTERN.match(line)
137 if index_match: 137 if index_match:
138 stack_frame_index = int(index_match.group(1)) 138 stack_frame_index = int(index_match.group(1))
139 else: 139 else:
140 stack_frame_index = len(self) 140 stack_frame_index = len(self)
141 141
142 self.append(StackFrame(stack_frame_index, dep_path, component, 142 self.append(StackFrame(stack_frame_index, dep_path, function,
143 function, file_path, crashed_line_numbers)) 143 file_path, raw_file_path, crashed_line_numbers))
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/crash/classifier.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698