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

Side by Side Diff: third_party/android_platform/development/scripts/symbol.py

Issue 642843003: Revert of Make it easier to debug failed symbolization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-crazy-linker
Patch Set: Created 6 years, 2 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 | « third_party/android_platform/development/scripts/stack_core.py ('k') | 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 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (C) 2013 The Android Open Source Project 3 # Copyright (C) 2013 The Android Open Source Project
4 # 4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License. 6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at 7 # You may obtain a copy of the License at
8 # 8 #
9 # http://www.apache.org/licenses/LICENSE-2.0 9 # http://www.apache.org/licenses/LICENSE-2.0
10 # 10 #
11 # Unless required by applicable law or agreed to in writing, software 11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS, 12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and 14 # See the License for the specific language governing permissions and
15 # limitations under the License. 15 # limitations under the License.
16 16
17 """Module for looking up symbolic debugging information. 17 """Module for looking up symbolic debugging information.
18 18
19 The information can include symbol names, offsets, and source locations. 19 The information can include symbol names, offsets, and source locations.
20 """ 20 """
21 21
22 import glob 22 import glob
23 import itertools 23 import itertools
24 import logging
25 import os 24 import os
26 import re 25 import re
27 import subprocess 26 import subprocess
28 import zipfile 27 import zipfile
29 28
30 CHROME_SRC = os.path.join(os.path.realpath(os.path.dirname(__file__)), 29 CHROME_SRC = os.path.join(os.path.realpath(os.path.dirname(__file__)),
31 os.pardir, os.pardir, os.pardir, os.pardir) 30 os.pardir, os.pardir, os.pardir, os.pardir)
32 ANDROID_BUILD_TOP = CHROME_SRC 31 ANDROID_BUILD_TOP = CHROME_SRC
33 SYMBOLS_DIR = CHROME_SRC 32 SYMBOLS_DIR = CHROME_SRC
34 CHROME_SYMBOLS_DIR = CHROME_SRC 33 CHROME_SYMBOLS_DIR = CHROME_SRC
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 out_dir = os.path.join(CHROME_SYMBOLS_DIR, out_dir) 201 out_dir = os.path.join(CHROME_SYMBOLS_DIR, out_dir)
203 buildtype = os.environ.get('BUILDTYPE') 202 buildtype = os.environ.get('BUILDTYPE')
204 if buildtype: 203 if buildtype:
205 buildtype_list = [ buildtype ] 204 buildtype_list = [ buildtype ]
206 else: 205 else:
207 buildtype_list = [ 'Debug', 'Release' ] 206 buildtype_list = [ 'Debug', 'Release' ]
208 207
209 candidates = PathListJoin([out_dir], buildtype_list) + [CHROME_SYMBOLS_DIR] 208 candidates = PathListJoin([out_dir], buildtype_list) + [CHROME_SYMBOLS_DIR]
210 candidates = PathListJoin(candidates, dirs) 209 candidates = PathListJoin(candidates, dirs)
211 candidates = PathListJoin(candidates, [filepart]) 210 candidates = PathListJoin(candidates, [filepart])
212 logging.debug('GetCandidates: prefiltered candidates = %s' % candidates)
213 candidates = list( 211 candidates = list(
214 itertools.chain.from_iterable(map(candidate_fun, candidates))) 212 itertools.chain.from_iterable(map(candidate_fun, candidates)))
215 candidates = sorted(candidates, key=os.path.getmtime, reverse=True) 213 candidates = sorted(candidates, key=os.path.getmtime, reverse=True)
216 return candidates 214 return candidates
217 215
218 def GetCandidateApks(): 216 def GetCandidateApks():
219 """Returns a list of APKs which could contain the library. 217 """Returns a list of APKs which could contain the library.
220 218
221 Args: 219 Args:
222 None 220 None
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 def GetCandidateLibraries(library_name): 275 def GetCandidateLibraries(library_name):
278 """Returns a list of candidate library filenames. 276 """Returns a list of candidate library filenames.
279 277
280 Args: 278 Args:
281 library_name: basename of the library to match. 279 library_name: basename of the library to match.
282 280
283 Returns: 281 Returns:
284 A list of matching library filenames for library_name. 282 A list of matching library filenames for library_name.
285 """ 283 """
286 return GetCandidates( 284 return GetCandidates(
287 ['lib', 'lib.target', '.'], library_name, 285 ['lib', 'lib.target'], library_name,
288 lambda filename: filter(os.path.exists, [filename])) 286 lambda filename: filter(os.path.exists, [filename]))
289 287
290 def TranslateLibPath(lib): 288 def TranslateLibPath(lib):
291 # SymbolInformation(lib, addr) receives lib as the path from symbols 289 # SymbolInformation(lib, addr) receives lib as the path from symbols
292 # root to the symbols file. This needs to be translated to point to the 290 # root to the symbols file. This needs to be translated to point to the
293 # correct .so path. If the user doesn't explicitly specify which directory to 291 # correct .so path. If the user doesn't explicitly specify which directory to
294 # use, then use the most recently updated one in one of the known directories. 292 # use, then use the most recently updated one in one of the known directories.
295 # If the .so is not found somewhere in CHROME_SYMBOLS_DIR, leave it 293 # If the .so is not found somewhere in CHROME_SYMBOLS_DIR, leave it
296 # untranslated in case it is an Android symbol in SYMBOLS_DIR. 294 # untranslated in case it is an Android symbol in SYMBOLS_DIR.
297 library_name = os.path.basename(lib) 295 library_name = os.path.basename(lib)
298 296
299 # The filename in the stack trace maybe an APK name rather than a library 297 # The filename in the stack trace maybe an APK name rather than a library
300 # name. This happens when the library was loaded directly from inside the 298 # name. This happens when the library was loaded directly from inside the
301 # APK. If this is the case we try to figure out the library name by looking 299 # APK. If this is the case we try to figure out the library name by looking
302 # for a matching APK file and finding the name of the library in contains. 300 # for a matching APK file and finding the name of the library in contains.
303 # The name of the APK file on the device is of the form 301 # The name of the APK file on the device is of the form
304 # <package_name>-<number>.apk. The APK file on the host may have any name 302 # <package_name>-<number>.apk. The APK file on the host may have any name
305 # so we look at the APK badging to see if the package name matches. 303 # so we look at the APK badging to see if the package name matches.
306 if re.search('-[0-9]+[.]apk$', library_name): 304 if re.search('-[0-9]+[.]apk$', library_name):
307 mapping = MapDeviceApkToLibrary(library_name) 305 mapping = MapDeviceApkToLibrary(library_name)
308 if mapping: 306 if mapping:
309 library_name = mapping 307 library_name = mapping
310 308
311 logging.debug('TranslateLibPath: lib=%s library_name=%s' % (lib, library_name) )
312
313 candidate_libraries = GetCandidateLibraries(library_name) 309 candidate_libraries = GetCandidateLibraries(library_name)
314 logging.debug('TranslateLibPath: candidate_libraries=%s' % candidate_libraries )
315 if not candidate_libraries: 310 if not candidate_libraries:
316 return lib 311 return lib
317 312
318 library_path = os.path.relpath(candidate_libraries[0], SYMBOLS_DIR) 313 library_path = os.path.relpath(candidate_libraries[0], SYMBOLS_DIR)
319 logging.debug('TranslateLibPath: library_path=%s' % library_path)
320 return '/' + library_path 314 return '/' + library_path
321 315
322 def SymbolInformation(lib, addr, get_detailed_info): 316 def SymbolInformation(lib, addr, get_detailed_info):
323 """Look up symbol information about an address. 317 """Look up symbol information about an address.
324 318
325 Args: 319 Args:
326 lib: library (or executable) pathname containing symbols 320 lib: library (or executable) pathname containing symbols
327 addr: string hexidecimal address 321 addr: string hexidecimal address
328 322
329 Returns: 323 Returns:
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 process.stdin.write("\n") 568 process.stdin.write("\n")
575 process.stdin.close() 569 process.stdin.close()
576 demangled_symbol = process.stdout.readline().strip() 570 demangled_symbol = process.stdout.readline().strip()
577 process.stdout.close() 571 process.stdout.close()
578 return demangled_symbol 572 return demangled_symbol
579 573
580 def FormatSymbolWithOffset(symbol, offset): 574 def FormatSymbolWithOffset(symbol, offset):
581 if offset == 0: 575 if offset == 0:
582 return symbol 576 return symbol
583 return "%s+%d" % (symbol, offset) 577 return "%s+%d" % (symbol, offset)
OLDNEW
« no previous file with comments | « third_party/android_platform/development/scripts/stack_core.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698