Mark ab/7061308 as merged in stage.

Bug: 180401296
Merged-In: Ib778c31f2396906e0c7b61e4b49dd8287418f1bb
Change-Id: I1d7246a36c419ea55e8f99b6a37b34abbe6209d6
diff --git a/Android.bp b/Android.bp
index 9a926eb..a6b4eae 100644
--- a/Android.bp
+++ b/Android.bp
@@ -14,6 +14,10 @@
 // limitations under the License.
 //
 
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 cc_defaults {
     name: "libprocinfo_defaults",
     cflags: [
@@ -38,7 +42,6 @@
     host_supported: true,
     srcs: [
         "process.cpp",
-        "process_map.cpp",
     ],
 
     local_include_dirs: ["include"],
diff --git a/include/procinfo/process_map.h b/include/procinfo/process_map.h
index 569a022..f5fee07 100644
--- a/include/procinfo/process_map.h
+++ b/include/procinfo/process_map.h
@@ -30,133 +30,6 @@
 namespace android {
 namespace procinfo {
 
-template <class CallbackType>
-bool ReadMapFileContent(char* content, const CallbackType& callback) {
-  uint64_t start_addr;
-  uint64_t end_addr;
-  uint16_t flags;
-  uint64_t pgoff;
-  ino_t inode;
-  char* next_line = content;
-  char* p;
-
-  auto pass_space = [&]() {
-    if (*p != ' ') {
-      return false;
-    }
-    while (*p == ' ') {
-      p++;
-    }
-    return true;
-  };
-
-  auto pass_xdigit = [&]() {
-    if (!isxdigit(*p)) {
-      return false;
-    }
-    do {
-      p++;
-    } while (isxdigit(*p));
-    return true;
-  };
-
-  while (next_line != nullptr && *next_line != '\0') {
-    p = next_line;
-    next_line = strchr(next_line, '\n');
-    if (next_line != nullptr) {
-      *next_line = '\0';
-      next_line++;
-    }
-    // Parse line like: 00400000-00409000 r-xp 00000000 fc:00 426998  /usr/lib/gvfs/gvfsd-http
-    char* end;
-    // start_addr
-    start_addr = strtoull(p, &end, 16);
-    if (end == p || *end != '-') {
-      return false;
-    }
-    p = end + 1;
-    // end_addr
-    end_addr = strtoull(p, &end, 16);
-    if (end == p) {
-      return false;
-    }
-    p = end;
-    if (!pass_space()) {
-      return false;
-    }
-    // flags
-    flags = 0;
-    if (*p == 'r') {
-      flags |= PROT_READ;
-    } else if (*p != '-') {
-      return false;
-    }
-    p++;
-    if (*p == 'w') {
-      flags |= PROT_WRITE;
-    } else if (*p != '-') {
-      return false;
-    }
-    p++;
-    if (*p == 'x') {
-      flags |= PROT_EXEC;
-    } else if (*p != '-') {
-      return false;
-    }
-    p++;
-    if (*p != 'p' && *p != 's') {
-      return false;
-    }
-    p++;
-    if (!pass_space()) {
-      return false;
-    }
-    // pgoff
-    pgoff = strtoull(p, &end, 16);
-    if (end == p) {
-      return false;
-    }
-    p = end;
-    if (!pass_space()) {
-      return false;
-    }
-    // major:minor
-    if (!pass_xdigit() || *p++ != ':' || !pass_xdigit() || !pass_space()) {
-      return false;
-    }
-    // inode
-    inode = strtoull(p, &end, 10);
-    if (end == p) {
-      return false;
-    }
-    p = end;
-
-    if (*p != '\0' && !pass_space()) {
-      return false;
-    }
-
-    // filename
-    callback(start_addr, end_addr, flags, pgoff, inode, p);
-  }
-  return true;
-}
-
-inline bool ReadMapFile(const std::string& map_file,
-                        const std::function<void(uint64_t, uint64_t, uint16_t, uint64_t, ino_t,
-                                                 const char*)>& callback) {
-  std::string content;
-  if (!android::base::ReadFileToString(map_file, &content)) {
-    return false;
-  }
-  return ReadMapFileContent(&content[0], callback);
-}
-
-inline bool ReadProcessMaps(pid_t pid,
-                            const std::function<void(uint64_t, uint64_t, uint16_t, uint64_t, ino_t,
-                                                     const char*)>& callback) {
-  return ReadMapFile("/proc/" + std::to_string(pid) + "/maps", callback);
-}
-
 struct MapInfo {
   uint64_t start;
   uint64_t end;
@@ -164,21 +37,275 @@
   uint64_t pgoff;
   ino_t inode;
   std::string name;
+  bool shared;
 
   MapInfo(uint64_t start, uint64_t end, uint16_t flags, uint64_t pgoff, ino_t inode,
-          const char* name)
-      : start(start), end(end), flags(flags), pgoff(pgoff), inode(inode), name(name) {}
+          const char* name, bool shared)
+      : start(start),
+        end(end),
+        flags(flags),
+        pgoff(pgoff),
+        inode(inode),
+        name(name),
+        shared(shared) {}
+
+  MapInfo(const MapInfo& params)
+      : start(params.start),
+        end(params.end),
+        flags(params.flags),
+        pgoff(params.pgoff),
+        inode(params.inode),
+        name(params.name),
+        shared(params.shared) {}
 };
 
-inline bool ReadProcessMaps(pid_t pid, std::vector<MapInfo>* maps) {
-  return ReadProcessMaps(
-      pid, [&](uint64_t start, uint64_t end, uint16_t flags, uint64_t pgoff, ino_t inode,
-               const char* name) { maps->emplace_back(start, end, flags, pgoff, inode, name); });
+typedef std::function<void(const MapInfo&)> MapInfoCallback;
+typedef std::function<void(uint64_t start, uint64_t end, uint16_t flags, uint64_t pgoff,
+                      ino_t inode, const char* name, bool shared)> MapInfoParamsCallback;
+
+static inline bool PassSpace(char** p) {
+  if (**p != ' ') {
+    return false;
+  }
+  while (**p == ' ') {
+    (*p)++;
+  }
+  return true;
 }
 
-bool ReadMapFileAsyncSafe(const char* map_file, void* buffer, size_t buffer_size,
-                          const std::function<void(uint64_t, uint64_t, uint16_t, uint64_t, ino_t,
-                                                   const char*)>& callback);
+static inline bool PassXdigit(char** p) {
+  if (!isxdigit(**p)) {
+    return false;
+  }
+  do {
+    (*p)++;
+  } while (isxdigit(**p));
+  return true;
+}
+
+// Parses a line given p pointing at proc/<pid>/maps content buffer and returns true on success
+// and false on failure parsing. The next end of line will be replaced by null character and the
+// immediate offset after the parsed line will be returned in next_line.
+//
+// Example of how a parsed line look line:
+// 00400000-00409000 r-xp 00000000 fc:00 426998  /usr/lib/gvfs/gvfsd-http
+static inline bool ParseMapsFileLine(char* p, uint64_t& start_addr, uint64_t& end_addr, uint16_t& flags,
+                      uint64_t& pgoff, ino_t& inode, char** name, bool& shared, char** next_line) {
+  // Make end of line be null
+  *next_line = strchr(p, '\n');
+  if (*next_line != nullptr) {
+    **next_line = '\0';
+    (*next_line)++;
+  }
+
+  char* end;
+  // start_addr
+  start_addr = strtoull(p, &end, 16);
+  if (end == p || *end != '-') {
+    return false;
+  }
+  p = end + 1;
+  // end_addr
+  end_addr = strtoull(p, &end, 16);
+  if (end == p) {
+    return false;
+  }
+  p = end;
+  if (!PassSpace(&p)) {
+    return false;
+  }
+  // flags
+  flags = 0;
+  if (*p == 'r') {
+    flags |= PROT_READ;
+  } else if (*p != '-') {
+    return false;
+  }
+  p++;
+  if (*p == 'w') {
+    flags |= PROT_WRITE;
+  } else if (*p != '-') {
+    return false;
+  }
+  p++;
+  if (*p == 'x') {
+    flags |= PROT_EXEC;
+  } else if (*p != '-') {
+    return false;
+  }
+  p++;
+  if (*p != 'p' && *p != 's') {
+    return false;
+  }
+  shared = *p == 's';
+
+  p++;
+  if (!PassSpace(&p)) {
+    return false;
+  }
+  // pgoff
+  pgoff = strtoull(p, &end, 16);
+  if (end == p) {
+    return false;
+  }
+  p = end;
+  if (!PassSpace(&p)) {
+    return false;
+  }
+  // major:minor
+  if (!PassXdigit(&p) || *p++ != ':' || !PassXdigit(&p) || !PassSpace(&p)) {
+    return false;
+  }
+  // inode
+  inode = strtoull(p, &end, 10);
+  if (end == p) {
+    return false;
+  }
+  p = end;
+
+  if (*p != '\0' && !PassSpace(&p)) {
+    return false;
+  }
+
+  *name = p;
+
+  return true;
+}
+
+inline bool ReadMapFileContent(char* content, const MapInfoParamsCallback& callback) {
+  uint64_t start_addr;
+  uint64_t end_addr;
+  uint16_t flags;
+  uint64_t pgoff;
+  ino_t inode;
+  char* line_start = content;
+  char* next_line;
+  char* name;
+  bool shared;
+
+  while (line_start != nullptr && *line_start != '\0') {
+    bool parsed = ParseMapsFileLine(line_start, start_addr, end_addr, flags, pgoff,
+                                    inode, &name, shared, &next_line);
+    if (!parsed) {
+      return false;
+    }
+
+    line_start = next_line;
+    callback(start_addr, end_addr, flags, pgoff, inode, name, shared);
+  }
+  return true;
+}
+
+inline bool ReadMapFileContent(char* content, const MapInfoCallback& callback) {
+  uint64_t start_addr;
+  uint64_t end_addr;
+  uint16_t flags;
+  uint64_t pgoff;
+  ino_t inode;
+  char* line_start = content;
+  char* next_line;
+  char* name;
+  bool shared;
+
+  while (line_start != nullptr && *line_start != '\0') {
+    bool parsed = ParseMapsFileLine(line_start, start_addr, end_addr, flags, pgoff,
+                                    inode, &name, shared, &next_line);
+    if (!parsed) {
+      return false;
+    }
+
+    line_start = next_line;
+    callback(MapInfo(start_addr, end_addr, flags, pgoff, inode, name, shared));
+  }
+  return true;
+}
+
+inline bool ReadMapFile(const std::string& map_file,
+                const MapInfoCallback& callback) {
+  std::string content;
+  if (!android::base::ReadFileToString(map_file, &content)) {
+    return false;
+  }
+  return ReadMapFileContent(&content[0], callback);
+}
+
+inline bool ReadProcessMaps(pid_t pid, const MapInfoCallback& callback) {
+  return ReadMapFile("/proc/" + std::to_string(pid) + "/maps", callback);
+}
+
+inline bool ReadProcessMaps(pid_t pid, std::vector<MapInfo>* maps) {
+  return ReadProcessMaps(pid, [&](const MapInfo& mapinfo) { maps->emplace_back(mapinfo); });
+}
+
+// Reads maps file and executes given callback for each mapping
+// Warning: buffer should not be modified asynchronously while this function executes
+template <class CallbackType>
+inline bool ReadMapFileAsyncSafe(const char* map_file, void* buffer, size_t buffer_size,
+                                 const CallbackType& callback) {
+  if (buffer == nullptr || buffer_size == 0) {
+    return false;
+  }
+
+  int fd = open(map_file, O_RDONLY | O_CLOEXEC);
+  if (fd == -1) {
+    return false;
+  }
+
+  char* char_buffer = reinterpret_cast<char*>(buffer);
+  size_t start = 0;
+  size_t read_bytes = 0;
+  char* line = nullptr;
+  bool read_complete = false;
+  while (true) {
+    ssize_t bytes =
+        TEMP_FAILURE_RETRY(read(fd, char_buffer + read_bytes, buffer_size - read_bytes - 1));
+    if (bytes <= 0) {
+      if (read_bytes == 0) {
+        close(fd);
+        return bytes == 0;
+      }
+      // Treat the last piece of data as the last line.
+      char_buffer[start + read_bytes] = '\n';
+      bytes = 1;
+      read_complete = true;
+    }
+    read_bytes += bytes;
+
+    while (read_bytes > 0) {
+      char* newline = reinterpret_cast<char*>(memchr(&char_buffer[start], '\n', read_bytes));
+      if (newline == nullptr) {
+        break;
+      }
+      *newline = '\0';
+      line = &char_buffer[start];
+      start = newline - char_buffer + 1;
+      read_bytes -= newline - line + 1;
+
+      // Ignore the return code, errors are okay.
+      ReadMapFileContent(line, callback);
+    }
+
+    if (read_complete) {
+      close(fd);
+      return true;
+    }
+
+    if (start == 0 && read_bytes == buffer_size - 1) {
+      // The buffer provided is too small to contain this line, give up
+      // and indicate failure.
+      close(fd);
+      return false;
+    }
+
+    // Copy any leftover data to the front  of the buffer.
+    if (start > 0) {
+      if (read_bytes > 0) {
+        memmove(char_buffer, &char_buffer[start], read_bytes);
+      }
+      start = 0;
+    }
+  }
+}
 
 } /* namespace procinfo */
 } /* namespace android */
diff --git a/process_map.cpp b/process_map.cpp
deleted file mode 100644
index 5e240b9..0000000
--- a/process_map.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <procinfo/process_map.h>
-
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <procinfo/process.h>
-
-namespace android {
-namespace procinfo {
-
-bool ReadMapFileAsyncSafe(const char* map_file, void* buffer, size_t buffer_size,
-                          const std::function<void(uint64_t, uint64_t, uint16_t, uint64_t, ino_t,
-                                                   const char*)>& callback) {
-  if (buffer == nullptr || buffer_size == 0) {
-    return false;
-  }
-
-  int fd = open(map_file, O_RDONLY | O_CLOEXEC);
-  if (fd == -1) {
-    return false;
-  }
-
-  char* char_buffer = reinterpret_cast<char*>(buffer);
-  size_t start = 0;
-  size_t read_bytes = 0;
-  char* line = nullptr;
-  bool read_complete = false;
-  while (true) {
-    ssize_t bytes =
-        TEMP_FAILURE_RETRY(read(fd, char_buffer + read_bytes, buffer_size - read_bytes - 1));
-    if (bytes <= 0) {
-      if (read_bytes == 0) {
-        close(fd);
-        return bytes == 0;
-      }
-      // Treat the last piece of data as the last line.
-      char_buffer[start + read_bytes] = '\n';
-      bytes = 1;
-      read_complete = true;
-    }
-    read_bytes += bytes;
-
-    while (read_bytes > 0) {
-      char* newline = reinterpret_cast<char*>(memchr(&char_buffer[start], '\n', read_bytes));
-      if (newline == nullptr) {
-        break;
-      }
-      *newline = '\0';
-      line = &char_buffer[start];
-      start = newline - char_buffer + 1;
-      read_bytes -= newline - line + 1;
-
-      // Ignore the return code, errors are okay.
-      ReadMapFileContent(line, callback);
-    }
-
-    if (read_complete) {
-      close(fd);
-      return true;
-    }
-
-    if (start == 0 && read_bytes == buffer_size - 1) {
-      // The buffer provided is too small to contain this line, give up
-      // and indicate failure.
-      close(fd);
-      return false;
-    }
-
-    // Copy any leftover data to the front  of the buffer.
-    if (start > 0) {
-      if (read_bytes > 0) {
-        memmove(char_buffer, &char_buffer[start], read_bytes);
-      }
-      start = 0;
-    }
-  }
-}
-
-} /* namespace procinfo */
-} /* namespace android */
diff --git a/process_map_benchmark.cpp b/process_map_benchmark.cpp
index eba4fd0..5a26302 100644
--- a/process_map_benchmark.cpp
+++ b/process_map_benchmark.cpp
@@ -32,10 +32,8 @@
   std::string map_file = android::base::GetExecutableDirectory() + "/testdata/maps";
   for (auto _ : state) {
     std::vector<android::procinfo::MapInfo> maps;
-    android::procinfo::ReadMapFile(map_file, [&](uint64_t start, uint64_t end, uint16_t flags,
-                                                 uint64_t pgoff, ino_t inode, const char* name) {
-      maps.emplace_back(start, end, flags, pgoff, inode, name);
-    });
+    android::procinfo::ReadMapFile(
+        map_file, [&](const android::procinfo::MapInfo& mapinfo) { maps.emplace_back(mapinfo); });
     CHECK_EQ(maps.size(), 2043u);
   }
 }
diff --git a/process_map_test.cpp b/process_map_test.cpp
index b1bdc08..cdc56fe 100644
--- a/process_map_test.cpp
+++ b/process_map_test.cpp
@@ -31,9 +31,7 @@
   std::string map_file = android::base::GetExecutableDirectory() + "/testdata/maps";
   std::vector<android::procinfo::MapInfo> maps;
   ASSERT_TRUE(android::procinfo::ReadMapFile(
-      map_file,
-      [&](uint64_t start, uint64_t end, uint16_t flags, uint64_t pgoff, ino_t inode,
-          const char* name) { maps.emplace_back(start, end, flags, pgoff, inode, name); }));
+      map_file, [&](const android::procinfo::MapInfo& mapinfo) { maps.emplace_back(mapinfo); }));
   ASSERT_EQ(2043u, maps.size());
   ASSERT_EQ(maps[0].start, 0x12c00000ULL);
   ASSERT_EQ(maps[0].end, 0x2ac00000ULL);
@@ -60,9 +58,7 @@
 TEST(process_map, ReadProcessMaps) {
   std::vector<android::procinfo::MapInfo> maps;
   ASSERT_TRUE(android::procinfo::ReadProcessMaps(
-      getpid(),
-      [&](uint64_t start, uint64_t end, uint16_t flags, uint64_t pgoff, ino_t inode,
-          const char* name) { maps.emplace_back(start, end, flags, pgoff, inode, name); }));
+      getpid(), [&](const android::procinfo::MapInfo& mapinfo) { maps.emplace_back(mapinfo); }));
   ASSERT_GT(maps.size(), 0u);
   maps.clear();
   ASSERT_TRUE(android::procinfo::ReadProcessMaps(getpid(), &maps));
@@ -75,8 +71,8 @@
 struct TestMapInfo {
   TestMapInfo() = default;
   TestMapInfo(uint64_t start, uint64_t end, uint16_t flags, uint64_t pgoff, ino_t inode,
-              const char* new_name)
-      : start(start), end(end), flags(flags), pgoff(pgoff), inode(inode) {
+              const char* new_name, bool isShared)
+      : start(start), end(end), flags(flags), pgoff(pgoff), inode(inode), isShared(isShared) {
     strcpy(name, new_name);
   }
   uint64_t start = 0;
@@ -85,6 +81,7 @@
   uint64_t pgoff = 0;
   ino_t inode = 0;
   char name[100] = {};
+  bool isShared = false;
 };
 
 void VerifyReadMapFileAsyncSafe(const char* maps_data,
@@ -96,7 +93,7 @@
   size_t num_maps = 0;
 
   auto callback = [&](uint64_t start, uint64_t end, uint16_t flags, uint64_t pgoff, ino_t inode,
-                      const char* name) {
+                      const char* name, bool shared) {
     if (num_maps != saved_info.size()) {
       TestMapInfo& saved = saved_info[num_maps];
       saved.start = start;
@@ -105,6 +102,7 @@
       saved.pgoff = pgoff;
       saved.inode = inode;
       strcpy(saved.name, name);
+      saved.isShared = shared;
     }
     num_maps++;
   };
@@ -134,6 +132,7 @@
     EXPECT_EQ(expected.pgoff, saved.pgoff);
     EXPECT_EQ(expected.inode, saved.inode);
     EXPECT_STREQ(expected.name, saved.name);
+    EXPECT_EQ(expected.isShared, saved.isShared);
   }
 }
 
@@ -146,7 +145,7 @@
 TEST(process_map, ReadMapFileAsyncSafe_single) {
   std::vector<TestMapInfo> expected_info;
   expected_info.emplace_back(0x12c00000, 0x2ac00000, PROT_READ | PROT_WRITE, 0x100, 10267643,
-                             "/lib/fake.so");
+                             "/lib/fake.so", false);
 
   VerifyReadMapFileAsyncSafe("12c00000-2ac00000 rw-p 00000100 00:05 10267643 /lib/fake.so",
                              expected_info);
@@ -155,7 +154,7 @@
 TEST(process_map, ReadMapFileAsyncSafe_single_with_newline) {
   std::vector<TestMapInfo> expected_info;
   expected_info.emplace_back(0x12c00000, 0x2ac00000, PROT_READ | PROT_WRITE, 0x100, 10267643,
-                             "/lib/fake.so");
+                             "/lib/fake.so", false);
 
   VerifyReadMapFileAsyncSafe("12c00000-2ac00000 rw-p 00000100 00:05 10267643 /lib/fake.so\n",
                              expected_info);
@@ -163,23 +162,28 @@
 
 TEST(process_map, ReadMapFileAsyncSafe_single_no_library) {
   std::vector<TestMapInfo> expected_info;
-  expected_info.emplace_back(0xa0000, 0xc0000, PROT_READ | PROT_WRITE | PROT_EXEC, 0xb00, 101, "");
+  expected_info.emplace_back(0xa0000, 0xc0000, PROT_READ | PROT_WRITE | PROT_EXEC, 0xb00, 101, "",
+                             false);
 
   VerifyReadMapFileAsyncSafe("a0000-c0000 rwxp 00000b00 00:05 101", expected_info);
 }
 
 TEST(process_map, ReadMapFileAsyncSafe_multiple) {
   std::vector<TestMapInfo> expected_info;
-  expected_info.emplace_back(0xa0000, 0xc0000, PROT_READ | PROT_WRITE | PROT_EXEC, 1, 100, "");
-  expected_info.emplace_back(0xd0000, 0xe0000, PROT_READ, 2, 101, "/lib/libsomething1.so");
-  expected_info.emplace_back(0xf0000, 0x100000, PROT_WRITE, 3, 102, "/lib/libsomething2.so");
-  expected_info.emplace_back(0x110000, 0x120000, PROT_EXEC, 4, 103, "[anon:something or another]");
+  expected_info.emplace_back(0xa0000, 0xc0000, PROT_READ | PROT_WRITE | PROT_EXEC, 1, 100, "",
+                             false);
+  expected_info.emplace_back(0xd0000, 0xe0000, PROT_READ, 2, 101, "/lib/libsomething1.so", false);
+  expected_info.emplace_back(0xf0000, 0x100000, PROT_WRITE, 3, 102, "/lib/libsomething2.so", false);
+  expected_info.emplace_back(0x110000, 0x120000, PROT_EXEC, 4, 103, "[anon:something or another]",
+                             false);
+  expected_info.emplace_back(0x130000, 0x140000, PROT_READ, 5, 104, "/lib/libsomething3.so", true);
 
   std::string map_data =
       "0a0000-0c0000 rwxp 00000001 00:05 100\n"
       "0d0000-0e0000 r--p 00000002 00:05 101  /lib/libsomething1.so\n"
       "0f0000-100000 -w-p 00000003 00:05 102  /lib/libsomething2.so\n"
-      "110000-120000 --xp 00000004 00:05 103  [anon:something or another]\n";
+      "110000-120000 --xp 00000004 00:05 103  [anon:something or another]\n"
+      "130000-140000 r--s 00000005 00:05 104  /lib/libsomething3.so\n";
 
   VerifyReadMapFileAsyncSafe(map_data.c_str(), expected_info);
 }
@@ -191,7 +195,7 @@
   for (size_t i = 0; i < 10000; i++) {
     map_data += android::base::StringPrintf("%" PRIx64 "-%" PRIx64 " r--p %zx 01:20 %zu fake.so\n",
                                             start, start + 0x1000, i, 1000 + i);
-    expected_info.emplace_back(start, start + 0x1000, PROT_READ, i, 1000 + i, "fake.so");
+    expected_info.emplace_back(start, start + 0x1000, PROT_READ, i, 1000 + i, "fake.so", false);
   }
 
   VerifyReadMapFileAsyncSafe(map_data.c_str(), expected_info);
@@ -199,7 +203,7 @@
 
 TEST(process_map, ReadMapFileAsyncSafe_buffer_nullptr) {
   size_t num_calls = 0;
-  auto callback = [&](uint64_t, uint64_t, uint16_t, uint64_t, ino_t, const char*) { num_calls++; };
+  auto callback = [&](const android::procinfo::MapInfo&) { num_calls++; };
 
 #if defined(__BIONIC__)
   // Any allocations will block after this call.
@@ -218,7 +222,7 @@
 
 TEST(process_map, ReadMapFileAsyncSafe_buffer_size_zero) {
   size_t num_calls = 0;
-  auto callback = [&](uint64_t, uint64_t, uint16_t, uint64_t, ino_t, const char*) { num_calls++; };
+  auto callback = [&](const android::procinfo::MapInfo&) { num_calls++; };
 
 #if defined(__BIONIC__)
   // Any allocations will block after this call.
@@ -238,7 +242,7 @@
 
 TEST(process_map, ReadMapFileAsyncSafe_buffer_too_small_no_calls) {
   size_t num_calls = 0;
-  auto callback = [&](uint64_t, uint64_t, uint16_t, uint64_t, ino_t, const char*) { num_calls++; };
+  auto callback = [&](const android::procinfo::MapInfo&) { num_calls++; };
 
 #if defined(__BIONIC__)
   // Any allocations will block after this call.
@@ -263,7 +267,7 @@
       "0a0000-0c0000 rwxp 00000001 00:05 100    /fake/lib.so\n", tf.fd));
 
   size_t num_calls = 0;
-  auto callback = [&](uint64_t, uint64_t, uint16_t, uint64_t, ino_t, const char*) { num_calls++; };
+  auto callback = [&](const android::procinfo::MapInfo&) { num_calls++; };
 
 #if defined(__BIONIC__)
   // Any allocations will block after this call.