aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectThread.cpp
diff options
context:
space:
mode:
authorWalter Erquinigo <wallace@fb.com>2021-07-21 14:46:51 -0700
committerWalter Erquinigo <wallace@fb.com>2021-07-26 18:01:50 -0700
commitc1b4632528cb405c9ef94cff90bf43afe688a899 (patch)
tree946ff57187f382e71a4c1b5bc0f2bb4f935c7a90 /lldb/source/Commands/CommandObjectThread.cpp
parent9654cfd5bb20926bcaf601b5da1707bcd280e37f (diff)
downloadllvm-c1b4632528cb405c9ef94cff90bf43afe688a899.zip
llvm-c1b4632528cb405c9ef94cff90bf43afe688a899.tar.gz
llvm-c1b4632528cb405c9ef94cff90bf43afe688a899.tar.bz2
[trace] Add the definition of a TraceExporter plugin
Copying from the inline documentation: ``` Trace exporter plug-ins operate on traces, converting the trace data provided by an \a lldb_private::TraceCursor into a different format that can be digested by other tools, e.g. Chrome Trace Event Profiler. Trace exporters are supposed to operate on an architecture-agnostic fashion, as a TraceCursor, which feeds the data, hides the actual trace technology being used. ``` I want to use this to make the code in https://reviews.llvm.org/D105741 a plug-in. I also imagine that there will be more and more exporters being implemented, as an exporter creates something useful out of trace data. And tbh I don't want to keep adding more stuff to the lldb/Target folder. This is the minimal definition for a TraceExporter plugin. I plan to use this with the following commands: - thread trace export <plug-in name> [plug-in specific args] - This command would support autocompletion of plug-in names - thread trace export list - This command would list the available trace exporter plug-ins I don't plan to create yet a "process trace export" because it's easier to start analyzing the trace of a given thread than of the entire process. When we need a process-level command, we can implement it. I also don't plan to force each "export" command implementation to support multiple threads (for example, "thread trace start 1 2 3" or "thread trace start all" operate on many threads simultaneously). The reason is that the format used by the exporter might or might not support multiple threads, so I'm leaving this decision to each trace exporter plug-in. Differential Revision: https://reviews.llvm.org/D106501
Diffstat (limited to 'lldb/source/Commands/CommandObjectThread.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectThread.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 3b58d71..7247601 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -1924,13 +1924,38 @@ public:
// Next are the subcommands of CommandObjectMultiwordTrace
+// CommandObjectTraceExport
+
+class CommandObjectTraceExport : public CommandObjectMultiword {
+public:
+ CommandObjectTraceExport(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(
+ interpreter, "trace thread export",
+ "Commands for exporting traces of the threads in the current "
+ "process to different formats.",
+ "thread trace export <export-plugin> [<subcommand objects>]") {
+
+ for (uint32_t i = 0; true; i++) {
+ if (const char *plugin_name =
+ PluginManager::GetTraceExporterPluginNameAtIndex(i)) {
+ if (ThreadTraceExportCommandCreator command_creator =
+ PluginManager::GetThreadTraceExportCommandCreatorAtIndex(i)) {
+ LoadSubCommand(plugin_name, command_creator(interpreter));
+ }
+ } else {
+ break;
+ }
+ }
+ }
+};
+
// CommandObjectTraceStart
class CommandObjectTraceStart : public CommandObjectTraceProxy {
public:
CommandObjectTraceStart(CommandInterpreter &interpreter)
: CommandObjectTraceProxy(
- /*live_debug_session_only*/ true, interpreter, "thread trace start",
+ /*live_debug_session_only=*/true, interpreter, "thread trace start",
"Start tracing threads with the corresponding trace "
"plug-in for the current process.",
"thread trace start [<trace-options>]") {}
@@ -2248,6 +2273,8 @@ public:
CommandObjectSP(new CommandObjectTraceStart(interpreter)));
LoadSubCommand("stop",
CommandObjectSP(new CommandObjectTraceStop(interpreter)));
+ LoadSubCommand("export",
+ CommandObjectSP(new CommandObjectTraceExport(interpreter)));
}
~CommandObjectMultiwordTrace() override = default;