OLD | NEW |
---|---|
(Empty) | |
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 import chromium_deps | |
6 import crash_utils | |
7 import findit_for_crash as findit | |
8 import stacktrace | |
9 | |
10 | |
11 def SplitStacktrace(stacktrace_string): | |
12 """Preprocesses stacktrace string into two parts, release and debug. | |
13 | |
14 Args: | |
15 stacktrace_string: A string representation of stacktrace, | |
16 in clusterfuzz format. | |
17 | |
18 Returns: | |
19 A tuple of list of strings, release build stacktrace and | |
20 debug build stacktrace. | |
21 """ | |
22 # Make sure we only parse release/debug build stacktrace, and ignore | |
23 # unsymbolised stacktrace. | |
24 in_release_or_debug_stacktrace = False | |
25 release_build_stacktrace_lines = None | |
26 debug_build_stacktrace_lines = None | |
27 current_stacktrace_lines = [] | |
28 | |
29 # Iterate through all lines in stacktrace. | |
30 for line in stacktrace_string.splitlines(): | |
31 line = line.strip() | |
32 | |
33 # If the line starts with +, it signifies the start of new stacktrace. | |
34 if line.startswith('+'): | |
35 if 'Release Build Stacktrace' in line: | |
36 in_release_or_debug_stacktrace = True | |
37 current_stacktrace_lines = [] | |
38 release_build_stacktrace_lines = current_stacktrace_lines | |
39 | |
40 elif 'Debug Build Stacktrace' in line: | |
41 in_release_or_debug_stacktrace = True | |
42 current_stacktrace_lines = [] | |
43 debug_build_stacktrace_lines = current_stacktrace_lines | |
44 | |
45 # If the stacktrace is neither release/debug build stacktrace, ignore | |
46 # all lines after it until we encounter release/debug build stacktrace. | |
47 else: | |
48 in_release_or_debug_stacktrace = False | |
49 | |
50 # This case, it must be that the line is an actual stack frame, so add to | |
51 # the current stacktrace. | |
52 elif in_release_or_debug_stacktrace: | |
53 current_stacktrace_lines.append(line) | |
54 | |
55 return (release_build_stacktrace_lines, debug_build_stacktrace_lines) | |
56 | |
57 | |
58 def GetResultsFromString(stacktrace_string, | |
stgao
2014/08/14 18:25:42
Rename to "FindCulpritCL"?
jeun
2014/08/14 20:54:12
Done.
| |
59 build_type, | |
60 chrome_regression=None, | |
61 component_regression=None, | |
62 chrome_crash_revision=None, | |
63 component_crash_revision=None, | |
64 crashing_component=None): | |
65 """Returns string representation of the result, a list of suspected CLs. | |
stgao
2014/08/14 18:25:42
After the result.py is committed, maybe refer to r
jeun
2014/08/14 20:54:12
Done.
| |
66 | |
67 Args: | |
68 stacktrace_string: A string representing stacktrace. | |
69 build_type: The type of the job. | |
70 chrome_regression: A string, chrome regression from clusterfuzz, in format | |
71 '123456:123457' | |
72 component_regression: A string, component regression in the same format. | |
73 chrome_crash_revision: A crash revision of chrome, in string. | |
74 component_crash_revision: A crash revision of the component, | |
75 if component build. | |
76 crashing_component: Yet to be decided. | |
77 | |
78 Returns: | |
79 A list of result objects. | |
stgao
2014/08/14 18:25:42
We agreed the returned result would be as below, r
jeun
2014/08/14 20:54:12
Done.
| |
80 """ | |
81 build_type = build_type.lower() | |
82 if 'android' in build_type or 'windows' in build_type: | |
83 return 'This build type is currently not supported.' | |
84 | |
85 crash_revision_dict = {} | |
86 regression_dict = {} | |
87 | |
88 # TODO(jeun): Come up with a good way to connect crashing component name to | |
89 # its path. | |
90 if component_regression or component_crash_revision: | |
91 return 'This feature is not supported.' | |
92 | |
93 # If chrome regression is available, parse DEPS file. | |
94 chrome_regression = crash_utils.SplitRange(chrome_regression) | |
95 if chrome_regression: | |
96 chrome_regression_start = chrome_regression[0] | |
97 chrome_regression_end = chrome_regression[1] | |
98 | |
99 # If the regression is not reliable, do not parse regression information. | |
100 if chrome_regression_start != '0': | |
101 regression_dict = chromium_deps.GetChromiumComponentRange( | |
102 chrome_regression_start, chrome_regression_end) | |
103 | |
104 # Parse crash revision. | |
105 if chrome_crash_revision: | |
106 crash_revision_dict = chromium_deps.GetChromiumComponents( | |
107 chrome_crash_revision) | |
108 | |
109 # Parsed DEPS is used to normalize the stacktrace. Since parsed regression | |
110 # and parsed crash state essentially contain same information, use either. | |
111 if regression_dict: | |
112 parsed_deps = regression_dict | |
113 elif crash_revision_dict: | |
114 parsed_deps = crash_revision_dict | |
115 else: | |
116 return 'No regression and crash revision information available.' | |
117 | |
118 # Split stacktrace into release build/debug build and parse them. | |
119 (release_build_stacktrace, debug_build_stacktrace) = SplitStacktrace( | |
120 stacktrace_string) | |
121 parsed_release_build_stacktrace = stacktrace.Stacktrace( | |
122 release_build_stacktrace, build_type, parsed_deps) | |
123 parsed_debug_build_stacktrace = stacktrace.Stacktrace( | |
124 debug_build_stacktrace, build_type, parsed_deps) | |
125 release_stacktrace_exists = parsed_release_build_stacktrace.stack_list | |
stgao
2014/08/14 18:25:42
*_exists is not necessary, could be merged into th
jeun
2014/08/14 20:54:12
Done.
| |
126 debug_stacktrace_exists = parsed_debug_build_stacktrace.stack_list | |
127 | |
128 # Get a highest priority callstack from stacktrace, with release build | |
129 # stacktrace in higher priority than debug build stacktace. | |
130 if release_stacktrace_exists: | |
131 main_stack = parsed_release_build_stacktrace.GetCrashStack() | |
132 elif debug_stacktrace_exists: | |
133 main_stack = parsed_debug_build_stacktrace.GetCrashStack() | |
134 else: | |
135 return 'ERROR: Stacktrace is malformed.' | |
136 | |
137 stacktrace_list = [parsed_release_build_stacktrace, | |
138 parsed_debug_build_stacktrace] | |
139 return findit.FindItForCrash(stacktrace_list, main_stack, build_type, | |
140 regression_dict, crash_revision_dict) | |
OLD | NEW |