]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/UnixSignals.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Target / UnixSignals.h
1 //===-- UnixSignals.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 lldb_UnixSignals_h_
11 #define lldb_UnixSignals_h_
12
13 #include <map>
14 #include <string>
15 #include <vector>
16
17 #include "lldb/Utility/ConstString.h"
18 #include "lldb/lldb-private.h"
19 #include "llvm/ADT/Optional.h"
20
21 namespace lldb_private {
22
23 class UnixSignals {
24 public:
25   static lldb::UnixSignalsSP Create(const ArchSpec &arch);
26
27   //------------------------------------------------------------------
28   // Constructors and Destructors
29   //------------------------------------------------------------------
30   UnixSignals();
31
32   virtual ~UnixSignals();
33
34   const char *GetSignalAsCString(int32_t signo) const;
35
36   bool SignalIsValid(int32_t signo) const;
37
38   int32_t GetSignalNumberFromName(const char *name) const;
39
40   const char *GetSignalInfo(int32_t signo, bool &should_suppress,
41                             bool &should_stop, bool &should_notify) const;
42
43   bool GetShouldSuppress(int32_t signo) const;
44
45   bool SetShouldSuppress(int32_t signo, bool value);
46
47   bool SetShouldSuppress(const char *signal_name, bool value);
48
49   bool GetShouldStop(int32_t signo) const;
50
51   bool SetShouldStop(int32_t signo, bool value);
52   bool SetShouldStop(const char *signal_name, bool value);
53
54   bool GetShouldNotify(int32_t signo) const;
55
56   bool SetShouldNotify(int32_t signo, bool value);
57
58   bool SetShouldNotify(const char *signal_name, bool value);
59
60   // These provide an iterator through the signals available on this system.
61   // Call GetFirstSignalNumber to get the first entry, then iterate on
62   // GetNextSignalNumber till you get back LLDB_INVALID_SIGNAL_NUMBER.
63   int32_t GetFirstSignalNumber() const;
64
65   int32_t GetNextSignalNumber(int32_t current_signal) const;
66
67   int32_t GetNumSignals() const;
68
69   int32_t GetSignalAtIndex(int32_t index) const;
70
71   ConstString GetShortName(ConstString name) const;
72
73   // We assume that the elements of this object are constant once it is
74   // constructed, since a process should never need to add or remove symbols as
75   // it runs.  So don't call these functions anywhere but the constructor of
76   // your subclass of UnixSignals or in your Process Plugin's GetUnixSignals
77   // method before you return the UnixSignal object.
78
79   void AddSignal(int signo, const char *name, bool default_suppress,
80                  bool default_stop, bool default_notify,
81                  const char *description, const char *alias = nullptr);
82
83   void RemoveSignal(int signo);
84
85   // Returns a current version of the data stored in this class. Version gets
86   // incremented each time Set... method is called.
87   uint64_t GetVersion() const;
88
89   // Returns a vector of signals that meet criteria provided in arguments. Each
90   // should_[suppress|stop|notify] flag can be None  - no filtering by this
91   // flag true  - only signals that have it set to true are returned false -
92   // only signals that have it set to true are returned
93   std::vector<int32_t> GetFilteredSignals(llvm::Optional<bool> should_suppress,
94                                           llvm::Optional<bool> should_stop,
95                                           llvm::Optional<bool> should_notify);
96
97 protected:
98   //------------------------------------------------------------------
99   // Classes that inherit from UnixSignals can see and modify these
100   //------------------------------------------------------------------
101
102   struct Signal {
103     ConstString m_name;
104     ConstString m_alias;
105     std::string m_description;
106     bool m_suppress : 1, m_stop : 1, m_notify : 1;
107
108     Signal(const char *name, bool default_suppress, bool default_stop,
109            bool default_notify, const char *description, const char *alias);
110
111     ~Signal() {}
112   };
113
114   virtual void Reset();
115
116   typedef std::map<int32_t, Signal> collection;
117
118   collection m_signals;
119
120   // This version gets incremented every time something is changing in this
121   // class, including when we call AddSignal from the constructor. So after the
122   // object is constructed m_version is going to be > 0 if it has at least one
123   // signal registered in it.
124   uint64_t m_version = 0;
125
126   // GDBRemote signals need to be copyable.
127   UnixSignals(const UnixSignals &rhs);
128
129   const UnixSignals &operator=(const UnixSignals &rhs) = delete;
130 };
131
132 } // Namespace lldb
133 #endif // lldb_UnixSignals_h_