Added the ability to get a broadcaster event name for a given broadcaster
event.

Modified the ProcessInfo structure to contain all process arguments. Using the
new function calls on MacOSX allows us to see the full process name, not just
the first 16 characters. 

Added a new platform command: "platform process info <pid> [<pid> <pid> ...]"
that can be used to get detailed information for a process including all 
arguments, user and group info and more.

llvm-svn: 128694
diff --git a/lldb/tools/debugserver/source/RNBSocket.cpp b/lldb/tools/debugserver/source/RNBSocket.cpp
index 08fa4ac..139a415 100644
--- a/lldb/tools/debugserver/source/RNBSocket.cpp
+++ b/lldb/tools/debugserver/source/RNBSocket.cpp
@@ -12,8 +12,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "RNBSocket.h"
+#include <arpa/inet.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <netdb.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 #include <termios.h>
@@ -106,6 +108,55 @@
     return rnb_success;
 }
 
+rnb_err_t
+RNBSocket::Connect (const char *host, uint16_t port)
+{
+    Disconnect (false);
+
+    // Create the socket
+    m_conn_port = ::socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
+    if (m_conn_port == -1)
+        return rnb_err;
+    
+    // Enable local address reuse
+    SetSocketOption (m_conn_port, SOL_SOCKET, SO_REUSEADDR, 1);
+    
+    struct sockaddr_in sa;
+    ::memset (&sa, 0, sizeof (sa));
+    sa.sin_family = AF_INET;
+    sa.sin_port = htons (port);
+    
+    if (host == NULL)
+        host = "localhost";
+
+    int inet_pton_result = ::inet_pton (AF_INET, host, &sa.sin_addr);
+    
+    if (inet_pton_result <= 0)
+    {
+        struct hostent *host_entry = gethostbyname (host);
+        if (host_entry)
+        {
+            std::string host_str (::inet_ntoa (*(struct in_addr *)*host_entry->h_addr_list));
+            inet_pton_result = ::inet_pton (AF_INET, host_str.c_str(), &sa.sin_addr);
+            if (inet_pton_result <= 0)
+            {
+                Disconnect (false);
+                return rnb_err;
+            }
+        }
+    }
+    
+    if (-1 == ::connect (m_conn_port, (const struct sockaddr *)&sa, sizeof(sa)))
+    {
+        Disconnect (false);
+        return rnb_err;
+    }
+    
+    // Keep our TCP packets coming without any delays.
+    SetSocketOption (m_conn_port, IPPROTO_TCP, TCP_NODELAY, 1);
+    return rnb_success;
+}
+
 #if defined (__arm__)
 rnb_err_t
 RNBSocket::ConnectToService()
diff --git a/lldb/tools/debugserver/source/RNBSocket.h b/lldb/tools/debugserver/source/RNBSocket.h
index de3db80..56608bb 100644
--- a/lldb/tools/debugserver/source/RNBSocket.h
+++ b/lldb/tools/debugserver/source/RNBSocket.h
@@ -36,6 +36,8 @@
     }
 
     rnb_err_t Listen (in_port_t listen_port_num);
+    rnb_err_t Connect (const char *host, uint16_t port);
+
 #if defined (__arm__)
     rnb_err_t ConnectToService();
 #endif
diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp
index 6c149f3..6e08d5d 100644
--- a/lldb/tools/debugserver/source/debugserver.cpp
+++ b/lldb/tools/debugserver/source/debugserver.cpp
@@ -374,6 +374,8 @@
                         case eStateStepping:
                             DNBProcessSignal (g_pid, SIGSTOP);
                             return;
+                        default:
+                            break;
                     }
                 }
             }
@@ -455,6 +457,7 @@
 
         case eStateExited:
             remote->HandlePacket_last_signal(NULL);
+        case eStateDetached:
             return eRNBRunLoopModeExit;
 
     }