diff options
author | Chris Bieneman <beanz@apple.com> | 2017-04-18 20:01:59 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2017-04-18 20:01:59 +0000 |
commit | d01a2fa38d728d0190e3a802d665726787a88b9c (patch) | |
tree | eb83356c5a0fad579871e665577d63dee8f8a554 /lldb/tools/debugserver/source/debugserver.cpp | |
parent | 31e7c5e89f2f3a1617a0aca6aa9935192ffc74b9 (diff) | |
download | llvm-d01a2fa38d728d0190e3a802d665726787a88b9c.zip llvm-d01a2fa38d728d0190e3a802d665726787a88b9c.tar.gz llvm-d01a2fa38d728d0190e3a802d665726787a88b9c.tar.bz2 |
Update DebugServer to support IPv6 over TCP
Summary: This patch adds IPv6 support to debugserver. It follows a similar pattern to the changes proposed for LLDB/Host except that the listen implementation is only with kqueue(2) because debugserver is only supported on Darwin.
Reviewers: jingham, jasonmolenda, clayborg
Reviewed By: clayborg
Subscribers: mgorny, lldb-commits
Differential Revision: https://reviews.llvm.org/D31824
llvm-svn: 300580
Diffstat (limited to 'lldb/tools/debugserver/source/debugserver.cpp')
-rw-r--r-- | lldb/tools/debugserver/source/debugserver.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp index 0cb72f4..bc1954d 100644 --- a/lldb/tools/debugserver/source/debugserver.cpp +++ b/lldb/tools/debugserver/source/debugserver.cpp @@ -1345,10 +1345,18 @@ int main(int argc, char *argv[]) { show_usage_and_exit(1); } // accept 'localhost:' prefix on port number - - int items_scanned = ::sscanf(argv[0], "%[^:]:%i", str, &port); - if (items_scanned == 2) { - host = str; + std::string host_specifier = argv[0]; + auto colon_location = host_specifier.rfind(':'); + if (colon_location != std::string::npos) { + host = host_specifier.substr(0, colon_location); + std::string port_str = + host_specifier.substr(colon_location + 1, std::string::npos); + char *end_ptr; + port = strtoul(port_str.c_str(), &end_ptr, 0); + if (end_ptr < port_str.c_str() + port_str.size()) + show_usage_and_exit(2); + if (host.front() == '[' && host.back() == ']') + host = host.substr(1, host.size() - 2); DNBLogDebug("host = '%s' port = %i", host.c_str(), port); } else { // No hostname means "localhost" |