AI 144278: Some changes to make examination of flaky devices easier.
  Added "dexcheck" shell script, which runs the dexdump checksum
  verification against every file in /data/dalvik-cache.
  Added "-c" flag to dexdump, which quits after the checksum test
  (faster than sending everything to /dev/null).
  Initialize a ZipArchive struct earlier; without this dexdump was
  crashing in some situations when dealing with a nonexistent file.
  BUG=1749836

Automated import of CL 144278
diff --git a/tools/dexcheck b/tools/dexcheck
new file mode 100755
index 0000000..a4f7399
--- /dev/null
+++ b/tools/dexcheck
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# This requires read permission on /data/dalvik-cache.  On an eng build this
+# works, on userdebug you will need to "adb root", or "su" followed by
+# "chmod 777 /data/dalvik-cache".
+
+# Get the list of files.  Use "sed" to drop the trailing carriage return.
+files=`adb shell "cd /data/dalvik-cache; echo *" | sed -e s/.$//`
+
+# Check each file in turn.  This is much faster with "dexdump -c", but that
+# was added post-cupcake.
+for file in $files; do
+	echo $file
+	errout=`adb shell "dexdump /data/dalvik-cache/$file > dev/null"`
+	echo $errout | grep ERROR > /dev/null
+	if [ $? -eq 0 ]; then
+		echo "  Failure in $file: $errout"
+	fi
+done
+
+exit 0
+