Skip to content

Commit

Permalink
android: Remove the legacy orderfile instrumentation.
Browse files Browse the repository at this point in the history
Bug: 813597
Change-Id: Ie4838ed3b816b483b3b44325f4159856c3b81d4e
Reviewed-on: https://chromium-review.googlesource.com/925424
Reviewed-by: Egor Pasko <pasko@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Matthew Cary <mattcary@chromium.org>
Commit-Queue: Benoit L <lizeb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#538082}
  • Loading branch information
Benoit Lize authored and Commit Bot committed Feb 21, 2018
1 parent ed718f5 commit 5ecdb8c
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 1,259 deletions.
1 change: 0 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ group("gn_all") {
"//tools/android/customtabs_benchmark:customtabs_benchmark_apk",
"//tools/android/errorprone_plugin:errorprone_plugin_java",
"//tools/android/kerberos/SpnegoAuthenticator:spnego_authenticator_apk",
"//tools/cygprofile:cygprofile_unittests",
"//ui/android:ui_junit_tests",
]
deps -= [
Expand Down
4 changes: 2 additions & 2 deletions base/android/library_loader/library_prefetcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ void DumpResidency(size_t start,

// static
bool NativeLibraryPrefetcher::ForkAndPrefetchNativeLibrary() {
// Avoid forking with cygprofile instrumentation because the latter performs
// memory allocations.
#if defined(CYGPROFILE_INSTRUMENTATION)
// Avoid forking with cygprofile instrumentation because the child process
// would create a dump as well.
return false;
#endif

Expand Down
6 changes: 1 addition & 5 deletions build/config/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,7 @@ config("default_cygprofile_instrumentation") {

config("cygprofile_instrumentation") {
defines = [ "CYGPROFILE_INSTRUMENTATION=1" ]
if (use_lightweight_order_profiling) {
cflags = [ "-finstrument-function-entry-bare" ]
} else {
cflags = [ "-finstrument-functions-after-inlining" ]
}
cflags = [ "-finstrument-function-entry-bare" ]
}

config("no_cygprofile_instrumentation") {
Expand Down
5 changes: 0 additions & 5 deletions build/config/android/abi.gni
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ declare_args() {
# functions are called at startup.
use_order_profiling = false

# Use a lightweight variant of order profiling. Does nothing without
# use_order_profiling set above. Will either replace use_order_profiling
# or be removed.
use_lightweight_order_profiling = false

# Builds secondary abi for APKs, supports build 32-bit arch as secondary
# abi in 64-bit Monochrome and WebView.
build_apk_secondary_abi = true
Expand Down
4 changes: 2 additions & 2 deletions chrome/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,8 @@ template("chrome_shared_library") {
deps += [ "//tools/cygprofile" ]
}

# See crbug.com/705088, crbug.com/717815.
if (target_cpu == "arm" && (is_asan || use_order_profiling)) {
# See crbug.com/705088.
if (target_cpu == "arm" && is_asan) {
ldflags = [ "-Wl,--long-plt" ]
}

Expand Down
70 changes: 4 additions & 66 deletions tools/cygprofile/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import("//build/config/android/config.gni")

if (target_cpu == "arm") {
static_library("lightweight_cygprofile") {
static_library("cygprofile") {
sources = [
"delayed_dumper.cc",
"lightweight_cygprofile.cc",
"lightweight_cygprofile.h",
]
Expand All @@ -17,71 +18,8 @@ if (target_cpu == "arm") {
configs -= [ "//build/config/android:default_cygprofile_instrumentation" ]
configs += [ "//build/config/android:no_cygprofile_instrumentation" ]
}
}

static_library("cygprofile") {
deps = [
# This adds uninstrumented symbols to the static library from base.
# These symbols are likely *not* to be used because there are many other
# duplicates in other objects/libraries.
"//base",
]

if (use_lightweight_order_profiling) {
assert(use_order_profiling)
assert(target_cpu == "arm")
sources = [
"delayed_dumper.cc",
]
deps += [ ":lightweight_cygprofile" ]
} else {
sources = [
"cygprofile.cc",
"cygprofile.h",
]
}

configs -= [ "//build/config/android:default_cygprofile_instrumentation" ]
configs += [ "//build/config/android:no_cygprofile_instrumentation" ]
}

executable("cygprofile_unittests") {
testonly = true

sources = [
"cygprofile_unittest.cc",
]

configs -= [ "//build/config/android:default_cygprofile_instrumentation" ]
configs += [ "//build/config/android:no_cygprofile_instrumentation" ]

deps = [
":cygprofile",
"//base",
"//testing/gtest",
]
}

executable("cygprofile_perftests") {
testonly = true

sources = [
"cygprofile_perftest.cc",
]

configs -= [ "//build/config/android:default_cygprofile_instrumentation" ]
configs += [ "//build/config/android:no_cygprofile_instrumentation" ]

deps = [
":cygprofile",
"//base",
"//testing/gtest",
"//testing/perf",
]
}

if (target_cpu == "arm") {
executable("lightweight_cygprofile_perftests") {
executable("cygprofile_perftests") {
testonly = true

sources = [
Expand All @@ -92,7 +30,7 @@ if (target_cpu == "arm") {
configs += [ "//build/config/android:no_cygprofile_instrumentation" ]

deps = [
":lightweight_cygprofile",
":cygprofile",
"//base",
"//testing/gtest",
"//testing/perf",
Expand Down
56 changes: 3 additions & 53 deletions tools/cygprofile/cyglog_to_orderfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import multiprocessing
import os
import re
import string
import sys
import tempfile

Expand Down Expand Up @@ -123,6 +122,7 @@ def _GetAllSymbolInfos(self):
symbol_infos_nested = pool.map(
symbol_extractor.SymbolInfosFromBinary, obj_files)
pool.close()
pool.join()
result = []
for symbol_infos in symbol_infos_nested:
result += symbol_infos
Expand Down Expand Up @@ -201,47 +201,6 @@ def _SymbolsAtOffset(self, offset):
raise _SymbolNotFoundException(offset)


def _ParseLogLines(log_file_lines):
"""Parses a merged cyglog produced by mergetraces.py.
Args:
log_file_lines: array of lines in log file produced by profiled run
Below is an example of a small log file:
5086e000-52e92000 r-xp 00000000 b3:02 51276 libchromeview.so
secs usecs pid:threadid func
START
1314897086 795828 3587:1074648168 0x509e105c
1314897086 795874 3587:1074648168 0x509e0eb4
1314897086 796326 3587:1074648168 0x509e0e3c
1314897086 796552 3587:1074648168 0x509e07bc
END
Returns:
An ordered list of callee offsets.
"""
call_lines = []
vm_start = 0
line = log_file_lines[0]
assert 'r-xp' in line
end_index = line.find('-')
vm_start = int(line[:end_index], 16)
for line in log_file_lines[3:]:
fields = line.split()
if len(fields) == 4:
call_lines.append(fields)
else:
assert fields[0] == 'END'
# Convert strings to int in fields.
call_info = []
for call_line in call_lines:
addr = int(call_line[3], 16)
if vm_start < addr:
addr -= vm_start
call_info.append(addr)
return call_info


def _WarnAboutDuplicates(offsets):
"""Warns about duplicate offsets.
Expand Down Expand Up @@ -275,9 +234,7 @@ def _CreateArgumentParser():
parser.add_argument('--target-arch', required=False,
choices=['arm', 'arm64', 'x86', 'x86_64', 'x64', 'mips'],
help='The target architecture for libchrome.so')
parser.add_argument('--merged-cyglog', type=str, required=False,
help='Path to the merged cyglog')
parser.add_argument('--reached-offsets', type=str, required=False,
parser.add_argument('--reached-offsets', type=str, required=True,
help='Path to the reached offsets')
parser.add_argument('--native-library', type=str, required=True,
help='Path to the unstripped instrumented library')
Expand All @@ -290,20 +247,13 @@ def main():
parser = _CreateArgumentParser()
args = parser.parse_args()

assert bool(args.merged_cyglog) ^ bool(args.reached_offsets)

if not args.target_arch:
args.arch = cygprofile_utils.DetectArchitecture()
symbol_extractor.SetArchitecture(args.target_arch)

obj_dir = cygprofile_utils.GetObjDir(args.native_library)

offsets = []
if args.merged_cyglog:
log_file_lines = map(string.rstrip, open(args.merged_cyglog).readlines())
offsets = _ParseLogLines(log_file_lines)
else:
offsets = _ReadReachedOffsets(args.reached_offsets)
offsets = _ReadReachedOffsets(args.reached_offsets)
assert offsets
_WarnAboutDuplicates(offsets)

Expand Down
11 changes: 0 additions & 11 deletions tools/cygprofile/cyglog_to_orderfile_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,6 @@ def assertDictWithUnorderedListEqual(self, expected, observed):
if failure_items:
raise self.failureException('\n'.join(failure_items))

def testParseLogLines(self):
lines = """5086e000-52e92000 r-xp 00000000 b3:02 51276 libchromeview.so
secs usecs pid:threadid func
START
1314897086 795828 3587:1074648168 0x509e105c
1314897086 795874 3587:1074648168 0x509e0eb4
END""".split('\n')
offsets = cyglog_to_orderfile._ParseLogLines(lines)
self.assertListEqual(
offsets, [0x509e105c - 0x5086e000, 0x509e0eb4 - 0x5086e000])

def testWarnAboutDuplicates(self):
offsets = [0x1, 0x2, 0x3]
self.assertTrue(cyglog_to_orderfile._WarnAboutDuplicates(offsets))
Expand Down
Loading

0 comments on commit 5ecdb8c

Please sign in to comment.