]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/lldb/Target/UnixSignals.h
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / 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
18 // Other libraries and framework includes
19 // Project includes
20 #include "lldb/Core/ConstString.h"
21 #include "lldb/lldb-private.h"
22
23 namespace lldb_private {
24
25 class UnixSignals {
26 public:
27   static lldb::UnixSignalsSP Create(const ArchSpec &arch);
28
29   //------------------------------------------------------------------
30   // Constructors and Destructors
31   //------------------------------------------------------------------
32   UnixSignals();
33
34   virtual ~UnixSignals();
35
36   const char *GetSignalAsCString(int32_t signo) const;
37
38   bool SignalIsValid(int32_t signo) const;
39
40   int32_t GetSignalNumberFromName(const char *name) const;
41
42   const char *GetSignalInfo(int32_t signo, bool &should_suppress,
43                             bool &should_stop, bool &should_notify) const;
44
45   bool GetShouldSuppress(int32_t signo) const;
46
47   bool SetShouldSuppress(int32_t signo, bool value);
48
49   bool SetShouldSuppress(const char *signal_name, bool value);
50
51   bool GetShouldStop(int32_t signo) const;
52
53   bool SetShouldStop(int32_t signo, bool value);
54   bool SetShouldStop(const char *signal_name, bool value);
55
56   bool GetShouldNotify(int32_t signo) const;
57
58   bool SetShouldNotify(int32_t signo, bool value);
59
60   bool SetShouldNotify(const char *signal_name, bool value);
61
62   // These provide an iterator through the signals available on this system.
63   // Call GetFirstSignalNumber to get the first entry, then iterate on
64   // GetNextSignalNumber
65   // till you get back LLDB_INVALID_SIGNAL_NUMBER.
66   int32_t GetFirstSignalNumber() const;
67
68   int32_t GetNextSignalNumber(int32_t current_signal) const;
69
70   int32_t GetNumSignals() const;
71
72   int32_t GetSignalAtIndex(int32_t index) const;
73
74   ConstString GetShortName(ConstString name) const;
75
76   // We assume that the elements of this object are constant once it is
77   // constructed,
78   // since a process should never need to add or remove symbols as it runs.  So
79   // don't
80   // call these functions anywhere but the constructor of your subclass of
81   // UnixSignals or in
82   // your Process Plugin's GetUnixSignals method before you return the
83   // UnixSignal object.
84
85   void AddSignal(int signo, const char *name, bool default_suppress,
86                  bool default_stop, bool default_notify,
87                  const char *description, const char *alias = nullptr);
88
89   void RemoveSignal(int signo);
90
91 protected:
92   //------------------------------------------------------------------
93   // Classes that inherit from UnixSignals can see and modify these
94   //------------------------------------------------------------------
95
96   struct Signal {
97     ConstString m_name;
98     ConstString m_alias;
99     std::string m_description;
100     bool m_suppress : 1, m_stop : 1, m_notify : 1;
101
102     Signal(const char *name, bool default_suppress, bool default_stop,
103            bool default_notify, const char *description, const char *alias);
104
105     ~Signal() {}
106   };
107
108   virtual void Reset();
109
110   typedef std::map<int32_t, Signal> collection;
111
112   collection m_signals;
113
114   // GDBRemote signals need to be copyable.
115   UnixSignals(const UnixSignals &rhs);
116
117   const UnixSignals &operator=(const UnixSignals &rhs) = delete;
118 };
119
120 } // Namespace lldb
121 #endif // lldb_UnixSignals_h_