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

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

Issue 1828953003: 🌿 Fix stack tool when packed relocations exist and built with GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 ('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/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2015 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 7
8 """Identifies address adjustments required for native crash dumps.""" 8 """Identifies address adjustments required for native crash dumps."""
9 9
10 import glob 10 import glob
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 # would return 0x1d6000. Ignores all non-LOAD lines. 83 # would return 0x1d6000. Ignores all non-LOAD lines.
84 for line in _ReadElfProgramHeaders(lib): 84 for line in _ReadElfProgramHeaders(lib):
85 elements = line.split() 85 elements = line.split()
86 if elements and elements[0] == 'LOAD': 86 if elements and elements[0] == 'LOAD':
87 vaddrs.append(int(elements[2], 16)) 87 vaddrs.append(int(elements[2], 16))
88 if vaddrs: 88 if vaddrs:
89 return min(vaddrs) 89 return min(vaddrs)
90 return 0 90 return 0
91 91
92 92
93 def GetLoadVaddrs(apk_dir): 93 def GetLoadVaddrs(stripped_libs_dir):
94 """Return a dictionary of minimum VirtAddr fields for libraries in apk_dir. 94 """Return a dict of minimum VirtAddr for libraries in the given directory.
95 95
96 The dictionary returned may be passed to stack_core.ConvertTrace(). In 96 The dictionary returned may be passed to stack_core.ConvertTrace(). In
97 pre-M Android releases the addresses printed by debuggerd into tombstones 97 pre-M Android releases the addresses printed by debuggerd into tombstones
98 do not take account of non-zero vaddrs. Here we collect this information, 98 do not take account of non-zero vaddrs. Here we collect this information,
99 so that we can use it later to correct such debuggerd tombstones. 99 so that we can use it later to correct such debuggerd tombstones.
100 100
101 Args: 101 Args:
102 apk_dir: Path to APK staging directory. 102 stripped_libs_dir: Path to directory containing apk's stripped libraries.
103 Returns: 103 Returns:
104 {'libchrome.so': 12345, ...} 104 {'libchrome.so': 12345, ...}
105 """ 105 """
106 pathname = apk_dir + '/libs/*/*.so' 106 libs = glob.glob(os.path.join(stripped_libs_dir, '*.so'))
107 libs = [lib for lib in glob.glob(pathname) if _HasElfHeader(lib)] 107 libs = [l for l in libs if _HasElfHeader(l)]
108 108
109 load_vaddrs = {} 109 load_vaddrs = {}
110 for lib in libs: 110 for lib in libs:
111 min_vaddr = _FindMinLoadVaddr(lib) 111 min_vaddr = _FindMinLoadVaddr(lib)
112 if min_vaddr: 112 if min_vaddr:
113 # Store with the library basename as the key. This is because once on 113 # Store with the library basename as the key. This is because once on
114 # the device its path may not fully match its place in the APK staging 114 # the device its path may not fully match its place in the APK staging
115 # directory 115 # directory
116 load_vaddrs[os.path.basename(lib)] = min_vaddr 116 load_vaddrs[os.path.basename(lib)] = min_vaddr
117 117
118 # Direct load from APK causes debuggerd to tag trace lines as if from the 118 # Direct load from APK causes debuggerd to tag trace lines as if from the
119 # file .../base.apk. So if we encounter a libchrome.so with packed 119 # file .../base.apk. So if we encounter a libchrome.so with packed
120 # relocations, replicate this as base.apk so that later adjustment code 120 # relocations, replicate this as base.apk so that later adjustment code
121 # finds the appropriate adjustment. 121 # finds the appropriate adjustment.
122 if _LIBCHROME_SO in load_vaddrs: 122 if _LIBCHROME_SO in load_vaddrs:
123 load_vaddrs[_BASE_APK] = load_vaddrs[_LIBCHROME_SO] 123 load_vaddrs[_BASE_APK] = load_vaddrs[_LIBCHROME_SO]
124 124
125 return load_vaddrs 125 return load_vaddrs
OLDNEW
« no previous file with comments | « third_party/android_platform/development/scripts/stack ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698