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

Unified Diff: third_party/android_platform/development/scripts/symbol.py

Issue 1304873010: Use fast ELF symbolizer for symbols.py and tombstones (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove the empty line added in patchset2 Created 5 years, 3 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 | « third_party/android_platform/README.chromium ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/android_platform/development/scripts/symbol.py
diff --git a/third_party/android_platform/development/scripts/symbol.py b/third_party/android_platform/development/scripts/symbol.py
index 4cde7d965afa27a0a5fe33fe928e8804fd4b92c2..b72253d63134446653e9db89dc97ddd6a8518394 100755
--- a/third_party/android_platform/development/scripts/symbol.py
+++ b/third_party/android_platform/development/scripts/symbol.py
@@ -26,6 +26,7 @@ import os
import re
import struct
import subprocess
+import sys
import zipfile
CHROME_SRC = os.path.join(os.path.realpath(os.path.dirname(__file__)),
@@ -38,6 +39,9 @@ ARCH = "arm"
TOOLCHAIN_INFO = None
+sys.path.insert(0, os.path.join(CHROME_SRC, 'build', 'android'))
+from pylib.symbols import elf_symbolizer
+
# See:
# http://bugs.python.org/issue14315
# https://hg.python.org/cpython/rev/6dd5e9556a60#l2.8
@@ -450,7 +454,6 @@ def CallAddr2LineForSet(lib, unique_addrs):
if not lib:
return None
-
symbols = SYMBOLS_DIR + lib
if not os.path.splitext(symbols)[1] in ['', '.so', '.apk']:
return None
@@ -458,37 +461,30 @@ def CallAddr2LineForSet(lib, unique_addrs):
if not os.path.isfile(symbols):
return None
- (label, platform, target) = FindToolchain()
- cmd = [ToolPath("addr2line"), "--functions", "--inlines",
- "--demangle", "--exe=" + symbols]
- child = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
-
- result = {}
addrs = sorted(unique_addrs)
- for addr in addrs:
- child.stdin.write("0x%s\n" % addr)
- child.stdin.flush()
+ result = {}
+
+ def _Callback(sym, addr):
records = []
- first = True
- while True:
- symbol = child.stdout.readline().strip()
- if symbol == "??":
- symbol = None
- location = child.stdout.readline().strip()
- if location == "??:0":
+ while sym: # Traverse all the inlines following the |inlined_by| chain.
+ if sym.source_path and sym.source_line:
+ location = '%s:%d' % (sym.source_path, sym.source_line)
+ else:
location = None
- if symbol is None and location is None:
- break
- records.append((symbol, location))
- if first:
- # Write a blank line as a sentinel so we know when to stop
- # reading inlines from the output.
- # The blank line will cause addr2line to emit "??\n??:0\n".
- child.stdin.write("\n")
- first = False
+ records += [(sym.name, location)]
+ sym = sym.inlined_by
result[addr] = records
- child.stdin.close()
- child.stdout.close()
+
+ (label, platform, target) = FindToolchain()
+ symbolizer = elf_symbolizer.ELFSymbolizer(
+ elf_file_path=symbols,
+ addr2line_path=ToolPath("addr2line"),
+ callback=_Callback,
+ inlines=True)
+
+ for addr in addrs:
+ symbolizer.SymbolizeAsync(int(addr, 16), addr)
+ symbolizer.Join()
return result
« no previous file with comments | « third_party/android_platform/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698