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

Unified Diff: third_party/android_platform/development/scripts/stack

Issue 18715002: Android: apply some optimizations to the stack symbolization tools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/android_platform/development/scripts/stack_core.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/android_platform/development/scripts/stack
diff --git a/third_party/android_platform/development/scripts/stack b/third_party/android_platform/development/scripts/stack
index 6bb8d0acb2f71f7ed6f5546243c20ca514a0eb8a..758c412cb7507ce0208a644f8f8c3a7c581b8b48 100755
--- a/third_party/android_platform/development/scripts/stack
+++ b/third_party/android_platform/development/scripts/stack
@@ -17,11 +17,14 @@
"""stack symbolizes native crash dumps."""
import getopt
+import glob
+import os
import sys
import stack_core
+import subprocess
import symbol
-
+import sys
def PrintUsage():
"""Print usage and exit with error."""
@@ -29,6 +32,26 @@ def PrintUsage():
print
print " usage: " + sys.argv[0] + " [options] [FILE]"
print
+ print " --symbols-dir=path"
+ print " the path to a symbols dir, such as =/tmp/out/target/product/dream/symbols"
+ print
+ print " --chrome-symbols-dir=path"
+ print " the path to a Chrome symbols dir (can be absolute or relative"
+ print " to src), such as =out/Debug/lib"
+ print " If not specified, will look for the newest lib in out/Debug or"
+ print " out/Release"
+ print
+ print " --symbols-zip=path"
+ print " the path to a symbols zip file, such as =dream-symbols-12345.zip"
+ print
+ print " --more-info"
+ print " --less-info"
+ print " Change the level of detail in the output."
+ print " --more-info is slower and more verbose, but more functions will"
+ print " be fully qualified with namespace/classname and have full"
+ print " argument information. Also, the 'stack data' section will be"
+ print " printed."
+ print
print " --arch=arm|x86"
print " the target architecture"
print
@@ -41,20 +64,78 @@ def PrintUsage():
# pylint: enable-msg=C6310
sys.exit(1)
+def UnzipSymbols(symbolfile, symdir=None):
+ """Unzips a file to DEFAULT_SYMROOT and returns the unzipped location.
+
+ Args:
+ symbolfile: The .zip file to unzip
+ symdir: Optional temporary directory to use for extraction
+
+ Returns:
+ A tuple containing (the directory into which the zip file was unzipped,
+ the path to the "symbols" directory in the unzipped file). To clean
+ up, the caller can delete the first element of the tuple.
+
+ Raises:
+ SymbolDownloadException: When the unzip fails.
+ """
+ if not symdir:
+ symdir = "%s/%s" % (DEFAULT_SYMROOT, hash(symbolfile))
+ if not os.path.exists(symdir):
+ os.makedirs(symdir)
+
+ print "extracting %s..." % symbolfile
+ saveddir = os.getcwd()
+ os.chdir(symdir)
+ try:
+ unzipcode = subprocess.call(["unzip", "-qq", "-o", symbolfile])
+ if unzipcode > 0:
+ os.remove(symbolfile)
+ raise SymbolDownloadException("failed to extract symbol files (%s)."
+ % symbolfile)
+ finally:
+ os.chdir(saveddir)
+
+ android_symbols = glob.glob("%s/out/target/product/*/symbols" % symdir)
+ if android_symbols:
+ return (symdir, android_symbols[0])
+ else:
+ # This is a zip of Chrome symbols, so symbol.CHROME_SYMBOLS_DIR needs to be
+ # updated to point here.
+ symbol.CHROME_SYMBOLS_DIR = symdir
+ return (symdir, symdir)
+
def main():
try:
options, arguments = getopt.getopt(sys.argv[1:], "",
- ["arch=",
+ ["more-info",
+ "less-info",
+ "chrome-symbols-dir=",
+ "symbols-dir=",
+ "symbols-zip=",
+ "arch=",
"help"])
except getopt.GetoptError, unused_error:
PrintUsage()
+ zip_arg = None
+ more_info = False
for option, value in options:
if option == "--help":
PrintUsage()
+ elif option == "--symbols-dir":
+ symbol.SYMBOLS_DIR = os.path.expanduser(value)
+ elif option == "--symbols-zip":
+ zip_arg = os.path.expanduser(value)
elif option == "--arch":
symbol.ARCH = value
+ elif option == "--chrome-symbols-dir":
+ symbol.CHROME_SYMBOLS_DIR = os.path.join(symbol.CHROME_SYMBOLS_DIR, value)
+ elif option == "--more-info":
+ more_info = True
+ elif option == "--less-info":
+ more_info = False
if len(arguments) > 1:
PrintUsage()
@@ -69,8 +150,19 @@ def main():
lines = f.readlines()
f.close()
- print "Reading symbols from", symbol.SYMBOLS_DIR
- stack_core.ConvertTrace(lines)
+ rootdir = None
+ if zip_arg:
+ rootdir, symbol.SYMBOLS_DIR = UnzipSymbols(zip_arg)
+
+ print "Reading Android symbols from", symbol.SYMBOLS_DIR
+ print "Reading Chrome symbols from", symbol.CHROME_SYMBOLS_DIR
+ stack_core.ConvertTrace(lines, more_info)
+
+ if rootdir:
+ # be a good citizen and clean up...os.rmdir and os.removedirs() don't work
+ cmd = "rm -rf \"%s\"" % rootdir
+ print "\ncleaning up (%s)" % cmd
+ os.system(cmd)
if __name__ == "__main__":
main()
« no previous file with comments | « no previous file | third_party/android_platform/development/scripts/stack_core.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698