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