mirror of
https://github.com/revanced/Apktool.git
synced 2025-02-08 01:56:50 +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,24 +56,28 @@ 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();
|
||||||
}
|
}
|
||||||
int pos2 = definition.indexOf(')', pos);
|
int pos2 = definition.indexOf(')', pos);
|
||||||
if (pos2 == -1) {
|
if (pos2 == -1) {
|
||||||
throw new AndrolibException();
|
throw new AndrolibException();
|
||||||
}
|
}
|
||||||
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++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean step() {
|
private boolean step() {
|
||||||
String line = next();
|
String line = next();
|
||||||
@ -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,11 +169,19 @@ 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 ")) {
|
}
|
||||||
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);
|
append(line);
|
||||||
if (line2.equals("end method")) {
|
if (line2.equals("end method")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user