summaryrefslogtreecommitdiffstats
path: root/test/304-method-tracing
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2013-12-17 10:42:03 +0100
committerSebastien Hertz <shertz@google.com>2014-07-09 16:10:45 +0200
commitbae182cbc6adc8796154162a87fc54ae804e0469 (patch)
treed5c1fdb048edab194e948e4e90bff66703c5f55e /test/304-method-tracing
parent0c1734665c38b3116e38a90ad06c3f152d9316c5 (diff)
downloadart-bae182cbc6adc8796154162a87fc54ae804e0469.zip
art-bae182cbc6adc8796154162a87fc54ae804e0469.tar.gz
art-bae182cbc6adc8796154162a87fc54ae804e0469.tar.bz2
Fix method tracing from command-line
Transitions current thread to the new kWaitingForMethodTracingStart thread state when starting method tracing. Ensures there is a current thread when method tracing is stopped due to runtime shutdown. If the current thread has been detached, we now re-attach it. Note: we only do this if method tracing has been activated from command-line. Fixes instrumentation when forcing interpreter mode (-Xint) with method tracing enabled. Removes unused parameter from UnsafeLogFatalForThreadSuspendAllTimeout. Bug: https://code.google.com/p/android/issues/detail?id=72094 Bug: 11683397 Change-Id: I70f000fb46ddd95d6ad51ea0a8eee77697a045e9
Diffstat (limited to 'test/304-method-tracing')
-rw-r--r--test/304-method-tracing/expected.txt0
-rw-r--r--test/304-method-tracing/info.txt1
-rwxr-xr-xtest/304-method-tracing/run18
-rw-r--r--test/304-method-tracing/src/Main.java48
4 files changed, 67 insertions, 0 deletions
diff --git a/test/304-method-tracing/expected.txt b/test/304-method-tracing/expected.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/304-method-tracing/expected.txt
diff --git a/test/304-method-tracing/info.txt b/test/304-method-tracing/info.txt
new file mode 100644
index 0000000..d3154e6
--- /dev/null
+++ b/test/304-method-tracing/info.txt
@@ -0,0 +1 @@
+Test method tracing from command-line.
diff --git a/test/304-method-tracing/run b/test/304-method-tracing/run
new file mode 100755
index 0000000..7bd1895
--- /dev/null
+++ b/test/304-method-tracing/run
@@ -0,0 +1,18 @@
+#!/bin/bash
+#
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Runs the test with method tracing enabled.
+exec ${RUN} "$@" --runtime-option -Xmethod-trace --runtime-option -Xmethod-trace-file:${DEX_LOCATION}/trace.bin
diff --git a/test/304-method-tracing/src/Main.java b/test/304-method-tracing/src/Main.java
new file mode 100644
index 0000000..25cee6d
--- /dev/null
+++ b/test/304-method-tracing/src/Main.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+
+public class Main {
+ static class ThreadRunnable implements Runnable {
+ public void run() {
+ for (int i = 0; i < 1000; ++i) {
+ doNothing();
+ }
+ }
+
+ private void doNothing() {}
+ }
+
+ public static void main(String[] args) {
+ ArrayList<Thread> threads = new ArrayList<Thread>();
+ for (int i = 0; i < 10; ++i) {
+ threads.add(new Thread(new ThreadRunnable(), "TestThread-" + i));
+ }
+
+ for (Thread t : threads) {
+ t.start();
+ }
+
+ for (Thread t : threads) {
+ try {
+ t.join();
+ } catch (InterruptedException e) {
+ System.out.println("Thread " + t.getName() + " has been interrupted");
+ }
+ }
+ }
+}