Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | |
| 26 import subprocess | 27 import subprocess |
| 27 import symbol | 28 import symbol |
| 28 import sys | 29 import sys |
| 29 | 30 |
| 30 DEFAULT_SYMROOT='/tmp/symbols' | 31 DEFAULT_SYMROOT='/tmp/symbols' |
| 32 DEFAULT_APK='chrome_apk' | |
| 31 | 33 |
| 32 def PrintUsage(): | 34 def PrintUsage(): |
| 33 """Print usage and exit with error.""" | 35 """Print usage and exit with error.""" |
| 34 # pylint: disable-msg=C6310 | 36 # pylint: disable-msg=C6310 |
| 35 print | 37 print |
| 36 print " usage: " + sys.argv[0] + " [options] [FILE]" | 38 print " usage: " + sys.argv[0] + " [options] [FILE]" |
| 37 print | 39 print |
| 38 print " --symbols-dir=path" | 40 print " --symbols-dir=path" |
| 39 print " the path to a symbols dir, such as =/tmp/out/target/product/drea m/symbols" | 41 print " the path to a symbols dir, such as =/tmp/out/target/product/drea m/symbols" |
| 40 print | 42 print |
| 41 print " --chrome-symbols-dir=path" | 43 print " --chrome-symbols-dir=path" |
| 42 print " the path to a Chrome symbols dir (can be absolute or relative" | 44 print " the path to a Chrome symbols dir (can be absolute or relative" |
| 43 print " to src), such as =out/Debug/lib" | 45 print " to src), such as =out/Debug/lib" |
| 44 print " If not specified, will look for the newest lib in out/Debug or" | 46 print " If not specified, will look for the newest lib in out/Debug or" |
| 45 print " out/Release" | 47 print " out/Release" |
| 46 print | 48 print |
| 49 print " --packed-relocation-adjustments" | |
| 50 print " --no-packed-relocation-adjustments" | |
| 51 print " turn packed relocation adjustment on and off (default is off)" | |
| 52 print " If running on pre-M Android and the stack trace appears to" | |
| 53 print " make no sense, try turning this feature on." | |
| 54 print | |
| 55 print " --chrome-apk-dir=path" | |
| 56 print " the path to the APK staging dir (can be absolute or relative" | |
| 57 print " to src), such as =out/Debug/chrome_apk" | |
| 58 print " If not specified, uses =|chrome-symbols-dir|/../chrome_apk" | |
| 59 print " Parses libraries here to find data for adjusting debuggerd" | |
| 60 print " tombstones where relocations are packed." | |
| 61 print " Enable/disable with --[no-]packed-relocation-adjustments." | |
| 62 print | |
| 47 print " --symbols-zip=path" | 63 print " --symbols-zip=path" |
| 48 print " the path to a symbols zip file, such as =dream-symbols-12345.zip " | 64 print " the path to a symbols zip file, such as =dream-symbols-12345.zip " |
| 49 print | 65 print |
| 50 print " --more-info" | 66 print " --more-info" |
| 51 print " --less-info" | 67 print " --less-info" |
| 52 print " Change the level of detail in the output." | 68 print " Change the level of detail in the output." |
| 53 print " --more-info is slower and more verbose, but more functions will" | 69 print " --more-info is slower and more verbose, but more functions will" |
| 54 print " be fully qualified with namespace/classname and have full" | 70 print " be fully qualified with namespace/classname and have full" |
| 55 print " argument information. Also, the 'stack data' section will be" | 71 print " argument information. Also, the 'stack data' section will be" |
| 56 print " printed." | 72 print " printed." |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 else: | 124 else: |
| 109 # This is a zip of Chrome symbols, so symbol.CHROME_SYMBOLS_DIR needs to be | 125 # This is a zip of Chrome symbols, so symbol.CHROME_SYMBOLS_DIR needs to be |
| 110 # updated to point here. | 126 # updated to point here. |
| 111 symbol.CHROME_SYMBOLS_DIR = symdir | 127 symbol.CHROME_SYMBOLS_DIR = symdir |
| 112 return (symdir, symdir) | 128 return (symdir, symdir) |
| 113 | 129 |
| 114 | 130 |
| 115 def main(argv): | 131 def main(argv): |
| 116 try: | 132 try: |
| 117 options, arguments = getopt.getopt(argv, "", | 133 options, arguments = getopt.getopt(argv, "", |
| 118 ["more-info", | 134 ["packed-relocation-adjustments", |
| 135 "no-packed-relocation-adjustments", | |
|
rmcilroy
2015/10/23 16:25:10
Do we really need no-packed-relocation-adjustments
simonb (inactive)
2015/10/26 12:38:31
We don't *need* it. It's here for symmetry with th
rmcilroy
2015/10/26 16:42:17
I'm not convinced the symmetry adds anything, even
simonb (inactive)
2015/10/27 11:12:27
Now useful as a way to override any state that may
| |
| 136 "more-info", | |
| 119 "less-info", | 137 "less-info", |
| 120 "chrome-symbols-dir=", | 138 "chrome-symbols-dir=", |
| 139 "chrome-apk-dir=", | |
| 121 "symbols-dir=", | 140 "symbols-dir=", |
| 122 "symbols-zip=", | 141 "symbols-zip=", |
| 123 "arch=", | 142 "arch=", |
| 124 "verbose", | 143 "verbose", |
| 125 "help"]) | 144 "help"]) |
| 126 except getopt.GetoptError, unused_error: | 145 except getopt.GetoptError, unused_error: |
| 127 PrintUsage() | 146 PrintUsage() |
| 128 | 147 |
| 129 zip_arg = None | 148 zip_arg = None |
| 130 more_info = False | 149 more_info = False |
| 150 chrome_apk_dir = symbol.CHROME_SYMBOLS_DIR | |
| 151 chrome_apk_dir_supplied = False | |
| 152 packed_relocation_adjustments = False | |
| 131 for option, value in options: | 153 for option, value in options: |
| 132 if option == "--help": | 154 if option == "--help": |
| 133 PrintUsage() | 155 PrintUsage() |
| 134 elif option == "--symbols-dir": | 156 elif option == "--symbols-dir": |
| 135 symbol.SYMBOLS_DIR = os.path.expanduser(value) | 157 symbol.SYMBOLS_DIR = os.path.expanduser(value) |
| 136 elif option == "--symbols-zip": | 158 elif option == "--symbols-zip": |
| 137 zip_arg = os.path.expanduser(value) | 159 zip_arg = os.path.expanduser(value) |
| 138 elif option == "--arch": | 160 elif option == "--arch": |
| 139 symbol.ARCH = value | 161 symbol.ARCH = value |
| 140 elif option == "--chrome-symbols-dir": | 162 elif option == "--chrome-symbols-dir": |
| 141 symbol.CHROME_SYMBOLS_DIR = os.path.join(symbol.CHROME_SYMBOLS_DIR, value) | 163 symbol.CHROME_SYMBOLS_DIR = os.path.join(symbol.CHROME_SYMBOLS_DIR, value) |
| 164 elif option == "--chrome-apk-dir": | |
| 165 chrome_apk_dir = os.path.join(chrome_apk_dir, value) | |
| 166 chrome_apk_dir_supplied = True | |
| 167 elif option == "--packed-relocation-adjustments": | |
| 168 packed_relocation_adjustments = True | |
| 169 elif option == "--no-packed-relocation-adjustments": | |
| 170 packed_relocation_adjustments = False | |
| 142 elif option == "--more-info": | 171 elif option == "--more-info": |
| 143 more_info = True | 172 more_info = True |
| 144 elif option == "--less-info": | 173 elif option == "--less-info": |
| 145 more_info = False | 174 more_info = False |
| 146 elif option == "--verbose": | 175 elif option == "--verbose": |
| 147 logging.basicConfig(level=logging.DEBUG) | 176 logging.basicConfig(level=logging.DEBUG) |
| 148 | 177 |
| 178 if not chrome_apk_dir_supplied: | |
| 179 chrome_apk_dir = os.path.join(symbol.CHROME_SYMBOLS_DIR, '..', DEFAULT_APK) | |
|
rmcilroy
2015/10/23 16:25:10
nit - just make should chrome_apk_dir be chrome_ap
simonb (inactive)
2015/10/26 12:38:31
Again, symmetry. In this case with the existing --
rmcilroy
2015/10/26 16:42:17
dir is fine - my confusion stemed from the fact th
simonb (inactive)
2015/10/27 11:12:27
Done
| |
| 180 | |
| 149 if len(arguments) > 1: | 181 if len(arguments) > 1: |
| 150 PrintUsage() | 182 PrintUsage() |
| 151 | 183 |
| 152 if not arguments or arguments[0] == "-": | 184 if not arguments or arguments[0] == "-": |
| 153 print "Reading native crash info from stdin" | 185 print "Reading native crash info from stdin" |
| 154 f = sys.stdin | 186 f = sys.stdin |
| 155 else: | 187 else: |
| 156 print "Searching for native crashes in %s" % arguments[0] | 188 print "Searching for native crashes in: " + os.path.realpath(arguments[0]) |
| 157 f = open(arguments[0], "r") | 189 f = open(arguments[0], "r") |
| 158 | 190 |
| 159 lines = f.readlines() | 191 lines = f.readlines() |
| 160 f.close() | 192 f.close() |
| 161 | 193 |
| 162 rootdir = None | 194 rootdir = None |
| 163 if zip_arg: | 195 if zip_arg: |
| 164 rootdir, symbol.SYMBOLS_DIR = UnzipSymbols(zip_arg) | 196 rootdir, symbol.SYMBOLS_DIR = UnzipSymbols(zip_arg) |
| 165 | 197 |
| 166 print "Reading Android symbols from", symbol.SYMBOLS_DIR | 198 if packed_relocation_adjustments: |
| 167 print "Reading Chrome symbols from", symbol.CHROME_SYMBOLS_DIR | 199 print ("Reading Chrome APK library data from: " |
| 168 stack_core.ConvertTrace(lines, more_info) | 200 + os.path.normpath(chrome_apk_dir)) |
| 201 load_vaddrs = stack_libs.GetLoadVaddrs(chrome_apk_dir) | |
| 202 else: | |
| 203 load_vaddrs = {} | |
| 204 | |
| 205 print ("Reading Android symbols from: " | |
| 206 + os.path.normpath(symbol.SYMBOLS_DIR)) | |
| 207 print ("Reading Chrome symbols from: " | |
| 208 + os.path.normpath(symbol.CHROME_SYMBOLS_DIR)) | |
| 209 stack_core.ConvertTrace(lines, load_vaddrs, more_info) | |
| 169 | 210 |
| 170 if rootdir: | 211 if rootdir: |
| 171 # be a good citizen and clean up...os.rmdir and os.removedirs() don't work | 212 # be a good citizen and clean up...os.rmdir and os.removedirs() don't work |
| 172 cmd = "rm -rf \"%s\"" % rootdir | 213 cmd = "rm -rf \"%s\"" % rootdir |
| 173 print "\ncleaning up (%s)" % cmd | 214 print "\ncleaning up (%s)" % cmd |
| 174 os.system(cmd) | 215 os.system(cmd) |
| 175 | 216 |
| 176 if __name__ == "__main__": | 217 if __name__ == "__main__": |
| 177 sys.exit(main(sys.argv[1:])) | 218 sys.exit(main(sys.argv[1:])) |
| 178 | 219 |
| 179 # vi: ts=2 sw=2 | 220 # vi: ts=2 sw=2 |
| OLD | NEW |