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

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

Issue 1407143010: Revert of stack: Adjust Pre-M Android incorrect debuggerd addresses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 #
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 """stack symbolizes native crash dumps.""" 17 """stack symbolizes native crash dumps."""
18 18
19 import getopt 19 import getopt
20 import glob 20 import glob
21 import logging 21 import logging
22 import os 22 import os
23 import sys 23 import sys
24 24
25 import stack_core 25 import stack_core
26 import stack_libs
27 import subprocess 26 import subprocess
28 import symbol 27 import symbol
29 import sys 28 import sys
30 29
31 DEFAULT_SYMROOT='/tmp/symbols' 30 DEFAULT_SYMROOT='/tmp/symbols'
32 DEFAULT_APK_DIR='chrome_apk'
33 # From: https://source.android.com/source/build-numbers.html
34 _ANDROID_M_MAJOR_VERSION=6
35 31
36 def PrintUsage(): 32 def PrintUsage():
37 """Print usage and exit with error.""" 33 """Print usage and exit with error."""
38 # pylint: disable-msg=C6310 34 # pylint: disable-msg=C6310
39 print 35 print
40 print " usage: " + sys.argv[0] + " [options] [FILE]" 36 print " usage: " + sys.argv[0] + " [options] [FILE]"
41 print 37 print
42 print " --symbols-dir=path" 38 print " --symbols-dir=path"
43 print " the path to a symbols dir, such as =/tmp/out/target/product/drea m/symbols" 39 print " the path to a symbols dir, such as =/tmp/out/target/product/drea m/symbols"
44 print 40 print
45 print " --chrome-symbols-dir=path" 41 print " --chrome-symbols-dir=path"
46 print " the path to a Chrome symbols dir (can be absolute or relative" 42 print " the path to a Chrome symbols dir (can be absolute or relative"
47 print " to src), such as =out/Debug/lib" 43 print " to src), such as =out/Debug/lib"
48 print " If not specified, will look for the newest lib in out/Debug or" 44 print " If not specified, will look for the newest lib in out/Debug or"
49 print " out/Release" 45 print " out/Release"
50 print 46 print
51 print " --packed-relocation-adjustments"
52 print " --no-packed-relocation-adjustments"
53 print " turn packed relocation adjustment on and off (default is off)"
54 print " If running on pre-M Android and the stack trace appears to"
55 print " make no sense, try turning this feature on."
56 print
57 print " --chrome-apk-dir=path"
58 print " the path to the APK staging dir (can be absolute or relative"
59 print " to src), such as =out/Debug/chrome_apk"
60 print " If not specified, uses =|chrome-symbols-dir|/../chrome_apk"
61 print " Parses libraries here to find data for adjusting debuggerd"
62 print " tombstones where relocations are packed."
63 print " Enable/disable with --[no-]packed-relocation-adjustments."
64 print
65 print " --symbols-zip=path" 47 print " --symbols-zip=path"
66 print " the path to a symbols zip file, such as =dream-symbols-12345.zip " 48 print " the path to a symbols zip file, such as =dream-symbols-12345.zip "
67 print 49 print
68 print " --more-info" 50 print " --more-info"
69 print " --less-info" 51 print " --less-info"
70 print " Change the level of detail in the output." 52 print " Change the level of detail in the output."
71 print " --more-info is slower and more verbose, but more functions will" 53 print " --more-info is slower and more verbose, but more functions will"
72 print " be fully qualified with namespace/classname and have full" 54 print " be fully qualified with namespace/classname and have full"
73 print " argument information. Also, the 'stack data' section will be" 55 print " argument information. Also, the 'stack data' section will be"
74 print " printed." 56 print " printed."
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 else: 108 else:
127 # This is a zip of Chrome symbols, so symbol.CHROME_SYMBOLS_DIR needs to be 109 # This is a zip of Chrome symbols, so symbol.CHROME_SYMBOLS_DIR needs to be
128 # updated to point here. 110 # updated to point here.
129 symbol.CHROME_SYMBOLS_DIR = symdir 111 symbol.CHROME_SYMBOLS_DIR = symdir
130 return (symdir, symdir) 112 return (symdir, symdir)
131 113
132 114
133 def main(argv): 115 def main(argv):
134 try: 116 try:
135 options, arguments = getopt.getopt(argv, "", 117 options, arguments = getopt.getopt(argv, "",
136 ["packed-relocation-adjustments", 118 ["more-info",
137 "no-packed-relocation-adjustments",
138 "more-info",
139 "less-info", 119 "less-info",
140 "chrome-symbols-dir=", 120 "chrome-symbols-dir=",
141 "chrome-apk-dir=",
142 "symbols-dir=", 121 "symbols-dir=",
143 "symbols-zip=", 122 "symbols-zip=",
144 "arch=", 123 "arch=",
145 "verbose", 124 "verbose",
146 "help"]) 125 "help"])
147 except getopt.GetoptError, unused_error: 126 except getopt.GetoptError, unused_error:
148 PrintUsage() 127 PrintUsage()
149 128
150 zip_arg = None 129 zip_arg = None
151 more_info = False 130 more_info = False
152 chrome_apk_dir = None
153 packed_relocation_adjustments = "unknown"
154 for option, value in options: 131 for option, value in options:
155 if option == "--help": 132 if option == "--help":
156 PrintUsage() 133 PrintUsage()
157 elif option == "--symbols-dir": 134 elif option == "--symbols-dir":
158 symbol.SYMBOLS_DIR = os.path.expanduser(value) 135 symbol.SYMBOLS_DIR = os.path.expanduser(value)
159 elif option == "--symbols-zip": 136 elif option == "--symbols-zip":
160 zip_arg = os.path.expanduser(value) 137 zip_arg = os.path.expanduser(value)
161 elif option == "--arch": 138 elif option == "--arch":
162 symbol.ARCH = value 139 symbol.ARCH = value
163 elif option == "--chrome-symbols-dir": 140 elif option == "--chrome-symbols-dir":
164 symbol.CHROME_SYMBOLS_DIR = os.path.join(symbol.CHROME_SRC, value) 141 symbol.CHROME_SYMBOLS_DIR = os.path.join(symbol.CHROME_SRC, value)
165 elif option == "--chrome-apk-dir":
166 chrome_apk_dir = os.path.join(symbol.CHROME_SRC, value)
167 elif option == "--packed-relocation-adjustments":
168 packed_relocation_adjustments = True
169 elif option == "--no-packed-relocation-adjustments":
170 packed_relocation_adjustments = False
171 elif option == "--more-info": 142 elif option == "--more-info":
172 more_info = True 143 more_info = True
173 elif option == "--less-info": 144 elif option == "--less-info":
174 more_info = False 145 more_info = False
175 elif option == "--verbose": 146 elif option == "--verbose":
176 logging.basicConfig(level=logging.DEBUG) 147 logging.basicConfig(level=logging.DEBUG)
177 148
178 if not chrome_apk_dir:
179 chrome_apk_dir = os.path.join(symbol.CHROME_SYMBOLS_DIR,
180 '..', DEFAULT_APK_DIR)
181
182 if len(arguments) > 1: 149 if len(arguments) > 1:
183 PrintUsage() 150 PrintUsage()
184 151
185 if not arguments or arguments[0] == "-": 152 if not arguments or arguments[0] == "-":
186 print "Reading native crash info from stdin" 153 print "Reading native crash info from stdin"
187 f = sys.stdin 154 f = sys.stdin
188 else: 155 else:
189 print "Searching for native crashes in: " + os.path.realpath(arguments[0]) 156 print "Searching for native crashes in %s" % arguments[0]
190 f = open(arguments[0], "r") 157 f = open(arguments[0], "r")
191 158
192 lines = f.readlines() 159 lines = f.readlines()
193 f.close() 160 f.close()
194 161
195 rootdir = None 162 rootdir = None
196 if zip_arg: 163 if zip_arg:
197 rootdir, symbol.SYMBOLS_DIR = UnzipSymbols(zip_arg) 164 rootdir, symbol.SYMBOLS_DIR = UnzipSymbols(zip_arg)
198 165
199 if packed_relocation_adjustments == "unknown": 166 print "Reading Android symbols from", symbol.SYMBOLS_DIR
200 version = stack_libs.GetTargetAndroidVersionNumber(lines)
201 if version == None:
202 print ("Unknown Android release, "
203 + "consider --[no-]packed-relocation-adjustments options")
204 packed_relocation_adjustments = False
205 elif version >= _ANDROID_M_MAJOR_VERSION:
206 packed_relocation_adjustments = False
207 else:
208 packed_relocation_adjustments = True
209 print ("Pre-M Android release detected, "
210 + "added --packed-relocation-adjustments option")
211
212 if packed_relocation_adjustments:
213 print ("Reading Chrome APK library data from: "
214 + os.path.normpath(chrome_apk_dir))
215 load_vaddrs = stack_libs.GetLoadVaddrs(chrome_apk_dir)
216 else:
217 load_vaddrs = {}
218
219 print ("Reading Android symbols from: "
220 + os.path.normpath(symbol.SYMBOLS_DIR))
221 chrome_search_path = symbol.GetLibrarySearchPaths() 167 chrome_search_path = symbol.GetLibrarySearchPaths()
222 print ("Searching for Chrome symbols from within: " 168 print "Searching for Chrome symbols from within", ':'.join(chrome_search_path)
223 + ':'.join((os.path.normpath(d) for d in chrome_search_path))) 169 stack_core.ConvertTrace(lines, more_info)
224 stack_core.ConvertTrace(lines, load_vaddrs, more_info)
225 170
226 if rootdir: 171 if rootdir:
227 # be a good citizen and clean up...os.rmdir and os.removedirs() don't work 172 # be a good citizen and clean up...os.rmdir and os.removedirs() don't work
228 cmd = "rm -rf \"%s\"" % rootdir 173 cmd = "rm -rf \"%s\"" % rootdir
229 print "\ncleaning up (%s)" % cmd 174 print "\ncleaning up (%s)" % cmd
230 os.system(cmd) 175 os.system(cmd)
231 176
232 if __name__ == "__main__": 177 if __name__ == "__main__":
233 sys.exit(main(sys.argv[1:])) 178 sys.exit(main(sys.argv[1:]))
234 179
235 # vi: ts=2 sw=2 180 # vi: ts=2 sw=2
OLDNEW
« no previous file with comments | « third_party/android_platform/README.chromium ('k') | third_party/android_platform/development/scripts/stack_core.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698