未验证 提交 99c70872 编写于 作者: S Skylot

fix: use debug line numbers only at fixed offsets (#1315)

上级 35666693
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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册