Add measurement of Dex code bytes and number of unique code items

Also modified -i option to also ignore Dex verificaiton, this allows
dumping jars that have gone through hidden API tool.

Bug: 77721545
Test: test-art-host
Change-Id: If608c0cddd232be465c5df9cdf9b06025e68ea83
diff --git a/tools/dexanalyze/dexanalyze.cc b/tools/dexanalyze/dexanalyze.cc
index 46c4852..083de70 100644
--- a/tools/dexanalyze/dexanalyze.cc
+++ b/tools/dexanalyze/dexanalyze.cc
@@ -49,7 +49,7 @@
         << "Usage " << argv[0] << " [options] <dex files>\n"
         << "    [options] is a combination of the following\n"
         << "    -count_indices (Count dex indices accessed from code items)\n"
-        << "    -i (Ignore DEX checksum failure)\n"
+        << "    -i (Ignore Dex checksum and verification failures)\n"
         << "    -a (Run all experiments)\n"
         << "    -d (Dump on per DEX basis)\n";
     return kExitCodeUsageError;
@@ -62,6 +62,7 @@
         const std::string arg = argv[i];
         if (arg == "-i") {
           verify_checksum_ = false;
+          run_dex_file_verifier_ = false;
         } else if (arg == "-a") {
           run_all_experiments_ = true;
         } else if (arg == "-count-indices") {
diff --git a/tools/dexanalyze/dexanalyze_experiments.cc b/tools/dexanalyze/dexanalyze_experiments.cc
index 427a465..2e95286 100644
--- a/tools/dexanalyze/dexanalyze_experiments.cc
+++ b/tools/dexanalyze/dexanalyze_experiments.cc
@@ -126,11 +126,13 @@
   num_field_ids_ += dex_file.NumFieldIds();
   num_type_ids_ += dex_file.NumTypeIds();
   num_class_defs_ += dex_file.NumClassDefs();
+  std::set<size_t> unique_code_items;
   for (ClassAccessor accessor : dex_file.GetClasses()) {
     std::set<size_t> unique_method_ids;
     std::set<size_t> unique_string_ids;
     accessor.VisitMethods([&](const ClassAccessor::Method& method) {
       dex_code_bytes_ += method.GetInstructions().InsnsSizeInBytes();
+      unique_code_items.insert(method.GetCodeItemOffset());
       for (const DexInstructionPcPair& inst : method.GetInstructions()) {
         switch (inst->Opcode()) {
           case Instruction::CONST_STRING: {
@@ -190,6 +192,7 @@
     total_unique_method_idx_ += unique_method_ids.size();
     total_unique_string_ids_ += unique_string_ids.size();
   }
+  total_unique_code_items_ += unique_code_items.size();
 }
 
 void CountDexIndices::Dump(std::ostream& os, uint64_t total_size) const {
@@ -212,7 +215,9 @@
   os << "Same class invoke: " << same_class_total << "\n";
   os << "Other class invoke: " << other_class_total << "\n";
   os << "Invokes from code: " << (same_class_total + other_class_total) << "\n";
-  os << "Total dex size: " << total_size << "\n";
+  os << "Total Dex code bytes: " << Percent(dex_code_bytes_, total_size) << "\n";
+  os << "Total unique code items: " << total_unique_code_items_ << "\n";
+  os << "Total Dex size: " << total_size << "\n";
 }
 
 }  // namespace art
diff --git a/tools/dexanalyze/dexanalyze_experiments.h b/tools/dexanalyze/dexanalyze_experiments.h
index 0fb4d32..c84b082 100644
--- a/tools/dexanalyze/dexanalyze_experiments.h
+++ b/tools/dexanalyze/dexanalyze_experiments.h
@@ -63,6 +63,7 @@
   size_t num_string_ids_from_code_ = 0;
   size_t total_unique_method_idx_ = 0;
   size_t total_unique_string_ids_ = 0;
+  uint64_t total_unique_code_items_ = 0u;
 
   // Other dex ids.
   size_t dex_code_bytes_ = 0;