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

Side by Side Diff: mojo/devtools/common/android_stack_parser/stack_utils.py

Issue 1895863004: Android stack tool: Treat /data/data as a synonym for /data/user/0. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 """Utility functions for the stack tool.""" 5 """Utility functions for the stack tool."""
6 6
7 import glob 7 import glob
8 import os 8 import os
9 import os.path 9 import os.path
10 import re 10 import re
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 72
73 def GetSymbolMapping(lines): 73 def GetSymbolMapping(lines):
74 """Returns a mapping (dictionary) from download file to .so.""" 74 """Returns a mapping (dictionary) from download file to .so."""
75 regex = re.compile('Caching mojo app (\S+?)(?:\?\S+)? at (\S+)') 75 regex = re.compile('Caching mojo app (\S+?)(?:\?\S+)? at (\S+)')
76 mappings = {} 76 mappings = {}
77 for line in lines: 77 for line in lines:
78 result = regex.search(line) 78 result = regex.search(line)
79 if result: 79 if result:
80 url = GetBasenameFromMojoApp(result.group(1)) 80 url = GetBasenameFromMojoApp(result.group(1))
81 mappings[os.path.normpath(result.group(2))] = GetSymboledNameForMojoApp( 81 path = os.path.normpath(result.group(2))
82 url) 82 name = GetSymboledNameForMojoApp(url)
83 mappings[path] = name
84 if path.startswith('/data/user/0/'):
85 mappings[path.replace('/data/user/0/', '/data/data/', 1)] = name
83 return mappings 86 return mappings
84 87
85 88
86 def _LowestAncestorContainingRelpath(dir_path, relpath): 89 def _LowestAncestorContainingRelpath(dir_path, relpath):
87 """Returns the lowest ancestor dir of |dir_path| that contains |relpath|. 90 """Returns the lowest ancestor dir of |dir_path| that contains |relpath|.
88 """ 91 """
89 cur_dir_path = os.path.abspath(dir_path) 92 cur_dir_path = os.path.abspath(dir_path)
90 while True: 93 while True:
91 if os.path.exists(os.path.join(cur_dir_path, relpath)): 94 if os.path.exists(os.path.join(cur_dir_path, relpath)):
92 return cur_dir_path 95 return cur_dir_path
93 96
94 next_dir_path = os.path.dirname(cur_dir_path) 97 next_dir_path = os.path.dirname(cur_dir_path)
95 if next_dir_path != cur_dir_path: 98 if next_dir_path != cur_dir_path:
96 cur_dir_path = next_dir_path 99 cur_dir_path = next_dir_path
97 else: 100 else:
98 return None 101 return None
99 102
100 103
101 def GuessDir(relpath): 104 def GuessDir(relpath):
102 """Returns absolute path to location |relpath| in the lowest ancestor of this 105 """Returns absolute path to location |relpath| in the lowest ancestor of this
103 file that contains it.""" 106 file that contains it."""
104 lowest_ancestor = _LowestAncestorContainingRelpath( 107 lowest_ancestor = _LowestAncestorContainingRelpath(
105 os.path.dirname(__file__), relpath) 108 os.path.dirname(__file__), relpath)
106 if not lowest_ancestor: 109 if not lowest_ancestor:
107 return None 110 return None
108 return os.path.join(lowest_ancestor, relpath) 111 return os.path.join(lowest_ancestor, relpath)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698