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

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

Issue 2840193003: [Android] Fix stack symbolization when packed relocations are on. (Closed)
Patch Set: agrieve comments Created 3 years, 7 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
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 try: 138 try:
139 options, arguments = getopt.getopt(argv, "", 139 options, arguments = getopt.getopt(argv, "",
140 ["packed-relocation-adjustments", 140 ["packed-relocation-adjustments",
141 "no-packed-relocation-adjustments", 141 "no-packed-relocation-adjustments",
142 "more-info", 142 "more-info",
143 "less-info", 143 "less-info",
144 "chrome-symbols-dir=", 144 "chrome-symbols-dir=",
145 "output-directory=", 145 "output-directory=",
146 "symbols-dir=", 146 "symbols-dir=",
147 "symbols-zip=", 147 "symbols-zip=",
148 "packed-lib=",
148 "arch=", 149 "arch=",
149 "fallback-monochrome", 150 "fallback-monochrome",
150 "verbose", 151 "verbose",
151 "help"]) 152 "help"])
152 except getopt.GetoptError, unused_error: 153 except getopt.GetoptError, unused_error:
153 PrintUsage() 154 PrintUsage()
154 155
155 zip_arg = None 156 zip_arg = None
156 more_info = False 157 more_info = False
157 packed_relocation_adjustments = "unknown"
158 fallback_monochrome = False 158 fallback_monochrome = False
159 arch_defined = False 159 arch_defined = False
160 packed_libs = []
160 for option, value in options: 161 for option, value in options:
161 if option == "--help": 162 if option == "--help":
162 PrintUsage() 163 PrintUsage()
163 elif option == "--symbols-dir": 164 elif option == "--symbols-dir":
164 symbol.SYMBOLS_DIR = os.path.expanduser(value) 165 symbol.SYMBOLS_DIR = os.path.expanduser(value)
165 elif option == "--symbols-zip": 166 elif option == "--symbols-zip":
166 zip_arg = os.path.expanduser(value) 167 zip_arg = os.path.expanduser(value)
167 elif option == "--arch": 168 elif option == "--arch":
168 symbol.ARCH = value 169 symbol.ARCH = value
169 arch_defined = True 170 arch_defined = True
170 elif option == "--chrome-symbols-dir": 171 elif option == "--chrome-symbols-dir":
171 symbol.CHROME_SYMBOLS_DIR = os.path.join(symbol.CHROME_SRC, value) 172 symbol.CHROME_SYMBOLS_DIR = os.path.join(symbol.CHROME_SRC, value)
172 elif option == "--output-directory": 173 elif option == "--output-directory":
173 constants.SetOutputDirectory(value) 174 constants.SetOutputDirectory(value)
174 elif option == "--packed-relocation-adjustments": 175 elif option == "--packed-lib":
175 packed_relocation_adjustments = True 176 packed_libs.append(os.path.expanduser(value))
176 elif option == "--no-packed-relocation-adjustments":
177 packed_relocation_adjustments = False
178 elif option == "--more-info": 177 elif option == "--more-info":
179 more_info = True 178 more_info = True
180 elif option == "--less-info": 179 elif option == "--less-info":
181 more_info = False 180 more_info = False
182 elif option == "--fallback-monochrome": 181 elif option == "--fallback-monochrome":
183 fallback_monochrome = True 182 fallback_monochrome = True
184 elif option == "--verbose": 183 elif option == "--verbose":
185 logging.basicConfig(level=logging.DEBUG) 184 logging.basicConfig(level=logging.DEBUG)
185 elif option in (
186 '--packed-relocation-adjustments',
187 '--no-packed-relocation-adjustments'):
188 print ('--[no-]packed-relocation-adjustments options are deprecated. '
189 'Specify packed libs directory instead.')
186 190
187 if len(arguments) > 1: 191 if len(arguments) > 1:
188 PrintUsage() 192 PrintUsage()
189 193
190 # Do an up-front test that the output directory is known. 194 # Do an up-front test that the output directory is known.
191 if not symbol.CHROME_SYMBOLS_DIR: 195 if not symbol.CHROME_SYMBOLS_DIR:
192 constants.CheckOutputDirectory() 196 constants.CheckOutputDirectory()
193 197
194 if not arguments or arguments[0] == "-": 198 if not arguments or arguments[0] == "-":
195 print "Reading native crash info from stdin" 199 print "Reading native crash info from stdin"
196 f = sys.stdin 200 f = sys.stdin
197 else: 201 else:
198 print "Searching for native crashes in: " + os.path.realpath(arguments[0]) 202 print "Searching for native crashes in: " + os.path.realpath(arguments[0])
199 f = open(arguments[0], "r") 203 f = open(arguments[0], "r")
200 204
201 lines = f.readlines() 205 lines = f.readlines()
202 f.close() 206 f.close()
203 207
204 rootdir = None 208 rootdir = None
205 if zip_arg: 209 if zip_arg:
206 rootdir, symbol.SYMBOLS_DIR = UnzipSymbols(zip_arg) 210 rootdir, symbol.SYMBOLS_DIR = UnzipSymbols(zip_arg)
207 211
208 if packed_relocation_adjustments == "unknown": 212 version = stack_libs.GetTargetAndroidVersionNumber(lines)
209 version = stack_libs.GetTargetAndroidVersionNumber(lines) 213 if version is None:
210 if version == None: 214 print ("Unknown Android release, "
211 packed_relocation_adjustments = False 215 "consider passing --packed-lib.")
212 print ("Unknown Android release, " 216 elif version < _ANDROID_M_MAJOR_VERSION and not packed_libs:
213 + "consider --[no-]packed-relocation-adjustments options") 217 print ("Pre-M Android release detected, "
214 elif version >= _ANDROID_M_MAJOR_VERSION: 218 "but --packed-lib not specified. Stack symbolization may fail.")
215 packed_relocation_adjustments = False
216 else:
217 packed_relocation_adjustments = True
218 print ("Pre-M Android release detected, "
219 + "added --packed-relocation-adjustments option")
220 else:
221 packed_relocation_adjustments = False
222 219
223 if packed_relocation_adjustments: 220 if (version is None or version < _ANDROID_M_MAJOR_VERSION) and packed_libs:
224 constants.CheckOutputDirectory() 221 load_vaddrs = stack_libs.GetLoadVaddrs(stripped_libs=packed_libs)
225 stripped_libs_dir = constants.GetOutDirectory()
226 load_vaddrs = stack_libs.GetLoadVaddrs(stripped_libs_dir)
227 else: 222 else:
228 load_vaddrs = {} 223 load_vaddrs = {}
229 224
230 print ("Reading Android symbols from: " 225 print ("Reading Android symbols from: "
231 + os.path.normpath(symbol.SYMBOLS_DIR)) 226 + os.path.normpath(symbol.SYMBOLS_DIR))
232 chrome_search_path = symbol.GetLibrarySearchPaths() 227 chrome_search_path = symbol.GetLibrarySearchPaths()
233 print ("Searching for Chrome symbols from within: " 228 print ("Searching for Chrome symbols from within: "
234 + ':'.join((os.path.normpath(d) for d in chrome_search_path))) 229 + ':'.join((os.path.normpath(d) for d in chrome_search_path)))
235 stack_core.ConvertTrace(lines, load_vaddrs, more_info, fallback_monochrome, 230 stack_core.ConvertTrace(lines, load_vaddrs, more_info, fallback_monochrome,
236 arch_defined) 231 arch_defined)
237 232
238 if rootdir: 233 if rootdir:
239 # be a good citizen and clean up...os.rmdir and os.removedirs() don't work 234 # be a good citizen and clean up...os.rmdir and os.removedirs() don't work
240 cmd = "rm -rf \"%s\"" % rootdir 235 cmd = "rm -rf \"%s\"" % rootdir
241 print "\ncleaning up (%s)" % cmd 236 print "\ncleaning up (%s)" % cmd
242 os.system(cmd) 237 os.system(cmd)
243 238
244 if __name__ == "__main__": 239 if __name__ == "__main__":
245 sys.exit(main(sys.argv[1:])) 240 sys.exit(main(sys.argv[1:]))
246 241
247 # vi: ts=2 sw=2 242 # vi: ts=2 sw=2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698