Skip to content

Commit 069eea8

Browse files
Debugger: write line number for catch clause declaration
1 parent dd964e9 commit 069eea8

File tree

9 files changed

+44
-4
lines changed

9 files changed

+44
-4
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Do not cast to runtime type unavailable in current scope
1919
- Fix text with line breaks in popup with line breakpoint variants
2020
- Fix breakpoints inside inline functions in libraries sources
21+
- Allow breakpoints at catch clause declaration
2122

2223
## 1.0.2
2324

compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3667,14 +3667,19 @@ public Unit invoke(InstructionAdapter v) {
36673667
Label clauseStart = new Label();
36683668
v.mark(clauseStart);
36693669

3670+
KtExpression catchBody = clause.getCatchBody();
3671+
if (catchBody != null) {
3672+
markLineNumber(catchBody, false);
3673+
}
3674+
36703675
VariableDescriptor descriptor = bindingContext.get(VALUE_PARAMETER, clause.getCatchParameter());
36713676
assert descriptor != null;
36723677
Type descriptorType = asmType(descriptor.getType());
36733678
myFrameMap.enter(descriptor, descriptorType);
36743679
int index = lookupLocalIndex(descriptor);
36753680
v.store(index, descriptorType);
36763681

3677-
gen(clause.getCatchBody(), expectedAsmType);
3682+
gen(catchBody, expectedAsmType);
36783683

36793684
if (!isStatement) {
36803685
v.store(savedValue, expectedAsmType);

compiler/testData/lineNumber/custom/tryCatchExpression.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ fun foo() {
1212
}
1313
}
1414

15-
// 2 3 5 6 8 9 11 8 13
15+
// 2 3 4 5 6 8 9 10 11 8 13

compiler/testData/lineNumber/custom/tryCatchFinally.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ fun foo() {
1616
}
1717
}
1818

19-
// 2 3 7 5 7 8 10 11 15 13 15 10 17
19+
// 2 3 7 4 5 7 8 10 11 15 12 13 15 10 17
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
LineBreakpoint created at stepOverCatchClause.kt:14
2+
!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! stepOverCatchClause.StepOverCatchClauseKt
3+
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
4+
stepOverCatchClause.kt:14
5+
stepOverCatchClause.kt:7
6+
stepOverCatchClause.kt:8
7+
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
8+
9+
Process finished with exit code 0

idea/testData/debugger/tinyApp/outs/stepOverTryCatchWithInline.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ stepOverTryCatchWithInline.kt:48
88
stepOverTryCatchWithInline.kt:17
99
stepOverTryCatchWithInline.kt:24
1010
stepOverTryCatchWithInline.kt:25
11+
stepOverTryCatchWithInline.kt:27
1112
stepOverTryCatchWithInline.kt:28
1213
stepOverTryCatchWithInline.kt:35
1314
stepOverTryCatchWithInline.kt:36
1415
stepOverTryCatchWithInline.kt:48
1516
stepOverTryCatchWithInline.kt:36
17+
stepOverTryCatchWithInline.kt:38
1618
stepOverTryCatchWithInline.kt:39
1719
stepOverTryCatchWithInline.kt:43
1820
stepOverTryCatchWithInline.kt:8
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package stepOverCatchClause
2+
3+
fun main(args: Array<String>) {
4+
try {
5+
bar()
6+
}
7+
catch(e: Exception) {
8+
val a = e
9+
}
10+
}
11+
12+
fun bar() {
13+
//Breakpoint!
14+
throw IllegalStateException()
15+
}
16+
17+
// STEP_OVER: 2

idea/testData/debugger/tinyApp/src/stepping/stepOver/stepOverTryCatchWithInline.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ inline fun foo(f: () -> Int): Int {
5151

5252
fun test(i: Int) = 1
5353

54-
// STEP_OVER: 15
54+
// STEP_OVER: 19

idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,12 @@ public void testInlineFunctionSameLines() throws Exception {
379379
doStepOverTest(fileName);
380380
}
381381

382+
@TestMetadata("stepOverCatchClause.kt")
383+
public void testStepOverCatchClause() throws Exception {
384+
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stepOverCatchClause.kt");
385+
doStepOverTest(fileName);
386+
}
387+
382388
@TestMetadata("stepOverForWithInline.kt")
383389
public void testStepOverForWithInline() throws Exception {
384390
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stepOverForWithInline.kt");

0 commit comments

Comments
 (0)