use of jadx.core.dex.attributes.nodes.LocalVarsDebugInfoAttr in project jadx by skylot.
the class DebugInfoApplyVisitor method searchDebugInfoByOffset.
private static void searchDebugInfoByOffset(MethodNode mth, SSAVar ssaVar) {
LocalVarsDebugInfoAttr debugInfoAttr = mth.get(AType.LOCAL_VARS_DEBUG_INFO);
if (debugInfoAttr == null) {
return;
}
OptionalInt max = ssaVar.getUseList().stream().mapToInt(DebugInfoApplyVisitor::getInsnOffsetByArg).max();
if (!max.isPresent()) {
return;
}
int startOffset = getInsnOffsetByArg(ssaVar.getAssign());
int endOffset = max.getAsInt();
int regNum = ssaVar.getRegNum();
for (ILocalVar localVar : debugInfoAttr.getLocalVars()) {
if (localVar.getRegNum() == regNum) {
int startAddr = localVar.getStartOffset();
int endAddr = localVar.getEndOffset();
if (isInside(startOffset, startAddr, endAddr) || isInside(endOffset, startAddr, endAddr)) {
if (Consts.DEBUG_TYPE_INFERENCE) {
LOG.debug("Apply debug info by offset for: {} to {}", ssaVar, localVar);
}
ArgType type = DebugInfoAttachVisitor.getVarType(mth, localVar);
applyDebugInfo(mth, ssaVar, type, localVar.getName());
break;
}
}
}
}
use of jadx.core.dex.attributes.nodes.LocalVarsDebugInfoAttr in project jadx by skylot.
the class DebugInfoAttachVisitor method attachDebugInfo.
private void attachDebugInfo(MethodNode mth, List<ILocalVar> localVars, InsnNode[] insnArr) {
if (localVars.isEmpty()) {
return;
}
for (ILocalVar var : localVars) {
int regNum = var.getRegNum();
int start = var.getStartOffset();
int end = var.getEndOffset();
ArgType type = getVarType(mth, var);
RegDebugInfoAttr debugInfoAttr = new RegDebugInfoAttr(type, var.getName());
if (start <= 0) {
// attach to method arguments
RegisterArg thisArg = mth.getThisArg();
if (thisArg != null) {
attachDebugInfo(thisArg, debugInfoAttr, regNum);
}
for (RegisterArg arg : mth.getArgRegs()) {
attachDebugInfo(arg, debugInfoAttr, regNum);
}
start = 0;
}
for (int i = start; i <= end; i++) {
InsnNode insn = insnArr[i];
if (insn == null) {
continue;
}
int count = 0;
for (InsnArg arg : insn.getArguments()) {
count += attachDebugInfo(arg, debugInfoAttr, regNum);
}
if (count != 0) {
// don't apply same info for result if applied to args
continue;
}
attachDebugInfo(insn.getResult(), debugInfoAttr, regNum);
}
}
mth.addAttr(new LocalVarsDebugInfoAttr(localVars));
}
Aggregations