Support gzip files in trace_to_text

Core change in trace_to_text:

1. Add `OnlineTraceToText` utility by refactoring the core TraceToText
   code to make it easy to use, easy to test independently without much
   boilerplate code and easy to compose with other streaming algorithms.
   Client OnlineTraceToText can continue to `feed` it a sequence of
   mem-blocks, and it will continue to write the output in a out_stream.

2. Rewrite trace_to_text driver function, which first figures out if the
   input file is gzip or proto files and setup/wire the streaming
   components as follows:

   when gzip file:

     {InputFile} --> {Streaming GzipDecompress} --> {OnlineTraceToText}
                                                      ||
                                                      ||
                                                      \/
                                                   {Output}

   when proto file:

     {InputFile} --> {OnlineTraceToText} --> {Output}

   The data is streamed from one component to the next one, in a
   sequence of mem-block, and finally written to the output_file/stdout.

3. Some other minor cleanup/refactoring in trace_to_text code.

4. Manual testing:

   For `example_android_trace_15s.gz` attached on b/148130323:

   >> ./tools/traceconv text /tmp/e_trace_15s           >   /tmp/p1.txt
   >> ./out/default/trace_to_text text /tmp/e_trace_15s  >  /tmp/p2.txt
   >> ./out/default/trace_to_text text /tmp/e_trace_15s.gz > /tmp/p3.txt
   >> md5sum /tmp/p1.txt
    ac7b8b397d3e5e543e91d2c909c35416  // [Baseline (before this CL)]
   >> md5sum /tmp/p2.txt
    ac7b8b397d3e5e543e91d2c909c35416  // [trace2text after this CL]
   >> md5sum /tmp/p3.txt
    ac7b8b397d3e5e543e91d2c909c35416  // [decompress + trace2text after
                                          this CL]

Bug: 148130323
Change-Id: I2c8aa080aba45434e202bd9ff99c4a20de69571e
diff --git a/Android.bp b/Android.bp
index 8d92551..b74dcf6 100644
--- a/Android.bp
+++ b/Android.bp
@@ -8492,6 +8492,7 @@
     name: "perfetto_src_trace_processor_util_unittests",
     srcs: [
         "src/trace_processor/util/debug_annotation_parser_unittest.cc",
+        "src/trace_processor/util/gzip_utils_unittest.cc",
         "src/trace_processor/util/proto_to_args_parser_unittest.cc",
         "src/trace_processor/util/protozero_to_text_unittests.cc",
     ],
@@ -9181,7 +9182,6 @@
     name: "perfetto_tools_trace_to_text_full",
     srcs: [
         "tools/trace_to_text/proto_full_utils.cc",
-        "tools/trace_to_text/trace_to_text.cc",
     ],
 }
 
@@ -9208,6 +9208,22 @@
     ],
 }
 
+// GN: //tools/trace_to_text:trace_to_text_lib
+filegroup {
+    name: "perfetto_tools_trace_to_text_trace_to_text_lib",
+    srcs: [
+        "tools/trace_to_text/trace_to_text.cc",
+    ],
+}
+
+// GN: //tools/trace_to_text:unittests
+filegroup {
+    name: "perfetto_tools_trace_to_text_unittests",
+    srcs: [
+        "tools/trace_to_text/trace_to_text_unittest.cc",
+    ],
+}
+
 // GN: //tools/trace_to_text:utils
 filegroup {
     name: "perfetto_tools_trace_to_text_utils",
@@ -9478,6 +9494,7 @@
         ":perfetto_src_profiling_perf_producer_unittests",
         ":perfetto_src_profiling_perf_regs_parsing",
         ":perfetto_src_profiling_perf_unwinding",
+        ":perfetto_src_profiling_symbolizer_symbolize_database",
         ":perfetto_src_profiling_symbolizer_symbolizer",
         ":perfetto_src_profiling_symbolizer_unittests",
         ":perfetto_src_profiling_unittests",
@@ -9578,6 +9595,9 @@
         ":perfetto_src_tracing_test_tracing_integration_test",
         ":perfetto_src_tracing_unittests",
         ":perfetto_tools_sanitizers_unittests_sanitizers_unittests",
+        ":perfetto_tools_trace_to_text_trace_to_text_lib",
+        ":perfetto_tools_trace_to_text_unittests",
+        ":perfetto_tools_trace_to_text_utils",
     ],
     shared_libs: [
         "libandroidicu",
@@ -9703,6 +9723,7 @@
         "perfetto_src_traced_probes_ftrace_test_messages_cpp_gen_headers",
         "perfetto_src_traced_probes_ftrace_test_messages_lite_gen_headers",
         "perfetto_src_traced_probes_ftrace_test_messages_zero_gen_headers",
+        "perfetto_tools_trace_to_text_gen_cc_trace_descriptor",
     ],
     defaults: [
         "perfetto_defaults",
@@ -9979,6 +10000,7 @@
         ":perfetto_tools_trace_to_text_common",
         ":perfetto_tools_trace_to_text_full",
         ":perfetto_tools_trace_to_text_pprofbuilder",
+        ":perfetto_tools_trace_to_text_trace_to_text_lib",
         ":perfetto_tools_trace_to_text_utils",
     ],
     static_libs: [