simpleperf: fix reading symbols from multidex apk.

Bug: none
Test: run simpleperf_unit_test.
Change-Id: I04715ff7abe22819b30881d73706fb59cd5521ea
diff --git a/simpleperf/read_apk.cpp b/simpleperf/read_apk.cpp
index 8c85073..a6aae6f 100644
--- a/simpleperf/read_apk.cpp
+++ b/simpleperf/read_apk.cpp
@@ -159,6 +159,10 @@
         if (entry_name_start < entry_name_end && zip_path_start < zip_path_end) {
           *entry_name = path.substr(entry_name_start, entry_name_end - entry_name_start);
           *zip_path = path.substr(zip_path_start, zip_path_end - zip_path_start);
+          size_t multidex_separator_pos = zip_path->find('!');
+          if (multidex_separator_pos != std::string::npos) {
+            zip_path->resize(multidex_separator_pos);
+          }
           return true;
         }
       }
diff --git a/simpleperf/read_apk_test.cpp b/simpleperf/read_apk_test.cpp
index 6d8bf2d..d9665ac 100644
--- a/simpleperf/read_apk_test.cpp
+++ b/simpleperf/read_apk_test.cpp
@@ -62,4 +62,11 @@
   ASSERT_EQ(entry_name, "classes.dex");
   ASSERT_FALSE(ParseExtractedInMemoryPath("/dev/ashmem/dalvik-thread local mark stack (deleted)",
                                           &zip_path, &entry_name));
+
+  // Parse multidex file.
+  ASSERT_TRUE(ParseExtractedInMemoryPath("/dev/ashmem/dalvik-classes2.dex extracted in memory from "
+      "/data/app/getxml.test.com.testgetxml-knxI11ZXLT-OVBs9X9bSkw==/base.apk!classes2.dex "
+      "(deleted)", &zip_path, &entry_name));
+  ASSERT_EQ(zip_path, "/data/app/getxml.test.com.testgetxml-knxI11ZXLT-OVBs9X9bSkw==/base.apk");
+  ASSERT_EQ(entry_name, "classes2.dex");
 }