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