1 //===-- TraceCursor.cpp -----------------------------------------*- C++ -*-===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "lldb/Target/TraceCursor.h" 10 11 #include "lldb/Target/ExecutionContext.h" 12 #include "lldb/Target/Trace.h" 13 14 using namespace lldb; 15 using namespace lldb_private; 16 using namespace llvm; 17 TraceCursor(lldb::ThreadSP thread_sp)18TraceCursor::TraceCursor(lldb::ThreadSP thread_sp) 19 : m_exe_ctx_ref(ExecutionContext(thread_sp)) {} 20 GetExecutionContextRef()21ExecutionContextRef &TraceCursor::GetExecutionContextRef() { 22 return m_exe_ctx_ref; 23 } 24 SetForwards(bool forwards)25void TraceCursor::SetForwards(bool forwards) { m_forwards = forwards; } 26 IsForwards() const27bool TraceCursor::IsForwards() const { return m_forwards; } 28 IsError() const29bool TraceCursor::IsError() const { 30 return GetItemKind() == lldb::eTraceItemKindError; 31 } 32 IsEvent() const33bool TraceCursor::IsEvent() const { 34 return GetItemKind() == lldb::eTraceItemKindEvent; 35 } 36 IsInstruction() const37bool TraceCursor::IsInstruction() const { 38 return GetItemKind() == lldb::eTraceItemKindInstruction; 39 } 40 GetEventTypeAsString() const41const char *TraceCursor::GetEventTypeAsString() const { 42 return EventKindToString(GetEventType()); 43 } 44 EventKindToString(lldb::TraceEvent event_kind)45const char *TraceCursor::EventKindToString(lldb::TraceEvent event_kind) { 46 switch (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"; 57 } 58 llvm_unreachable("Fully covered switch above"); 59 } 60