Enable multi-dex content per file in dexlist/dump.

Rationale:
Unlike the original Dalvik-based utilities, the Art-based
utilities are able to extract multi-dex content from one file.
So no need for any artificial restriction on number of dex files.

Bug: 22322814
Change-Id: I7c603d22c7e0caa5ae712b905d9bb83982f1b918
diff --git a/dexdump/dexdump.cc b/dexdump/dexdump.cc
index f55dccd..84c465f 100644
--- a/dexdump/dexdump.cc
+++ b/dexdump/dexdump.cc
@@ -52,7 +52,7 @@
 struct Options gOptions;
 
 /*
- * Output file. Defaults to stdout, but tests can modify.
+ * Output file. Defaults to stdout.
  */
 FILE* gOutFile = stdout;
 
@@ -63,8 +63,6 @@
 typedef uint16_t u2;
 typedef uint32_t u4;
 typedef uint64_t u8;
-typedef int8_t   s1;
-typedef int16_t  s2;
 typedef int32_t  s4;
 typedef int64_t  s8;
 
@@ -1274,23 +1272,14 @@
     return -1;
   }
 
-  // Determine if opening file yielded a single dex file. On failure,
-  // the parse error message of the original dexdump utility is shown.
-  //
-  // TODO(ajcbik): this restriction is not really needed, but kept
-  //               for now to stay close to original dexdump; we can
-  //               later relax this!
-  //
-  if (dex_files.size() != 1) {
-    fprintf(stderr, "ERROR: DEX parse failed\n");
-    return -1;
-  }
-
-  // Success. Either report checksum verification or process dex file.
+  // Success. Either report checksum verification or process
+  // all dex files found in given file.
   if (gOptions.checksumOnly) {
     fprintf(gOutFile, "Checksum verified\n");
   } else {
-    processDexFile(fileName, dex_files[0].get());
+    for (size_t i = 0; i < dex_files.size(); i++) {
+      processDexFile(fileName, dex_files[i].get());
+    }
   }
   return 0;
 }
diff --git a/dexdump/dexdump_main.cc b/dexdump/dexdump_main.cc
index 756f879..9be0922 100644
--- a/dexdump/dexdump_main.cc
+++ b/dexdump/dexdump_main.cc
@@ -108,8 +108,8 @@
       default:
         wantUsage = true;
         break;
-    }
-  }
+    }  // switch
+  }  // while
 
   // Detect early problems.
   if (optind == argc) {
@@ -138,7 +138,7 @@
   int result = 0;
   while (optind < argc) {
     result |= processFile(argv[optind++]);
-  }
+  }  // while
   return result != 0;
 }
 
diff --git a/dexlist/dexlist.cc b/dexlist/dexlist.cc
index d7c0e4c..d8fd242 100644
--- a/dexlist/dexlist.cc
+++ b/dexlist/dexlist.cc
@@ -51,11 +51,8 @@
  * Data types that match the definitions in the VM specification.
  */
 typedef uint8_t  u1;
-typedef uint16_t u2;
 typedef uint32_t u4;
 typedef uint64_t u8;
-typedef int32_t  s4;
-typedef int64_t  s8;
 
 /*
  * Returns a newly-allocated string for the "dot version" of the class
@@ -193,23 +190,15 @@
     return -1;
   }
 
-  // Determine if opening file yielded a single dex file.
-  //
-  // TODO(ajcbik): this restriction is not really needed, but kept
-  //               for now to stay close to original dexlist; we can
-  //               later relax this!
-  //
-  if (dex_files.size() != 1) {
-    fprintf(stderr, "ERROR: DEX parse failed\n");
-    return -1;
-  }
-  const DexFile* pDexFile = dex_files[0].get();
-
-  // Success. Iterate over all classes.
+  // Success. Iterate over all dex files found in given file.
   fprintf(gOutFile, "#%s\n", fileName);
-  const u4 classDefsSize = pDexFile->GetHeader().class_defs_size_;
-  for (u4 idx = 0; idx < classDefsSize; idx++) {
-    dumpClass(pDexFile, idx);
+  for (size_t i = 0; i < dex_files.size(); i++) {
+    // Iterate over all classes in one dex file.
+    const DexFile* pDexFile = dex_files[i].get();
+    const u4 classDefsSize = pDexFile->GetHeader().class_defs_size_;
+    for (u4 idx = 0; idx < classDefsSize; idx++) {
+      dumpClass(pDexFile, idx);
+    }
   }
   return 0;
 }
@@ -246,7 +235,7 @@
         gOptions.outputFileName = optarg;
         break;
       case 'm':
-        // If -m X.Y.Z is given, then find all instances of the
+        // If -m x.y.z is given, then find all instances of the
         // fully-qualified method name. This isn't really what
         // dexlist is for, but it's easy to do it here.
         {