LLDB  mainline
TraceInstructionDumper.h
Go to the documentation of this file.
1 //===-- TraceInstructionDumper.h --------------------------------*- 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 
10 
11 #ifndef LLDB_TARGET_TRACE_INSTRUCTION_DUMPER_H
12 #define LLDB_TARGET_TRACE_INSTRUCTION_DUMPER_H
13 
14 namespace lldb_private {
15 
16 /// Class used to dump the instructions of a \a TraceCursor using its current
17 /// state and granularity.
19 public:
20  /// Create a instruction dumper for the cursor.
21  ///
22  /// \param[in] cursor
23  /// The cursor whose instructions will be dumped.
24  ///
25  /// \param[in] initial_index
26  /// Presentation index to use for referring to the current instruction
27  /// of the cursor. If the direction is forwards, the index will increase,
28  /// and if the direction is backwards, the index will decrease.
29  ///
30  /// \param[in] raw
31  /// Dump only instruction addresses without disassembly nor symbol
32  /// information.
33  ///
34  /// \param[in] show_tsc
35  /// For each instruction, print the corresponding timestamp counter if
36  /// available.
37  TraceInstructionDumper(lldb::TraceCursorUP &&cursor_up, int initial_index = 0,
38  bool raw = false, bool show_tsc = false);
39 
40  /// Dump \a count instructions of the thread trace starting at the current
41  /// cursor position.
42  ///
43  /// This effectively moves the cursor to the next unvisited position, so that
44  /// a subsequent call to this method continues where it left off.
45  ///
46  /// \param[in] s
47  /// The stream object where the instructions are printed.
48  ///
49  /// \param[in] count
50  /// The number of instructions to print.
51  void DumpInstructions(Stream &s, size_t count);
52 
53  /// Indicate the dumper that no more data is available in the trace.
54  void SetNoMoreData();
55 
56  /// \return
57  /// \b true if there's still more data to traverse in the trace.
58  bool HasMoreData();
59 
60 private:
61  /// Move the cursor one step.
62  ///
63  /// \return
64  /// \b true if the cursor moved.
65  bool TryMoveOneStep();
66 
67  lldb::TraceCursorUP m_cursor_up;
68  int m_index;
69  bool m_raw;
70  bool m_show_tsc;
71  /// If \b true, all the instructions have been traversed.
72  bool m_no_more_data = false;
73 };
74 
75 } // namespace lldb_private
76 
77 #endif // LLDB_TARGET_TRACE_INSTRUCTION_DUMPER_H
lldb_private::TraceInstructionDumper::SetNoMoreData
void SetNoMoreData()
Indicate the dumper that no more data is available in the trace.
Definition: TraceInstructionDumper.cpp:158
lldb_private::TraceInstructionDumper
Class used to dump the instructions of a TraceCursor using its current state and granularity.
Definition: TraceInstructionDumper.h:18
lldb_private::Stream
Definition: Stream.h:28
lldb_private::TraceInstructionDumper::HasMoreData
bool HasMoreData()
Definition: TraceInstructionDumper.cpp:160
lldb_private::TraceInstructionDumper::m_raw
bool m_raw
Definition: TraceInstructionDumper.h:69
lldb_private::TraceInstructionDumper::m_index
int m_index
Definition: TraceInstructionDumper.h:68
lldb_private::TraceInstructionDumper::TraceInstructionDumper
TraceInstructionDumper(lldb::TraceCursorUP &&cursor_up, int initial_index=0, bool raw=false, bool show_tsc=false)
Create a instruction dumper for the cursor.
Definition: TraceInstructionDumper.cpp:21
TraceCursor.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::TraceInstructionDumper::m_show_tsc
bool m_show_tsc
Definition: TraceInstructionDumper.h:70
lldb_private::TraceInstructionDumper::DumpInstructions
void DumpInstructions(Stream &s, size_t count)
Dump count instructions of the thread trace starting at the current cursor position.
Definition: TraceInstructionDumper.cpp:162
lldb_private::TraceInstructionDumper::m_cursor_up
lldb::TraceCursorUP m_cursor_up
Definition: TraceInstructionDumper.h:67
lldb_private::TraceInstructionDumper::m_no_more_data
bool m_no_more_data
If true, all the instructions have been traversed.
Definition: TraceInstructionDumper.h:72
lldb_private::TraceInstructionDumper::TryMoveOneStep
bool TryMoveOneStep()
Move the cursor one step.
Definition: TraceInstructionDumper.cpp:29