Add proto for smaps.

Bug: 150930222
Change-Id: I331a7375ada35027d077eee362ef7479b9c87f53
diff --git a/Android.bp b/Android.bp
index ded223d..99fb506 100644
--- a/Android.bp
+++ b/Android.bp
@@ -4852,6 +4852,7 @@
     "protos/perfetto/trace/profiling/heap_graph.proto",
     "protos/perfetto/trace/profiling/profile_common.proto",
     "protos/perfetto/trace/profiling/profile_packet.proto",
+    "protos/perfetto/trace/profiling/smaps.proto",
   ],
   tools: [
     "aprotoc",
@@ -4862,6 +4863,7 @@
     "external/perfetto/protos/perfetto/trace/profiling/heap_graph.gen.cc",
     "external/perfetto/protos/perfetto/trace/profiling/profile_common.gen.cc",
     "external/perfetto/protos/perfetto/trace/profiling/profile_packet.gen.cc",
+    "external/perfetto/protos/perfetto/trace/profiling/smaps.gen.cc",
   ],
 }
 
@@ -4872,6 +4874,7 @@
     "protos/perfetto/trace/profiling/heap_graph.proto",
     "protos/perfetto/trace/profiling/profile_common.proto",
     "protos/perfetto/trace/profiling/profile_packet.proto",
+    "protos/perfetto/trace/profiling/smaps.proto",
   ],
   tools: [
     "aprotoc",
@@ -4882,6 +4885,7 @@
     "external/perfetto/protos/perfetto/trace/profiling/heap_graph.gen.h",
     "external/perfetto/protos/perfetto/trace/profiling/profile_common.gen.h",
     "external/perfetto/protos/perfetto/trace/profiling/profile_packet.gen.h",
+    "external/perfetto/protos/perfetto/trace/profiling/smaps.gen.h",
   ],
   export_include_dirs: [
     ".",
@@ -4896,6 +4900,7 @@
     "protos/perfetto/trace/profiling/heap_graph.proto",
     "protos/perfetto/trace/profiling/profile_common.proto",
     "protos/perfetto/trace/profiling/profile_packet.proto",
+    "protos/perfetto/trace/profiling/smaps.proto",
   ],
   tools: [
     "aprotoc",
@@ -4905,6 +4910,7 @@
     "external/perfetto/protos/perfetto/trace/profiling/heap_graph.pb.cc",
     "external/perfetto/protos/perfetto/trace/profiling/profile_common.pb.cc",
     "external/perfetto/protos/perfetto/trace/profiling/profile_packet.pb.cc",
+    "external/perfetto/protos/perfetto/trace/profiling/smaps.pb.cc",
   ],
 }
 
@@ -4915,6 +4921,7 @@
     "protos/perfetto/trace/profiling/heap_graph.proto",
     "protos/perfetto/trace/profiling/profile_common.proto",
     "protos/perfetto/trace/profiling/profile_packet.proto",
+    "protos/perfetto/trace/profiling/smaps.proto",
   ],
   tools: [
     "aprotoc",
@@ -4924,6 +4931,7 @@
     "external/perfetto/protos/perfetto/trace/profiling/heap_graph.pb.h",
     "external/perfetto/protos/perfetto/trace/profiling/profile_common.pb.h",
     "external/perfetto/protos/perfetto/trace/profiling/profile_packet.pb.h",
+    "external/perfetto/protos/perfetto/trace/profiling/smaps.pb.h",
   ],
   export_include_dirs: [
     ".",
@@ -4938,6 +4946,7 @@
     "protos/perfetto/trace/profiling/heap_graph.proto",
     "protos/perfetto/trace/profiling/profile_common.proto",
     "protos/perfetto/trace/profiling/profile_packet.proto",
+    "protos/perfetto/trace/profiling/smaps.proto",
   ],
   tools: [
     "aprotoc",
@@ -4948,6 +4957,7 @@
     "external/perfetto/protos/perfetto/trace/profiling/heap_graph.pbzero.cc",
     "external/perfetto/protos/perfetto/trace/profiling/profile_common.pbzero.cc",
     "external/perfetto/protos/perfetto/trace/profiling/profile_packet.pbzero.cc",
+    "external/perfetto/protos/perfetto/trace/profiling/smaps.pbzero.cc",
   ],
 }
 
@@ -4958,6 +4968,7 @@
     "protos/perfetto/trace/profiling/heap_graph.proto",
     "protos/perfetto/trace/profiling/profile_common.proto",
     "protos/perfetto/trace/profiling/profile_packet.proto",
+    "protos/perfetto/trace/profiling/smaps.proto",
   ],
   tools: [
     "aprotoc",
@@ -4968,6 +4979,7 @@
     "external/perfetto/protos/perfetto/trace/profiling/heap_graph.pbzero.h",
     "external/perfetto/protos/perfetto/trace/profiling/profile_common.pbzero.h",
     "external/perfetto/protos/perfetto/trace/profiling/profile_packet.pbzero.h",
+    "external/perfetto/protos/perfetto/trace/profiling/smaps.pbzero.h",
   ],
   export_include_dirs: [
     ".",
diff --git a/BUILD b/BUILD
index dd6f6e6..efdb732 100644
--- a/BUILD
+++ b/BUILD
@@ -2426,6 +2426,7 @@
         "protos/perfetto/trace/profiling/heap_graph.proto",
         "protos/perfetto/trace/profiling/profile_common.proto",
         "protos/perfetto/trace/profiling/profile_packet.proto",
+        "protos/perfetto/trace/profiling/smaps.proto",
     ],
     visibility = [
         PERFETTO_CONFIG.proto_library_visibility,
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto
index 60e797f..0fae738 100644
--- a/protos/perfetto/trace/perfetto_trace.proto
+++ b/protos/perfetto/trace/perfetto_trace.proto
@@ -3482,6 +3482,22 @@
 
 // End of protos/perfetto/trace/profiling/profile_packet.proto
 
+// Begin of protos/perfetto/trace/profiling/smaps.proto
+
+message SmapsEntry {
+  optional string path = 1;
+  optional uint64 size_kb = 2;
+  optional uint64 private_dirty_kb = 3;
+  optional uint64 swap_kb = 4;
+};
+
+message SmapsPacket {
+  optional uint32 pid = 1;
+  repeated SmapsEntry entries = 2;
+};
+
+// End of protos/perfetto/trace/profiling/smaps.proto
+
 // Begin of protos/perfetto/trace/ps/process_stats.proto
 
 // Per-process periodically sampled stats. These samples are wrapped in a
@@ -3694,7 +3710,7 @@
 // TracePacket(s).
 //
 // Next reserved id: 13 (up to 15).
-// Next id: 68.
+// Next id: 69.
 message TracePacket {
   // The timestamp of the TracePacket.
   // By default this timestamps refers to the trace clock (CLOCK_BOOTTIME on
@@ -3747,6 +3763,7 @@
     VulkanApiEvent vulkan_api_event = 65;
     PerfSample perf_sample = 66;
     CpuInfo cpu_info = 67;
+    SmapsPacket smaps_packet = 68;
 
     // Only used in profile packets.
     ProfiledFrameSymbols profiled_frame_symbols = 55;
diff --git a/protos/perfetto/trace/profiling/BUILD.gn b/protos/perfetto/trace/profiling/BUILD.gn
index 3b607a2..3bf8905 100644
--- a/protos/perfetto/trace/profiling/BUILD.gn
+++ b/protos/perfetto/trace/profiling/BUILD.gn
@@ -19,5 +19,6 @@
     "heap_graph.proto",
     "profile_common.proto",
     "profile_packet.proto",
+    "smaps.proto",
   ]
 }
diff --git a/protos/perfetto/trace/profiling/smaps.proto b/protos/perfetto/trace/profiling/smaps.proto
new file mode 100644
index 0000000..ec8ec2e
--- /dev/null
+++ b/protos/perfetto/trace/profiling/smaps.proto
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+message SmapsEntry {
+  optional string path = 1;
+  optional uint64 size_kb = 2;
+  optional uint64 private_dirty_kb = 3;
+  optional uint64 swap_kb = 4;
+};
+
+message SmapsPacket {
+  optional uint32 pid = 1;
+  repeated SmapsEntry entries = 2;
+};
diff --git a/protos/perfetto/trace/trace_packet.proto b/protos/perfetto/trace/trace_packet.proto
index ca5f7ce..87b1ff0 100644
--- a/protos/perfetto/trace/trace_packet.proto
+++ b/protos/perfetto/trace/trace_packet.proto
@@ -40,6 +40,7 @@
 import "protos/perfetto/trace/profiling/heap_graph.proto";
 import "protos/perfetto/trace/profiling/profile_common.proto";
 import "protos/perfetto/trace/profiling/profile_packet.proto";
+import "protos/perfetto/trace/profiling/smaps.proto";
 import "protos/perfetto/trace/ps/process_stats.proto";
 import "protos/perfetto/trace/ps/process_tree.proto";
 import "protos/perfetto/trace/sys_stats/sys_stats.proto";
@@ -59,7 +60,7 @@
 // TracePacket(s).
 //
 // Next reserved id: 13 (up to 15).
-// Next id: 68.
+// Next id: 69.
 message TracePacket {
   // The timestamp of the TracePacket.
   // By default this timestamps refers to the trace clock (CLOCK_BOOTTIME on
@@ -112,6 +113,7 @@
     VulkanApiEvent vulkan_api_event = 65;
     PerfSample perf_sample = 66;
     CpuInfo cpu_info = 67;
+    SmapsPacket smaps_packet = 68;
 
     // Only used in profile packets.
     ProfiledFrameSymbols profiled_frame_symbols = 55;
diff --git a/tools/gen_merged_protos b/tools/gen_merged_protos
index 37306ed..2bcde9a 100755
--- a/tools/gen_merged_protos
+++ b/tools/gen_merged_protos
@@ -89,6 +89,7 @@
     'protos/perfetto/trace/profiling/heap_graph.proto',
     'protos/perfetto/trace/profiling/profile_common.proto',
     'protos/perfetto/trace/profiling/profile_packet.proto',
+    'protos/perfetto/trace/profiling/smaps.proto',
     'protos/perfetto/trace/ps/process_stats.proto',
     'protos/perfetto/trace/ps/process_tree.proto',
     'protos/perfetto/trace/sys_stats/sys_stats.proto',