| 1 | //===-- TraceCursor.cpp -----------------------------------------*- C++ -*-===// |
|---|---|
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "lldb/Target/TraceCursor.h" |
| 10 | |
| 11 | #include "lldb/Target/ExecutionContext.h" |
| 12 | #include "lldb/Target/Trace.h" |
| 13 | |
| 14 | using namespace lldb; |
| 15 | using namespace lldb_private; |
| 16 | using namespace llvm; |
| 17 | |
| 18 | TraceCursor::TraceCursor(lldb::ThreadSP thread_sp) |
| 19 | : m_exe_ctx_ref(ExecutionContext(thread_sp)) {} |
| 20 | |
| 21 | ExecutionContextRef &TraceCursor::GetExecutionContextRef() { |
| 22 | return m_exe_ctx_ref; |
| 23 | } |
| 24 | |
| 25 | void TraceCursor::SetForwards(bool forwards) { m_forwards = forwards; } |
| 26 | |
| 27 | bool TraceCursor::IsForwards() const { return m_forwards; } |
| 28 | |
| 29 | bool TraceCursor::IsError() const { |
| 30 | return GetItemKind() == lldb::eTraceItemKindError; |
| 31 | } |
| 32 | |
| 33 | bool TraceCursor::IsEvent() const { |
| 34 | return GetItemKind() == lldb::eTraceItemKindEvent; |
| 35 | } |
| 36 | |
| 37 | bool TraceCursor::IsInstruction() const { |
| 38 | return GetItemKind() == lldb::eTraceItemKindInstruction; |
| 39 | } |
| 40 | |
| 41 | const char *TraceCursor::GetEventTypeAsString() const { |
| 42 | return EventKindToString(event_kind: GetEventType()); |
| 43 | } |
| 44 | |
| 45 | const char *TraceCursor::EventKindToString(lldb::TraceEvent event_kind) { |
| 46 | switch (event_kind) { |
| 47 | case lldb::eTraceEventDisabledHW: |
| 48 | return "hardware disabled tracing"; |
| 49 | case lldb::eTraceEventDisabledSW: |
| 50 | return "software disabled tracing"; |
| 51 | case lldb::eTraceEventCPUChanged: |
| 52 | return "CPU core changed"; |
| 53 | case lldb::eTraceEventHWClockTick: |
| 54 | return "HW clock tick"; |
| 55 | case lldb::eTraceEventSyncPoint: |
| 56 | return "trace synchronization point"; |
| 57 | } |
| 58 | llvm_unreachable("Fully covered switch above"); |
| 59 | } |
| 60 |
