xref: /freebsd-src/contrib/llvm-project/lldb/source/Target/TraceCursor.cpp (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1fe6060f1SDimitry Andric //===-- TraceCursor.cpp -----------------------------------------*- C++ -*-===//
2fe6060f1SDimitry Andric //
3fe6060f1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4fe6060f1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5fe6060f1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6fe6060f1SDimitry Andric //
7fe6060f1SDimitry Andric //===----------------------------------------------------------------------===//
8fe6060f1SDimitry Andric 
9fe6060f1SDimitry Andric #include "lldb/Target/TraceCursor.h"
10fe6060f1SDimitry Andric 
11fe6060f1SDimitry Andric #include "lldb/Target/ExecutionContext.h"
1281ad6265SDimitry Andric #include "lldb/Target/Trace.h"
13fe6060f1SDimitry Andric 
14fe6060f1SDimitry Andric using namespace lldb;
15fe6060f1SDimitry Andric using namespace lldb_private;
16fe6060f1SDimitry Andric using namespace llvm;
17fe6060f1SDimitry Andric 
TraceCursor(lldb::ThreadSP thread_sp)18fe6060f1SDimitry Andric TraceCursor::TraceCursor(lldb::ThreadSP thread_sp)
19fe6060f1SDimitry Andric     : m_exe_ctx_ref(ExecutionContext(thread_sp)) {}
20fe6060f1SDimitry Andric 
GetExecutionContextRef()21fe6060f1SDimitry Andric ExecutionContextRef &TraceCursor::GetExecutionContextRef() {
22fe6060f1SDimitry Andric   return m_exe_ctx_ref;
23fe6060f1SDimitry Andric }
24fe6060f1SDimitry Andric 
SetForwards(bool forwards)25fe6060f1SDimitry Andric void TraceCursor::SetForwards(bool forwards) { m_forwards = forwards; }
26fe6060f1SDimitry Andric 
IsForwards() const27fe6060f1SDimitry Andric bool TraceCursor::IsForwards() const { return m_forwards; }
2881ad6265SDimitry Andric 
IsError() const2981ad6265SDimitry Andric bool TraceCursor::IsError() const {
3081ad6265SDimitry Andric   return GetItemKind() == lldb::eTraceItemKindError;
3181ad6265SDimitry Andric }
3281ad6265SDimitry Andric 
IsEvent() const3381ad6265SDimitry Andric bool TraceCursor::IsEvent() const {
3481ad6265SDimitry Andric   return GetItemKind() == lldb::eTraceItemKindEvent;
3581ad6265SDimitry Andric }
3681ad6265SDimitry Andric 
IsInstruction() const3781ad6265SDimitry Andric bool TraceCursor::IsInstruction() const {
3881ad6265SDimitry Andric   return GetItemKind() == lldb::eTraceItemKindInstruction;
3981ad6265SDimitry Andric }
4081ad6265SDimitry Andric 
GetEventTypeAsString() const4181ad6265SDimitry Andric const char *TraceCursor::GetEventTypeAsString() const {
4281ad6265SDimitry Andric   return EventKindToString(GetEventType());
4381ad6265SDimitry Andric }
4481ad6265SDimitry Andric 
EventKindToString(lldb::TraceEvent event_kind)4581ad6265SDimitry Andric const char *TraceCursor::EventKindToString(lldb::TraceEvent event_kind) {
4681ad6265SDimitry Andric   switch (event_kind) {
4781ad6265SDimitry Andric   case lldb::eTraceEventDisabledHW:
4881ad6265SDimitry Andric     return "hardware disabled tracing";
4981ad6265SDimitry Andric   case lldb::eTraceEventDisabledSW:
5081ad6265SDimitry Andric     return "software disabled tracing";
51753f127fSDimitry Andric   case lldb::eTraceEventCPUChanged:
52753f127fSDimitry Andric     return "CPU core changed";
53972a253aSDimitry Andric   case lldb::eTraceEventHWClockTick:
54972a253aSDimitry Andric     return "HW clock tick";
55*bdd1243dSDimitry Andric   case lldb::eTraceEventSyncPoint:
56*bdd1243dSDimitry Andric     return "trace synchronization point";
5781ad6265SDimitry Andric   }
58753f127fSDimitry Andric   llvm_unreachable("Fully covered switch above");
5981ad6265SDimitry Andric }
60