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

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

Issue 1006603002: Fix stack tool for library in apk crashes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 #
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 os 22 import os
22 import sys 23 import sys
23 24
24 import stack_core 25 import stack_core
25 import subprocess 26 import subprocess
26 import symbol 27 import symbol
27 import sys 28 import sys
28 29
29 DEFAULT_SYMROOT='/tmp/symbols' 30 DEFAULT_SYMROOT='/tmp/symbols'
30 31
(...skipping 19 matching lines...) Expand all
50 print " --less-info" 51 print " --less-info"
51 print " Change the level of detail in the output." 52 print " Change the level of detail in the output."
52 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"
53 print " be fully qualified with namespace/classname and have full" 54 print " be fully qualified with namespace/classname and have full"
54 print " argument information. Also, the 'stack data' section will be" 55 print " argument information. Also, the 'stack data' section will be"
55 print " printed." 56 print " printed."
56 print 57 print
57 print " --arch=arm|arm64|x64|x86|mips" 58 print " --arch=arm|arm64|x64|x86|mips"
58 print " the target architecture" 59 print " the target architecture"
59 print 60 print
61 print " --verbose"
62 print " enable extra logging, particularly for debugging failed symboliz ation"
63 print
60 print " FILE should contain a stack trace in it somewhere" 64 print " FILE should contain a stack trace in it somewhere"
61 print " the tool will find that and re-print it with" 65 print " the tool will find that and re-print it with"
62 print " source files and line numbers. If you don't" 66 print " source files and line numbers. If you don't"
63 print " pass FILE, or if file is -, it reads from" 67 print " pass FILE, or if file is -, it reads from"
64 print " stdin." 68 print " stdin."
65 print 69 print
66 # pylint: enable-msg=C6310 70 # pylint: enable-msg=C6310
67 sys.exit(1) 71 sys.exit(1)
68 72
69 def UnzipSymbols(symbolfile, symdir=None): 73 def UnzipSymbols(symbolfile, symdir=None):
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 android_symbols = glob.glob("%s/out/target/product/*/symbols" % symdir) 105 android_symbols = glob.glob("%s/out/target/product/*/symbols" % symdir)
102 if android_symbols: 106 if android_symbols:
103 return (symdir, android_symbols[0]) 107 return (symdir, android_symbols[0])
104 else: 108 else:
105 # 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
106 # updated to point here. 110 # updated to point here.
107 symbol.CHROME_SYMBOLS_DIR = symdir 111 symbol.CHROME_SYMBOLS_DIR = symdir
108 return (symdir, symdir) 112 return (symdir, symdir)
109 113
110 114
111 def main(): 115 def main(argv):
112 try: 116 try:
113 options, arguments = getopt.getopt(sys.argv[1:], "", 117 options, arguments = getopt.getopt(argv, "",
114 ["more-info", 118 ["more-info",
115 "less-info", 119 "less-info",
116 "chrome-symbols-dir=", 120 "chrome-symbols-dir=",
117 "symbols-dir=", 121 "symbols-dir=",
118 "symbols-zip=", 122 "symbols-zip=",
119 "arch=", 123 "arch=",
124 "verbose",
120 "help"]) 125 "help"])
121 except getopt.GetoptError, unused_error: 126 except getopt.GetoptError, unused_error:
122 PrintUsage() 127 PrintUsage()
123 128
124 zip_arg = None 129 zip_arg = None
125 more_info = False 130 more_info = False
126 for option, value in options: 131 for option, value in options:
127 if option == "--help": 132 if option == "--help":
128 PrintUsage() 133 PrintUsage()
129 elif option == "--symbols-dir": 134 elif option == "--symbols-dir":
130 symbol.SYMBOLS_DIR = os.path.expanduser(value) 135 symbol.SYMBOLS_DIR = os.path.expanduser(value)
131 elif option == "--symbols-zip": 136 elif option == "--symbols-zip":
132 zip_arg = os.path.expanduser(value) 137 zip_arg = os.path.expanduser(value)
133 elif option == "--arch": 138 elif option == "--arch":
134 symbol.ARCH = value 139 symbol.ARCH = value
135 elif option == "--chrome-symbols-dir": 140 elif option == "--chrome-symbols-dir":
136 symbol.CHROME_SYMBOLS_DIR = os.path.join(symbol.CHROME_SYMBOLS_DIR, value) 141 symbol.CHROME_SYMBOLS_DIR = os.path.join(symbol.CHROME_SYMBOLS_DIR, value)
137 elif option == "--more-info": 142 elif option == "--more-info":
138 more_info = True 143 more_info = True
139 elif option == "--less-info": 144 elif option == "--less-info":
140 more_info = False 145 more_info = False
146 elif option == "--verbose":
147 logging.basicConfig(level=logging.DEBUG)
141 148
142 if len(arguments) > 1: 149 if len(arguments) > 1:
143 PrintUsage() 150 PrintUsage()
144 151
145 if not arguments or arguments[0] == "-": 152 if not arguments or arguments[0] == "-":
146 print "Reading native crash info from stdin" 153 print "Reading native crash info from stdin"
147 f = sys.stdin 154 f = sys.stdin
148 else: 155 else:
149 print "Searching for native crashes in %s" % arguments[0] 156 print "Searching for native crashes in %s" % arguments[0]
150 f = open(arguments[0], "r") 157 f = open(arguments[0], "r")
151 158
152 lines = f.readlines() 159 lines = f.readlines()
153 f.close() 160 f.close()
154 161
155 rootdir = None 162 rootdir = None
156 if zip_arg: 163 if zip_arg:
157 rootdir, symbol.SYMBOLS_DIR = UnzipSymbols(zip_arg) 164 rootdir, symbol.SYMBOLS_DIR = UnzipSymbols(zip_arg)
158 165
159 print "Reading Android symbols from", symbol.SYMBOLS_DIR 166 print "Reading Android symbols from", symbol.SYMBOLS_DIR
160 print "Reading Chrome symbols from", symbol.CHROME_SYMBOLS_DIR 167 print "Reading Chrome symbols from", symbol.CHROME_SYMBOLS_DIR
161 stack_core.ConvertTrace(lines, more_info) 168 stack_core.ConvertTrace(lines, more_info)
162 169
163 if rootdir: 170 if rootdir:
164 # be a good citizen and clean up...os.rmdir and os.removedirs() don't work 171 # be a good citizen and clean up...os.rmdir and os.removedirs() don't work
165 cmd = "rm -rf \"%s\"" % rootdir 172 cmd = "rm -rf \"%s\"" % rootdir
166 print "\ncleaning up (%s)" % cmd 173 print "\ncleaning up (%s)" % cmd
167 os.system(cmd) 174 os.system(cmd)
168 175
169 if __name__ == "__main__": 176 if __name__ == "__main__":
170 main() 177 sys.exit(main(sys.argv[1:]))
171 178
172 # vi: ts=2 sw=2 179 # 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