Fix dex file lookup in DumpInfo when dex file locations have full paths.
If `profman --dump-info` is used together with --apk (rather than
--apk-fd and --dex-location), the dex file locations returned by
DexFile.GetLocation may include full paths like
"system_ext/priv-app/SystemUI/SystemUI.apk", which don't match base
keys like "SystemUI.apk" used in DexFileData.profile_key. The result is
that --dump-info dumps methods and classes by ids rather than pretty
printed names.
This replicates how dex files are looked up in
FindDexDataUsingAnnotations used by GetClassesAndMethods, used by
`profman --dump-classes-and-methods` which works fine. Also adopt the
use of ChecksumMatch from there.
Test: adb root
adb shell kill -SIGUSR1 '$(pidof com.android.systemui)' && \
sleep 1 && \
adb shell pm compile -m speed-profile com.android.systemui
adb shell profman --dump-only \
--profile-file=data/misc/profiles/ref/com.android.systemui/primary.prof \
--apk=system_ext/priv-app/SystemUI/SystemUI.apk
verify that the output shows nice method and class names
Change-Id: Ib383d2cc24ddbca0bc6bfb0c7419475c68e4b387
diff --git a/libprofile/profile/profile_compilation_info.cc b/libprofile/profile/profile_compilation_info.cc
index b5cc6b7..f135805 100644
--- a/libprofile/profile/profile_compilation_info.cc
+++ b/libprofile/profile/profile_compilation_info.cc
@@ -2020,9 +2020,11 @@
os << " [num_method_ids=" << dex_data->num_method_ids << "]";
const DexFile* dex_file = nullptr;
for (const DexFile* current : dex_files) {
- if (GetBaseKeyViewFromAugmentedKey(dex_data->profile_key) == current->GetLocation() &&
- dex_data->checksum == current->GetLocationChecksum()) {
+ if (GetBaseKeyViewFromAugmentedKey(dex_data->profile_key) ==
+ GetProfileDexFileBaseKeyView(current->GetLocation()) &&
+ ChecksumMatch(dex_data->checksum, current->GetLocationChecksum())) {
dex_file = current;
+ break;
}
}
os << "\n\thot methods: ";