diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2021-08-22 19:00:43 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2021-11-13 20:39:49 +0000 |
commit | fe6060f10f634930ff71b7c50291ddc610da2475 (patch) | |
tree | 1483580c790bd4d27b6500a7542b5ee00534d3cc /contrib/llvm-project/lldb/source/Commands/CommandObjectTrace.cpp | |
parent | b61bce17f346d79cecfd8f195a64b10f77be43b1 (diff) | |
parent | 344a3780b2e33f6ca763666c380202b18aab72a3 (diff) |
Diffstat (limited to 'contrib/llvm-project/lldb/source/Commands/CommandObjectTrace.cpp')
-rw-r--r-- | contrib/llvm-project/lldb/source/Commands/CommandObjectTrace.cpp | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/contrib/llvm-project/lldb/source/Commands/CommandObjectTrace.cpp b/contrib/llvm-project/lldb/source/Commands/CommandObjectTrace.cpp index 170630b85b2e..c55fed45d4f4 100644 --- a/contrib/llvm-project/lldb/source/Commands/CommandObjectTrace.cpp +++ b/contrib/llvm-project/lldb/source/Commands/CommandObjectTrace.cpp @@ -23,6 +23,7 @@ #include "lldb/Interpreter/OptionValueLanguage.h" #include "lldb/Interpreter/OptionValueString.h" #include "lldb/Interpreter/Options.h" +#include "lldb/Target/Process.h" #include "lldb/Target/Trace.h" using namespace lldb; @@ -86,14 +87,12 @@ protected: result.AppendError( "a single path to a JSON file containing a trace session" "is required"); - result.SetStatus(eReturnStatusFailed); return false; } auto end_with_failure = [&result](llvm::Error err) -> bool { result.AppendErrorWithFormat("%s\n", llvm::toString(std::move(err)).c_str()); - result.SetStatus(eReturnStatusFailed); return false; }; @@ -113,10 +112,11 @@ protected: return end_with_failure(session_file.takeError()); if (Expected<lldb::TraceSP> traceOrErr = - Trace::FindPlugin(GetDebugger(), *session_file, - json_file.GetDirectory().AsCString())) { + Trace::FindPluginForPostMortemProcess( + GetDebugger(), *session_file, + json_file.GetDirectory().AsCString())) { lldb::TraceSP trace_sp = traceOrErr.get(); - if (m_options.m_verbose) + if (m_options.m_verbose && trace_sp) result.AppendMessageWithFormat("loading trace with plugin %s\n", trace_sp->GetPluginName().AsCString()); } else @@ -188,7 +188,6 @@ protected: result.SetStatus(eReturnStatusSuccessFinishResult); } else { result.AppendErrorWithFormat("%s\n", error.AsCString()); - result.SetStatus(eReturnStatusFailed); } return result.Succeeded(); } @@ -252,7 +251,7 @@ protected: bool DoExecute(Args &command, CommandReturnObject &result) override { Status error; if (command.empty()) { - result.SetError( + result.AppendError( "trace schema cannot be invoked without a plug-in as argument"); return false; } @@ -279,7 +278,6 @@ protected: result.SetStatus(eReturnStatusSuccessFinishResult); } else { result.AppendErrorWithFormat("%s\n", error.AsCString()); - result.SetStatus(eReturnStatusFailed); } return result.Succeeded(); } @@ -303,3 +301,33 @@ CommandObjectTrace::CommandObjectTrace(CommandInterpreter &interpreter) } CommandObjectTrace::~CommandObjectTrace() = default; + +Expected<CommandObjectSP> CommandObjectTraceProxy::DoGetProxyCommandObject() { + ProcessSP process_sp = m_interpreter.GetExecutionContext().GetProcessSP(); + + if (!process_sp) + return createStringError(inconvertibleErrorCode(), + "Process not available."); + if (m_live_debug_session_only && !process_sp->IsLiveDebugSession()) + return createStringError(inconvertibleErrorCode(), + "Process must be alive."); + + if (Expected<TraceSP> trace_sp = process_sp->GetTarget().GetTraceOrCreate()) + return GetDelegateCommand(**trace_sp); + else + return createStringError(inconvertibleErrorCode(), + "Tracing is not supported. %s", + toString(trace_sp.takeError()).c_str()); +} + +CommandObject *CommandObjectTraceProxy::GetProxyCommandObject() { + if (Expected<CommandObjectSP> delegate = DoGetProxyCommandObject()) { + m_delegate_sp = *delegate; + m_delegate_error.clear(); + return m_delegate_sp.get(); + } else { + m_delegate_sp.reset(); + m_delegate_error = toString(delegate.takeError()); + return nullptr; + } +} |