1//===-- ThreadPlanTracer.h --------------------------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef liblldb_ThreadPlanTracer_h_
11#define liblldb_ThreadPlanTracer_h_
12
13// C Includes
14// C++ Includes
15// Other libraries and framework includes
16// Project includes
17#include "lldb/lldb-private.h"
18#include "lldb/Core/RegisterValue.h"
19#include "lldb/Symbol/TaggedASTType.h"
20#include "lldb/Target/Thread.h"
21
22namespace lldb_private {
23
24class ThreadPlanTracer
25{
26friend class ThreadPlan;
27
28public:
29
30    typedef enum ThreadPlanTracerStyle
31    {
32        eLocation = 0,
33        eStateChange,
34        eCheckFrames,
35        ePython
36    } ThreadPlanTracerStyle;
37    ThreadPlanTracer (Thread &thread, lldb::StreamSP &stream_sp);
38    ThreadPlanTracer (Thread &thread);
39
40    virtual ~ThreadPlanTracer()
41    {
42    }
43
44    virtual void TracingStarted ()
45    {
46
47    }
48
49    virtual void TracingEnded ()
50    {
51
52    }
53
54    bool
55    EnableTracing(bool value)
56    {
57        bool old_value = m_enabled;
58        m_enabled = value;
59        if (old_value == false && value == true)
60            TracingStarted();
61        else if (old_value == true && value == false)
62            TracingEnded();
63
64        return old_value;
65    }
66
67    bool
68    TracingEnabled()
69    {
70        return m_enabled;
71    }
72
73    bool
74    EnableSingleStep (bool value)
75    {
76        bool old_value = m_single_step;
77        m_single_step = value;
78        return old_value;
79    }
80
81    bool
82    SingleStepEnabled ()
83    {
84        return m_single_step;
85    }
86
87protected:
88    Thread &m_thread;
89
90    Stream *
91    GetLogStream ();
92
93
94
95    virtual void Log();
96
97private:
98    bool
99    TracerExplainsStop ();
100
101    bool m_single_step;
102    bool m_enabled;
103    lldb::StreamSP m_stream_sp;
104};
105
106class ThreadPlanAssemblyTracer : public ThreadPlanTracer
107{
108public:
109    ThreadPlanAssemblyTracer (Thread &thread, lldb::StreamSP &stream_sp);
110    ThreadPlanAssemblyTracer (Thread &thread);
111    virtual ~ThreadPlanAssemblyTracer ();
112    virtual void TracingStarted ();
113    virtual void TracingEnded ();
114    virtual void Log();
115private:
116
117    Disassembler *
118    GetDisassembler ();
119
120    TypeFromUser
121    GetIntPointerType();
122
123    lldb::DisassemblerSP    m_disassembler_sp;
124    TypeFromUser            m_intptr_type;
125    std::vector<RegisterValue> m_register_values;
126    lldb::DataBufferSP      m_buffer_sp;
127};
128
129} // namespace lldb_private
130
131#endif  // liblldb_ThreadPlanTracer_h_
132