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

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

Issue 2157433002: [Findit] Pass changed files info to Fracas, 2 face design. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix nits. Created 4 years, 5 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/findit_for_crash.py ('k') | appengine/findit/crash/results.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 logging 5 import logging
6 import os 6 import os
7 import re 7 import re
8 8
9 from crash.type_enums import CallStackFormatType, CallStackLanguageType 9 from crash.type_enums import CallStackFormatType, CallStackLanguageType
10 10
11 11
12 GENERATED_CODE_FILE_PATH_PATTERN = re.compile(r'.*out/[^/]+/gen/') 12 GENERATED_CODE_FILE_PATH_PATTERN = re.compile(r'.*out/[^/]+/gen/')
13 THIRD_PARTY_FILE_PATH_MARKER = 'third_party' 13 THIRD_PARTY_FILE_PATH_MARKER = 'third_party'
14 CHROMIUM_REPO_URL = 'https://chromium.googlesource.com/chromium/src.git'
14 15
15 16
16 def GetFullPathForJavaFrame(function): 17 def GetFullPathForJavaFrame(function):
17 """Uses java function package name to normalize and generate full file path. 18 """Uses java function package name to normalize and generate full file path.
18 19
19 Args: 20 Args:
20 function: Java function, for example, 'org.chromium.CrAct.onDestroy'. 21 function: Java function, for example, 'org.chromium.CrAct.onDestroy'.
21 22
22 Returns: 23 Returns:
23 A string of normalized full path, for example, org/chromium/CrAct.java 24 A string of normalized full path, for example, org/chromium/CrAct.java
(...skipping 21 matching lines...) Expand all
45 46
46 47
47 def GetDepPathAndNormalizedFilePath(path, deps): 48 def GetDepPathAndNormalizedFilePath(path, deps):
48 """Determines the dep of a file path and normalizes the path. 49 """Determines the dep of a file path and normalizes the path.
49 50
50 Args: 51 Args:
51 path (str): Represents a path. 52 path (str): Represents a path.
52 deps (dict): Map dependency path to its corresponding Dependency. 53 deps (dict): Map dependency path to its corresponding Dependency.
53 54
54 Returns: 55 Returns:
55 A tuple - (dep_path, normalized_path), dep_path is the dependency path 56 A tuple - (dep_path, normalized_path, repo_url)
56 of this path. (e.g 'src/', 'src/v8/' ...etc), '' is no match found. 57 dep_path (str): Dependency path of this path. (e.g 'src/', 'src/v8/'
58 ...etc), '' is no match found.
59 normalized_path (str): Normalized relative file path starting from dep_path.
60 repo_url (str): Repository url corresponding to dep_path.
57 """ 61 """
58 # First normalize the path by retreiving the normalized path. 62 # First normalize the path by retreiving the normalized path.
59 normalized_path = os.path.normpath(path).replace('\\', '/') 63 normalized_path = os.path.normpath(path).replace('\\', '/')
60 64
61 if GENERATED_CODE_FILE_PATH_PATTERN.match(normalized_path): 65 if GENERATED_CODE_FILE_PATH_PATTERN.match(normalized_path):
62 logging.info('Generated code path %s', normalized_path) 66 logging.info('Generated code path %s', normalized_path)
63 return '', normalized_path 67 return '', normalized_path, None
64 68
65 # Iterate through all dep paths in the parsed DEPS in an order. 69 # Iterate through all dep paths in the parsed DEPS in an order.
66 for dep_path in sorted(deps.keys(), key=lambda path: -path.count('/')): 70 for dep_path in sorted(deps.keys(), key=lambda path: -path.count('/')):
67 # trim the 'src/' in the beginning of the dep_path to match, because there 71 # trim the 'src/' in the beginning of the dep_path to match, because there
68 # are many cases, especially in linux platform, the file paths are like, 72 # are many cases, especially in linux platform, the file paths are like,
69 # 'third_party/WebKit/Source/...', or 'v8/...'. 73 # 'third_party/WebKit/Source/...', or 'v8/...'.
70 trimmed_dep_path = dep_path 74 trimmed_dep_path = dep_path
71 if trimmed_dep_path.startswith('src/') and trimmed_dep_path != 'src/': 75 if trimmed_dep_path.startswith('src/') and trimmed_dep_path != 'src/':
72 trimmed_dep_path = trimmed_dep_path[len('src/'):] 76 trimmed_dep_path = trimmed_dep_path[len('src/'):]
73 77
(...skipping 23 matching lines...) Expand all
97 if dep_path in normalized_path: 101 if dep_path in normalized_path:
98 current_dep_path = dep_path 102 current_dep_path = dep_path
99 else: 103 else:
100 current_dep_path = dep_path_lower 104 current_dep_path = dep_path_lower
101 105
102 # Normalize the path by stripping everything off the dep's relative 106 # Normalize the path by stripping everything off the dep's relative
103 # path. 107 # path.
104 if current_dep_path: 108 if current_dep_path:
105 normalized_path = normalized_path.split(current_dep_path, 1)[1] 109 normalized_path = normalized_path.split(current_dep_path, 1)[1]
106 110
107 return (dep_path, normalized_path) 111 return dep_path, normalized_path, deps[dep_path].repo_url
108 112
109 logging.info( 113 logging.info(
110 'Cannot find match of dep path for file path %s, Default to src/', 114 'Cannot find match of dep path for file path %s, Default to src/',
111 normalized_path) 115 normalized_path)
112 116
113 # For some crashes, the file path looks like this: 117 # For some crashes, the file path looks like this:
114 # third_party/WebKit/Source/a.cc, the src/ in the beginning is trimmed, so 118 # third_party/WebKit/Source/a.cc, the src/ in the beginning is trimmed, so
115 # default the dep path to 'src/' if no match found. 119 # default the dep path to 'src/' if no match found.
116 return 'src/', normalized_path 120 return 'src/', normalized_path, CHROMIUM_REPO_URL
117 121
118 122
119 def GetLanguageTypeFromFormatType(format_type): 123 def GetLanguageTypeFromFormatType(format_type):
120 """Gets language type of a callstack from its format type.""" 124 """Gets language type of a callstack from its format type."""
121 if format_type == CallStackFormatType.JAVA: 125 if format_type == CallStackFormatType.JAVA:
122 return CallStackLanguageType.JAVA 126 return CallStackLanguageType.JAVA
123 127
124 return CallStackLanguageType.CPP 128 return CallStackLanguageType.CPP
OLDNEW
« no previous file with comments | « appengine/findit/crash/findit_for_crash.py ('k') | appengine/findit/crash/results.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698