summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2017-05-03 14:46:55 -0700
committerYabin Cui <yabinc@google.com>2017-05-03 14:56:08 -0700
commitcbddd3829b6cf125340d1795f04931a5c8ff83ef (patch)
tree13b58af79f2477978c3bef37ebb349d350f14c60
parentc248f1f76182d7f5bf7f8d0a5432b4a7bc2befd2 (diff)
downloadextras-cbddd3829b6cf125340d1795f04931a5c8ff83ef.tar.gz
simpleperf: fix scripts on windows.
1. Fix handling windows path like C:\xxx. 2. Fix adding windows executable suffix. 3. Fix one indent error in annotate.py. 4. Collect libwinpthread-1.dll in update.py. 5. simpleperf.exe on windows x86_64 doesn't work, replace it with simpleperf.exe on windows x86. Bug: http://b/37788631 Test: run demo examples on windows. Change-Id: I7195881149e70f1af9a60efc41e65fe301c62984
-rw-r--r--simpleperf/README.md3
-rw-r--r--simpleperf/demo/README.md6
-rw-r--r--simpleperf/scripts/annotate.py14
-rw-r--r--simpleperf/scripts/simpleperf_report_lib.py9
-rw-r--r--simpleperf/scripts/update.py11
-rw-r--r--simpleperf/scripts/utils.py2
6 files changed, 34 insertions, 11 deletions
diff --git a/simpleperf/README.md b/simpleperf/README.md
index 74b7fb70..b6dc9d79 100644
--- a/simpleperf/README.md
+++ b/simpleperf/README.md
@@ -523,6 +523,8 @@ It builds an app-profiling.apk for profiling.
# Open SimpleperfExamplesPureJava project with Android studio,
# and build this project sucessfully, otherwise the `./gradlew` command below will fail.
$cd SimpleperfExamplePureJava
+
+ # On windows, use "gradlew" instead.
$./gradlew clean assemble
$adb install -r app/build/outputs/apk/app-profiling.apk
@@ -618,6 +620,7 @@ There are many options to record profiling data, check [record command](#simplep
$adb shell run-as com.example.simpleperf.simpleperfexamplepurejava cat perf.data >perf.data
# Report samples using corresponding simpleperf executable on host.
+ # On windows, use "bin\windows\x86_64\simpleperf" instead.
$bin/linux/x86_64/simpleperf report
...
Overhead Command Pid Tid Shared Object Symbol
diff --git a/simpleperf/demo/README.md b/simpleperf/demo/README.md
index 2376e944..3737416d 100644
--- a/simpleperf/demo/README.md
+++ b/simpleperf/demo/README.md
@@ -35,6 +35,8 @@ steps:
# Open SimpleperfExamplesPureJava project with Android Studio,
# and build this project sucessfully, otherwise the `./gradlew` command below will fail.
$cd SimpleperfExamplePureJava
+
+ # On windows, use "gradlew" instead.
$./gradlew clean assemble
$adb install -r app/build/outputs/apk/app-profiling.apk
@@ -49,6 +51,7 @@ steps:
3. Show profiling data:
a. show call graph in txt mode
+ # On windows, use "bin\windows\x86\simpleperf" instead.
$bin/linux/x86_64/simpleperf report -g --brief-callgraph | more
If on other hosts, use corresponding simpleperf binary.
b. show call graph in gui mode
@@ -72,6 +75,8 @@ steps:
# Open SimpleperfExamplesPureJava project with Android Studio,
# and build this project sucessfully, otherwise the `./gradlew` command below will fail.
$cd SimpleperfExampleWithNative
+
+ # On windows, use "gradlew" instead.
$./gradlew clean assemble
$adb install -r app/build/outputs/apk/app-profiling.apk
@@ -86,6 +91,7 @@ steps:
3. Show profiling data:
a. show call graph in txt mode
+ # On windows, use "bin\windows\x86\simpleperf" instead.
$bin/linux/x86_64/simpleperf report -g --brief-callgraph | more
If on other hosts, use corresponding simpleperf binary.
b. show call graph in gui mode
diff --git a/simpleperf/scripts/annotate.py b/simpleperf/scripts/annotate.py
index 1f3a2ef0..d88a9169 100644
--- a/simpleperf/scripts/annotate.py
+++ b/simpleperf/scripts/annotate.py
@@ -111,7 +111,11 @@ class Addr2Line(object):
function = stdoutdata[out_pos]
out_pos += 1
assert out_pos < len(stdoutdata)
- file, line = stdoutdata[out_pos].split(':')
+ # Handle lines like "C:\Users\...\file:32".
+ items = stdoutdata[out_pos].rsplit(':', 1)
+ if len(items) != 2:
+ continue
+ (file, line) = items
line = line.split()[0] # Remove comments after line number
out_pos += 1
if file.find('?') != -1:
@@ -123,8 +127,8 @@ class Addr2Line(object):
else:
line = int(line)
source_lines.append(SourceLine(file, function, line))
- dso[addrs[addr_pos]] = source_lines
- addr_pos += 1
+ dso[addrs[addr_pos]] = source_lines
+ addr_pos += 1
assert addr_pos == len(addrs)
@@ -557,6 +561,9 @@ class SourceFileAnnotator(object):
path = key
from_path = path
to_path = os.path.join(dest_dir, path[1:])
+ elif is_windows() and key.find(':\\') != -1 and os.path.isfile(key):
+ from_path = key
+ to_path = os.path.join(dest_dir, key.replace(':\\', '\\'))
else:
path = key[1:] if key.startswith('/') else key
# Change path on device to path on host
@@ -626,3 +633,4 @@ if __name__ == '__main__':
config = load_config(args.config)
annotator = SourceFileAnnotator(config)
annotator.annotate()
+ log_info('annotate finish successfully, please check result in annotated_files/.') \ No newline at end of file
diff --git a/simpleperf/scripts/simpleperf_report_lib.py b/simpleperf/scripts/simpleperf_report_lib.py
index 27ce08a9..de904669 100644
--- a/simpleperf/scripts/simpleperf_report_lib.py
+++ b/simpleperf/scripts/simpleperf_report_lib.py
@@ -167,14 +167,9 @@ class ReportLib(object):
self.convert_to_str = (sys.version_info >= (3, 0))
def _load_dependent_lib(self):
- # As the windows dll is built with mingw we need to also find "libwinpthread-1.dll".
- # Load it before libsimpleperf_report.dll if it does exist in the same folder as this script.
+ # As the windows dll is built with mingw we need to load "libwinpthread-1.dll".
if is_windows():
- libwinpthread_path = os.path.join(get_script_dir(), "libwinpthread-1.dll")
- if os.path.exists(libwinpthread_path):
- self._libwinpthread = ct.CDLL(libwinpthread_path)
- else:
- log_fatal('%s is missing' % libwinpthread_path)
+ self._libwinpthread = ct.CDLL(get_host_binary_path('libwinpthread-1.dll'))
def Close(self):
if self._instance is None:
diff --git a/simpleperf/scripts/update.py b/simpleperf/scripts/update.py
index 7065ef08..fbdc4044 100644
--- a/simpleperf/scripts/update.py
+++ b/simpleperf/scripts/update.py
@@ -46,7 +46,8 @@ install_list = [
InstallEntry('sdk_arm64-sdk', 'simpleperf_host32', 'linux/x86/simpleperf', True),
InstallEntry('sdk_mac', 'simpleperf_host', 'darwin/x86_64/simpleperf'),
InstallEntry('sdk_mac', 'simpleperf_host32', 'darwin/x86/simpleperf'),
- InstallEntry('sdk', 'simpleperf.exe', 'windows/x86_64/simpleperf.exe', True),
+ # simpleperf.exe on x86_64 windows doesn't work, use simpleperf32.exe instead.
+ InstallEntry('sdk', 'simpleperf32.exe', 'windows/x86_64/simpleperf.exe', True),
InstallEntry('sdk', 'simpleperf32.exe', 'windows/x86/simpleperf.exe', True),
# libsimpleperf_report.so on host
@@ -56,6 +57,12 @@ install_list = [
InstallEntry('sdk_mac', 'libsimpleperf_report32.so', 'darwin/x86/libsimpleperf_report.dylib'),
InstallEntry('sdk', 'libsimpleperf_report.dll', 'windows/x86_64/libsimpleperf_report.dll', True),
InstallEntry('sdk', 'libsimpleperf_report32.dll', 'windows/x86/libsimpleperf_report.dll', True),
+
+ # libwinpthread-1.dll on windows host
+ InstallEntry('local', '../../../../prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/bin/libwinpthread-1.dll',
+ 'windows/x86_64/libwinpthread-1.dll', False),
+ InstallEntry('local', '../../../../prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/lib32/libwinpthread-1.dll',
+ 'windows/x86/libwinpthread-1.dll', False),
]
@@ -73,6 +80,8 @@ def check_call(cmd):
def fetch_artifact(branch, build, target, pattern):
"""Fetches and artifact from the build server."""
+ if target == 'local':
+ return
logger().info('Fetching %s from %s %s (artifacts matching %s)', build,
target, branch, pattern)
fetch_artifact_path = '/google/data/ro/projects/android/fetch_artifact'
diff --git a/simpleperf/scripts/utils.py b/simpleperf/scripts/utils.py
index ab76c3f5..d5515baf 100644
--- a/simpleperf/scripts/utils.py
+++ b/simpleperf/scripts/utils.py
@@ -65,6 +65,8 @@ def get_host_binary_path(binary_name):
if is_windows():
if binary_name.endswith('.so'):
binary_name = binary_name[0:-3] + '.dll'
+ elif binary_name.find('.') == -1:
+ binary_name += '.exe'
dir = os.path.join(dir, 'windows')
elif sys.platform == 'darwin': # OSX
if binary_name.endswith('.so'):