Trace Processor: add --httpd
This CL adds a built-in HTTP RPC interface to
TraceProcessor. It allows to use a native trace
proocessor with the UI over HTTP.
It also move the RPC-related classes in a rpc/ subdir.
Bug: 143074239
Change-Id: I05416f8f604bafa4a9d26dbe0ff0db25fdd4d555
diff --git a/src/trace_processor/trace_processor_shell.cc b/src/trace_processor/trace_processor_shell.cc
index c113e95..25ffb6f 100644
--- a/src/trace_processor/trace_processor_shell.cc
+++ b/src/trace_processor/trace_processor_shell.cc
@@ -39,6 +39,10 @@
#include "src/trace_processor/metrics/metrics.descriptor.h"
#include "src/trace_processor/proto_to_json.h"
+#if PERFETTO_BUILDFLAG(PERFETTO_TP_HTTPD)
+#include "src/trace_processor/rpc/httpd.h"
+#endif
+
#if PERFETTO_BUILDFLAG(PERFETTO_OS_LINUX) || \
PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID) || \
PERFETTO_BUILDFLAG(PERFETTO_OS_MACOSX)
@@ -635,6 +639,7 @@
std::string metric_extra;
std::string trace_file_path;
bool launch_shell = false;
+ bool enable_httpd = false;
bool wide = false;
bool force_full_sort = false;
};
@@ -694,6 +699,7 @@
If used with --run-metrics, the query is
executed after the selected metrics and
the metrics output is suppressed.
+ -D, --httpd Enables the HTTP RPC server.
-i, --interactive Starts interactive mode even after a query
file is specified with -q or
--run-metrics.
@@ -730,6 +736,7 @@
{"help", no_argument, nullptr, 'h'},
{"version", no_argument, nullptr, 'v'},
{"wide", no_argument, nullptr, 'W'},
+ {"httpd", no_argument, nullptr, 'D'},
{"interactive", no_argument, nullptr, 'i'},
{"debug", no_argument, nullptr, 'd'},
{"perf-file", required_argument, nullptr, 'p'},
@@ -745,7 +752,7 @@
int option_index = 0;
for (;;) {
int option =
- getopt_long(argc, argv, "hvWidp:q:e:", long_options, &option_index);
+ getopt_long(argc, argv, "hvWiDdp:q:e:", long_options, &option_index);
if (option == -1)
break; // EOF.
@@ -760,6 +767,15 @@
continue;
}
+ if (option == 'D') {
+#if PERFETTO_BUILDFLAG(PERFETTO_TP_HTTPD)
+ command_line_options.enable_httpd = true;
+#else
+ PERFETTO_FATAL("HTTP RPC module not supported in this build");
+#endif
+ continue;
+ }
+
if (option == 'W') {
command_line_options.wide = true;
continue;
@@ -873,6 +889,13 @@
int TraceProcessorMain(int argc, char** argv) {
CommandLineOptions options = ParseCommandLineOptions(argc, argv);
+#if PERFETTO_BUILDFLAG(PERFETTO_TP_HTTPD)
+ if (options.enable_httpd) {
+ RunHttpRPCServer();
+ return 0;
+ }
+#endif
+
// Load the trace file into the trace processor.
Config config;
config.force_full_sort = options.force_full_sort;