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

Side by Side Diff: appengine/findit/crash/stacktrace.py

Issue 2704843002: [Predator] Add TouchCrashedDirectory feature. (Closed)
Patch Set: . Created 3 years, 10 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 | « appengine/findit/crash/predator.py ('k') | appengine/findit/crash/test/crash_util_test.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 from collections import namedtuple 5 from collections import namedtuple
6 import copy 6 import copy
7 import logging 7 import logging
8 import math 8 import math
9 import re 9 import re
10 10
11 from crash import parse_util 11 from crash import parse_util
12 from crash.type_enums import CallStackFormatType 12 from crash.type_enums import CallStackFormatType
13 from crash.type_enums import LanguageType 13 from crash.type_enums import LanguageType
14 14
15 # Used to parse a line into StackFrame of a Callstack. 15 # Used to parse a line into StackFrame of a Callstack.
16 CALLSTACK_FORMAT_TO_PATTERN = { 16 CALLSTACK_FORMAT_TO_PATTERN = {
17 CallStackFormatType.JAVA: re.compile( 17 CallStackFormatType.JAVA: re.compile(
18 r'at ([A-Za-z0-9$._<>]+)\(\w+(\.java)?:(\d+)\)'), 18 r'at ([A-Za-z0-9$._<>]+)\(\w+(\.java)?:(\d+)\)'),
19 CallStackFormatType.SYZYASAN: re.compile( 19 CallStackFormatType.SYZYASAN: re.compile(
20 r'(CF: )?(.*?)( \(FPO: .*\) )?( \(CONV: .*\) )?\[(.*) @ (\d+)\]'), 20 r'(CF: )?(.*?)( \(FPO: .*\) )?( \(CONV: .*\) )?\[(.*) @ (\d+)\]'),
21 CallStackFormatType.DEFAULT: re.compile( 21 CallStackFormatType.DEFAULT: re.compile(
22 r'(.*?):(\d+)(:\d+)?$') 22 r'(.*?):(\d+)(:\d+)?$')
23 } 23 }
24 24
25 FRAME_INDEX_PATTERN = re.compile(r'\s*#(\d+)\s.*') 25 FRAME_INDEX_PATTERN = re.compile(r'\s*#(\d+)\s.*')
26 26
27 _DEFAULT_FORMAT_TYPE = CallStackFormatType.DEFAULT 27 _DEFAULT_FORMAT_TYPE = CallStackFormatType.DEFAULT
28 28
29 29
30 # TODO(wrengr): it's not clear why the ``priority`` is stored at all,
31 # given that every use in this file discards it. ``Result.file_to_stack_infos``
32 # should just store pointers directly to the frames themselves rather
33 # than needing this intermediate object.
34 # TODO(http://crbug.com/644476): this class needs a better name.
35 class StackInfo(namedtuple('StackInfo', ['frame', 'priority'])):
36 """Pair of a frame and the ``priority`` of the ``CallStack`` it came from."""
37 __slots__ = ()
38
39 def __str__(self): # pragma: no cover
40 return ('%s(frame = %s, priority = %f)'
41 % (self.__class__.__name__, self.frame, self.priority))
42
43
44 class StackFrame(namedtuple('StackFrame', 30 class StackFrame(namedtuple('StackFrame',
45 ['index', 'dep_path', 'function', 'file_path', 'raw_file_path', 31 ['index', 'dep_path', 'function', 'file_path', 'raw_file_path',
46 'crashed_line_numbers', 'repo_url'])): 32 'crashed_line_numbers', 'repo_url'])):
47 """Represents a frame in a stacktrace. 33 """Represents a frame in a stacktrace.
48 34
49 Attributes: 35 Attributes:
50 index (int): Index shown in the stacktrace if a stackframe line 36 index (int): Index shown in the stacktrace if a stackframe line
51 looks like this - '#0 ...', else use the index in the callstack 37 looks like this - '#0 ...', else use the index in the callstack
52 list. 38 list.
53 dep_path (str): Path of the dep this frame represents, for example, 39 dep_path (str): Path of the dep this frame represents, for example,
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 for stack_buffer in self.stacks] 389 for stack_buffer in self.stacks]
404 390
405 if crash_stack_index is None: 391 if crash_stack_index is None:
406 # If there is no signature callstack, fall back to set crash stack using 392 # If there is no signature callstack, fall back to set crash stack using
407 # the first least priority callstack. 393 # the first least priority callstack.
408 crash_stack = min(callstacks, key=lambda stack: stack.priority) 394 crash_stack = min(callstacks, key=lambda stack: stack.priority)
409 else: 395 else:
410 crash_stack = callstacks[crash_stack_index] 396 crash_stack = callstacks[crash_stack_index]
411 397
412 return Stacktrace(tuple(callstacks), crash_stack) 398 return Stacktrace(tuple(callstacks), crash_stack)
OLDNEW
« no previous file with comments | « appengine/findit/crash/predator.py ('k') | appengine/findit/crash/test/crash_util_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698