xref: /openbsd-src/gnu/llvm/lldb/tools/debugserver/source/DNBThreadResumeActions.h (revision dda2819751e49c83612958492e38917049128b41)
1061da546Spatrick //===-- DNBThreadResumeActions.h --------------------------------*- C++ -*-===//
2061da546Spatrick //
3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information.
5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6061da546Spatrick //
7061da546Spatrick //===----------------------------------------------------------------------===//
8061da546Spatrick //
9061da546Spatrick //  Created by Greg Clayton on 03/13/2010
10061da546Spatrick //
11061da546Spatrick //===----------------------------------------------------------------------===//
12061da546Spatrick 
13*dda28197Spatrick #ifndef LLDB_TOOLS_DEBUGSERVER_SOURCE_DNBTHREADRESUMEACTIONS_H
14*dda28197Spatrick #define LLDB_TOOLS_DEBUGSERVER_SOURCE_DNBTHREADRESUMEACTIONS_H
15061da546Spatrick 
16061da546Spatrick #include <vector>
17061da546Spatrick 
18061da546Spatrick #include "DNBDefs.h"
19061da546Spatrick 
20061da546Spatrick class DNBThreadResumeActions {
21061da546Spatrick public:
22061da546Spatrick   DNBThreadResumeActions();
23061da546Spatrick 
24061da546Spatrick   DNBThreadResumeActions(nub_state_t default_action, int signal);
25061da546Spatrick 
26061da546Spatrick   DNBThreadResumeActions(const DNBThreadResumeAction *actions,
27061da546Spatrick                          size_t num_actions);
28061da546Spatrick 
IsEmpty()29061da546Spatrick   bool IsEmpty() const { return m_actions.empty(); }
30061da546Spatrick 
31061da546Spatrick   void Append(const DNBThreadResumeAction &action);
32061da546Spatrick 
33061da546Spatrick   void AppendAction(nub_thread_t tid, nub_state_t state, int signal = 0,
34061da546Spatrick                     nub_addr_t addr = INVALID_NUB_ADDRESS);
35061da546Spatrick 
AppendResumeAll()36061da546Spatrick   void AppendResumeAll() { AppendAction(INVALID_NUB_THREAD, eStateRunning); }
37061da546Spatrick 
AppendSuspendAll()38061da546Spatrick   void AppendSuspendAll() { AppendAction(INVALID_NUB_THREAD, eStateStopped); }
39061da546Spatrick 
AppendStepAll()40061da546Spatrick   void AppendStepAll() { AppendAction(INVALID_NUB_THREAD, eStateStepping); }
41061da546Spatrick 
42061da546Spatrick   const DNBThreadResumeAction *GetActionForThread(nub_thread_t tid,
43061da546Spatrick                                                   bool default_ok) const;
44061da546Spatrick 
45061da546Spatrick   size_t NumActionsWithState(nub_state_t state) const;
46061da546Spatrick 
47061da546Spatrick   bool SetDefaultThreadActionIfNeeded(nub_state_t action, int signal);
48061da546Spatrick 
49061da546Spatrick   void SetSignalHandledForThread(nub_thread_t tid) const;
50061da546Spatrick 
GetFirst()51061da546Spatrick   const DNBThreadResumeAction *GetFirst() const { return m_actions.data(); }
52061da546Spatrick 
GetSize()53061da546Spatrick   size_t GetSize() const { return m_actions.size(); }
54061da546Spatrick 
Clear()55061da546Spatrick   void Clear() {
56061da546Spatrick     m_actions.clear();
57061da546Spatrick     m_signal_handled.clear();
58061da546Spatrick   }
59061da546Spatrick 
60061da546Spatrick protected:
61061da546Spatrick   std::vector<DNBThreadResumeAction> m_actions;
62061da546Spatrick   mutable std::vector<bool> m_signal_handled;
63061da546Spatrick };
64061da546Spatrick 
65*dda28197Spatrick #endif // LLDB_TOOLS_DEBUGSERVER_SOURCE_DNBTHREADRESUMEACTIONS_H
66