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 #ifndef __DNBThreadResumeActions_h__
15 #define __DNBThreadResumeActions_h__
16 
17 #include <vector>
18 
19 #include "DNBDefs.h"
20 
21 class DNBThreadResumeActions {
22 public:
23   DNBThreadResumeActions();
24 
25   DNBThreadResumeActions(nub_state_t default_action, int signal);
26 
27   DNBThreadResumeActions(const DNBThreadResumeAction *actions,
28                          size_t num_actions);
29 
30   bool IsEmpty() const { return m_actions.empty(); }
31 
32   void Append(const DNBThreadResumeAction &action);
33 
34   void AppendAction(nub_thread_t tid, nub_state_t state, int signal = 0,
35                     nub_addr_t addr = INVALID_NUB_ADDRESS);
36 
37   void AppendResumeAll() { AppendAction(INVALID_NUB_THREAD, eStateRunning); }
38 
39   void AppendSuspendAll() { AppendAction(INVALID_NUB_THREAD, eStateStopped); }
40 
41   void AppendStepAll() { AppendAction(INVALID_NUB_THREAD, eStateStepping); }
42 
43   const DNBThreadResumeAction *GetActionForThread(nub_thread_t tid,
44                                                   bool default_ok) const;
45 
46   size_t NumActionsWithState(nub_state_t state) const;
47 
48   bool SetDefaultThreadActionIfNeeded(nub_state_t action, int signal);
49 
50   void SetSignalHandledForThread(nub_thread_t tid) const;
51 
52   const DNBThreadResumeAction *GetFirst() const { return m_actions.data(); }
53 
54   size_t GetSize() const { return m_actions.size(); }
55 
56   void Clear() {
57     m_actions.clear();
58     m_signal_handled.clear();
59   }
60 
61 protected:
62   std::vector<DNBThreadResumeAction> m_actions;
63   mutable std::vector<bool> m_signal_handled;
64 };
65 
66 #endif // #ifndef __DNBThreadResumeActions_h__
67