Debugger doesn't step into 'for' body if there's inline function call in range expression (KT-13534)
#KT-13534 Fixed
This commit is contained in:
committed by
Nikolay Krasko
parent
ef602be98e
commit
8b84b7158a
@@ -105,7 +105,7 @@ public class DebuggerSteppingHelper {
|
|||||||
try {
|
try {
|
||||||
StackFrameProxyImpl frameProxy = suspendContext.getFrameProxy();
|
StackFrameProxyImpl frameProxy = suspendContext.getFrameProxy();
|
||||||
if (frameProxy != null) {
|
if (frameProxy != null) {
|
||||||
Action action = KotlinSteppingCommandProviderKt.getStepOutPosition(
|
Action action = KotlinSteppingCommandProviderKt.getStepOutAction(
|
||||||
frameProxy.location(),
|
frameProxy.location(),
|
||||||
suspendContext,
|
suspendContext,
|
||||||
inlineFunctions,
|
inlineFunctions,
|
||||||
|
|||||||
+17
-2
@@ -347,10 +347,25 @@ fun getStepOverPosition(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isBackEdgeLocation(): Boolean {
|
||||||
|
val previousSuitableLocation = computedReferenceType.allLineLocations().reversed()
|
||||||
|
.dropWhile { it != location }
|
||||||
|
.drop(1)
|
||||||
|
.filter(::isLocationSuitable)
|
||||||
|
.dropWhile { it.lineNumber() == location.lineNumber() }
|
||||||
|
.firstOrNull()
|
||||||
|
|
||||||
|
return previousSuitableLocation != null && previousSuitableLocation.lineNumber() > location.lineNumber()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isBackEdgeLocation()) {
|
||||||
|
return Action.STEP_OVER()
|
||||||
|
}
|
||||||
|
|
||||||
val locations = computedReferenceType.allLineLocations()
|
val locations = computedReferenceType.allLineLocations()
|
||||||
.dropWhile { it != location }
|
.dropWhile { it != location }
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.filter { isLocationSuitable(it) }
|
.filter(::isLocationSuitable)
|
||||||
.dropWhile { it.lineNumber() == location.lineNumber() }
|
.dropWhile { it.lineNumber() == location.lineNumber() }
|
||||||
|
|
||||||
for (locationAtLine in locations) {
|
for (locationAtLine in locations) {
|
||||||
@@ -378,7 +393,7 @@ fun getStepOverPosition(
|
|||||||
return Action.STEP_OVER()
|
return Action.STEP_OVER()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getStepOutPosition(
|
fun getStepOutAction(
|
||||||
location: Location,
|
location: Location,
|
||||||
suspendContext: SuspendContextImpl,
|
suspendContext: SuspendContextImpl,
|
||||||
inlineFunctions: List<KtNamedFunction>,
|
inlineFunctions: List<KtNamedFunction>,
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
LineBreakpoint created at asIterableInFor.kt:7
|
||||||
|
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! asIterableInFor.AsIterableInForKt
|
||||||
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
asIterableInFor.kt:7
|
||||||
|
asIterableInFor.kt:8
|
||||||
|
asIterableInFor.kt:9
|
||||||
|
asIterableInFor.kt:8
|
||||||
|
asIterableInFor.kt:9
|
||||||
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
LineBreakpoint created at inlineCallInForRangeExpression.kt:7
|
||||||
|
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! inlineCallInForRangeExpression.InlineCallInForRangeExpressionKt
|
||||||
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
inlineCallInForRangeExpression.kt:7
|
||||||
|
inlineCallInForRangeExpression.kt:8
|
||||||
|
inlineCallInForRangeExpression.kt:9
|
||||||
|
inlineCallInForRangeExpression.kt:8
|
||||||
|
inlineCallInForRangeExpression.kt:9
|
||||||
|
inlineCallInForRangeExpression.kt:8
|
||||||
|
inlineCallInForRangeExpression.kt:11
|
||||||
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package asIterableInFor
|
||||||
|
|
||||||
|
fun <T> nonInline(p: T): T = p
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
//Breakpoint!
|
||||||
|
val list = listOf("a", "b", "c")
|
||||||
|
for (element in list.asIterable()) {
|
||||||
|
nonInline(element)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// STEP_OVER: 4
|
||||||
|
|
||||||
|
// Tests that last line will be "9", no "11". See KT-13534.
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package inlineCallInForRangeExpression
|
||||||
|
|
||||||
|
fun <T> nonInline(p: T) = p
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
//Breakpoint!
|
||||||
|
nonInline(12)
|
||||||
|
for (e in range()) {
|
||||||
|
nonInline(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun range() = 1..2
|
||||||
|
|
||||||
|
// STEP_OVER: 6
|
||||||
@@ -373,6 +373,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/debugger/tinyApp/src/stepping/stepOver"), Pattern.compile("^([^.]+)\\.kt$"), true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/debugger/tinyApp/src/stepping/stepOver"), Pattern.compile("^([^.]+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("asIterableInFor.kt")
|
||||||
|
public void testAsIterableInFor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/asIterableInFor.kt");
|
||||||
|
doStepOverTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("dexInlineInClass.kt")
|
@TestMetadata("dexInlineInClass.kt")
|
||||||
public void testDexInlineInClass() throws Exception {
|
public void testDexInlineInClass() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInClass.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/dexInlineInClass.kt");
|
||||||
@@ -403,6 +409,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
|
|||||||
doStepOverTest(fileName);
|
doStepOverTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineCallInForRangeExpression.kt")
|
||||||
|
public void testInlineCallInForRangeExpression() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/inlineCallInForRangeExpression.kt");
|
||||||
|
doStepOverTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inlineFunctionSameLines.kt")
|
@TestMetadata("inlineFunctionSameLines.kt")
|
||||||
public void testInlineFunctionSameLines() throws Exception {
|
public void testInlineFunctionSameLines() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/inlineFunctionSameLines.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/inlineFunctionSameLines.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user