[Lldb-commits] [lldb] r116561 - in /lldb/trunk: include/lldb/Target/UnixSignals.h source/Target/UnixSignals.cpp

Greg Clayton gclayton at apple.com
Thu Oct 14 19:39:01 PDT 2010


Author: gclayton
Date: Thu Oct 14 21:39:01 2010
New Revision: 116561

URL: http://llvm.org/viewvc/llvm-project?rev=116561&view=rev
Log:
Added short names and descriptions to the UnixSignals class. Also cleaned up
the code a bit.


Modified:
    lldb/trunk/include/lldb/Target/UnixSignals.h
    lldb/trunk/source/Target/UnixSignals.cpp

Modified: lldb/trunk/include/lldb/Target/UnixSignals.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/UnixSignals.h?rev=116561&r1=116560&r2=116561&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/UnixSignals.h (original)
+++ lldb/trunk/include/lldb/Target/UnixSignals.h Thu Oct 14 21:39:01 2010
@@ -97,9 +97,11 @@
     void
     AddSignal (int signo,
                const char *name,
+               const char *short_name,
                bool default_suppress,
                bool default_stop,
-               bool default_notify);
+               bool default_notify,
+               const char *description);
 
     void
     RemoveSignal (int signo);
@@ -111,37 +113,23 @@
 
     struct Signal
     {
-        typedef enum
-        {
-            eCondSuppress = 0,
-            eCondStop = 1,
-            eCondNotify
-        } Condition;
-
         ConstString m_name;
-        bool m_conditions[3];
+        ConstString m_short_name;
+        std::string m_description;
+        bool m_suppress:1,
+             m_stop:1,
+             m_notify:1;
 
         Signal (const char *name,
+                const char *short_name,
                 bool default_suppress,
                 bool default_stop,
-                bool default_notify);
+                bool default_notify,
+                const char *description);
 
         ~Signal () {}
     };
 
-    bool
-    GetCondition (int signo,
-                  Signal::Condition cond_pos) const;
-    bool
-    SetCondition (int signo,
-                  Signal::Condition cond_pos,
-                  bool value);
-
-    bool
-    SetCondition (const char *signal_name,
-                  Signal::Condition cond_pos,
-                  bool value);
-
     Signal *
     GetSignalByName (const char *name,
                      int32_t &signo);

Modified: lldb/trunk/source/Target/UnixSignals.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/UnixSignals.cpp?rev=116561&r1=116560&r2=116561&view=diff
==============================================================================
--- lldb/trunk/source/Target/UnixSignals.cpp (original)
+++ lldb/trunk/source/Target/UnixSignals.cpp Thu Oct 14 21:39:01 2010
@@ -16,13 +16,24 @@
 
 using namespace lldb_private;
 
-UnixSignals::Signal::Signal (const char *name, bool default_suppress, bool default_stop, bool default_notify) :
+UnixSignals::Signal::Signal 
+(
+    const char *name, 
+    const char *short_name, 
+    bool default_suppress, 
+    bool default_stop, 
+    bool default_notify,
+    const char *description
+) :
     m_name (name),
-    m_conditions ()
+    m_short_name (short_name),
+    m_description (),
+    m_suppress (default_suppress),
+    m_stop (default_stop),
+    m_notify (default_notify)
 {
-    m_conditions[Signal::eCondSuppress] = default_suppress;
-    m_conditions[Signal::eCondStop]     = default_stop;
-    m_conditions[Signal::eCondNotify]   = default_notify;
+    if (description)
+        m_description.assign (description);
 }
 
 //----------------------------------------------------------------------
@@ -47,51 +58,55 @@
     // order, you can either subclass this class, and use Add & Remove to change them
     // or you can subclass and build them afresh in your constructor;
     m_signals.clear();
-    //        SIGNO NAME         SUPPRESS   STOP   NOTIFY
-    //        ===== ============ =========  ====== ======
-    AddSignal(1,    "SIGHUP",    false,     true,  true );    // 1     hangup
-    AddSignal(2,    "SIGINT",    true,      true,  true );    // 2     interrupt
-    AddSignal(3,    "SIGQUIT",   false,     true,  true );    // 3     quit
-    AddSignal(4,    "SIGILL",    false,     true,  true );    // 4     illegal instruction (not reset when caught)
-    AddSignal(5,    "SIGTRAP",   true,      true,  true );    // 5     trace trap (not reset when caught)
-    AddSignal(6,    "SIGABRT",   false,     true,  true );    // 6     abort()
-    AddSignal(7,    "SIGEMT",    false,     true,  true );    // 7     pollable event ([XSR] generated, not supported)
-    AddSignal(8,    "SIGFPE",    false,     true,  true );    // 8     floating point exception
-    AddSignal(9,    "SIGKILL",   false,     true,  true );    // 9     kill (cannot be caught or ignored)
-    AddSignal(10,   "SIGBUS",    false,     true,  true );    // 10    bus error
-    AddSignal(11,   "SIGSEGV",   false,     true,  true );    // 11    segmentation violation
-    AddSignal(12,   "SIGSYS",    false,     true,  true );    // 12    bad argument to system call
-    AddSignal(13,   "SIGPIPE",   false,     true,  true );    // 13    write on a pipe with no one to read it
-    AddSignal(14,   "SIGALRM",   false,     false, true );    // 14    alarm clock
-    AddSignal(15,   "SIGTERM",   false,     true,  true );    // 15    software termination signal from kill
-    AddSignal(16,   "SIGURG",    false,     false, false);    // 16    urgent condition on IO channel
-    AddSignal(17,   "SIGSTOP",   false,     true,  true );    // 17    sendable stop signal not from tty
-    AddSignal(18,   "SIGTSTP",   false,     true,  true );    // 18    stop signal from tty
-    AddSignal(19,   "SIGCONT",   false,     true,  true );    // 19    continue a stopped process
-    AddSignal(20,   "SIGCHLD",   false,     false, true );    // 20    to parent on child stop or exit
-    AddSignal(21,   "SIGTTIN",   false,     true,  true );    // 21    to readers pgrp upon background tty read
-    AddSignal(22,   "SIGTTOU",   false,     true,  true );    // 22    like TTIN for output if (tp->t_local&LTOSTOP)
-    AddSignal(23,   "SIGIO",     false,     false, false);    // 23    input/output possible signal
-    AddSignal(24,   "SIGXCPU",   false,     true,  true );    // 24    exceeded CPU time limit
-    AddSignal(25,   "SIGXFSZ",   false,     true,  true );    // 25    exceeded file size limit
-    AddSignal(26,   "SIGVTALRM", false,     false, false);    // 26    virtual time alarm
-    AddSignal(27,   "SIGPROF",   false,     false, false);    // 27    profiling time alarm
-    AddSignal(28,   "SIGWINCH",  false,     false, false);    // 28    window size changes
-    AddSignal(29,   "SIGINFO",   false,     true,  true );    // 29    information request
-    AddSignal(30,   "SIGUSR1",   false,     true,  true );    // 30    user defined signal 1
-    AddSignal(31,   "SIGUSR2",   false,     true,  true );    // 31    user defined signal 2
+    //        SIGNO  NAME         SHORT NAME SUPPRESS   STOP   NOTIFY DESCRIPTION
+    //        ====== ============ ========== =========  ====== ====== ===================================================
+    AddSignal (1,    "SIGHUP",    "HUP",     false,     true,  true,  "hangup");
+    AddSignal (2,    "SIGINT",    "INT",     true,      true,  true,  "interrupt");
+    AddSignal (3,    "SIGQUIT",   "QUIT",    false,     true,  true,  "quit");
+    AddSignal (4,    "SIGILL",    "ILL",     false,     true,  true,  "illegal instruction");
+    AddSignal (5,    "SIGTRAP",   "TRAP",    true,      true,  true,  "trace trap (not reset when caught)");
+    AddSignal (6,    "SIGABRT",   "ABRT",    false,     true,  true,  "abort()");
+    AddSignal (7,    "SIGEMT",    "EMT",     false,     true,  true,  "pollable event");
+    AddSignal (8,    "SIGFPE",    "FPE",     false,     true,  true,  "floating point exception");
+    AddSignal (9,    "SIGKILL",   "KILL",    false,     true,  true,  "kill");
+    AddSignal (10,   "SIGBUS",    "BUS",     false,     true,  true,  "bus error");
+    AddSignal (11,   "SIGSEGV",   "SEGV",    false,     true,  true,  "segmentation violation");
+    AddSignal (12,   "SIGSYS",    "SYS",     false,     true,  true,  "bad argument to system call");
+    AddSignal (13,   "SIGPIPE",   "PIPE",    false,     true,  true,  "write on a pipe with no one to read it");
+    AddSignal (14,   "SIGALRM",   "ALRM",    false,     false, true,  "alarm clock");
+    AddSignal (15,   "SIGTERM",   "TERM",    false,     true,  true,  "software termination signal from kill");
+    AddSignal (16,   "SIGURG",    "URG",     false,     false, false, "urgent condition on IO channel");
+    AddSignal (17,   "SIGSTOP",   "STOP",    false,     true,  true,  "sendable stop signal not from tty");
+    AddSignal (18,   "SIGTSTP",   "TSTP",    false,     true,  true,  "stop signal from tty");
+    AddSignal (19,   "SIGCONT",   "CONT",    false,     true,  true,  "continue a stopped process");
+    AddSignal (20,   "SIGCHLD",   "CHLD",    false,     false, true,  "to parent on child stop or exit");
+    AddSignal (21,   "SIGTTIN",   "TTIN",    false,     true,  true,  "to readers process group upon background tty read");
+    AddSignal (22,   "SIGTTOU",   "TTOU",    false,     true,  true,  "to readers process group upon background tty write");
+    AddSignal (23,   "SIGIO",     "IO",      false,     false, false, "input/output possible signal");
+    AddSignal (24,   "SIGXCPU",   "XCPU",    false,     true,  true,  "exceeded CPU time limit");
+    AddSignal (25,   "SIGXFSZ",   "XFSZ",    false,     true,  true,  "exceeded file size limit");
+    AddSignal (26,   "SIGVTALRM", "VTALRM",  false,     false, false, "virtual time alarm");
+    AddSignal (27,   "SIGPROF",   "PROF",    false,     false, false, "profiling time alarm");
+    AddSignal (28,   "SIGWINCH",  "WINCH",   false,     false, false, "window size changes");
+    AddSignal (29,   "SIGINFO",   "INFO",    false,     true,  true,  "information request");
+    AddSignal (30,   "SIGUSR1",   "USR1",    false,     true,  true,  "user defined signal 1");
+    AddSignal (31,   "SIGUSR2",   "USR2",    false,     true,  true,  "user defined signal 2");
 }
 
 void
-UnixSignals::AddSignal (int signo, const char *name, bool default_suppress, bool default_stop, bool default_notify)
+UnixSignals::AddSignal 
+(
+    int signo,
+    const char *name,
+    const char *short_name,
+    bool default_suppress,
+    bool default_stop,
+    bool default_notify,
+    const char *description
+)
 {
-    collection::iterator iter = m_signals.find (signo);
-    struct Signal new_signal (name, default_suppress, default_stop, default_notify);
-
-    if (iter != m_signals.end())
-        m_signals.erase (iter);
-
-    m_signals.insert (iter, collection::value_type (signo, new_signal));
+    Signal new_signal (name, short_name, default_suppress, default_stop, default_notify, description);
+    m_signals.insert (std::make_pair(signo, new_signal));
 }
 
 void
@@ -110,10 +125,10 @@
     collection::iterator pos, end = m_signals.end ();
     for (pos = m_signals.begin (); pos != end; pos++)
     {
-        if (const_name == (*pos).second.m_name)
+        if ((const_name == pos->second.m_name) || (const_name == pos->second.m_short_name))
         {
-            signo = (*pos).first;
-            return &((*pos).second);
+            signo = pos->first;
+            return &pos->second;
         }
     }
     return NULL;
@@ -128,10 +143,10 @@
     collection::const_iterator pos, end = m_signals.end ();
     for (pos = m_signals.begin (); pos != end; pos++)
     {
-        if (const_name == (*pos).second.m_name)
+        if (const_name == pos->second.m_name)
         {
-            signo = (*pos).first;
-            return &((*pos).second);
+            signo = pos->first;
+            return &(pos->second);
         }
     }
     return NULL;
@@ -144,7 +159,7 @@
     if (pos == m_signals.end())
         return NULL;
     else
-        return (*pos).second.m_name.GetCString ();
+        return pos->second.m_name.GetCString ();
 }
 
 
@@ -188,7 +203,7 @@
         if (pos == end)
             return LLDB_INVALID_SIGNAL_NUMBER;
         else
-            return (*pos).first;
+            return pos->first;
     }
 }
 
@@ -206,107 +221,92 @@
         return NULL;
     else
     {
-        const Signal &signal = (*pos).second;
-        should_suppress = signal.m_conditions[Signal::eCondSuppress];
-        should_stop     = signal.m_conditions[Signal::eCondStop];
-        should_notify   = signal.m_conditions[Signal::eCondNotify];
+        const Signal &signal = pos->second;
+        should_suppress = signal.m_suppress;
+        should_stop     = signal.m_stop;
+        should_notify   = signal.m_notify;
         return signal.m_name.AsCString("");
     }
 }
 
 bool
-UnixSignals::GetCondition
-(
-    int32_t signo,
-    UnixSignals::Signal::Condition cond_pos
-) const
+UnixSignals::GetShouldSuppress (int signo) const
 {
     collection::const_iterator pos = m_signals.find (signo);
-    if (pos == m_signals.end())
-        return false;
-    else
-        return (*pos).second.m_conditions[cond_pos];
+    if (pos != m_signals.end())
+        return pos->second.m_suppress;
+    return false;
 }
 
 bool
-UnixSignals::SetCondition (int32_t signo, UnixSignals::Signal::Condition cond_pos, bool value)
+UnixSignals::SetShouldSuppress (int signo, bool value)
 {
     collection::iterator pos = m_signals.find (signo);
-    if (pos == m_signals.end())
-        return false;
-    else
-    {
-        bool ret_value = (*pos).second.m_conditions[cond_pos];
-        (*pos).second.m_conditions[cond_pos] = value;
-        return ret_value;
-    }
-}
-
-bool
-UnixSignals::SetCondition (const char *signal_name, UnixSignals::Signal::Condition cond_pos, bool value)
-{
-    int32_t signo;
-    Signal *signal = GetSignalByName (signal_name, signo);
-    if (signal == NULL)
-        return false;
-    else
+    if (pos != m_signals.end())
     {
-        bool ret_value = signal->m_conditions[cond_pos];
-        signal->m_conditions[cond_pos] = value;
-        return ret_value;
+        pos->second.m_suppress = value;
+        return true;
     }
-}
-
-bool
-UnixSignals::GetShouldSuppress (int signo) const
-{
-    return GetCondition (signo, Signal::eCondSuppress);
-}
-
-bool
-UnixSignals::SetShouldSuppress (int signo, bool value)
-{
-    return SetCondition (signo, Signal::eCondSuppress, value);
+    return false;
 }
 
 bool
 UnixSignals::SetShouldSuppress (const char *signal_name, bool value)
 {
-    return SetCondition (signal_name, Signal::eCondSuppress, value);
+    return SetShouldSuppress (GetSignalNumberFromName (signal_name), value);
 }
 
 bool
 UnixSignals::GetShouldStop (int signo) const
 {
-    return GetCondition (signo, Signal::eCondStop);
+    collection::const_iterator pos = m_signals.find (signo);
+    if (pos != m_signals.end())
+        return pos->second.m_stop;
+    return false;
 }
 
 bool
 UnixSignals::SetShouldStop (int signo, bool value)
 {
-    return SetCondition (signo, Signal::eCondStop, value);
+    collection::iterator pos = m_signals.find (signo);
+    if (pos != m_signals.end())
+    {
+        pos->second.m_stop = value;
+        return true;
+    }
+    return false;
 }
 
 bool
 UnixSignals::SetShouldStop (const char *signal_name, bool value)
 {
-    return SetCondition (signal_name, Signal::eCondStop, value);
+    return SetShouldStop (GetSignalNumberFromName (signal_name), value);
 }
 
 bool
 UnixSignals::GetShouldNotify (int signo) const
 {
-    return GetCondition (signo, Signal::eCondNotify);
+    collection::const_iterator pos = m_signals.find (signo);
+    if (pos != m_signals.end())
+        return pos->second.m_notify;
+    return false;
 }
 
 bool
 UnixSignals::SetShouldNotify (int signo, bool value)
 {
-    return SetCondition (signo, Signal::eCondNotify, value);
+    collection::iterator pos = m_signals.find (signo);
+    if (pos != m_signals.end())
+    {
+        pos->second.m_notify = value;
+        return true;
+    }
+    return false;
 }
 
 bool
 UnixSignals::SetShouldNotify (const char *signal_name, bool value)
 {
-    return SetCondition (signal_name, Signal::eCondNotify, value);
+    return SetShouldNotify (GetSignalNumberFromName (signal_name), value);
 }
+





More information about the lldb-commits mailing list