diff --git a/lldb/include/lldb/Target/Trace.h b/lldb/include/lldb/Target/Trace.h --- a/lldb/include/lldb/Target/Trace.h +++ b/lldb/include/lldb/Target/Trace.h @@ -169,9 +169,9 @@ /// Get a \a TraceCursor for the given thread's trace. /// /// \return - /// A \a TraceCursorUP. If the thread is not traced or its trace + /// A \a TraceCursorSP. If the thread is not traced or its trace /// information failed to load, an \a llvm::Error is returned. - virtual llvm::Expected + virtual llvm::Expected CreateNewCursor(Thread &thread) = 0; /// Dump general info about a given thread's trace. Each Trace plug-in diff --git a/lldb/include/lldb/Target/TraceCursor.h b/lldb/include/lldb/Target/TraceCursor.h --- a/lldb/include/lldb/Target/TraceCursor.h +++ b/lldb/include/lldb/Target/TraceCursor.h @@ -52,7 +52,7 @@ /// /// Sample usage: /// -/// TraceCursorUP cursor = trace.GetTrace(thread); +/// TraceCursorSP cursor = trace.GetTrace(thread); /// /// for (; cursor->HasValue(); cursor->Next()) { /// TraceItemKind kind = cursor->GetItemKind(); diff --git a/lldb/include/lldb/Target/TraceDumper.h b/lldb/include/lldb/Target/TraceDumper.h --- a/lldb/include/lldb/Target/TraceDumper.h +++ b/lldb/include/lldb/Target/TraceDumper.h @@ -93,7 +93,7 @@ /// /// \param[in] options /// Additional options for configuring the dumping. - TraceDumper(lldb::TraceCursorUP &&cursor_up, Stream &s, + TraceDumper(lldb::TraceCursorSP cursor_sp, Stream &s, const TraceDumperOptions &options); /// Dump \a count instructions of the thread trace starting at the current @@ -114,7 +114,7 @@ /// Create a trace item for the current position without symbol information. TraceItem CreatRawTraceItem(); - lldb::TraceCursorUP m_cursor_up; + lldb::TraceCursorSP m_cursor_sp; TraceDumperOptions m_options; std::unique_ptr m_writer_up; }; diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -420,7 +420,7 @@ typedef std::shared_ptr ThreadPlanTracerSP; typedef std::shared_ptr TraceSP; typedef std::unique_ptr TraceExporterUP; -typedef std::unique_ptr TraceCursorUP; +typedef std::shared_ptr TraceCursorSP; typedef std::shared_ptr TypeSP; typedef std::weak_ptr TypeWP; typedef std::shared_ptr TypeCategoryImplSP; diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -2269,17 +2269,17 @@ m_options.m_dumper_options.id = m_last_id; } - llvm::Expected cursor_or_error = + llvm::Expected cursor_or_error = m_exe_ctx.GetTargetSP()->GetTrace()->CreateNewCursor(*thread_sp); if (!cursor_or_error) { result.AppendError(llvm::toString(cursor_or_error.takeError())); return false; } - TraceCursorUP &cursor_up = *cursor_or_error; + TraceCursorSP &cursor_sp = *cursor_or_error; if (m_options.m_dumper_options.id && - !cursor_up->HasId(*m_options.m_dumper_options.id)) { + !cursor_sp->HasId(*m_options.m_dumper_options.id)) { result.AppendError("invalid instruction id\n"); return false; } @@ -2295,10 +2295,10 @@ // We need to stop processing data when we already ran out of instructions // in a previous command. We can fake this by setting the cursor past the // end of the trace. - cursor_up->Seek(1, TraceCursor::SeekType::End); + cursor_sp->Seek(1, TraceCursor::SeekType::End); } - TraceDumper dumper(std::move(cursor_up), + TraceDumper dumper(std::move(cursor_sp), out_file ? *out_file : result.GetOutputStream(), m_options.m_dumper_options); diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h @@ -71,7 +71,7 @@ llvm::StringRef GetSchema() override; - llvm::Expected CreateNewCursor(Thread &thread) override; + llvm::Expected CreateNewCursor(Thread &thread) override; void DumpTraceInfo(Thread &thread, Stream &s, bool verbose, bool json) override; diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp @@ -176,12 +176,12 @@ return storage.beginning_of_time_nanos; } -llvm::Expected +llvm::Expected TraceIntelPT::CreateNewCursor(Thread &thread) { if (Expected decoded_thread = Decode(thread)) { if (Expected> beginning_of_time = FindBeginningOfTimeNanos()) - return std::make_unique( + return std::make_shared( thread.shared_from_this(), *decoded_thread, m_storage.tsc_conversion, *beginning_of_time); else diff --git a/lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp b/lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp --- a/lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp +++ b/lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp @@ -81,7 +81,7 @@ return false; } else { auto do_work = [&]() -> Error { - Expected cursor = trace_sp->CreateNewCursor(*thread); + Expected cursor = trace_sp->CreateNewCursor(*thread); if (!cursor) return cursor.takeError(); TraceHTR htr(*thread, **cursor); diff --git a/lldb/source/Target/TraceDumper.cpp b/lldb/source/Target/TraceDumper.cpp --- a/lldb/source/Target/TraceDumper.cpp +++ b/lldb/source/Target/TraceDumper.cpp @@ -295,32 +295,32 @@ new OutputWriterCLI(s, options, thread)); } -TraceDumper::TraceDumper(lldb::TraceCursorUP &&cursor_up, Stream &s, +TraceDumper::TraceDumper(lldb::TraceCursorSP cursor_sp, Stream &s, const TraceDumperOptions &options) - : m_cursor_up(std::move(cursor_up)), m_options(options), + : m_cursor_sp(std::move(cursor_sp)), m_options(options), m_writer_up(CreateWriter( - s, m_options, *m_cursor_up->GetExecutionContextRef().GetThreadSP())) { + s, m_options, *m_cursor_sp->GetExecutionContextRef().GetThreadSP())) { if (m_options.id) - m_cursor_up->GoToId(*m_options.id); + m_cursor_sp->GoToId(*m_options.id); else if (m_options.forwards) - m_cursor_up->Seek(0, TraceCursor::SeekType::Beginning); + m_cursor_sp->Seek(0, TraceCursor::SeekType::Beginning); else - m_cursor_up->Seek(0, TraceCursor::SeekType::End); + m_cursor_sp->Seek(0, TraceCursor::SeekType::End); - m_cursor_up->SetForwards(m_options.forwards); + m_cursor_sp->SetForwards(m_options.forwards); if (m_options.skip) { - m_cursor_up->Seek((m_options.forwards ? 1 : -1) * *m_options.skip, + m_cursor_sp->Seek((m_options.forwards ? 1 : -1) * *m_options.skip, TraceCursor::SeekType::Current); } } TraceDumper::TraceItem TraceDumper::CreatRawTraceItem() { TraceItem item = {}; - item.id = m_cursor_up->GetId(); + item.id = m_cursor_sp->GetId(); if (m_options.show_timestamps) - item.timestamp = m_cursor_up->GetWallClockTime(); + item.timestamp = m_cursor_sp->GetWallClockTime(); return item; } @@ -378,7 +378,7 @@ } Optional TraceDumper::DumpInstructions(size_t count) { - ThreadSP thread_sp = m_cursor_up->GetExecutionContextRef().GetThreadSP(); + ThreadSP thread_sp = m_cursor_sp->GetExecutionContextRef().GetThreadSP(); SymbolInfo prev_symbol_info; Optional last_id; @@ -386,32 +386,32 @@ ExecutionContext exe_ctx; thread_sp->GetProcess()->GetTarget().CalculateExecutionContext(exe_ctx); - for (size_t insn_seen = 0; insn_seen < count && m_cursor_up->HasValue(); - m_cursor_up->Next()) { + for (size_t insn_seen = 0; insn_seen < count && m_cursor_sp->HasValue(); + m_cursor_sp->Next()) { - last_id = m_cursor_up->GetId(); + last_id = m_cursor_sp->GetId(); TraceItem item = CreatRawTraceItem(); - if (m_cursor_up->IsEvent()) { + if (m_cursor_sp->IsEvent()) { if (!m_options.show_events) continue; - item.event = m_cursor_up->GetEventType(); + item.event = m_cursor_sp->GetEventType(); switch (*item.event) { case eTraceEventCPUChanged: - item.cpu_id = m_cursor_up->GetCPU(); + item.cpu_id = m_cursor_sp->GetCPU(); break; case eTraceEventHWClockTick: - item.hw_clock = m_cursor_up->GetHWClock(); + item.hw_clock = m_cursor_sp->GetHWClock(); break; case eTraceEventDisabledHW: case eTraceEventDisabledSW: break; } - } else if (m_cursor_up->IsError()) { - item.error = m_cursor_up->GetError(); + } else if (m_cursor_sp->IsError()) { + item.error = m_cursor_sp->GetError(); } else { insn_seen++; - item.load_address = m_cursor_up->GetLoadAddress(); + item.load_address = m_cursor_sp->GetLoadAddress(); if (!m_options.raw) { SymbolInfo symbol_info; @@ -429,7 +429,7 @@ } m_writer_up->TraceItem(item); } - if (!m_cursor_up->HasValue()) + if (!m_cursor_sp->HasValue()) m_writer_up->NoMoreData(); return last_id; }