1 //===-- SBTraceCursor.cpp
2 //-------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "lldb/API/SBTraceCursor.h"
11 #include "Utils.h"
12 #include "lldb/Utility/Instrumentation.h"
13 #include "lldb/Target/TraceCursor.h"
14 
15 using namespace lldb;
16 using namespace lldb_private;
17 
18 SBTraceCursor::SBTraceCursor() { LLDB_INSTRUMENT_VA(this); }
19 
20 SBTraceCursor::SBTraceCursor(TraceCursorSP trace_cursor_sp)
21     : m_opaque_sp{std::move(trace_cursor_sp)} {
22   LLDB_INSTRUMENT_VA(this, trace_cursor_sp);
23 }
24 
25 void SBTraceCursor::SetForwards(bool forwards) {
26   LLDB_INSTRUMENT_VA(this, forwards);
27 
28   m_opaque_sp->SetForwards(forwards);
29 }
30 
31 bool SBTraceCursor::IsForwards() const {
32   LLDB_INSTRUMENT_VA(this);
33 
34   return m_opaque_sp->IsForwards();
35 }
36 
37 void SBTraceCursor::Next() {
38   LLDB_INSTRUMENT_VA(this);
39 
40   return m_opaque_sp->Next();
41 }
42 
43 bool SBTraceCursor::HasValue() const {
44   LLDB_INSTRUMENT_VA(this);
45 
46   return m_opaque_sp->HasValue();
47 }
48 
49 bool SBTraceCursor::GoToId(lldb::user_id_t id) {
50   LLDB_INSTRUMENT_VA(this, id);
51 
52   return m_opaque_sp->GoToId(id);
53 }
54 
55 bool SBTraceCursor::HasId(lldb::user_id_t id) const {
56   LLDB_INSTRUMENT_VA(this, id);
57 
58   return m_opaque_sp->HasId(id);
59 }
60 
61 lldb::user_id_t SBTraceCursor::GetId() const {
62   LLDB_INSTRUMENT_VA(this);
63 
64   return m_opaque_sp->GetId();
65 }
66 
67 bool SBTraceCursor::Seek(int64_t offset, lldb::TraceCursorSeekType origin) {
68   LLDB_INSTRUMENT_VA(this, offset);
69 
70   return m_opaque_sp->Seek(offset, origin);
71 }
72 
73 lldb::TraceItemKind SBTraceCursor::GetItemKind() const {
74   LLDB_INSTRUMENT_VA(this);
75 
76   return m_opaque_sp->GetItemKind();
77 }
78 
79 bool SBTraceCursor::IsError() const {
80   LLDB_INSTRUMENT_VA(this);
81 
82   return m_opaque_sp->IsError();
83 }
84 
85 const char *SBTraceCursor::GetError() const {
86   LLDB_INSTRUMENT_VA(this);
87 
88   return ConstString(m_opaque_sp->GetError()).GetCString();
89 }
90 
91 bool SBTraceCursor::IsEvent() const {
92   LLDB_INSTRUMENT_VA(this);
93 
94   return m_opaque_sp->IsEvent();
95 }
96 
97 lldb::TraceEvent SBTraceCursor::GetEventType() const {
98   LLDB_INSTRUMENT_VA(this);
99 
100   return m_opaque_sp->GetEventType();
101 }
102 
103 const char *SBTraceCursor::GetEventTypeAsString() const {
104   LLDB_INSTRUMENT_VA(this);
105 
106   return ConstString(m_opaque_sp->GetEventTypeAsString()).GetCString();
107 }
108 
109 bool SBTraceCursor::IsInstruction() const {
110   LLDB_INSTRUMENT_VA(this);
111 
112   return m_opaque_sp->IsInstruction();
113 }
114 
115 lldb::addr_t SBTraceCursor::GetLoadAddress() const {
116   LLDB_INSTRUMENT_VA(this);
117 
118   return m_opaque_sp->GetLoadAddress();
119 }
120 
121 lldb::cpu_id_t SBTraceCursor::GetCPU() const {
122   LLDB_INSTRUMENT_VA(this);
123 
124   return m_opaque_sp->GetCPU();
125 }
126 
127 bool SBTraceCursor::IsValid() const {
128   LLDB_INSTRUMENT_VA(this);
129 
130   return this->operator bool();
131 }
132 
133 SBTraceCursor::operator bool() const {
134   LLDB_INSTRUMENT_VA(this);
135 
136   return m_opaque_sp.get() != nullptr;
137 }
138