1 //===-- DNBThreadResumeActions.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 //  Created by Greg Clayton on 03/13/2010
11 //
12 //===----------------------------------------------------------------------===//
13 
14 
15 #ifndef __DNBThreadResumeActions_h__
16 #define __DNBThreadResumeActions_h__
17 
18 #include <vector>
19 
20 #include "DNBDefs.h"
21 
22 
23 class DNBThreadResumeActions
24 {
25 public:
26     DNBThreadResumeActions ();
27 
28     DNBThreadResumeActions (nub_state_t default_action, int signal);
29 
30     DNBThreadResumeActions (const DNBThreadResumeAction *actions, size_t num_actions);
31 
32     bool
IsEmpty()33     IsEmpty() const
34     {
35         return m_actions.empty();
36     }
37 
38     void
39     Append (const DNBThreadResumeAction &action);
40 
41     void
42     AppendAction (nub_thread_t tid,
43                   nub_state_t state,
44                   int signal = 0,
45                   nub_addr_t addr = INVALID_NUB_ADDRESS);
46 
47     void
AppendResumeAll()48     AppendResumeAll ()
49     {
50         AppendAction (INVALID_NUB_THREAD, eStateRunning);
51     }
52 
53     void
AppendSuspendAll()54     AppendSuspendAll ()
55     {
56         AppendAction (INVALID_NUB_THREAD, eStateStopped);
57     }
58 
59     void
AppendStepAll()60     AppendStepAll ()
61     {
62         AppendAction (INVALID_NUB_THREAD, eStateStepping);
63     }
64 
65     const DNBThreadResumeAction *
66     GetActionForThread (nub_thread_t tid, bool default_ok) const;
67 
68     size_t
69     NumActionsWithState (nub_state_t state) const;
70 
71     bool
72     SetDefaultThreadActionIfNeeded (nub_state_t action, int signal);
73 
74     void
75     SetSignalHandledForThread (nub_thread_t tid) const;
76 
77     const DNBThreadResumeAction *
GetFirst()78     GetFirst() const
79     {
80         return m_actions.data();
81     }
82 
83     size_t
GetSize()84     GetSize () const
85     {
86         return m_actions.size();
87     }
88 
89     void
Clear()90     Clear()
91     {
92         m_actions.clear();
93         m_signal_handled.clear();
94     }
95 
96 protected:
97     std::vector<DNBThreadResumeAction> m_actions;
98     mutable std::vector<bool> m_signal_handled;
99 };
100 
101 
102 #endif    // #ifndef __DNBThreadResumeActions_h__
103