Add trace_to_text

To estimate overhead of perfetto we would like to use... perfetto!
To allow for this reintroduce the 'trace_to_text' binary from the demo
which takes in a Trace and outputs systrace formatted text viewable
in the TraceViewer.

Other changes in this CL:
- Introduce a 'Trace' proto.
  This proto is just a repeated field of TracePackets
- Modify perfetto_cmd to output a Trace rather than just all the
  TracePackets back to back.
- To allow for this perfetto_cmd has a new dep on protozero.
- Fix a bug in ftrace_controller.cc where we implemented the generation
  count for each periodic task we started rather than once for each set
  of periodic tasks.

Change-Id: I2c9c194dfa85217bb2de02741bc2c4bcd1a0f908
diff --git a/Android.bp b/Android.bp
index eb9d198..868e196 100644
--- a/Android.bp
+++ b/Android.bp
@@ -228,6 +228,7 @@
   name: "perfetto_protos_lite_gen",
   srcs: [
     "protos/test_event.proto",
+    "protos/trace.proto",
     "protos/trace_packet.proto",
   ],
   tools: [
@@ -236,6 +237,7 @@
   cmd: "mkdir -p $(genDir)/external/perfetto && $(location aprotoc) --cpp_out=$(genDir)/external/perfetto --proto_path=external/perfetto $(in)",
   out: [
     "external/perfetto/protos/test_event.pb.cc",
+    "external/perfetto/protos/trace.pb.cc",
     "external/perfetto/protos/trace_packet.pb.cc",
   ],
 }
@@ -245,6 +247,7 @@
   name: "perfetto_protos_lite_gen_headers",
   srcs: [
     "protos/test_event.proto",
+    "protos/trace.proto",
     "protos/trace_packet.proto",
   ],
   tools: [
@@ -253,6 +256,7 @@
   cmd: "mkdir -p $(genDir)/external/perfetto && $(location aprotoc) --cpp_out=$(genDir)/external/perfetto --proto_path=external/perfetto $(in)",
   out: [
     "external/perfetto/protos/test_event.pb.h",
+    "external/perfetto/protos/trace.pb.h",
     "external/perfetto/protos/trace_packet.pb.h",
   ],
   export_include_dirs: [
@@ -349,6 +353,7 @@
   name: "perfetto_protos_zero_gen",
   srcs: [
     "protos/test_event.proto",
+    "protos/trace.proto",
     "protos/trace_packet.proto",
   ],
   tools: [
@@ -358,6 +363,7 @@
   cmd: "mkdir -p $(genDir)/external/perfetto && $(location aprotoc) --cpp_out=$(genDir)/external/perfetto --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location perfetto_src_protozero_protoc_plugin_protoc_plugin___gn_standalone_toolchain_gcc_like_host_) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto $(in)",
   out: [
     "external/perfetto/protos/test_event.pbzero.cc",
+    "external/perfetto/protos/trace.pbzero.cc",
     "external/perfetto/protos/trace_packet.pbzero.cc",
   ],
 }
@@ -367,6 +373,7 @@
   name: "perfetto_protos_zero_gen_headers",
   srcs: [
     "protos/test_event.proto",
+    "protos/trace.proto",
     "protos/trace_packet.proto",
   ],
   tools: [
@@ -376,6 +383,7 @@
   cmd: "mkdir -p $(genDir)/external/perfetto && $(location aprotoc) --cpp_out=$(genDir)/external/perfetto --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location perfetto_src_protozero_protoc_plugin_protoc_plugin___gn_standalone_toolchain_gcc_like_host_) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto $(in)",
   out: [
     "external/perfetto/protos/test_event.pbzero.h",
+    "external/perfetto/protos/trace.pbzero.h",
     "external/perfetto/protos/trace_packet.pbzero.h",
   ],
   export_include_dirs: [