Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from crash.classifier import Classifier | |
| 6 from model.crash.crash_config import CrashConfig | |
| 7 | |
| 8 | |
| 9 class ComponentClassifier(Classifier): | |
| 10 """Determines the component of a crash. | |
| 11 | |
| 12 For example: ['Blink>DOM', 'Blink>HTML']. | |
| 13 """ | |
| 14 | |
| 15 CONFIG = CrashConfig.Get().parsed_component_classifier | |
| 16 | |
| 17 def GetClassFromStackFrame(self, frame): | |
| 18 """Gets the component from file path and function of a frame.""" | |
| 19 for path_regx, function_regx, component in ComponentClassifier.CONFIG[ | |
|
Martin Barbella
2016/05/05 18:33:41
Nit: s/regx/regex/
Sharu Jiang
2016/05/10 03:11:02
Done.
| |
| 20 'path_function_component']: | |
| 21 path_match = path_regx.match(frame.dep_path + frame.file_path) | |
| 22 if not path_match: | |
| 23 continue | |
| 24 | |
| 25 if not function_regx: | |
| 26 return component | |
| 27 | |
| 28 function_match = function_regx.match(frame.function) | |
| 29 if function_match: | |
| 30 return component | |
| 31 | |
| 32 return '' | |
| 33 | |
| 34 def GetClassFromResult(self, result): | |
| 35 """Gets the component from a result. | |
| 36 | |
| 37 Note that Findit assumes files that the culprit result touched come from | |
| 38 the same component. | |
| 39 """ | |
| 40 for frame, _ in result.file_to_stack_infos.iteritems(): | |
|
Martin Barbella
2016/05/05 18:33:41
Why not just use keys()?
Sharu Jiang
2016/05/10 03:11:02
Done.
| |
| 41 return self.GetClassFromStackFrame(frame) | |
| 42 | |
| 43 def Classify(self, results, crash_stack): | |
| 44 """Classifies project of a crash. | |
| 45 | |
| 46 Args: | |
| 47 results (list of Result): Culprit results. | |
| 48 crash_stack (CallStack): The callstack that caused the crash. | |
| 49 | |
| 50 Returns: | |
| 51 List of top 2 components. | |
| 52 """ | |
| 53 print type(ComponentClassifier.CONFIG['top_n']) | |
|
Martin Barbella
2016/05/05 18:33:41
Is this for debugging? Please remove before landin
Sharu Jiang
2016/05/10 03:11:02
Done.
| |
| 54 return self._Classify(results, crash_stack, | |
| 55 ComponentClassifier.CONFIG['top_n'], 2) | |
| OLD | NEW |