diff options
author | Walter Erquinigo <a20012251@gmail.com> | 2020-10-26 21:22:06 -0700 |
---|---|---|
committer | Walter Erquinigo <a20012251@gmail.com> | 2020-11-18 18:24:36 -0800 |
commit | fb19f11ef47bc479d42c11450817c5e855a9830b (patch) | |
tree | 54a34a6be75b39928683e89ad76ee4d9e8395968 /lldb/source/Commands/CommandObjectMultiword.cpp | |
parent | 25f5406f087579d43ca9a82dee7f3e76f0691bad (diff) | |
download | llvm-fb19f11ef47bc479d42c11450817c5e855a9830b.zip llvm-fb19f11ef47bc479d42c11450817c5e855a9830b.tar.gz llvm-fb19f11ef47bc479d42c11450817c5e855a9830b.tar.bz2 |
[trace][intel-pt] Scaffold the 'thread trace start | stop' commands
Depends on D90490.
The stop command is simple and invokes the new method Trace::StopTracingThread(thread).
On the other hand, the start command works by delegating its implementation to a CommandObject provided by the Trace plugin. This is necessary because each trace plugin needs different options for this command. There's even the chance that a Trace plugin can't support live tracing, but instead supports offline decoding and analysis, which means that "thread trace dump instructions" works but "thread trace start" doest. Because of this and a few other reasons, it's better to have each plugin provide this implementation.
Besides, I'm using the GetSupportedTraceType method introduced in D90490 to quickly infer what's the trace plug-in that works for the current process.
As an implementation note, I moved CommandObjectIterateOverThreads to its header so that I can use it from the IntelPT plugin. Besides, the actual start and stop logic for intel-pt is not part of this diff.
Reviewed By: clayborg
Differential Revision: https://reviews.llvm.org/D90729
Diffstat (limited to 'lldb/source/Commands/CommandObjectMultiword.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectMultiword.cpp | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp index 9033cfe..0f20a1d 100644 --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -261,11 +261,32 @@ CommandObjectProxy::CommandObjectProxy(CommandInterpreter &interpreter, CommandObjectProxy::~CommandObjectProxy() = default; +Options *CommandObjectProxy::GetOptions() { + CommandObject *proxy_command = GetProxyCommandObject(); + if (proxy_command) + return proxy_command->GetOptions(); + return CommandObject::GetOptions(); +} + +llvm::StringRef CommandObjectProxy::GetHelp() { + CommandObject *proxy_command = GetProxyCommandObject(); + if (proxy_command) + return proxy_command->GetHelp(); + return CommandObject::GetHelp(); +} + +llvm::StringRef CommandObjectProxy::GetSyntax() { + CommandObject *proxy_command = GetProxyCommandObject(); + if (proxy_command) + return proxy_command->GetSyntax(); + return CommandObject::GetSyntax(); +} + llvm::StringRef CommandObjectProxy::GetHelpLong() { CommandObject *proxy_command = GetProxyCommandObject(); if (proxy_command) return proxy_command->GetHelpLong(); - return llvm::StringRef(); + return CommandObject::GetHelpLong(); } bool CommandObjectProxy::IsRemovable() const { @@ -293,7 +314,9 @@ CommandObjectMultiword *CommandObjectProxy::GetAsMultiwordCommand() { void CommandObjectProxy::GenerateHelpText(Stream &result) { CommandObject *proxy_command = GetProxyCommandObject(); if (proxy_command) - return proxy_command->GenerateHelpText(result); + proxy_command->GenerateHelpText(result); + else + CommandObject::GenerateHelpText(result); } lldb::CommandObjectSP @@ -345,13 +368,6 @@ bool CommandObjectProxy::WantsCompletion() { return false; } -Options *CommandObjectProxy::GetOptions() { - CommandObject *proxy_command = GetProxyCommandObject(); - if (proxy_command) - return proxy_command->GetOptions(); - return nullptr; -} - void CommandObjectProxy::HandleCompletion(CompletionRequest &request) { CommandObject *proxy_command = GetProxyCommandObject(); if (proxy_command) @@ -373,12 +389,15 @@ const char *CommandObjectProxy::GetRepeatCommand(Args ¤t_command_args, return nullptr; } +llvm::StringRef CommandObjectProxy::GetUnsupportedError() { + return "command is not implemented"; +} + bool CommandObjectProxy::Execute(const char *args_string, CommandReturnObject &result) { CommandObject *proxy_command = GetProxyCommandObject(); if (proxy_command) return proxy_command->Execute(args_string, result); - result.AppendError("command is not implemented"); - result.SetStatus(eReturnStatusFailed); + result.SetError(GetUnsupportedError()); return false; } |