use of jadx.core.dex.attributes.nodes.RegDebugInfoAttr in project jadx by skylot.
the class MoveInlineVisitor method processMove.
private static boolean processMove(MethodNode mth, InsnNode move) {
RegisterArg resultArg = move.getResult();
InsnArg moveArg = move.getArg(0);
if (resultArg.sameRegAndSVar(moveArg)) {
return true;
}
SSAVar ssaVar = resultArg.getSVar();
if (ssaVar.isUsedInPhi()) {
return deleteMove(mth, move);
}
RegDebugInfoAttr debugInfo = moveArg.get(AType.REG_DEBUG_INFO);
for (RegisterArg useArg : ssaVar.getUseList()) {
InsnNode useInsn = useArg.getParentInsn();
if (useInsn == null) {
return false;
}
if (debugInfo == null) {
RegDebugInfoAttr debugInfoAttr = useArg.get(AType.REG_DEBUG_INFO);
if (debugInfoAttr != null) {
debugInfo = debugInfoAttr;
}
}
}
// all checks passed, execute inline
for (RegisterArg useArg : new ArrayList<>(ssaVar.getUseList())) {
InsnNode useInsn = useArg.getParentInsn();
if (useInsn == null) {
continue;
}
InsnArg replaceArg;
if (moveArg.isRegister()) {
replaceArg = ((RegisterArg) moveArg).duplicate(useArg.getInitType());
} else {
replaceArg = moveArg.duplicate();
}
useInsn.inheritMetadata(move);
replaceArg.copyAttributesFrom(useArg);
if (debugInfo != null) {
replaceArg.addAttr(debugInfo);
}
if (!useInsn.replaceArg(useArg, replaceArg)) {
mth.addWarnComment("Failed to replace arg in insn: " + useInsn);
}
}
return true;
}
use of jadx.core.dex.attributes.nodes.RegDebugInfoAttr 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));
}
use of jadx.core.dex.attributes.nodes.RegDebugInfoAttr in project jadx by skylot.
the class SSAVar method getDetailedVarInfo.
public String getDetailedVarInfo(MethodNode mth) {
Set<ArgType> types = new HashSet<>();
Set<String> names = Collections.emptySet();
List<RegisterArg> useArgs = new ArrayList<>(1 + useList.size());
useArgs.add(assign);
useArgs.addAll(useList);
if (mth.contains(AType.LOCAL_VARS_DEBUG_INFO)) {
names = new HashSet<>();
for (RegisterArg arg : useArgs) {
RegDebugInfoAttr debugInfoAttr = arg.get(AType.REG_DEBUG_INFO);
if (debugInfoAttr != null) {
names.add(debugInfoAttr.getName());
types.add(debugInfoAttr.getRegType());
}
}
}
for (RegisterArg arg : useArgs) {
ArgType initType = arg.getInitType();
if (initType.isTypeKnown()) {
types.add(initType);
}
ArgType type = arg.getType();
if (type.isTypeKnown()) {
types.add(type);
}
}
StringBuilder sb = new StringBuilder();
sb.append('r').append(regNum).append('v').append(version);
if (!names.isEmpty()) {
sb.append(", names: ").append(names);
}
if (!types.isEmpty()) {
sb.append(", types: ").append(types);
}
return sb.toString();
}
Aggregations