Skip to content

Commit

Permalink
Make it easier to debug failed symbolization
Browse files Browse the repository at this point in the history
This just adds a --verbose argument and some debug logging sprinkled in
useful places.

Adds '.' as a candidate directory for libraries (gn puts shared
libraries at the root build directory).

Review URL: https://codereview.chromium.org/646683002

Cr-Commit-Position: refs/heads/master@{#298952}
  • Loading branch information
cjhopman authored and Commit bot committed Oct 9, 2014
1 parent 6ba7355 commit 17ffc51
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
6 changes: 6 additions & 0 deletions third_party/android_platform/README.chromium
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ glue layer against.

Local Modifications:
Only picked the few scripts needed by chrome.

The scripts have been modified to better suit Chromium development. Changes
include, but are not limited to, the following:
Added memoization of addr2line and objdump.
Added option to change the amount of symbolization done.
Updated output directories to use environment variable.
When calling addr2line, check the symbol is a file (and not a directory).
Added support for parsing LOG(FATAL) and DCHECK errors and their
stack traces, as emitted by src/base/debug/stack_trace_android.cc
Added support for finding symbols when library is loaded directly from the APK.
Added debug logging and --verbose parameter.
13 changes: 10 additions & 3 deletions third_party/android_platform/development/scripts/stack
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import getopt
import glob
import logging
import os
import sys

Expand Down Expand Up @@ -57,6 +58,9 @@ def PrintUsage():
print " --arch=arm|arm64|x86_64|x86|mips"
print " the target architecture"
print
print " --verbose"
print " enable extra logging, particularly for debugging failed symbolization"
print
print " FILE should contain a stack trace in it somewhere"
print " the tool will find that and re-print it with"
print " source files and line numbers. If you don't"
Expand Down Expand Up @@ -108,15 +112,16 @@ def UnzipSymbols(symbolfile, symdir=None):
return (symdir, symdir)


def main():
def main(argv):
try:
options, arguments = getopt.getopt(sys.argv[1:], "",
options, arguments = getopt.getopt(argv, "",
["more-info",
"less-info",
"chrome-symbols-dir=",
"symbols-dir=",
"symbols-zip=",
"arch=",
"verbose",
"help"])
except getopt.GetoptError, unused_error:
PrintUsage()
Expand All @@ -138,6 +143,8 @@ def main():
more_info = True
elif option == "--less-info":
more_info = False
elif option == "--verbose":
logging.basicConfig(level=logging.DEBUG)

if len(arguments) > 1:
PrintUsage()
Expand Down Expand Up @@ -167,6 +174,6 @@ def main():
os.system(cmd)

if __name__ == "__main__":
main()
sys.exit(main(sys.argv[1:]))

# vi: ts=2 sw=2
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

"""stack symbolizes native crash dumps."""

import logging
import re

import symbol
Expand Down Expand Up @@ -192,6 +193,7 @@ def ConvertTrace(lines, more_info):
if match:
frame, code_addr, area, symbol_present, symbol_name = match.group(
'frame', 'address', 'lib', 'symbol_present', 'symbol_name')
logging.debug('Found trace line: %s' % line.strip())

if frame <= last_frame and (trace_lines or value_lines):
PrintOutput(trace_lines, value_lines, more_info)
Expand All @@ -203,9 +205,11 @@ def ConvertTrace(lines, more_info):
if area == UNKNOWN or area == HEAP or area == STACK:
trace_lines.append((code_addr, "", area))
else:
logging.debug('Identified lib: %s' % area)
# If a calls b which further calls c and c is inlined to b, we want to
# display "a -> b -> c" in the stack trace instead of just "a -> c"
info = symbol.SymbolInformation(area, code_addr, more_info)
logging.debug('symbol information: %s' % info)
nest_count = len(info) - 1
for (source_symbol, source_location, object_symbol_with_offset) in info:
if not source_symbol:
Expand Down
8 changes: 7 additions & 1 deletion third_party/android_platform/development/scripts/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import glob
import itertools
import logging
import os
import re
import subprocess
Expand Down Expand Up @@ -208,6 +209,7 @@ def GetCandidates(dirs, filepart, candidate_fun):
candidates = PathListJoin([out_dir], buildtype_list) + [CHROME_SYMBOLS_DIR]
candidates = PathListJoin(candidates, dirs)
candidates = PathListJoin(candidates, [filepart])
logging.debug('GetCandidates: prefiltered candidates = %s' % candidates)
candidates = list(
itertools.chain.from_iterable(map(candidate_fun, candidates)))
candidates = sorted(candidates, key=os.path.getmtime, reverse=True)
Expand Down Expand Up @@ -282,7 +284,7 @@ def GetCandidateLibraries(library_name):
A list of matching library filenames for library_name.
"""
return GetCandidates(
['lib', 'lib.target'], library_name,
['lib', 'lib.target', '.'], library_name,
lambda filename: filter(os.path.exists, [filename]))

def TranslateLibPath(lib):
Expand All @@ -306,11 +308,15 @@ def TranslateLibPath(lib):
if mapping:
library_name = mapping

logging.debug('TranslateLibPath: lib=%s library_name=%s' % (lib, library_name))

candidate_libraries = GetCandidateLibraries(library_name)
logging.debug('TranslateLibPath: candidate_libraries=%s' % candidate_libraries)
if not candidate_libraries:
return lib

library_path = os.path.relpath(candidate_libraries[0], SYMBOLS_DIR)
logging.debug('TranslateLibPath: library_path=%s' % library_path)
return '/' + library_path

def SymbolInformation(lib, addr, get_detailed_info):
Expand Down

0 comments on commit 17ffc51

Please sign in to comment.