1 //===-- SBTraceCursor.cpp
2 //-------------------------------------------------------===//
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
8 //===----------------------------------------------------------------------===//
10 #include "lldb/API/SBTraceCursor.h"
12 #include "lldb/Utility/Instrumentation.h"
13 #include "lldb/Target/TraceCursor.h"
16 using namespace lldb_private
;
18 SBTraceCursor::SBTraceCursor() { LLDB_INSTRUMENT_VA(this); }
20 SBTraceCursor::SBTraceCursor(TraceCursorSP trace_cursor_sp
)
21 : m_opaque_sp
{std::move(trace_cursor_sp
)} {
22 LLDB_INSTRUMENT_VA(this, trace_cursor_sp
);
25 void SBTraceCursor::SetForwards(bool forwards
) {
26 LLDB_INSTRUMENT_VA(this, forwards
);
28 m_opaque_sp
->SetForwards(forwards
);
31 bool SBTraceCursor::IsForwards() const {
32 LLDB_INSTRUMENT_VA(this);
34 return m_opaque_sp
->IsForwards();
37 void SBTraceCursor::Next() {
38 LLDB_INSTRUMENT_VA(this);
40 return m_opaque_sp
->Next();
43 bool SBTraceCursor::HasValue() const {
44 LLDB_INSTRUMENT_VA(this);
46 return m_opaque_sp
->HasValue();
49 bool SBTraceCursor::GoToId(lldb::user_id_t id
) {
50 LLDB_INSTRUMENT_VA(this, id
);
52 return m_opaque_sp
->GoToId(id
);
55 bool SBTraceCursor::HasId(lldb::user_id_t id
) const {
56 LLDB_INSTRUMENT_VA(this, id
);
58 return m_opaque_sp
->HasId(id
);
61 lldb::user_id_t
SBTraceCursor::GetId() const {
62 LLDB_INSTRUMENT_VA(this);
64 return m_opaque_sp
->GetId();
67 bool SBTraceCursor::Seek(int64_t offset
, lldb::TraceCursorSeekType origin
) {
68 LLDB_INSTRUMENT_VA(this, offset
);
70 return m_opaque_sp
->Seek(offset
, origin
);
73 lldb::TraceItemKind
SBTraceCursor::GetItemKind() const {
74 LLDB_INSTRUMENT_VA(this);
76 return m_opaque_sp
->GetItemKind();
79 bool SBTraceCursor::IsError() const {
80 LLDB_INSTRUMENT_VA(this);
82 return m_opaque_sp
->IsError();
85 const char *SBTraceCursor::GetError() const {
86 LLDB_INSTRUMENT_VA(this);
88 return ConstString(m_opaque_sp
->GetError()).GetCString();
91 bool SBTraceCursor::IsEvent() const {
92 LLDB_INSTRUMENT_VA(this);
94 return m_opaque_sp
->IsEvent();
97 lldb::TraceEvent
SBTraceCursor::GetEventType() const {
98 LLDB_INSTRUMENT_VA(this);
100 return m_opaque_sp
->GetEventType();
103 const char *SBTraceCursor::GetEventTypeAsString() const {
104 LLDB_INSTRUMENT_VA(this);
106 return ConstString(m_opaque_sp
->GetEventTypeAsString()).GetCString();
109 bool SBTraceCursor::IsInstruction() const {
110 LLDB_INSTRUMENT_VA(this);
112 return m_opaque_sp
->IsInstruction();
115 lldb::addr_t
SBTraceCursor::GetLoadAddress() const {
116 LLDB_INSTRUMENT_VA(this);
118 return m_opaque_sp
->GetLoadAddress();
121 lldb::cpu_id_t
SBTraceCursor::GetCPU() const {
122 LLDB_INSTRUMENT_VA(this);
124 return m_opaque_sp
->GetCPU();
127 bool SBTraceCursor::IsValid() const {
128 LLDB_INSTRUMENT_VA(this);
130 return this->operator bool();
133 SBTraceCursor::operator bool() const {
134 LLDB_INSTRUMENT_VA(this);
136 return m_opaque_sp
.get() != nullptr;