mirror of
https://github.com/skylot/jadx.git
synced 2024-11-23 12:50:02 +00:00
fix: use debug line numbers only at fixed offsets (#1315)
This commit is contained in:
parent
3566669303
commit
99c70872c1
@ -0,0 +1,39 @@
|
||||
package jadx.tests.integration.debuginfo;
|
||||
|
||||
import jadx.core.dex.nodes.ClassNode;
|
||||
import jadx.tests.api.IntegrationTest;
|
||||
import jadx.tests.api.extensions.inputs.InputPlugin;
|
||||
import jadx.tests.api.extensions.inputs.TestWithInputPlugins;
|
||||
|
||||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
|
||||
|
||||
public class TestLineNumbers3 extends IntegrationTest {
|
||||
|
||||
public static class TestCls extends Exception {
|
||||
|
||||
public TestCls(final Object message) {
|
||||
super((message == null) ? "" : message.toString());
|
||||
/*
|
||||
* comment to increase line number in return instruction
|
||||
* -
|
||||
* -
|
||||
* -
|
||||
* -
|
||||
* -
|
||||
* -
|
||||
* -
|
||||
* -
|
||||
* -
|
||||
* -
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@TestWithInputPlugins({ InputPlugin.DEX, InputPlugin.JAVA })
|
||||
public void test() {
|
||||
ClassNode cls = getClassNode(TestCls.class);
|
||||
assertThat(cls).code().containsOne("super(message == null ? \"\" : message.toString());");
|
||||
String linesMapStr = cls.getCode().getLineMapping().toString();
|
||||
assertThat(linesMapStr).isEqualTo("{4=13, 5=14, 6=15}");
|
||||
}
|
||||
}
|
@ -185,25 +185,16 @@ public class DebugInfoParser {
|
||||
}
|
||||
}
|
||||
}
|
||||
setSourceLines(addr, codeSize, line);
|
||||
|
||||
return new DebugInfo(linesMap, resultList);
|
||||
}
|
||||
|
||||
private int addrChange(int addr, int addrInc, int line) {
|
||||
int newAddr = addr + addrInc;
|
||||
int maxAddr = codeSize - 1;
|
||||
newAddr = Math.min(newAddr, maxAddr);
|
||||
setSourceLines(addr, newAddr, line);
|
||||
int newAddr = Math.min(addr + addrInc, codeSize - 1);
|
||||
setLine(newAddr, line);
|
||||
return newAddr;
|
||||
}
|
||||
|
||||
private void setSourceLines(int start, int end, int line) {
|
||||
for (int offset = start + 1; offset < end; offset++) {
|
||||
setLine(offset, line);
|
||||
}
|
||||
}
|
||||
|
||||
private void setLine(int offset, int line) {
|
||||
linesMap.put(offset, line);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user