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

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

Issue 164113003: [Android] Use fast ELF symbolizer for symbols.py and tombstones. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mi_sym
Patch Set: Created 6 years, 10 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 | 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 9eb248493419e9513d20ddee881bfdf6b92587d3..04822aeea44bb6c42bddcc926856360225b284e1 100755
--- a/third_party/android_platform/development/scripts/symbol.py
+++ b/third_party/android_platform/development/scripts/symbol.py
@@ -21,6 +21,7 @@ The information can include symbol names, offsets, and source locations.
import os
import re
+import sys
import subprocess
CHROME_SRC = os.path.join(os.path.realpath(os.path.dirname(__file__)),
@@ -33,6 +34,9 @@ ARCH = "arm"
TOOLCHAIN_INFO = None
+sys.path.insert(0, os.path.join(CHROME_SRC, 'build', 'android'))
+from pylib.symbols import elf_symbolizer
+
def Uname():
"""'uname' for constructing prebuilt/<...> and out/host/<...> paths."""
uname = os.uname()[0]
@@ -240,42 +244,34 @@ def CallAddr2LineForSet(lib, unique_addrs):
if not lib:
return None
-
symbols = SYMBOLS_DIR + lib
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:
+ 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 | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698