From 44c5c07c5724e9448d803b3585c9ef47117c3d4e Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Sat, 28 Sep 2013 17:55:52 -0700 Subject: [PATCH] Don't output parameter names when using the -b/--no-debug-info option --- .../org/jf/baksmali/Adaptors/ClassDefinition.java | 4 ++-- .../org/jf/baksmali/Adaptors/MethodDefinition.java | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/ClassDefinition.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/ClassDefinition.java index 8c5e4846..60ef448c 100644 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/ClassDefinition.java +++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/ClassDefinition.java @@ -263,7 +263,7 @@ public class ClassDefinition { MethodImplementation methodImpl = method.getImplementation(); if (methodImpl == null) { - MethodDefinition.writeEmptyMethodTo(methodWriter, method); + MethodDefinition.writeEmptyMethodTo(methodWriter, method, options); } else { MethodDefinition methodDefinition = new MethodDefinition(this, method, methodImpl); methodDefinition.writeTo(methodWriter); @@ -308,7 +308,7 @@ public class ClassDefinition { MethodImplementation methodImpl = method.getImplementation(); if (methodImpl == null) { - MethodDefinition.writeEmptyMethodTo(methodWriter, method); + MethodDefinition.writeEmptyMethodTo(methodWriter, method, options); } else { MethodDefinition methodDefinition = new MethodDefinition(this, method, methodImpl); methodDefinition.writeTo(methodWriter); diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodDefinition.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodDefinition.java index 611936b6..8ebd1e78 100644 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodDefinition.java +++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodDefinition.java @@ -31,6 +31,7 @@ package org.jf.baksmali.Adaptors; import com.google.common.collect.ImmutableList; import org.jf.baksmali.Adaptors.Debug.DebugMethodItem; import org.jf.baksmali.Adaptors.Format.InstructionMethodItemFactory; +import org.jf.baksmali.baksmaliOptions; import org.jf.dexlib2.AccessFlags; import org.jf.dexlib2.Format; import org.jf.dexlib2.Opcode; @@ -113,7 +114,8 @@ public class MethodDefinition { } } - public static void writeEmptyMethodTo(IndentingWriter writer, Method method) throws IOException { + public static void writeEmptyMethodTo(IndentingWriter writer, Method method, + baksmaliOptions options) throws IOException { writer.write(".method "); writeAccessFlags(writer, method.getAccessFlags()); writer.write(method.getName()); @@ -127,7 +129,7 @@ public class MethodDefinition { writer.write('\n'); writer.indent(4); - writeParameters(writer, method, methodParameters); + writeParameters(writer, method, methodParameters, options); AnnotationFormatter.writeTo(writer, method.getAnnotations()); writer.deindent(4); writer.write(".end method\n"); @@ -164,7 +166,7 @@ public class MethodDefinition { writer.printSignedIntAsDec(methodImpl.getRegisterCount()); } writer.write('\n'); - writeParameters(writer, method, methodParameters); + writeParameters(writer, method, methodParameters, classDef.options); if (registerFormatter == null) { registerFormatter = new RegisterFormatter(classDef.options, methodImpl.getRegisterCount(), @@ -218,7 +220,8 @@ public class MethodDefinition { } private static void writeParameters(IndentingWriter writer, Method method, - List parameters) throws IOException { + List parameters, + baksmaliOptions options) throws IOException { boolean isStatic = AccessFlags.STATIC.isSet(method.getAccessFlags()); int registerNumber = isStatic?0:1; for (MethodParameter parameter: parameters) { @@ -229,7 +232,7 @@ public class MethodDefinition { writer.write(".param p"); writer.printSignedIntAsDec(registerNumber); - if (parameterName != null) { + if (parameterName != null && options.outputDebugInfo) { writer.write(", "); ReferenceFormatter.writeStringReference(writer, parameterName); }