mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-20 16:57:34 +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 {
|
||||
|
||||
private boolean areParamsInjected;
|
||||
private int currParam;
|
||||
private int lastParam;
|
||||
|
||||
public static void inject(ListIterator<String> it, StringBuilder out)
|
||||
throws AndrolibException {
|
||||
new DebugInjector(it, out).inject();
|
||||
@ -44,7 +48,7 @@ public class DebugInjector {
|
||||
nextAndAppend();
|
||||
return;
|
||||
}
|
||||
injectParameters(definition);
|
||||
parseParamsNumber(definition);
|
||||
|
||||
boolean end = false;
|
||||
while (!end) {
|
||||
@ -52,24 +56,28 @@ public class DebugInjector {
|
||||
}
|
||||
}
|
||||
|
||||
private void injectParameters(String definition) throws AndrolibException {
|
||||
int pos = definition.indexOf('(');
|
||||
if (pos == -1) {
|
||||
throw new AndrolibException();
|
||||
}
|
||||
int pos2 = definition.indexOf(')', pos);
|
||||
if (pos2 == -1) {
|
||||
throw new AndrolibException();
|
||||
}
|
||||
String params = definition.substring(pos + 1, pos2);
|
||||
private void parseParamsNumber(String definition) throws AndrolibException {
|
||||
int pos = definition.indexOf('(');
|
||||
if (pos == -1) {
|
||||
throw new AndrolibException();
|
||||
}
|
||||
int pos2 = definition.indexOf(')', pos);
|
||||
if (pos2 == -1) {
|
||||
throw new AndrolibException();
|
||||
}
|
||||
String params = definition.substring(pos + 1, pos2);
|
||||
|
||||
int i = definition.contains(" static ") ? 0 : 1;
|
||||
int argc = TypeName.listFromInternalName(params).size() + i;
|
||||
while (i < argc) {
|
||||
mOut.append(".parameter \"p").append(i).append("\"\n");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
currParam = definition.contains(" static ") ? 0 : 1;
|
||||
lastParam = TypeName.listFromInternalName(params).size() + currParam - 1;
|
||||
}
|
||||
|
||||
private void injectRemainingParams() {
|
||||
areParamsInjected = true;
|
||||
while(currParam <= lastParam) {
|
||||
mOut.append(".parameter \"p").append(currParam).append("\"\n");
|
||||
currParam++;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean step() {
|
||||
String line = next();
|
||||
@ -86,6 +94,9 @@ public class DebugInjector {
|
||||
case '.':
|
||||
return processDirective(line);
|
||||
default:
|
||||
if (! areParamsInjected) {
|
||||
injectRemainingParams();
|
||||
}
|
||||
return processInstruction(line);
|
||||
}
|
||||
}
|
||||
@ -158,11 +169,19 @@ public class DebugInjector {
|
||||
|
||||
private boolean processDirective(String line) {
|
||||
String line2 = line.substring(1);
|
||||
if (line2.startsWith("line ") || line2.equals("prologue")
|
||||
|| line2.startsWith("parameter") || line2.startsWith("local ")
|
||||
|| line2.startsWith("end local ")) {
|
||||
return false;
|
||||
}
|
||||
if (line2.startsWith("line ") || line2.startsWith("local ") || line2.startsWith("end local ")) {
|
||||
return false;
|
||||
}
|
||||
if (line2.equals("prologue")) {
|
||||
if (! areParamsInjected) {
|
||||
injectRemainingParams();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (line2.equals("parameter")) {
|
||||
mOut.append(".parameter \"p").append(currParam++).append("\"\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
append(line);
|
||||
if (line2.equals("end method")) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user