Merge changes Id9b221f4,I9d00f06d
* changes:
Support Kotlin in continuous stepping tests
Debugging tests: fix breakpoint setup when line table is empty
diff --git a/src/test/java/com/android/tools/r8/debug/ContinuousSteppingTest.java b/src/test/java/com/android/tools/r8/debug/ContinuousSteppingTest.java
index 1236866..d371243 100644
--- a/src/test/java/com/android/tools/r8/debug/ContinuousSteppingTest.java
+++ b/src/test/java/com/android/tools/r8/debug/ContinuousSteppingTest.java
@@ -12,24 +12,32 @@
public class ContinuousSteppingTest extends DebugTestBase {
- private static DebugTestConfig config;
+ private static DebugTestConfig javaD8Config;
+ private static DebugTestConfig kotlinD8Config;
@BeforeClass
public static void setup() {
- config = new D8DebugTestResourcesConfig(temp);
+ javaD8Config = new D8DebugTestResourcesConfig(temp);
+ kotlinD8Config = new KotlinD8Config(temp);
}
@Test
public void testArithmetic() throws Throwable {
- runContinuousTest("Arithmetic");
+ runContinuousTest("Arithmetic", javaD8Config);
}
@Test
public void testLocals() throws Throwable {
- runContinuousTest("Locals");
+ runContinuousTest("Locals", javaD8Config);
}
- private void runContinuousTest(String debuggeeClassName) throws Throwable {
+ @Test
+ public void testKotlinInline() throws Throwable {
+ runContinuousTest("KotlinInline", kotlinD8Config);
+ }
+
+ private void runContinuousTest(String debuggeeClassName, DebugTestConfig config)
+ throws Throwable {
runDebugTest(
config,
debuggeeClassName,
diff --git a/src/test/java/com/android/tools/r8/debug/DebugTestBase.java b/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
index 646f116..e8d21f2 100644
--- a/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
+++ b/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
@@ -1488,10 +1488,16 @@
ReplyPacket replyPacket = getMirror().getLineTable(classId, breakpointMethodId);
checkReplyPacket(replyPacket, "Failed to get method line table");
long start = replyPacket.getNextValueAsLong(); // start
- long end = replyPacket.getNextValueAsLong(); // end
+ replyPacket.getNextValueAsLong(); // end
int linesCount = replyPacket.getNextValueAsInt();
if (linesCount == 0) {
- pcs.add(-1L);
+ if (lineToSearch == FIRST_LINE) {
+ // There is no line table but we are not looking for a specific line. Therefore just
+ // set the breakpoint on the 1st instruction.
+ pcs.add(start);
+ } else {
+ pcs.add(-1L);
+ }
} else {
if (lineToSearch == FIRST_LINE) {
// Read only the 1st line because code indices are in ascending order
diff --git a/src/test/java/com/android/tools/r8/debug/KotlinD8Config.java b/src/test/java/com/android/tools/r8/debug/KotlinD8Config.java
new file mode 100644
index 0000000..fa5f5ca
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/debug/KotlinD8Config.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2018, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.android.tools.r8.debug;
+
+import com.android.tools.r8.OutputMode;
+import com.android.tools.r8.ToolHelper;
+import com.android.tools.r8.utils.AndroidApp;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collections;
+import org.junit.rules.TemporaryFolder;
+
+/**
+ * Shared test configuration for D8 compiled resources from the "debugTestResourcesKotlin" target.
+ */
+class KotlinD8Config extends D8DebugTestConfig {
+
+ private static final Path DEBUGGEE_KOTLIN_JAR =
+ Paths.get(ToolHelper.BUILD_DIR, "test", "debug_test_resources_kotlin.jar");
+
+ private static AndroidApp compiledResources = null;
+
+ private static synchronized AndroidApp getCompiledResources() throws Throwable {
+ if (compiledResources == null) {
+ compiledResources =
+ D8DebugTestConfig.d8Compile(
+ Collections.singletonList(DEBUGGEE_KOTLIN_JAR), null);
+ }
+ return compiledResources;
+ }
+
+ public KotlinD8Config(TemporaryFolder temp) {
+ super();
+ try {
+ Path out = temp.newFolder().toPath().resolve("d8_debug_test_resources_kotlin.jar");
+ getCompiledResources().write(out, OutputMode.DexIndexed);
+ addPaths(out);
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/src/test/java/com/android/tools/r8/debug/KotlinDebugTestBase.java b/src/test/java/com/android/tools/r8/debug/KotlinDebugTestBase.java
index 845a450..5ddd98c 100644
--- a/src/test/java/com/android/tools/r8/debug/KotlinDebugTestBase.java
+++ b/src/test/java/com/android/tools/r8/debug/KotlinDebugTestBase.java
@@ -4,51 +4,20 @@
package com.android.tools.r8.debug;
-import com.android.tools.r8.OutputMode;
import com.android.tools.r8.ToolHelper;
-import com.android.tools.r8.utils.AndroidApp;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import org.apache.harmony.jpda.tests.framework.jdwp.Frame.Variable;
import org.apache.harmony.jpda.tests.framework.jdwp.Location;
import org.junit.BeforeClass;
-import org.junit.rules.TemporaryFolder;
/**
* A specialization for Kotlin-based tests which provides extra commands.
*/
public abstract class KotlinDebugTestBase extends DebugTestBase {
- private static final Path DEBUGGEE_KOTLIN_JAR =
- Paths.get(ToolHelper.BUILD_DIR, "test", "debug_test_resources_kotlin.jar");
-
- protected static class KotlinD8Config extends D8DebugTestConfig {
-
- private static AndroidApp compiledResources = null;
-
- private static synchronized AndroidApp getCompiledResources() throws Throwable {
- if (compiledResources == null) {
- compiledResources =
- D8DebugTestConfig.d8Compile(Collections.singletonList(DEBUGGEE_KOTLIN_JAR), null);
- }
- return compiledResources;
- }
-
- public KotlinD8Config(TemporaryFolder temp) {
- super();
- try {
- Path out = temp.newFolder().toPath().resolve("d8_debug_test_resources_kotlin.jar");
- getCompiledResources().write(out, OutputMode.DexIndexed);
- addPaths(out);
- } catch (Throwable e) {
- throw new RuntimeException(e);
- }
- }
- }
-
private static KotlinD8Config d8Config;
@BeforeClass