| OLD | NEW |
| 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 """Process crashes from Chrome crash server and find culprits for them.""" | 5 """Process crashes from Chrome crash server and find culprits for them.""" |
| 6 | 6 |
| 7 from common import chromium_deps |
| 8 from crash import detect_regression_range |
| 9 from crash import findit_for_crash |
| 10 from crash.fracas_parser import FracasParser |
| 7 | 11 |
| 8 def FindCulpritForChromeCrash( # Not implemented yet pylint: disable=W0613 | 12 |
| 9 channel, platform, signature, stack_trace, | 13 def FindCulpritForChromeCrash(signature, platform, |
| 10 crashed_version, versions_to_cpm): | 14 stack_trace, crashed_version, historic_metadata): |
| 11 """Finds culprits for a Chrome crash. | 15 """Finds culprits for a Chrome crash. |
| 12 | 16 |
| 13 Args: | 17 Args: |
| 14 channel (str): The channel name, could be 'dev', 'canary', 'beta', etc. | |
| 15 platform (str): The platform name, could be 'win', 'mac', 'linux', | 18 platform (str): The platform name, could be 'win', 'mac', 'linux', |
| 16 'android', 'ios', etc. | 19 'android', 'ios', etc. |
| 17 signature (str): The signature of a crash on the Chrome crash server. | 20 signature (str): The signature of a crash on the Chrome crash server. |
| 18 stack_trace (str): A string containing the stack trace of a crash. | 21 stack_trace (str): A string containing the stack trace of a crash. |
| 19 crash_version (str): The version of Chrome in which the crash occurred. | 22 crash_version (str): The version of Chrome in which the crash occurred. |
| 20 versions_to_cpm (dict): Mapping from Chrome version to crash per million | 23 historic_metadata (list): list of dicts mapping from Chrome version to |
| 21 page loads. | 24 historic metadata. |
| 22 | 25 |
| 23 Returns: | 26 Returns: |
| 24 (analysis_result_dict, tag_dict) | 27 (analysis_result_dict, tag_dict) |
| 25 The analysis result is a dict like below: | 28 The analysis result is a dict like below: |
| 26 { | 29 { |
| 27 "found": True, # Indicate whether anything is found. | 30 "found": True, # Indicate whether anything is found. |
| 28 "suspected_project_path": "src/v8", # The full path to the dependency. | 31 "suspected_project": "src/v8", # The full path to the dependency. |
| 29 "suspected_project_name": "v8", # A project name of the dependency. | 32 # Components to file bug against. |
| 30 "components": ["blink>javascript"], # Components to file bug against. | 33 "suspected_components": ["blink>javascript"], |
| 31 "culprits": [ | 34 "culprits": [ |
| 32 { | 35 { |
| 33 "url": "https://chromium.googlesource.com/chromium/.../+/hash", | 36 "url": "https://chromium.googlesource.com/chromium/.../+/hash", |
| 34 "revision": "commit-hash", | 37 "revision": "commit-hash", |
| 35 "code_review_url": "https://codereview.chromium.org/ISSUE", | 38 "code_review_url": "https://codereview.chromium.org/ISSUE", |
| 36 "project_path": "src/v8", | 39 "project_path": "src/v8", |
| 37 "project_name": "v8", | |
| 38 "author": "who@chromium.org", | 40 "author": "who@chromium.org", |
| 39 "time": "2015-08-17 03:38:16", # When the revision was committed. | 41 "time": "2015-08-17 03:38:16", # When the revision was committed. |
| 40 "reason": "A plain string with '\n' as line break to explain why", | 42 "reason": "A plain string with '\n' as line break to explain why", |
| 41 "confidence": "0.6", # Optional confidence score. | 43 "confidence": "0.6", # Optional confidence score. |
| 42 }, | 44 }, |
| 43 ], | 45 ], |
| 44 } | 46 } |
| 45 The code review url might not always be available, because not all commits | 47 The code review url might not always be available, because not all commits |
| 46 go through code review. In that case, commit url should be used instead. | 48 go through code review. In that case, commit url should be used instead. |
| 47 | 49 |
| 48 The tag dict are allowed key/value pairs to tag the analysis result for | 50 The tag dict are allowed key/value pairs to tag the analysis result for |
| 49 query and monitoring purpose on Findit side. For allowed keys, please | 51 query and monitoring purpose on Findit side. For allowed keys, please |
| 50 refer to crash_analysis.py and fracas_crash_analysis.py: | 52 refer to crash_analysis.py and fracas_crash_analysis.py: |
| 51 For results with normal culprit-finding algorithm: | 53 For results with normal culprit-finding algorithm: { |
| 52 { | |
| 53 'found_suspects': True, | 54 'found_suspects': True, |
| 54 'has_regression_range': True, | 55 'has_regression_range': True, |
| 55 'solution': 'core_algorithm', | 56 'solution': 'core_algorithm', |
| 56 } | 57 } |
| 57 For results using git blame without a regression range: | 58 For results using git blame without a regression range: { |
| 58 { | |
| 59 'found_suspects': True, | 59 'found_suspects': True, |
| 60 'has_regression_range': False, | 60 'has_regression_range': False, |
| 61 'solution': 'blame', | 61 'solution': 'blame', |
| 62 } | 62 } |
| 63 If nothing is found: | 63 If nothing is found: { |
| 64 { | |
| 65 'found_suspects': False, | 64 'found_suspects': False, |
| 66 } | 65 } |
| 67 """ | 66 """ |
| 68 # TODO (katesonia): hook the analysis logic up here. | 67 crash_deps = chromium_deps.GetChromeDependency(crashed_version, platform) |
| 69 return {'found': False}, {'found_suspects': False} # pragma: no cover. | 68 stacktrace = FracasParser().Parse(stack_trace, crash_deps, signature) |
| 69 |
| 70 regression_deps_rolls = {} |
| 71 regression_versions = detect_regression_range.DetectRegressionRange( |
| 72 historic_metadata) |
| 73 |
| 74 if regression_versions: |
| 75 last_good_version, first_bad_version = regression_versions |
| 76 # Get regression deps and crash deps. |
| 77 regression_deps_rolls = chromium_deps.GetDEPSRollsDict( |
| 78 last_good_version, first_bad_version, platform) |
| 79 |
| 80 culprit_results = findit_for_crash.FindItForCrash( |
| 81 stacktrace, regression_deps_rolls, crash_deps) |
| 82 |
| 83 # TODO(katesonia): Enable dependency classifier and component classifier. |
| 84 suspected_project = '' |
| 85 suspected_components = [] |
| 86 |
| 87 return ( |
| 88 { |
| 89 'found': (bool(suspected_project) or bool(suspected_components) or |
| 90 bool(culprit_results)), |
| 91 'suspected_project': suspected_project, |
| 92 'suspected_components': suspected_components, |
| 93 'culprits': culprit_results, |
| 94 }, |
| 95 { |
| 96 'found_suspects': bool(culprit_results), |
| 97 'has_regression_range': bool(regression_versions), |
| 98 'solution': 'core_algorithm', |
| 99 } |
| 100 ) |
| OLD | NEW |