Further improve debug logging for 77342775

Previous logging had long log lines that were truncated.

For multidex, replace the base location for other than the
first dex file with "+". Split the first line into two, so
that if there are too many dex files in the class loader,
we still get to see at least some of them also for the other
class loader.

Test: Manual; change 108-check-cast to multi-dex and disable
      the Lorg/apache/http/ filtering, check error message.
Bug: 77342775

(cherry picked from commit d54f1f92b3b6c99f1877b50fe98ed95a51fb59fd)

Change-Id: Ic1c6d80ed11dc720f21b0cde1c892573a76c0c3e
diff --git a/runtime/debug_print.cc b/runtime/debug_print.cc
index 6048767..7e075ce 100644
--- a/runtime/debug_print.cc
+++ b/runtime/debug_print.cc
@@ -97,14 +97,27 @@
       StackHandleScope<1> hs(soa.Self());
       Handle<mirror::ClassLoader> handle(hs.NewHandle(loader));
       const char* path_separator = "";
-      VisitClassLoaderDexFiles(soa,
-                               handle,
-                               [&](const DexFile* dex_file) {
-                                 oss << path_separator << dex_file->GetLocation()
-                                     << "/" << static_cast<const void*>(dex_file);
-                                 path_separator = ":";
-                                 return true;  // Continue with the next DexFile.
-                               });
+      const DexFile* base_dex_file = nullptr;
+      VisitClassLoaderDexFiles(
+          soa,
+          handle,
+          [&](const DexFile* dex_file) {
+              oss << path_separator;
+              path_separator = ":";
+              if (base_dex_file != nullptr &&
+                  dex_file->GetLocation().length() > base_dex_file->GetLocation().length() &&
+                  dex_file->GetLocation().compare(0u,
+                                                  base_dex_file->GetLocation().length(),
+                                                  base_dex_file->GetLocation()) == 0) {
+                // Replace the base location with "+" to shorten the output.
+                oss << "+" << dex_file->GetLocation().substr(base_dex_file->GetLocation().length());
+              } else {
+                oss << dex_file->GetLocation();
+                base_dex_file = dex_file;
+              }
+              oss << "/" << static_cast<const void*>(dex_file);
+              return true;  // Continue with the next DexFile.
+          });
       oss << ")";
     }
   }
@@ -132,13 +145,13 @@
   std::string source_descriptor_storage;
   const char* source_descriptor = src_class->GetDescriptor(&source_descriptor_storage);
 
+  LOG(ERROR) << "Maybe bug 77342775, looking for " << target_descriptor
+      << " with loader " << DescribeLoaders(target_class->GetClassLoader(), target_descriptor);
   if (target_class->IsInterface()) {
     ObjPtr<mirror::IfTable> iftable = src_class->GetIfTable();
     CHECK(iftable != nullptr);
     size_t ifcount = iftable->Count();
-    LOG(ERROR) << "Maybe bug 77342775, looking for " << target_descriptor
-        << " with loader " << DescribeLoaders(target_class->GetClassLoader(), target_descriptor)
-        << " in interface table for " << source_descriptor << " ifcount=" << ifcount
+    LOG(ERROR) << "  in interface table for " << source_descriptor << " ifcount=" << ifcount
         << " with loader " << DescribeLoaders(src_class->GetClassLoader(), source_descriptor);
     for (size_t i = 0; i != ifcount; ++i) {
       ObjPtr<mirror::Class> iface = iftable->GetInterface(i);
@@ -147,9 +160,7 @@
       matcher(iface);
     }
   } else {
-    LOG(ERROR) << "Maybe bug 77342775, looking for " << target_descriptor
-        << " with loader " << DescribeLoaders(target_class->GetClassLoader(), target_descriptor)
-        << " in superclass chain for " << source_descriptor
+    LOG(ERROR) << "  in superclass chain for " << source_descriptor
         << " with loader " << DescribeLoaders(src_class->GetClassLoader(), source_descriptor);
     for (ObjPtr<mirror::Class> klass = src_class;
          klass != nullptr;