Skip to content

Commit

Permalink
feat: add a flag to disable debug info (#276) (PR #502)
Browse files Browse the repository at this point in the history
  • Loading branch information
asashour authored and skylot committed Mar 23, 2019
1 parent eed762d commit d111fd0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions jadx-cli/src/main/java/jadx/cli/JadxCLIArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class JadxCLIArgs {
@Parameter(names = {"--no-imports"}, description = "disable use of imports, always write entire package name")
protected boolean useImports = true;

@Parameter(names = {"--no-debug-info"}, description = "disable debug info")
protected boolean debugInfo = true;

@Parameter(names = "--no-replace-consts", description = "don't replace constant value with matching constant field")
protected boolean replaceConsts = true;

Expand Down Expand Up @@ -160,6 +163,7 @@ public JadxArgs toJadxArgs() {
args.setRespectBytecodeAccModifiers(respectBytecodeAccessModifiers);
args.setExportAsGradleProject(exportAsGradleProject);
args.setUseImports(useImports);
args.setDebugInfo(debugInfo);
return args;
}

Expand Down Expand Up @@ -203,6 +207,10 @@ public boolean isUseImports() {
return useImports;
}

public boolean isDebugInfo() {
return debugInfo;
}

public boolean isDeobfuscationOn() {
return deobfuscationOn;
}
Expand Down
3 changes: 3 additions & 0 deletions jadx-cli/src/test/java/jadx/cli/JadxCLIArgsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ public void testSrcOption() {
@Test
public void testOptionsOverride() {
assertThat(override(new JadxCLIArgs(), "--no-imports").isUseImports(), is(false));
assertThat(override(new JadxCLIArgs(), "--no-debug-info").isDebugInfo(), is(false));
assertThat(override(new JadxCLIArgs(), "").isUseImports(), is(true));

JadxCLIArgs args = new JadxCLIArgs();
args.useImports = false;
assertThat(override(args, "--no-imports").isUseImports(), is(false));
args.debugInfo = false;
assertThat(override(args, "--no-debug-info").isDebugInfo(), is(false));

args = new JadxCLIArgs();
args.useImports = false;
Expand Down
9 changes: 9 additions & 0 deletions jadx-core/src/main/java/jadx/api/JadxArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class JadxArgs {
private boolean showInconsistentCode = false;

private boolean useImports = true;
private boolean debugInfo = true;

private boolean isSkipResources = false;
private boolean isSkipSources = false;
Expand Down Expand Up @@ -133,6 +134,14 @@ public void setUseImports(boolean useImports) {
this.useImports = useImports;
}

public boolean isDebugInfo() {
return debugInfo;
}

public void setDebugInfo(boolean debugInfo) {
this.debugInfo = debugInfo;
}

public boolean isSkipResources() {
return isSkipResources;
}
Expand Down
4 changes: 3 additions & 1 deletion jadx-core/src/main/java/jadx/core/Jadx.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public static List<IDexTreeVisitor> getPassesList(JadxArgs args) {
passes.add(new BlockFinish());

passes.add(new SSATransform());
passes.add(new DebugInfoVisitor());
if (args.isDebugInfo()) {
passes.add(new DebugInfoVisitor());
}
passes.add(new TypeInference());

if (args.isRawCFGOutput()) {
Expand Down

0 comments on commit d111fd0

Please sign in to comment.