Add ftrace support to DebugService
This allows us to do ad-hoc kernel-level tracing on a running Metropolis node.
Useful for tracking down complex bugs.
Example: `bazel run //metropolis/cli/dbg -- trace -function_graph_filter blkdev_* function_graph`
Test Plan: Debug utility, manually tested
X-Origin-Diff: phab/D748
GitOrigin-RevId: 924eb795250412a73eb30c0eef4a8c1cc726e5fd
diff --git a/metropolis/proto/api/debug.proto b/metropolis/proto/api/debug.proto
index 25e369e..6cbe32b 100644
--- a/metropolis/proto/api/debug.proto
+++ b/metropolis/proto/api/debug.proto
@@ -39,6 +39,9 @@
//
// TODO(q3k): move method and its related messages to the non-debug node endpoint once we have one.
rpc GetLogs(GetLogsRequest) returns (stream GetLogsResponse);
+
+ // Trace enables tracing of Metropolis using the Linux ftrace infrastructure.
+ rpc Trace(TraceRequest) returns (stream TraceEvent);
}
@@ -146,3 +149,21 @@
Raw raw = 3;
}
}
+
+message TraceRequest {
+ // Name of the tracer to use. Defined in https://www.kernel.org/doc/html/latest/trace/ftrace.html#the-tracers.
+ // Useful ones enabled in Metropolis: function_graph, function.
+ // Gets reset to nop automatically after the stream is terminated.
+ string tracer = 1;
+
+ // List of functions to trace. Accepts wildcards using the '*' character. If left empty traces all functions.
+ repeated string function_filter = 2;
+
+ // List of functions and their descendants to trace with the function_graph tracer.
+ repeated string graph_function_filter = 3;
+}
+
+message TraceEvent {
+ // Currently we do not parse the event data and just return what the kernel outputs, line-by-line.
+ string raw_line = 1;
+}
\ No newline at end of file