StopInfo.h revision 6fb8baa66796cdb23f337dd03272bf15d97fdab9
1//===-- StopInfo.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_StopInfo_h_
11#define liblldb_StopInfo_h_
12
13// C Includes
14// C++ Includes
15// Other libraries and framework includes
16// Project includes
17#include "lldb/lldb-include.h"
18
19namespace lldb_private {
20
21class StopInfo
22{
23public:
24    //------------------------------------------------------------------
25    // Constructors and Destructors
26    //------------------------------------------------------------------
27    StopInfo (Thread &thread, uint64_t value);
28
29    virtual ~StopInfo()
30    {
31    }
32
33
34    bool
35    IsValid () const;
36
37    Thread &
38    GetThread()
39    {
40        return m_thread;
41    }
42
43    const Thread &
44    GetThread() const
45    {
46        return m_thread;
47    }
48
49    uint64_t
50    GetValue() const
51    {
52        return m_value;
53    }
54
55    virtual lldb::StopReason
56    GetStopReason () const = 0;
57
58    // Perform any action that is associated with this stop.  This is done as the
59    // Event is removed from the event queue.
60    virtual void
61    PerformAction (Event *event_ptr)
62    {
63    }
64
65    // Stop the thread by default. Subclasses can override this to allow
66    // the thread to continue if desired.
67    virtual bool
68    ShouldStop (Event *event_ptr)
69    {
70        return true;
71    }
72
73    // If should stop returns false, check if we should notify of this event
74    virtual bool
75    ShouldNotify (Event *event_ptr)
76    {
77        return false;
78    }
79
80    virtual void
81    WillResume (lldb::StateType resume_state)
82    {
83        // By default, don't do anything
84    }
85
86    virtual const char *
87    GetDescription () = 0;
88
89
90    static lldb::StopInfoSP
91    CreateStopReasonWithBreakpointSiteID (Thread &thread, lldb::break_id_t break_id);
92
93    static lldb::StopInfoSP
94    CreateStopReasonWithWatchpointID (Thread &thread, lldb::break_id_t watch_id);
95
96    static lldb::StopInfoSP
97    CreateStopReasonWithSignal (Thread &thread, int signo);
98
99    static lldb::StopInfoSP
100    CreateStopReasonToTrace (Thread &thread);
101
102    static lldb::StopInfoSP
103    CreateStopReasonWithPlan (lldb::ThreadPlanSP &plan);
104
105protected:
106    //------------------------------------------------------------------
107    // Classes that inherit from StackID can see and modify these
108    //------------------------------------------------------------------
109    Thread &        m_thread;   // The thread corresponding to the stop reason.
110    const uint32_t  m_stop_id;  // The process stop ID for which this stop info is valid
111    uint64_t        m_value;    // A generic value that can be used for things pertaining to this stop info
112private:
113    DISALLOW_COPY_AND_ASSIGN (StopInfo);
114};
115
116
117} // namespace lldb_private
118
119#endif  // liblldb_StopInfo_h_
120