Remove some methods from DdmVmInternal.
Test: m
Change-Id: I4fa9c6f9db951333697201fa819bbaec145f03ab
diff --git a/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
index b50825a..7a640a4 100644
--- a/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
+++ b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
@@ -33,21 +33,16 @@
namespace art {
-static Thread* GetSelf(JNIEnv* env) {
- return static_cast<JNIEnvExt*>(env)->GetSelf();
-}
-
static void DdmVmInternal_enableRecentAllocations(JNIEnv*, jclass, jboolean enable) {
Dbg::SetAllocTrackingEnabled(enable);
}
-static jbyteArray DdmVmInternal_getRecentAllocations(JNIEnv* env, jclass) {
- ScopedFastNativeObjectAccess soa(env);
- return Dbg::GetRecentAllocations();
+static void DdmVmInternal_threadNotify(JNIEnv*, jclass, jboolean enable) {
+ Dbg::DdmSetThreadNotification(enable);
}
-static jboolean DdmVmInternal_getRecentAllocationStatus(JNIEnv*, jclass) {
- return Runtime::Current()->GetHeap()->IsAllocTrackingEnabled();
+static Thread* GetSelf(JNIEnv* env) {
+ return static_cast<JNIEnvExt*>(env)->GetSelf();
}
/*
@@ -214,28 +209,11 @@
return result;
}
-static jboolean DdmVmInternal_heapInfoNotify(JNIEnv* env, jclass, jint when) {
- ScopedFastNativeObjectAccess soa(env);
- return Dbg::DdmHandleHpifChunk(static_cast<Dbg::HpifWhen>(when));
-}
-
-static jboolean DdmVmInternal_heapSegmentNotify(JNIEnv*, jclass, jint when, jint what, jboolean native) {
- return Dbg::DdmHandleHpsgNhsgChunk(static_cast<Dbg::HpsgWhen>(when), static_cast<Dbg::HpsgWhat>(what), native);
-}
-
-static void DdmVmInternal_threadNotify(JNIEnv*, jclass, jboolean enable) {
- Dbg::DdmSetThreadNotification(enable);
-}
-
static JNINativeMethod gMethods[] = {
NATIVE_METHOD(DdmVmInternal, enableRecentAllocations, "(Z)V"),
- FAST_NATIVE_METHOD(DdmVmInternal, getRecentAllocations, "()[B"),
- FAST_NATIVE_METHOD(DdmVmInternal, getRecentAllocationStatus, "()Z"),
+ NATIVE_METHOD(DdmVmInternal, threadNotify, "(Z)V"),
NATIVE_METHOD(DdmVmInternal, getStackTraceById, "(I)[Ljava/lang/StackTraceElement;"),
NATIVE_METHOD(DdmVmInternal, getThreadStats, "()[B"),
- FAST_NATIVE_METHOD(DdmVmInternal, heapInfoNotify, "(I)Z"),
- NATIVE_METHOD(DdmVmInternal, heapSegmentNotify, "(IIZ)Z"),
- NATIVE_METHOD(DdmVmInternal, threadNotify, "(Z)V"),
};
void register_org_apache_harmony_dalvik_ddmc_DdmVmInternal(JNIEnv* env) {
diff --git a/test/098-ddmc/Android.bp b/test/098-ddmc/Android.bp
deleted file mode 100644
index 6afdbb3..0000000
--- a/test/098-ddmc/Android.bp
+++ /dev/null
@@ -1,40 +0,0 @@
-// Generated by `regen-test-files`. Do not edit manually.
-
-// Build rules for ART run-test `098-ddmc`.
-
-package {
- // See: http://go/android-license-faq
- // A large-scale-change added 'default_applicable_licenses' to import
- // all of the 'license_kinds' from "art_license"
- // to get the below license kinds:
- // SPDX-license-identifier-Apache-2.0
- default_applicable_licenses: ["art_license"],
-}
-
-// Test's Dex code.
-java_test {
- name: "art-run-test-098-ddmc",
- defaults: ["art-run-test-defaults"],
- test_config_template: ":art-run-test-target-template",
- srcs: ["src/**/*.java"],
- data: [
- ":art-run-test-098-ddmc-expected-stdout",
- ":art-run-test-098-ddmc-expected-stderr",
- ],
-}
-
-// Test's expected standard output.
-genrule {
- name: "art-run-test-098-ddmc-expected-stdout",
- out: ["art-run-test-098-ddmc-expected-stdout.txt"],
- srcs: ["expected-stdout.txt"],
- cmd: "cp -f $(in) $(out)",
-}
-
-// Test's expected standard error.
-genrule {
- name: "art-run-test-098-ddmc-expected-stderr",
- out: ["art-run-test-098-ddmc-expected-stderr.txt"],
- srcs: ["expected-stderr.txt"],
- cmd: "cp -f $(in) $(out)",
-}
diff --git a/test/098-ddmc/expected-stderr.txt b/test/098-ddmc/expected-stderr.txt
deleted file mode 100644
index e69de29..0000000
--- a/test/098-ddmc/expected-stderr.txt
+++ /dev/null
diff --git a/test/098-ddmc/expected-stdout.txt b/test/098-ddmc/expected-stdout.txt
deleted file mode 100644
index f8cda4c..0000000
--- a/test/098-ddmc/expected-stdout.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-Confirm empty
-empty=Allocations[message header len: 15 entry header len: 9 stack frame len: 8 number of entries: 0 offset to string table from start of message: 15 number of class name strings: 0 number of method name strings: 0 number of source file name strings: 0]
-Confirm enable
-status=false
-status=true
-Capture some allocations (note just this causes allocations)
-before > 0=true
-Confirm when we overflow, we don't roll over to zero. b/17392248
-before < overflowAllocations=true
-after > before=true
-after.numberOfEntries=65535
-Disable and confirm back to empty
-status=false
-reset=Allocations[message header len: 15 entry header len: 9 stack frame len: 8 number of entries: 0 offset to string table from start of message: 15 number of class name strings: 0 number of method name strings: 0 number of source file name strings: 0]
-Confirm we can disable twice in a row
-status=false
-status=false
-Confirm we can reenable twice in a row without losing allocations
-status=true
-status=true
-second > first =true
-Goodbye
-goodbye=Allocations[message header len: 15 entry header len: 9 stack frame len: 8 number of entries: 0 offset to string table from start of message: 15 number of class name strings: 0 number of method name strings: 0 number of source file name strings: 0]
diff --git a/test/098-ddmc/info.txt b/test/098-ddmc/info.txt
deleted file mode 100644
index 39d26db..0000000
--- a/test/098-ddmc/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Tests of private org.apache.harmony.dalvik.ddmc.* APIs used for ddms support.
diff --git a/test/098-ddmc/src/Main.java b/test/098-ddmc/src/Main.java
deleted file mode 100644
index e9a11d7..0000000
--- a/test/098-ddmc/src/Main.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * 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.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-
-public class Main {
- public static void main(String[] args) throws Exception {
- String name = System.getProperty("java.vm.name");
- if (!"Dalvik".equals(name)) {
- System.out.println("This test is not supported on " + name);
- return;
- }
- testRecentAllocationTracking();
- }
-
- private static ArrayList<Object> staticHolder = new ArrayList<>(100000);
-
- private static void testRecentAllocationTracking() throws Exception {
- System.out.println("Confirm empty");
- Allocations empty = new Allocations(DdmVmInternal.getRecentAllocations());
- System.out.println("empty=" + empty);
-
- System.out.println("Confirm enable");
- System.out.println("status=" + DdmVmInternal.getRecentAllocationStatus());
- DdmVmInternal.enableRecentAllocations(true);
- System.out.println("status=" + DdmVmInternal.getRecentAllocationStatus());
-
- System.out.println("Capture some allocations (note just this causes allocations)");
- Allocations before = new Allocations(DdmVmInternal.getRecentAllocations());
- System.out.println("before > 0=" + (before.numberOfEntries > 0));
-
- System.out.println("Confirm when we overflow, we don't roll over to zero. b/17392248");
- final int overflowAllocations = 64 * 1024; // Won't fit in unsigned 16-bit value.
- for (int i = 0; i < overflowAllocations; i++) {
- allocate(i, 0);
- }
- Allocations after = new Allocations(DdmVmInternal.getRecentAllocations());
- System.out.println("before < overflowAllocations=" + (before.numberOfEntries < overflowAllocations));
- System.out.println("after > before=" + (after.numberOfEntries > before.numberOfEntries));
- System.out.println("after.numberOfEntries=" + after.numberOfEntries);
-
- staticHolder.clear(); // Free the allocated objects.
-
- System.out.println("Disable and confirm back to empty");
- DdmVmInternal.enableRecentAllocations(false);
- System.out.println("status=" + DdmVmInternal.getRecentAllocationStatus());
- Allocations reset = new Allocations(DdmVmInternal.getRecentAllocations());
- System.out.println("reset=" + reset);
-
- System.out.println("Confirm we can disable twice in a row");
- DdmVmInternal.enableRecentAllocations(false);
- System.out.println("status=" + DdmVmInternal.getRecentAllocationStatus());
- DdmVmInternal.enableRecentAllocations(false);
- System.out.println("status=" + DdmVmInternal.getRecentAllocationStatus());
-
- System.out.println("Confirm we can reenable twice in a row without losing allocations");
- DdmVmInternal.enableRecentAllocations(true);
- System.out.println("status=" + DdmVmInternal.getRecentAllocationStatus());
- for (int i = 0; i < 16 * 1024; i++) {
- staticHolder.add(new String("fnord"));
- }
- Allocations first = new Allocations(DdmVmInternal.getRecentAllocations());
- DdmVmInternal.enableRecentAllocations(true);
- System.out.println("status=" + DdmVmInternal.getRecentAllocationStatus());
- Allocations second = new Allocations(DdmVmInternal.getRecentAllocations());
- System.out.println("second > first =" + (second.numberOfEntries > first.numberOfEntries));
-
- System.out.println("Goodbye");
- DdmVmInternal.enableRecentAllocations(false);
- Allocations goodbye = new Allocations(DdmVmInternal.getRecentAllocations());
- System.out.println("goodbye=" + goodbye);
- }
-
- // Allocate a simple object. Use depth for a reasonably deep stack.
- private static final int ALLOCATE1_DEPTH = 50;
-
- private static Object createProxy() {
- try {
- InvocationHandler handler = new InvocationHandler() {
- public Object invoke(Object proxy, Method method, Object[] args) {
- // Don't expect to be invoked.
- return null;
- }
- };
- return Proxy.newProxyInstance(Main.class.getClassLoader(),
- new Class[] { Runnable.class }, handler);
- } catch (Exception e) {
- // We don't really expect exceptions here.
- throw new RuntimeException(e);
- }
- }
-
- private static void allocate(int i, int depth) {
- if (depth >= ALLOCATE1_DEPTH) {
- // Mix proxies, int arrays and Objects to test the different descriptor paths.
- switch (i) {
- case 0:
- staticHolder.add(createProxy());
- break;
-
- case 1:
- staticHolder.add(new int[0]);
- break;
-
- case 2:
- staticHolder.add(new Object[0]);
- break;
-
- default:
- staticHolder.add(new Object());
- break;
- }
- } else {
- allocate(i, depth + 1);
- }
- }
-
- private static class Allocations {
- final int messageHeaderLen;
- final int entryHeaderLen;
- final int stackFrameLen;
- final int numberOfEntries;
- final int offsetToStringTableFromStartOfMessage;
- final int numberOfClassNameStrings;
- final int numberOfMethodNameStrings;
- final int numberOfSourceFileNameStrings;
-
- Allocations(byte[] allocations) {
- ByteBuffer b = ByteBuffer.wrap(allocations);
- messageHeaderLen = b.get() & 0xff;
- if (messageHeaderLen != 15) {
- throw new IllegalArgumentException("Unexpected messageHeaderLen " + messageHeaderLen);
- }
- entryHeaderLen = b.get() & 0xff;
- if (entryHeaderLen != 9) {
- throw new IllegalArgumentException("Unexpected entryHeaderLen " + entryHeaderLen);
- }
- stackFrameLen = b.get() & 0xff;
- if (stackFrameLen != 8) {
- throw new IllegalArgumentException("Unexpected messageHeaderLen " + stackFrameLen);
- }
- numberOfEntries = b.getShort() & 0xffff;
- offsetToStringTableFromStartOfMessage = b.getInt();
- numberOfClassNameStrings = b.getShort() & 0xffff;
- numberOfMethodNameStrings = b.getShort() & 0xffff;
- numberOfSourceFileNameStrings = b.getShort() & 0xffff;
- }
-
- public String toString() {
- return ("Allocations[message header len: " + messageHeaderLen +
- " entry header len: " + entryHeaderLen +
- " stack frame len: " + stackFrameLen +
- " number of entries: " + numberOfEntries +
- " offset to string table from start of message: " + offsetToStringTableFromStartOfMessage +
- " number of class name strings: " + numberOfClassNameStrings +
- " number of method name strings: " + numberOfMethodNameStrings +
- " number of source file name strings: " + numberOfSourceFileNameStrings +
- "]");
- }
- }
-
- private static class DdmVmInternal {
- private static final Method enableRecentAllocationsMethod;
- private static final Method getRecentAllocationStatusMethod;
- private static final Method getRecentAllocationsMethod;
- static {
- try {
- Class<?> c = Class.forName("org.apache.harmony.dalvik.ddmc.DdmVmInternal");
- enableRecentAllocationsMethod = c.getDeclaredMethod("enableRecentAllocations",
- Boolean.TYPE);
- getRecentAllocationStatusMethod = c.getDeclaredMethod("getRecentAllocationStatus");
- getRecentAllocationsMethod = c.getDeclaredMethod("getRecentAllocations");
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public static void enableRecentAllocations(boolean enable) throws Exception {
- enableRecentAllocationsMethod.invoke(null, enable);
- }
- public static boolean getRecentAllocationStatus() throws Exception {
- return (boolean) getRecentAllocationStatusMethod.invoke(null);
- }
- public static byte[] getRecentAllocations() throws Exception {
- return (byte[]) getRecentAllocationsMethod.invoke(null);
- }
- }
-}
diff --git a/test/1940-ddms-ext/expected-stdout.txt b/test/1940-ddms-ext/expected-stdout.txt
index 5af1116..99a2c52 100644
--- a/test/1940-ddms-ext/expected-stdout.txt
+++ b/test/1940-ddms-ext/expected-stdout.txt
@@ -21,5 +21,4 @@
Target thread finished!
threadNotify Disabled!
Saw expected thread events.
-Expected chunk type published: 1213221190
Expected chunk type published: 1297109829
diff --git a/test/1940-ddms-ext/src-art/art/Test1940.java b/test/1940-ddms-ext/src-art/art/Test1940.java
index 6fa31ca..14cf6a8 100644
--- a/test/1940-ddms-ext/src-art/art/Test1940.java
+++ b/test/1940-ddms-ext/src-art/art/Test1940.java
@@ -240,21 +240,6 @@
System.out.println("Saw expected thread events.");
}
- // Test heap chunks are sent.
- AwaitChunkHandler hpif = new AwaitChunkHandler((x) -> x.type == TYPE_HPIF, (type, cdata) -> {
- // The actual data is far to noisy for this test as it includes information about global heap
- // state.
- if (type == TYPE_HPIF) {
- System.out.println("Expected chunk type published: " + type);
- }
- });
- CURRENT_HANDLER = hpif;
- final int HPIF_WHEN_NOW = 1;
- if (!DdmVmInternal.heapInfoNotify(HPIF_WHEN_NOW)) {
- System.out.println("Unexpected failure for heapInfoNotify!");
- }
- hpif.Await();
-
// method Tracing
AwaitChunkHandler mpse = new AwaitChunkHandler((x) -> x.type == TYPE_MPSE, (type, cdata) -> {
// This chunk includes timing and thread information so we just check the type.
diff --git a/test/knownfailures.json b/test/knownfailures.json
index 13ed23f..0ceb15e 100644
--- a/test/knownfailures.json
+++ b/test/knownfailures.json
@@ -481,7 +481,6 @@
"004-StackWalk",
"064-field-access",
"083-compiler-regressions",
- "098-ddmc",
"107-int-math2",
"129-ThreadGetId",
"135-MirandaDispatch",
@@ -816,7 +815,6 @@
"088-monitor-verification",
"091-override-package-private-method",
"097-duplicate-method",
- "098-ddmc",
"099-vmdebug",
"100-reflect2",
"104-growth-limit",