aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-04-01 00:29:43 +0000
committerGreg Clayton <gclayton@apple.com>2011-04-01 00:29:43 +0000
commitff39f746ebaa3710c44ba49bd9b0a6cf05f60a3f (patch)
treea22cf1e2c124e3b04d8f6c74a831622e3fc07e29 /tools
parent0de37195f17fefb536157b3296a18999116b8125 (diff)
downloadlldb-ff39f746ebaa3710c44ba49bd9b0a6cf05f60a3f.tar.gz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@128694 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/debugserver/source/RNBSocket.cpp51
-rw-r--r--tools/debugserver/source/RNBSocket.h2
-rw-r--r--tools/debugserver/source/debugserver.cpp3
3 files changed, 56 insertions, 0 deletions
diff --git a/tools/debugserver/source/RNBSocket.cpp b/tools/debugserver/source/RNBSocket.cpp
index 08fa4ac79..139a4150a 100644
--- a/tools/debugserver/source/RNBSocket.cpp
+++ b/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 @@ RNBSocket::Listen (in_port_t listen_port_num)
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/tools/debugserver/source/RNBSocket.h b/tools/debugserver/source/RNBSocket.h
index de3db806d..56608bb17 100644
--- a/tools/debugserver/source/RNBSocket.h
+++ b/tools/debugserver/source/RNBSocket.h
@@ -36,6 +36,8 @@ public:
}
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/tools/debugserver/source/debugserver.cpp b/tools/debugserver/source/debugserver.cpp
index 6c149f3c2..6e08d5dd8 100644
--- a/tools/debugserver/source/debugserver.cpp
+++ b/tools/debugserver/source/debugserver.cpp
@@ -374,6 +374,8 @@ signal_handler(int signo)
case eStateStepping:
DNBProcessSignal (g_pid, SIGSTOP);
return;
+ default:
+ break;
}
}
}
@@ -455,6 +457,7 @@ HandleProcessStateChange (RNBRemote *remote, bool initialize)
case eStateExited:
remote->HandlePacket_last_signal(NULL);
+ case eStateDetached:
return eRNBRunLoopModeExit;
}