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

Side by Side Diff: third_party/android_platform/development/scripts/stack

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 | « no previous file | third_party/android_platform/development/scripts/stack_libs.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 #!/usr/bin/env python 1 #!/usr/bin/env 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 #
(...skipping 17 matching lines...) Expand all
28 import symbol 28 import symbol
29 import sys 29 import sys
30 30
31 sys.path.insert(0, os.path.join(os.path.dirname(__file__), 31 sys.path.insert(0, os.path.join(os.path.dirname(__file__),
32 os.pardir, os.pardir, os.pardir, os.pardir, 32 os.pardir, os.pardir, os.pardir, os.pardir,
33 'build', 'android')) 33 'build', 'android'))
34 from pylib import constants 34 from pylib import constants
35 35
36 36
37 DEFAULT_SYMROOT='/tmp/symbols' 37 DEFAULT_SYMROOT='/tmp/symbols'
38 DEFAULT_APK_DIR='chrome_apk'
39 # From: https://source.android.com/source/build-numbers.html 38 # From: https://source.android.com/source/build-numbers.html
40 _ANDROID_M_MAJOR_VERSION=6 39 _ANDROID_M_MAJOR_VERSION=6
41 40
42 def PrintUsage(): 41 def PrintUsage():
43 """Print usage and exit with error.""" 42 """Print usage and exit with error."""
44 # pylint: disable-msg=C6310 43 # pylint: disable-msg=C6310
45 print 44 print
46 print " usage: " + sys.argv[0] + " [options] [FILE]" 45 print " usage: " + sys.argv[0] + " [options] [FILE]"
47 print 46 print
48 print " --symbols-dir=path" 47 print " --symbols-dir=path"
49 print " the path to a symbols dir, such as =/tmp/out/target/product/drea m/symbols" 48 print " the path to a symbols dir, such as =/tmp/out/target/product/drea m/symbols"
50 print 49 print
51 print " --chrome-symbols-dir=path" 50 print " --chrome-symbols-dir=path"
52 print " the path to a Chrome symbols dir (can be absolute or relative" 51 print " the path to a Chrome symbols dir (can be absolute or relative"
53 print " to src), such as =out/Debug/lib" 52 print " to src), such as =out/Debug/lib.unstripped"
54 print 53 print
55 print " --output-directory=path" 54 print " --output-directory=path"
56 print " the path to the build output directory, such as out/Debug." 55 print " the path to the build output directory, such as out/Debug."
57 print " Ignored if --chrome-symbols-dir is passed." 56 print " Ignored if --chrome-symbols-dir is passed."
58 print 57 print
59 print " --packed-relocation-adjustments" 58 print " --packed-relocation-adjustments"
60 print " --no-packed-relocation-adjustments" 59 print " --no-packed-relocation-adjustments"
61 print " turn packed relocation adjustment on and off (default is off)" 60 print " turn packed relocation adjustment on and off (default is off)"
62 print " If running on pre-M Android and the stack trace appears to" 61 print " If running on pre-M Android and the stack trace appears to"
63 print " make no sense, try turning this feature on." 62 print " make no sense, try turning this feature on."
64 print 63 print
65 print " --chrome-apk-dir=path"
66 print " the path to the APK staging dir (can be absolute or relative"
67 print " to src), such as =out/Debug/chrome_apk"
68 print " If not specified, uses =|chrome-symbols-dir|/../chrome_apk"
69 print " Parses libraries here to find data for adjusting debuggerd"
70 print " tombstones where relocations are packed."
71 print " Enable/disable with --[no-]packed-relocation-adjustments."
72 print
73 print " --symbols-zip=path" 64 print " --symbols-zip=path"
74 print " the path to a symbols zip file, such as =dream-symbols-12345.zip " 65 print " the path to a symbols zip file, such as =dream-symbols-12345.zip "
75 print 66 print
76 print " --more-info" 67 print " --more-info"
77 print " --less-info" 68 print " --less-info"
78 print " Change the level of detail in the output." 69 print " Change the level of detail in the output."
79 print " --more-info is slower and more verbose, but more functions will" 70 print " --more-info is slower and more verbose, but more functions will"
80 print " be fully qualified with namespace/classname and have full" 71 print " be fully qualified with namespace/classname and have full"
81 print " argument information. Also, the 'stack data' section will be" 72 print " argument information. Also, the 'stack data' section will be"
82 print " printed." 73 print " printed."
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 130
140 131
141 def main(argv): 132 def main(argv):
142 try: 133 try:
143 options, arguments = getopt.getopt(argv, "", 134 options, arguments = getopt.getopt(argv, "",
144 ["packed-relocation-adjustments", 135 ["packed-relocation-adjustments",
145 "no-packed-relocation-adjustments", 136 "no-packed-relocation-adjustments",
146 "more-info", 137 "more-info",
147 "less-info", 138 "less-info",
148 "chrome-symbols-dir=", 139 "chrome-symbols-dir=",
149 "chrome-apk-dir=",
150 "output-directory=", 140 "output-directory=",
151 "symbols-dir=", 141 "symbols-dir=",
152 "symbols-zip=", 142 "symbols-zip=",
153 "arch=", 143 "arch=",
154 "verbose", 144 "verbose",
155 "help"]) 145 "help"])
156 except getopt.GetoptError, unused_error: 146 except getopt.GetoptError, unused_error:
157 PrintUsage() 147 PrintUsage()
158 148
159 zip_arg = None 149 zip_arg = None
160 more_info = False 150 more_info = False
161 chrome_apk_dir = None
162 packed_relocation_adjustments = "unknown" 151 packed_relocation_adjustments = "unknown"
163 for option, value in options: 152 for option, value in options:
164 if option == "--help": 153 if option == "--help":
165 PrintUsage() 154 PrintUsage()
166 elif option == "--symbols-dir": 155 elif option == "--symbols-dir":
167 symbol.SYMBOLS_DIR = os.path.expanduser(value) 156 symbol.SYMBOLS_DIR = os.path.expanduser(value)
168 elif option == "--symbols-zip": 157 elif option == "--symbols-zip":
169 zip_arg = os.path.expanduser(value) 158 zip_arg = os.path.expanduser(value)
170 elif option == "--arch": 159 elif option == "--arch":
171 symbol.ARCH = value 160 symbol.ARCH = value
172 elif option == "--chrome-symbols-dir": 161 elif option == "--chrome-symbols-dir":
173 symbol.CHROME_SYMBOLS_DIR = os.path.join(symbol.CHROME_SRC, value) 162 symbol.CHROME_SYMBOLS_DIR = os.path.join(symbol.CHROME_SRC, value)
174 elif option == "--chrome-apk-dir":
175 chrome_apk_dir = os.path.join(symbol.CHROME_SRC, value)
176 elif option == "--output-directory": 163 elif option == "--output-directory":
177 constants.SetOutputDirectory(value) 164 constants.SetOutputDirectory(value)
178 elif option == "--packed-relocation-adjustments": 165 elif option == "--packed-relocation-adjustments":
179 packed_relocation_adjustments = True 166 packed_relocation_adjustments = True
180 elif option == "--no-packed-relocation-adjustments": 167 elif option == "--no-packed-relocation-adjustments":
181 packed_relocation_adjustments = False 168 packed_relocation_adjustments = False
182 elif option == "--more-info": 169 elif option == "--more-info":
183 more_info = True 170 more_info = True
184 elif option == "--less-info": 171 elif option == "--less-info":
185 more_info = False 172 more_info = False
186 elif option == "--verbose": 173 elif option == "--verbose":
187 logging.basicConfig(level=logging.DEBUG) 174 logging.basicConfig(level=logging.DEBUG)
188 175
189 if len(arguments) > 1: 176 if len(arguments) > 1:
190 PrintUsage() 177 PrintUsage()
191 178
192 # Do an up-front test that the output directory is known. 179 # Do an up-front test that the output directory is known.
193 if not symbol.CHROME_SYMBOLS_DIR: 180 if not symbol.CHROME_SYMBOLS_DIR:
194 constants.CheckOutputDirectory() 181 constants.CheckOutputDirectory()
195 182
196 if not chrome_apk_dir:
197 # TODO(agrieve): This directory doesn't exist with GN.
198 probable_dir = os.path.join(constants.GetOutDirectory(), DEFAULT_APK_DIR)
199 if os.path.exists(probable_dir):
200 chrome_apk_dir = probable_dir
201
202 if not arguments or arguments[0] == "-": 183 if not arguments or arguments[0] == "-":
203 print "Reading native crash info from stdin" 184 print "Reading native crash info from stdin"
204 f = sys.stdin 185 f = sys.stdin
205 else: 186 else:
206 print "Searching for native crashes in: " + os.path.realpath(arguments[0]) 187 print "Searching for native crashes in: " + os.path.realpath(arguments[0])
207 f = open(arguments[0], "r") 188 f = open(arguments[0], "r")
208 189
209 lines = f.readlines() 190 lines = f.readlines()
210 f.close() 191 f.close()
211 192
212 rootdir = None 193 rootdir = None
213 if zip_arg: 194 if zip_arg:
214 rootdir, symbol.SYMBOLS_DIR = UnzipSymbols(zip_arg) 195 rootdir, symbol.SYMBOLS_DIR = UnzipSymbols(zip_arg)
215 196
216 if packed_relocation_adjustments == "unknown": 197 if packed_relocation_adjustments == "unknown":
217 if chrome_apk_dir: 198 version = stack_libs.GetTargetAndroidVersionNumber(lines)
218 version = stack_libs.GetTargetAndroidVersionNumber(lines) 199 if version == None:
219 if version == None: 200 packed_relocation_adjustments = False
220 packed_relocation_adjustments = False 201 print ("Unknown Android release, "
221 print ("Unknown Android release, " 202 + "consider --[no-]packed-relocation-adjustments options")
222 + "consider --[no-]packed-relocation-adjustments options") 203 elif version >= _ANDROID_M_MAJOR_VERSION:
223 elif version >= _ANDROID_M_MAJOR_VERSION: 204 packed_relocation_adjustments = False
224 packed_relocation_adjustments = False
225 else:
226 packed_relocation_adjustments = True
227 print ("Pre-M Android release detected, "
228 + "added --packed-relocation-adjustments option")
229 else: 205 else:
230 packed_relocation_adjustments = False 206 packed_relocation_adjustments = True
231 207 print ("Pre-M Android release detected, "
232 if packed_relocation_adjustments and not chrome_apk_dir: 208 + "added --packed-relocation-adjustments option")
209 else:
233 packed_relocation_adjustments = False 210 packed_relocation_adjustments = False
234 print ("No APK directory given or defaulted, "
235 + "--packed-relocation-adjustments option ignored")
236 211
237 if packed_relocation_adjustments: 212 if packed_relocation_adjustments:
238 print ("Reading Chrome APK library data from: " 213 constants.CheckOutputDirectory()
239 + os.path.normpath(chrome_apk_dir)) 214 stripped_libs_dir = constants.GetOutDirectory()
240 load_vaddrs = stack_libs.GetLoadVaddrs(chrome_apk_dir) 215 load_vaddrs = stack_libs.GetLoadVaddrs(stripped_libs_dir)
241 else: 216 else:
242 load_vaddrs = {} 217 load_vaddrs = {}
243 218
244 print ("Reading Android symbols from: " 219 print ("Reading Android symbols from: "
245 + os.path.normpath(symbol.SYMBOLS_DIR)) 220 + os.path.normpath(symbol.SYMBOLS_DIR))
246 chrome_search_path = symbol.GetLibrarySearchPaths() 221 chrome_search_path = symbol.GetLibrarySearchPaths()
247 print ("Searching for Chrome symbols from within: " 222 print ("Searching for Chrome symbols from within: "
248 + ':'.join((os.path.normpath(d) for d in chrome_search_path))) 223 + ':'.join((os.path.normpath(d) for d in chrome_search_path)))
249 stack_core.ConvertTrace(lines, load_vaddrs, more_info) 224 stack_core.ConvertTrace(lines, load_vaddrs, more_info)
250 225
251 if rootdir: 226 if rootdir:
252 # be a good citizen and clean up...os.rmdir and os.removedirs() don't work 227 # be a good citizen and clean up...os.rmdir and os.removedirs() don't work
253 cmd = "rm -rf \"%s\"" % rootdir 228 cmd = "rm -rf \"%s\"" % rootdir
254 print "\ncleaning up (%s)" % cmd 229 print "\ncleaning up (%s)" % cmd
255 os.system(cmd) 230 os.system(cmd)
256 231
257 if __name__ == "__main__": 232 if __name__ == "__main__":
258 sys.exit(main(sys.argv[1:])) 233 sys.exit(main(sys.argv[1:]))
259 234
260 # vi: ts=2 sw=2 235 # vi: ts=2 sw=2
OLDNEW
« no previous file with comments | « no previous file | third_party/android_platform/development/scripts/stack_libs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698