1 //===-- UnixSignals.h -------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef lldb_UnixSignals_h_
11 #define lldb_UnixSignals_h_
19 // Other libraries and framework includes
21 #include "lldb/Utility/ConstString.h"
22 #include "lldb/lldb-private.h"
23 #include "llvm/ADT/Optional.h"
25 namespace lldb_private {
29 static lldb::UnixSignalsSP Create(const ArchSpec &arch);
31 //------------------------------------------------------------------
32 // Constructors and Destructors
33 //------------------------------------------------------------------
36 virtual ~UnixSignals();
38 const char *GetSignalAsCString(int32_t signo) const;
40 bool SignalIsValid(int32_t signo) const;
42 int32_t GetSignalNumberFromName(const char *name) const;
44 const char *GetSignalInfo(int32_t signo, bool &should_suppress,
45 bool &should_stop, bool &should_notify) const;
47 bool GetShouldSuppress(int32_t signo) const;
49 bool SetShouldSuppress(int32_t signo, bool value);
51 bool SetShouldSuppress(const char *signal_name, bool value);
53 bool GetShouldStop(int32_t signo) const;
55 bool SetShouldStop(int32_t signo, bool value);
56 bool SetShouldStop(const char *signal_name, bool value);
58 bool GetShouldNotify(int32_t signo) const;
60 bool SetShouldNotify(int32_t signo, bool value);
62 bool SetShouldNotify(const char *signal_name, bool value);
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 till you get back LLDB_INVALID_SIGNAL_NUMBER.
67 int32_t GetFirstSignalNumber() const;
69 int32_t GetNextSignalNumber(int32_t current_signal) const;
71 int32_t GetNumSignals() const;
73 int32_t GetSignalAtIndex(int32_t index) const;
75 ConstString GetShortName(ConstString name) const;
77 // We assume that the elements of this object are constant once it is
78 // constructed, since a process should never need to add or remove symbols as
79 // it runs. So don't call these functions anywhere but the constructor of
80 // your subclass of UnixSignals or in your Process Plugin's GetUnixSignals
81 // method before you return the UnixSignal object.
83 void AddSignal(int signo, const char *name, bool default_suppress,
84 bool default_stop, bool default_notify,
85 const char *description, const char *alias = nullptr);
87 void RemoveSignal(int signo);
89 // Returns a current version of the data stored in this class. Version gets
90 // incremented each time Set... method is called.
91 uint64_t GetVersion() const;
93 // Returns a vector of signals that meet criteria provided in arguments. Each
94 // should_[suppress|stop|notify] flag can be None - no filtering by this
95 // flag true - only signals that have it set to true are returned false -
96 // only signals that have it set to true are returned
97 std::vector<int32_t> GetFilteredSignals(llvm::Optional<bool> should_suppress,
98 llvm::Optional<bool> should_stop,
99 llvm::Optional<bool> should_notify);
102 //------------------------------------------------------------------
103 // Classes that inherit from UnixSignals can see and modify these
104 //------------------------------------------------------------------
109 std::string m_description;
110 bool m_suppress : 1, m_stop : 1, m_notify : 1;
112 Signal(const char *name, bool default_suppress, bool default_stop,
113 bool default_notify, const char *description, const char *alias);
118 virtual void Reset();
120 typedef std::map<int32_t, Signal> collection;
122 collection m_signals;
124 // This version gets incremented every time something is changing in this
125 // class, including when we call AddSignal from the constructor. So after the
126 // object is constructed m_version is going to be > 0 if it has at least one
127 // signal registered in it.
128 uint64_t m_version = 0;
130 // GDBRemote signals need to be copyable.
131 UnixSignals(const UnixSignals &rhs);
133 const UnixSignals &operator=(const UnixSignals &rhs) = delete;
137 #endif // lldb_UnixSignals_h_