diff options
Diffstat (limited to 'contrib/llvm-project/lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp')
-rw-r--r-- | contrib/llvm-project/lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/contrib/llvm-project/lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp b/contrib/llvm-project/lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp index a72e46a0b703..194cc7459027 100644 --- a/contrib/llvm-project/lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp @@ -73,15 +73,22 @@ bool CommandObjectThreadTraceExportCTF::DoExecute(Args &command, if (thread == nullptr) { const uint32_t num_threads = process->GetThreadList().GetSize(); - size_t tid = m_options.m_thread_index.getValueOr(LLDB_INVALID_THREAD_ID); + size_t tid = m_options.m_thread_index.value_or(LLDB_INVALID_THREAD_ID); result.AppendErrorWithFormatv( "Thread index {0} is out of range (valid values are 1 - {1}).\n", tid, num_threads); return false; } else { - TraceHTR htr(*thread, *trace_sp->GetCursor(*thread)); - htr.ExecutePasses(); - if (llvm::Error err = htr.Export(m_options.m_file)) { + auto do_work = [&]() -> Error { + Expected<TraceCursorUP> cursor = trace_sp->CreateNewCursor(*thread); + if (!cursor) + return cursor.takeError(); + TraceHTR htr(*thread, **cursor); + htr.ExecutePasses(); + return htr.Export(m_options.m_file); + }; + + if (llvm::Error err = do_work()) { result.AppendErrorWithFormat("%s\n", toString(std::move(err)).c_str()); return false; } else { |