Add support for the -b option for baksmali, to suppress the output of debug info

git-svn-id: https://smali.googlecode.com/svn/trunk@522 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
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 4ca94ea..2d07ee5 100644
--- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodDefinition.java
+++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodDefinition.java
@@ -91,7 +91,7 @@
     private static List<StringTemplate> getParameters(StringTemplateGroup stg, CodeItem codeItem,
                                                                AnnotationSetRefList parameterAnnotations) {
         DebugInfoItem debugInfoItem = null;
-        if (codeItem != null) {
+        if (baksmali.outputDebugInfo && codeItem != null) {
             debugInfoItem = codeItem.getDebugInfo();
         }
 
@@ -169,7 +169,9 @@
         methodItems.addAll(methodItemList.instructions);
         methodItems.addAll(methodItemList.blanks);
         methodItems.addAll(methodItemList.catches);
-        methodItems.addAll(methodItemList.debugItems);
+        if (baksmali.outputDebugInfo) {
+            methodItems.addAll(methodItemList.debugItems);
+        }
         Collections.sort(methodItems);
 
         return methodItems;
diff --git a/baksmali/src/main/java/org/jf/baksmali/baksmali.java b/baksmali/src/main/java/org/jf/baksmali/baksmali.java
index b52e9ba..31ec0fa 100644
--- a/baksmali/src/main/java/org/jf/baksmali/baksmali.java
+++ b/baksmali/src/main/java/org/jf/baksmali/baksmali.java
@@ -44,15 +44,17 @@
     public static boolean noParameterRegisters = false;
     public static boolean useLocalsDirective = false;
     public static boolean useIndexedLabels = false;
+    public static boolean outputDebugInfo = true;
     public static DeodexUtil deodexUtil = null;
 
     public static void disassembleDexFile(DexFile dexFile, Deodexerant deodexerant, String outputDirectory,
                                           boolean noParameterRegisters, boolean useLocalsDirective,
-                                          boolean useIndexedLabels)
+                                          boolean useIndexedLabels, boolean outputDebugInfo)
     {
         baksmali.noParameterRegisters = noParameterRegisters;
         baksmali.useLocalsDirective = useLocalsDirective;
         baksmali.useIndexedLabels = useIndexedLabels;
+        baksmali.outputDebugInfo = outputDebugInfo;
 
         if (deodexerant != null) {
             baksmali.deodexUtil = new DeodexUtil(deodexerant);
diff --git a/baksmali/src/main/java/org/jf/baksmali/main.java b/baksmali/src/main/java/org/jf/baksmali/main.java
index a30da92..f03b74d 100644
--- a/baksmali/src/main/java/org/jf/baksmali/main.java
+++ b/baksmali/src/main/java/org/jf/baksmali/main.java
@@ -74,6 +74,7 @@
         boolean noParameterRegisters = false;
         boolean useLocalsDirective = false;
         boolean useIndexedLabels = false;
+        boolean outputDebugInfo = true;
 
 
         String outputDirectory = "out";
@@ -140,6 +141,10 @@
             useIndexedLabels = true;
         }
 
+        if (commandLine.hasOption("b")) {
+            outputDebugInfo = false;
+        }
+
         if (commandLine.hasOption("x")) {
             String deodexerantAddress = commandLine.getOptionValue("x");
             String[] parts = deodexerantAddress.split(":");
@@ -191,7 +196,7 @@
 
             if (disassemble) {
                 baksmali.disassembleDexFile(dexFile, deodexerant, outputDirectory, noParameterRegisters,
-                        useLocalsDirective, useIndexedLabels);
+                        useLocalsDirective, useIndexedLabels, outputDebugInfo);
             }
 
             if ((doDump || write) && !dexFile.isOdex()) {
@@ -296,7 +301,9 @@
                         " rather than the bytecode offset")
                 .create("i");
 
-        OptionGroup dumpCommand = new OptionGroup();
+        Option noDebugInfoOption = OptionBuilder.withLongOpt("no-debug-info")
+                .withDescription("don't write out debug info (.local, .param, .line, etc.)")
+                .create("b");
 
         options.addOption(versionOption);
         options.addOption(helpOption);
@@ -310,5 +317,6 @@
         options.addOption(deodexerantOption);
         options.addOption(useLocalsOption);
         options.addOption(indexedLabelsOption);
+        options.addOption(noDebugInfoOption);
     }
 }
\ No newline at end of file