xref: /freebsd-src/contrib/llvm-project/lldb/source/Target/TraceCursor.cpp (revision 753f127f3ace09432b2baeffd71a308760641a62)
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 
18fe6060f1SDimitry Andric TraceCursor::TraceCursor(lldb::ThreadSP thread_sp)
19fe6060f1SDimitry Andric     : m_exe_ctx_ref(ExecutionContext(thread_sp)) {}
20fe6060f1SDimitry Andric 
21fe6060f1SDimitry Andric ExecutionContextRef &TraceCursor::GetExecutionContextRef() {
22fe6060f1SDimitry Andric   return m_exe_ctx_ref;
23fe6060f1SDimitry Andric }
24fe6060f1SDimitry Andric 
25fe6060f1SDimitry Andric void TraceCursor::SetForwards(bool forwards) { m_forwards = forwards; }
26fe6060f1SDimitry Andric 
27fe6060f1SDimitry Andric bool TraceCursor::IsForwards() const { return m_forwards; }
2881ad6265SDimitry Andric 
2981ad6265SDimitry Andric bool TraceCursor::IsError() const {
3081ad6265SDimitry Andric   return GetItemKind() == lldb::eTraceItemKindError;
3181ad6265SDimitry Andric }
3281ad6265SDimitry Andric 
3381ad6265SDimitry Andric bool TraceCursor::IsEvent() const {
3481ad6265SDimitry Andric   return GetItemKind() == lldb::eTraceItemKindEvent;
3581ad6265SDimitry Andric }
3681ad6265SDimitry Andric 
3781ad6265SDimitry Andric bool TraceCursor::IsInstruction() const {
3881ad6265SDimitry Andric   return GetItemKind() == lldb::eTraceItemKindInstruction;
3981ad6265SDimitry Andric }
4081ad6265SDimitry Andric 
4181ad6265SDimitry Andric const char *TraceCursor::GetEventTypeAsString() const {
4281ad6265SDimitry Andric   return EventKindToString(GetEventType());
4381ad6265SDimitry Andric }
4481ad6265SDimitry Andric 
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";
51*753f127fSDimitry Andric   case lldb::eTraceEventCPUChanged:
52*753f127fSDimitry Andric     return "CPU core changed";
5381ad6265SDimitry Andric   }
54*753f127fSDimitry Andric   llvm_unreachable("Fully covered switch above");
5581ad6265SDimitry Andric }
56