aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectThread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Commands/CommandObjectThread.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectThread.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 1d31f11..292f9c6 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -2086,15 +2086,20 @@ protected:
ThreadSP thread_sp =
m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
- size_t count = m_options.m_count;
- ssize_t position = m_options.m_position.getValueOr(
- trace_sp->GetCursorPosition(*thread_sp)) -
- m_consecutive_repetitions * count;
- if (position < 0)
- result.AppendError("error: no more data");
- else
- trace_sp->DumpTraceInstructions(*thread_sp, result.GetOutputStream(),
- count, position, m_options.m_raw);
+ if (llvm::Optional<size_t> insn_count =
+ trace_sp->GetInstructionCount(*thread_sp)) {
+ size_t count = m_options.m_count;
+ ssize_t position =
+ m_options.m_position.getValueOr((ssize_t)*insn_count - 1) -
+ m_consecutive_repetitions * count;
+ if (position < 0)
+ result.AppendError("error: no more data");
+ else
+ trace_sp->DumpTraceInstructions(*thread_sp, result.GetOutputStream(),
+ count, position, m_options.m_raw);
+ } else {
+ result.AppendError("error: not traced");
+ }
return true;
}