1 //===-- TraceCursor.cpp -----------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Target/TraceCursor.h"
11 #include "lldb/Target/ExecutionContext.h"
12 #include "lldb/Target/Trace.h"
15 using namespace lldb_private
;
18 TraceCursor::TraceCursor(lldb::ThreadSP thread_sp
)
19 : m_exe_ctx_ref(ExecutionContext(thread_sp
)) {}
21 ExecutionContextRef
&TraceCursor::GetExecutionContextRef() {
25 void TraceCursor::SetForwards(bool forwards
) { m_forwards
= forwards
; }
27 bool TraceCursor::IsForwards() const { return m_forwards
; }
29 bool TraceCursor::IsError() const {
30 return GetItemKind() == lldb::eTraceItemKindError
;
33 bool TraceCursor::IsEvent() const {
34 return GetItemKind() == lldb::eTraceItemKindEvent
;
37 bool TraceCursor::IsInstruction() const {
38 return GetItemKind() == lldb::eTraceItemKindInstruction
;
41 const char *TraceCursor::GetEventTypeAsString() const {
42 return EventKindToString(GetEventType());
45 const char *TraceCursor::EventKindToString(lldb::TraceEvent event_kind
) {
47 case lldb::eTraceEventDisabledHW
:
48 return "hardware disabled tracing";
49 case lldb::eTraceEventDisabledSW
:
50 return "software disabled tracing";
51 case lldb::eTraceEventCPUChanged
:
52 return "CPU core changed";
53 case lldb::eTraceEventHWClockTick
:
54 return "HW clock tick";
55 case lldb::eTraceEventSyncPoint
:
56 return "trace synchronization point";
58 llvm_unreachable("Fully covered switch above");