1254721Semaste//===-- UnixSignals.h -------------------------------------------*- C++ -*-===//
2254721Semaste//
3254721Semaste//                     The LLVM Compiler Infrastructure
4254721Semaste//
5254721Semaste// This file is distributed under the University of Illinois Open Source
6254721Semaste// License. See LICENSE.TXT for details.
7254721Semaste//
8254721Semaste//===----------------------------------------------------------------------===//
9254721Semaste
10254721Semaste#ifndef lldb_UnixSignals_h_
11254721Semaste#define lldb_UnixSignals_h_
12254721Semaste
13254721Semaste// C Includes
14254721Semaste// C++ Includes
15254721Semaste#include <string>
16254721Semaste#include <map>
17254721Semaste
18254721Semaste// Other libraries and framework includes
19254721Semaste// Project includes
20254721Semaste#include "lldb/lldb-private.h"
21254721Semaste#include "lldb/Core/ConstString.h"
22254721Semaste
23254721Semastenamespace lldb_private
24254721Semaste{
25254721Semaste
26254721Semasteclass UnixSignals
27254721Semaste{
28254721Semastepublic:
29254721Semaste    //------------------------------------------------------------------
30254721Semaste    // Constructors and Destructors
31254721Semaste    //------------------------------------------------------------------
32254721Semaste    UnixSignals();
33254721Semaste
34254721Semaste    virtual
35254721Semaste    ~UnixSignals();
36254721Semaste
37254721Semaste    const char *
38254721Semaste    GetSignalAsCString (int32_t signo) const;
39254721Semaste
40254721Semaste    bool
41254721Semaste    SignalIsValid (int32_t signo) const;
42254721Semaste
43254721Semaste    int32_t
44254721Semaste    GetSignalNumberFromName (const char *name) const;
45254721Semaste
46254721Semaste    const char *
47254721Semaste    GetSignalInfo (int32_t signo,
48254721Semaste                   bool &should_suppress,
49254721Semaste                   bool &should_stop,
50254721Semaste                   bool &should_notify) const;
51254721Semaste
52254721Semaste    bool
53254721Semaste    GetShouldSuppress (int32_t signo) const;
54254721Semaste
55254721Semaste    bool
56254721Semaste    SetShouldSuppress (int32_t signo,
57254721Semaste                       bool value);
58254721Semaste
59254721Semaste    bool
60254721Semaste    SetShouldSuppress (const char *signal_name,
61254721Semaste                       bool value);
62254721Semaste
63254721Semaste    bool
64254721Semaste    GetShouldStop (int32_t signo) const;
65254721Semaste
66254721Semaste    bool
67254721Semaste    SetShouldStop (int32_t signo,
68254721Semaste                   bool value);
69254721Semaste    bool
70254721Semaste    SetShouldStop (const char *signal_name,
71254721Semaste                   bool value);
72254721Semaste
73254721Semaste    bool
74254721Semaste    GetShouldNotify (int32_t signo) const;
75254721Semaste
76254721Semaste    bool
77254721Semaste    SetShouldNotify (int32_t signo, bool value);
78254721Semaste
79254721Semaste    bool
80254721Semaste    SetShouldNotify (const char *signal_name,
81254721Semaste                     bool value);
82254721Semaste
83254721Semaste    // These provide an iterator through the signals available on this system.
84254721Semaste    // Call GetFirstSignalNumber to get the first entry, then iterate on GetNextSignalNumber
85254721Semaste    // till you get back LLDB_INVALID_SIGNAL_NUMBER.
86254721Semaste    int32_t
87254721Semaste    GetFirstSignalNumber () const;
88254721Semaste
89254721Semaste    int32_t
90254721Semaste    GetNextSignalNumber (int32_t current_signal) const;
91254721Semaste
92254721Semaste    // We assume that the elements of this object are constant once it is constructed,
93254721Semaste    // since a process should never need to add or remove symbols as it runs.  So don't
94254721Semaste    // call these functions anywhere but the constructor of your subclass of UnixSignals or in
95254721Semaste    // your Process Plugin's GetUnixSignals method before you return the UnixSignal object.
96254721Semaste
97254721Semaste    void
98254721Semaste    AddSignal (int signo,
99254721Semaste               const char *name,
100254721Semaste               const char *short_name,
101254721Semaste               bool default_suppress,
102254721Semaste               bool default_stop,
103254721Semaste               bool default_notify,
104254721Semaste               const char *description);
105254721Semaste
106254721Semaste    void
107254721Semaste    RemoveSignal (int signo);
108254721Semaste
109254721Semasteprotected:
110254721Semaste    //------------------------------------------------------------------
111254721Semaste    // Classes that inherit from UnixSignals can see and modify these
112254721Semaste    //------------------------------------------------------------------
113254721Semaste
114254721Semaste    struct Signal
115254721Semaste    {
116254721Semaste        ConstString m_name;
117254721Semaste        ConstString m_short_name;
118254721Semaste        std::string m_description;
119254721Semaste        bool m_suppress:1,
120254721Semaste             m_stop:1,
121254721Semaste             m_notify:1;
122254721Semaste
123254721Semaste        Signal (const char *name,
124254721Semaste                const char *short_name,
125254721Semaste                bool default_suppress,
126254721Semaste                bool default_stop,
127254721Semaste                bool default_notify,
128254721Semaste                const char *description);
129254721Semaste
130254721Semaste        ~Signal () {}
131254721Semaste    };
132254721Semaste
133254721Semaste    void
134254721Semaste    Reset ();
135254721Semaste
136254721Semaste    typedef std::map <int32_t, Signal> collection;
137254721Semaste
138254721Semaste    collection m_signals;
139254721Semaste
140254721Semaste    DISALLOW_COPY_AND_ASSIGN (UnixSignals);
141254721Semaste};
142254721Semaste
143254721Semaste} // Namespace lldb
144254721Semaste#endif  // lldb_UnixSignals_h_
145