mirror of
https://github.com/revanced/Apktool.git
synced 2025-02-12 20:06:48 +01:00
Fixed debug injection if there are annotated method parameters.
This commit is contained in:
parent
fed7f763b9
commit
ed0e4eb64c
@ -27,6 +27,10 @@ import org.jf.dexlib.Code.Analysis.RegisterType;
|
|||||||
*/
|
*/
|
||||||
public class DebugInjector {
|
public class DebugInjector {
|
||||||
|
|
||||||
|
private boolean areParamsInjected;
|
||||||
|
private int currParam;
|
||||||
|
private int lastParam;
|
||||||
|
|
||||||
public static void inject(ListIterator<String> it, StringBuilder out)
|
public static void inject(ListIterator<String> it, StringBuilder out)
|
||||||
throws AndrolibException {
|
throws AndrolibException {
|
||||||
new DebugInjector(it, out).inject();
|
new DebugInjector(it, out).inject();
|
||||||
@ -44,7 +48,7 @@ public class DebugInjector {
|
|||||||
nextAndAppend();
|
nextAndAppend();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
injectParameters(definition);
|
parseParamsNumber(definition);
|
||||||
|
|
||||||
boolean end = false;
|
boolean end = false;
|
||||||
while (!end) {
|
while (!end) {
|
||||||
@ -52,7 +56,7 @@ public class DebugInjector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void injectParameters(String definition) throws AndrolibException {
|
private void parseParamsNumber(String definition) throws AndrolibException {
|
||||||
int pos = definition.indexOf('(');
|
int pos = definition.indexOf('(');
|
||||||
if (pos == -1) {
|
if (pos == -1) {
|
||||||
throw new AndrolibException();
|
throw new AndrolibException();
|
||||||
@ -63,11 +67,15 @@ public class DebugInjector {
|
|||||||
}
|
}
|
||||||
String params = definition.substring(pos + 1, pos2);
|
String params = definition.substring(pos + 1, pos2);
|
||||||
|
|
||||||
int i = definition.contains(" static ") ? 0 : 1;
|
currParam = definition.contains(" static ") ? 0 : 1;
|
||||||
int argc = TypeName.listFromInternalName(params).size() + i;
|
lastParam = TypeName.listFromInternalName(params).size() + currParam - 1;
|
||||||
while (i < argc) {
|
}
|
||||||
mOut.append(".parameter \"p").append(i).append("\"\n");
|
|
||||||
i++;
|
private void injectRemainingParams() {
|
||||||
|
areParamsInjected = true;
|
||||||
|
while(currParam <= lastParam) {
|
||||||
|
mOut.append(".parameter \"p").append(currParam).append("\"\n");
|
||||||
|
currParam++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,6 +94,9 @@ public class DebugInjector {
|
|||||||
case '.':
|
case '.':
|
||||||
return processDirective(line);
|
return processDirective(line);
|
||||||
default:
|
default:
|
||||||
|
if (! areParamsInjected) {
|
||||||
|
injectRemainingParams();
|
||||||
|
}
|
||||||
return processInstruction(line);
|
return processInstruction(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,9 +169,17 @@ public class DebugInjector {
|
|||||||
|
|
||||||
private boolean processDirective(String line) {
|
private boolean processDirective(String line) {
|
||||||
String line2 = line.substring(1);
|
String line2 = line.substring(1);
|
||||||
if (line2.startsWith("line ") || line2.equals("prologue")
|
if (line2.startsWith("line ") || line2.startsWith("local ") || line2.startsWith("end local ")) {
|
||||||
|| line2.startsWith("parameter") || line2.startsWith("local ")
|
return false;
|
||||||
|| line2.startsWith("end local ")) {
|
}
|
||||||
|
if (line2.equals("prologue")) {
|
||||||
|
if (! areParamsInjected) {
|
||||||
|
injectRemainingParams();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (line2.equals("parameter")) {
|
||||||
|
mOut.append(".parameter \"p").append(currParam++).append("\"\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user