IDEA-140321 Wrong current line highlighting when debugging synchronized block in decompiled code
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.jetbrains.java.decompiler.modules.decompiler.stats;
|
||||
|
||||
import org.jetbrains.java.decompiler.code.CodeConstants;
|
||||
import org.jetbrains.java.decompiler.code.cfg.BasicBlock;
|
||||
import org.jetbrains.java.decompiler.main.TextBuffer;
|
||||
import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor;
|
||||
@@ -84,11 +86,20 @@ public class SynchronizedStatement extends Statement {
|
||||
buf.append(ExprProcessor.jmpWrapper(body, indent + 1, true, tracer));
|
||||
|
||||
buf.appendIndent(indent).append("}").appendLineSeparator();
|
||||
mapMonitorExitInstr(tracer);
|
||||
tracer.incrementCurrentSourceLine();
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
private void mapMonitorExitInstr(BytecodeMappingTracer tracer) {
|
||||
BasicBlock block = body.getBasichead().getBlock();
|
||||
if (!block.getSeq().isEmpty() && block.getLastInstruction().opcode == CodeConstants.opc_monitorexit) {
|
||||
Integer offset = block.getOldOffset(block.size() - 1);
|
||||
if (offset > -1) tracer.addMapping(offset);
|
||||
}
|
||||
}
|
||||
|
||||
public void initExprents() {
|
||||
headexprent.set(0, first.getExprents().remove(first.getExprents().size() - 1));
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -3,33 +3,37 @@ package pkg;
|
||||
public class TestSynchronizedMapping {
|
||||
public int test(int var1) {
|
||||
synchronized(this) {// 8
|
||||
return var1++;// 9
|
||||
}
|
||||
++var1;// 9
|
||||
}// 10
|
||||
|
||||
return var1++;// 11
|
||||
}
|
||||
|
||||
public void test2(String var1) {
|
||||
System.out.println(var1);// 14
|
||||
}// 15
|
||||
System.out.println(var1);// 15
|
||||
}// 16
|
||||
}
|
||||
|
||||
class 'pkg/TestSynchronizedMapping' {
|
||||
method 'test (I)I' {
|
||||
3 4
|
||||
5 5
|
||||
a 5
|
||||
4 5
|
||||
8 6
|
||||
12 8
|
||||
15 8
|
||||
}
|
||||
|
||||
method 'test2 (Ljava/lang/String;)V' {
|
||||
0 10
|
||||
4 10
|
||||
7 11
|
||||
0 12
|
||||
4 12
|
||||
7 13
|
||||
}
|
||||
}
|
||||
|
||||
Lines mapping:
|
||||
8 <-> 5
|
||||
9 <-> 6
|
||||
14 <-> 11
|
||||
15 <-> 12
|
||||
Not mapped:
|
||||
10
|
||||
10 <-> 7
|
||||
11 <-> 9
|
||||
15 <-> 13
|
||||
16 <-> 14
|
||||
|
||||
@@ -6,8 +6,9 @@ import java.lang.Runnable;
|
||||
public class TestSynchronizedMapping {
|
||||
public int test(int a) {
|
||||
synchronized (this) {
|
||||
return a++;
|
||||
a++;
|
||||
}
|
||||
return a++;
|
||||
}
|
||||
|
||||
public void test2(String a) {
|
||||
|
||||
Reference in New Issue
Block a user