Fix ahat tests
Proguard maps may contain comment lines anywhere in the file.
Adjust the parser to be able to process them when they occur
in the middle of a class spec.
Test: atest ahat-tests:com.android.ahat.SiteHandlerTest#noCrash -- --abi
x86
Bug: 162939236
Change-Id: Id2268e52874c2ba88a1ab6a7b9ce8e19fae604e6
diff --git a/tools/ahat/src/main/com/android/ahat/proguard/ProguardMap.java b/tools/ahat/src/main/com/android/ahat/proguard/ProguardMap.java
index 88231dd..f2f2383 100644
--- a/tools/ahat/src/main/com/android/ahat/proguard/ProguardMap.java
+++ b/tools/ahat/src/main/com/android/ahat/proguard/ProguardMap.java
@@ -232,8 +232,15 @@
// After the class line comes zero or more field/method lines of the form:
// ' type clearName -> obfuscatedName'
+ // '# comment line'
line = reader.readLine();
- while (line != null && line.startsWith(" ")) {
+ while (line != null && (line.startsWith(" ") || line.startsWith("#"))) {
+ // Comment lines start with '#' and may occur anywhere in the file.
+ // Skip over them.
+ if (line.startsWith("#")) {
+ line = reader.readLine();
+ continue;
+ }
String trimmed = line.trim();
int ws = trimmed.indexOf(' ');
sep = trimmed.indexOf(" -> ");