summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common/Socket.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [lldb/Host] Use cmakedefine01 for LLDB_ENABLE_POSIXJonas Devlieghere2019-12-131-2/+2
| | | | | Rename LLDB_DISABLE_POSIX to LLDB_ENABLE_POSIX and use cmakedefine01 for consistency.
* refactor: move IOObject::m_should_close_fd into subclassesLawrence D'Anna2019-09-271-2/+3
| | | | | | | | | | | | | | | | | | Summary: m_should_close_fd doesn't need to be in IOObject. It will be useful for my next change to move it down into File and Socket. Reviewers: labath, JDevlieghere, jasonmolenda Reviewed By: JDevlieghere Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68152 llvm-svn: 373126
* [LLDB] Cast -1 (as invalid socket) to the socket type before comparingMartin Storsjo2019-09-211-4/+4
| | | | | | | | | | This silences warnings about comparison of integers between unsigned long long (which is what the Windows SOCKET type is) and signed int when building in MinGW mode. Differential Revision: https://reviews.llvm.org/D67863 llvm-svn: 372486
* [lldb] Fix log statement in Socket::WriteRaphael Isemann2019-09-041-1/+2
| | | | | | | | We change num_bytes in this method, so this doesn't actually log the parameter that we called the function with. No test as we don't test logging code. llvm-svn: 370887
* [Utility] Reimplement RegularExpression on top of llvm::RegexJonas Devlieghere2019-08-161-19/+17
| | | | | | | | | | | | | | | Originally I wanted to remove the RegularExpression class in Utility and replace it with llvm::Regex. However, during that transition I noticed that there are several places where need the regular expression string. So instead I propose to keep the RegularExpression class and make it a thin wrapper around llvm::Regex. This patch also removes the workaround for empty regular expressions. The result is that we are now (more or less) POSIX conformant. Differential revision: https://reviews.llvm.org/D66174 llvm-svn: 369153
* [LLDB] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-4/+4
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368933
* [Logging] Replace Log::Printf with LLDB_LOG macro (NFC)Jonas Devlieghere2019-07-241-23/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch replaces explicit calls to log::Printf with the new LLDB_LOGF macro. The macro is similar to LLDB_LOG but supports printf-style format strings, instead of formatv-style format strings. So instead of writing: if (log) log->Printf("%s\n", str); You'd write: LLDB_LOG(log, "%s\n", str); This change was done mechanically with the command below. I replaced the spurious if-checks with vim, since I know how to do multi-line replacements with it. find . -type f -name '*.cpp' -exec \ sed -i '' -E 's/log->Printf\(/LLDB_LOGF\(log, /g' "{}" + Differential revision: https://reviews.llvm.org/D65128 llvm-svn: 366936
* Fix LLDB warnings when compiling with Clang 8.0Alexandre Ganea2019-05-211-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D62021 llvm-svn: 361295
* [lldb-server] Introduce Socket::Initialize and Terminate to simply WSASocket ↵Aaron Smith2019-04-101-0/+27
| | | | | | | | | | | | | | | | setup Reviewers: zturner, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D60440 llvm-svn: 358044
* Fix a stack buffer overflow found by ASAN.Adrian Prantl2019-04-081-5/+6
| | | | | | | | | | llvm::StringRef host_and_port is not guaranteed to be null-terminated. Generally, it is not safe at all to convert a StringRef into a char * by calling data() on it. <rdar://problem/49698580> llvm-svn: 357948
* [lldb] Add missing EINTR handlingMichal Gorny2019-03-211-2/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D59606 llvm-svn: 356703
* Fix invalid use of StringRef::data in Socket::DecodeHostAndPortPavel Labath2019-03-111-5/+3
| | | | | | | | | | | | the input StringRef is not guaranteed to be null-terminated, so using data to get the c string is wrong. Luckily, in two of the usages the target function already accepts a StringRef so we can just drop the data() call, and the third one is easily replaced by a stringref-aware function. Issue found by msan. llvm-svn: 355817
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Reflow paragraphs in comments.Adrian Prantl2018-04-301-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is intended as a clean up after the big clang-format commit (r280751), which unfortunately resulted in many of the comment paragraphs in LLDB being very hard to read. FYI, the script I used was: import textwrap import commands import os import sys import re tmp = "%s.tmp"%sys.argv[1] out = open(tmp, "w+") with open(sys.argv[1], "r") as f: header = "" text = "" comment = re.compile(r'^( *//) ([^ ].*)$') special = re.compile(r'^((([A-Z]+[: ])|([0-9]+ )).*)|(.*;)$') for line in f: match = comment.match(line) if match and not special.match(match.group(2)): # skip intentionally short comments. if not text and len(match.group(2)) < 40: out.write(line) continue if text: text += " " + match.group(2) else: header = match.group(1) text = match.group(2) continue if text: filled = textwrap.wrap(text, width=(78-len(header)), break_long_words=False) for l in filled: out.write(header+" "+l+'\n') text = "" out.write(line) os.rename(tmp, sys.argv[1]) Differential Revision: https://reviews.llvm.org/D46144 llvm-svn: 331197
* More precise c library feature detection for Android.Eugene Zemtsov2017-09-161-1/+1
| | | | llvm-svn: 313436
* Clean up lldb-types.hPavel Labath2017-07-181-0/+1
| | | | | | | | | | | | | | | | | | | | Summary: It defined a couple of types (condition_t) which we don't use anymore, as we have c++11 goodies now. I remove these definitions. Also it unnecessarily included a couple of headers which weren't necessary for it's operation. I remove these, and place the includes in the relevant files (usually .cpp, usually in Host code) which use them. This allows us to reduce namespace pollution in most of the lldb files which don't need the OS-specific definitions. Reviewers: zturner, jingham Subscribers: ki.stfu, lldb-commits Differential Revision: https://reviews.llvm.org/D35113 llvm-svn: 308304
* Rename Error -> Status.Zachary Turner2017-05-121-36/+37
| | | | | | | | | | | | | | | This renames the LLDB error class to Status, as discussed on the lldb-dev mailing list. A change of this magnitude cannot easily be done without find and replace, but that has potential to catch unwanted occurrences of common strings such as "Error". Every effort was made to find all the obvious things such as the word "Error" appearing in a string, etc, but it's possible there are still some lingering occurences left around. Hopefully nothing too serious. llvm-svn: 302872
* Re-landing IPv6 support for LLDB HostChris Bieneman2017-04-261-13/+25
| | | | | | | | | | | | | | | | | | | | | | This support was landed in r300579, and reverted in r300669 due to failures on the bots. The failures were caused by sockets not being properly closed, and this updated version of the patches should resolve that. Summary from the original change: This patch adds IPv6 support to LLDB/Host's TCP socket implementation. Supporting IPv6 involved a few significant changes to the implementation of the socket layers, and I have performed some significant code cleanup along the way. This patch changes the Socket constructors for all types of sockets to not create sockets until first use. This is required for IPv6 support because the socket type will vary based on the address you are connecting to. This also has the benefit of removing code that could have errors from the Socket subclass constructors (which seems like a win to me). The patch also slightly changes the API and behaviors of the Listen/Accept pattern. Previously both Listen and Accept calls took an address specified as a string. Now only listen does. This change was made because the Listen call can result in opening more than one socket. In order to support listening for both IPv4 and IPv6 connections we need to open one AF_INET socket and one AF_INET6 socket. During the listen call we construct a map of file descriptors to addrin structures which represent the allowable incoming connection address. This map removes the need for taking an address into the Accept call. This does have a change in functionality. Previously you could Listen for connections based on one address, and Accept connections from a different address. This is no longer supported. I could not find anywhere in LLDB where we actually used the APIs in that way. The new API does still support AnyAddr for allowing incoming connections from any address. The Listen implementation is implemented using kqueue on FreeBSD and Darwin, WSAPoll on Windows and poll(2) everywhere else. https://reviews.llvm.org/D31823 llvm-svn: 301492
* Revert yesterdays IPv6 patchesPavel Labath2017-04-191-22/+13
| | | | | | | | | | | | | The break the linux bots (and probably any other machine which would run the test suite in a massively parallel way). The problem is that it can happen that we only successfully create an IPv6 listening socket (because the relevant IPv4 port is used by another process) and then the connecting side attempts to connect to the IPv4 port and fails. It's not very obvious how to fix this problem, so I am reverting this until we come up with a solution. llvm-svn: 300669
* Fixing bot failure caused by r300579Chris Bieneman2017-04-181-1/+1
| | | | llvm-svn: 300582
* Update LLDB Host to support IPv6 over TCPChris Bieneman2017-04-181-13/+22
| | | | | | | | | | | | | | | | | | | | | Summary: This patch adds IPv6 support to LLDB/Host's TCP socket implementation. Supporting IPv6 involved a few significant changes to the implementation of the socket layers, and I have performed some significant code cleanup along the way. This patch changes the Socket constructors for all types of sockets to not create sockets until first use. This is required for IPv6 support because the socket type will vary based on the address you are connecting to. This also has the benefit of removing code that could have errors from the Socket subclass constructors (which seems like a win to me). The patch also slightly changes the API and behaviors of the Listen/Accept pattern. Previously both Listen and Accept calls took an address specified as a string. Now only listen does. This change was made because the Listen call can result in opening more than one socket. In order to support listening for both IPv4 and IPv6 connections we need to open one AF_INET socket and one AF_INET6 socket. During the listen call we construct a map of file descriptors to addrin structures which represent the allowable incoming connection address. This map removes the need for taking an address into the Accept call. This does have a change in functionality. Previously you could Listen for connections based on one address, and Accept connections from a different address. This is no longer supported. I could not find anywhere in LLDB where we actually used the APIs in that way. The new API does still support AnyAddr for allowing incoming connections from any address. The Listen implementation is implemented using kqueue on FreeBSD and Darwin, WSAPoll on Windows and poll(2) everywhere else. Reviewers: zturner, clayborg Subscribers: jasonmolenda, labath, lldb-commits, emaste Differential Revision: https://reviews.llvm.org/D31823 llvm-svn: 300579
* Change how UDP sockets are set up -- use the same one socket forJason Molenda2017-04-061-4/+2
| | | | | | | | | both sending and receiving information, instead of using one socket to send and another to receive. The two socket arrangement fails over when a firewall is between the two systems. <rdar://problem/31286757> llvm-svn: 299608
* Move Log from Core -> Utility.Zachary Turner2017-03-031-1/+1
| | | | | | | | | All references to Host and Core have been removed, so this class can now safely be lowered into Utility. Differential Revision: https://reviews.llvm.org/D30559 llvm-svn: 296909
* Switch NetBSD from paccept(2) to accept4(2)Kamil Rytarowski2017-02-241-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: NetBSD 8.0 will ship with accept4(2) in libc wrapping paccept(2). This change reduces needless difference with other platforms. Older versions of NetBSD will not be supported. No functional change. Sponsored by <The NetBSD Foundation> Reviewers: joerg, emaste, labath, clayborg Reviewed By: emaste, labath, clayborg Subscribers: #lldb Tags: #lldb Differential Revision: https://reviews.llvm.org/D30288 llvm-svn: 296070
* Move classes from Core -> Utility.Zachary Turner2017-02-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This moves the following classes from Core -> Utility. ConstString Error RegularExpression Stream StreamString The goal here is to get lldbUtility into a state where it has no dependendencies except on itself and LLVM, so it can be the starting point at which to start untangling LLDB's dependencies. These are all low level and very widely used classes, and previously lldbUtility had dependencies up to lldbCore in order to use these classes. So moving then down to lldbUtility makes sense from both the short term and long term perspective in solving this problem. Differential Revision: https://reviews.llvm.org/D29427 llvm-svn: 293941
* Address post-commit review remarksPavel Labath2017-01-271-1/+1
| | | | | | | Tamas pointed out that the macro name I used in r293282 was too vague. Rename it to better reflect what it is used for. llvm-svn: 293287
* Refactor the android accept hackPavel Labath2017-01-271-5/+7
| | | | | | | | This moves the accept hack from the android toolchain file into LLDBConfig.cmake. This allows successful lldb android compilation without relying on our custom toolchain file. llvm-svn: 293281
* Remove superfluous android includePavel Labath2016-12-051-1/+0
| | | | | | | This file is not in the include path when building with a non-standalone toolchain. In does not seem to be necessary anyway. llvm-svn: 288674
* Replace __ANDROID_NDK__ with __ANDROID__Pavel Labath2016-12-021-2/+2
| | | | | | | | | | | | | | | | | | | | Summary: This replaces all the uses of the __ANDROID_NDK__ define with __ANDROID__. This is a preparatory step to remove our custom android toolchain file and rely on the standard android NDK one instead, which does not provide this define. Instead I rely, on __ANDROID__, which is set by the compiler. I haven't yet removed the cmake variable with the same name, as we will need to do something completely different there -- NDK toolchain defines CMAKE_SYSTEM_NAME to Android, while our current one pretends it's linux. Reviewers: tberghammer, zturner Subscribers: danalbert, srhines, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D27305 llvm-svn: 288494
* Remove TimeValue usage from lldb/HostPavel Labath2016-11-091-1/+0
| | | | llvm-svn: 286371
* Make lldb::Regex use StringRef.Zachary Turner2016-09-211-2/+2
| | | | | | | | | | This updates getters and setters to use StringRef instead of const char *. I tested the build on Linux, Windows, and OSX and saw no build or test failures. I cannot test any BSD or Android variants, however I expect the required changes to be minimal or non-existant. llvm-svn: 282079
* *** This commit represents a complete reformatting of the LLDB source codeKate Stone2016-09-061-346/+314
| | | | | | | | | | | | | | | | | | | | | | | *** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
* Fix an off-by-one in SocketTest::DecodeHostAndPortPavel Labath2016-02-031-1/+1
| | | | | | | 65535 is still a valid port. This should fix the android failures we were getting when we chose to connect over 65535 to the remote lldb-server. llvm-svn: 259638
* Use accept4 workaround for MIPS Android build.Chaoren Lin2015-10-271-3/+3
| | | | | | | | | | | | Summary: Similar to http://reviews.llvm.org/rL242319, which was for ARM. Reviewers: chying, ovyalov Subscribers: aemerson, tberghammer, danalbert, srhines, lldb-commits Differential Revision: http://reviews.llvm.org/D14127 llvm-svn: 251439
* Add Socket::Create factory method which uses socket protocol to find an ↵Oleksiy Vyalov2015-10-271-21/+41
| | | | | | | | appropriate implementation class. http://reviews.llvm.org/D14085 llvm-svn: 251417
* Add support for abstract domain sockets.Oleksiy Vyalov2015-10-221-0/+42
| | | | | | http://reviews.llvm.org/D13970 llvm-svn: 251034
* Split Socket class into Tcp/Udp/DomainSocket subclasses.Oleksiy Vyalov2015-10-151-469/+100
| | | | | | http://reviews.llvm.org/D13754 llvm-svn: 250474
* NetBSD ships with paccept(2), a superset of accept4(2)Stephane Sezer2015-09-031-2/+4
| | | | | | | | | | | | | | Summary: accept4(2) and paccept(2) are nonstandard extensions. Reviewers: joerg, sas Subscribers: emaste, sas, lldb-commits Differential Revision: http://reviews.llvm.org/D12485 Change by Kamil Rytarowski <n54@gmx.com> llvm-svn: 246787
* Log socket communications to LIBLLDB_LOG_COMMUNICATION instead ofJason Molenda2015-07-241-3/+3
| | | | | | | | the Host channel. http://reviews.llvm.org/D11497 llvm-svn: 243175
* Bind to the loopback when we are expecting a connection from 127.0.0.1 so we ↵Greg Clayton2015-07-241-9/+18
| | | | | | | | don't set off firewall protections. <rdar://problem/17897318> llvm-svn: 243118
* Add missing include for android-arm buildTamas Berghammer2015-07-161-0/+1
| | | | llvm-svn: 242396
* Use accept instead of accept4 for Android.Chaoren Lin2015-07-151-2/+19
| | | | | | | | | | | | | | | Summary: The accept4 syscall is missing on older ARM Android kernels, and the accept() call is implemented with the accept4 syscall, so we'll need to call the accept syscall directly. Reviewers: vharron, tberghammer, labath Subscribers: ovyalov, chaoren, labath, tberghammer, aemerson, lldb-commits Differential Revision: http://reviews.llvm.org/D10887 llvm-svn: 242319
* Refactor many file functions to use FileSpec over strings.Chaoren Lin2015-05-291-1/+1
| | | | | | | | | | | | | | | | | Summary: This should solve the issue of sending denormalized paths over gdb-remote if we stick to GetPath(false) in GDBRemoteCommunicationClient, and let the server handle any denormalization. Reviewers: ovyalov, zturner, vharron, clayborg Reviewed By: clayborg Subscribers: tberghammer, emaste, lldb-commits Differential Revision: http://reviews.llvm.org/D9728 llvm-svn: 238604
* Wrap socket error handling with SetLastError and IsInterrupted internal ↵Oleksiy Vyalov2015-04-101-32/+38
| | | | | | | | functions which can properly treat Windows and POSIX errors. http://reviews.llvm.org/D8939 llvm-svn: 234559
* Fix warnings generated by clang-cl.Zachary Turner2015-04-021-4/+4
| | | | | | | | | | | | | | There were a couple of real bugs here regarding error checking and signed/unsigned comparisons, but mostly these were just noise. There was one class of bugs fixed here which is particularly annoying, dealing with MSVC's non-standard behavior regarding the underlying type of enums. See the comment in lldb-enumerations.h for details. In short, from now on please use FLAGS_ENUM and FLAGS_ANONYMOUS_ENUM when defining enums which contain values larger than can fit into a signed integer. llvm-svn: 233943
* Increate backlog of lldb-platform's listener socketVince Harron2015-03-311-2/+7
| | | | | | | | | | | | | | | lldb-platform's listener socket only had a backlog of one connection. That means that if more than one client connected simultaneously, the connection would be refused. The test suite can be run remotely with dozens of threads connecting simultaneously. Raised this limit to 100 to effectively eliminate lost connections. Test Plan: run tests against a remote target Differential Revision: http://reviews.llvm.org/D8696 llvm-svn: 233652
* Revert "Fix warnings found with clang-cl."Zachary Turner2015-02-251-3/+3
| | | | | | | SWIG doesn't like enum : unsigned. Revert this until I can fix this in a way that swig likes. llvm-svn: 230531
* Fix warnings found with clang-cl.Zachary Turner2015-02-251-3/+3
| | | | | | | | | | | Earlier this week I was able to get clang-cl on Windows to be able to self host. This opened the door to being able to get a whole new slew of warnings for the Windows build. This patch fixes all of the warnings, many of which were real bugs. llvm-svn: 230522
* Added Connection::GetURI()Vince Harron2015-01-171-1/+1
| | | | | | | | | | | | | This function returns a URI of the resource that the connection is connected to. This is especially important for connections established by accepting a connection from a remote host. Also added implementations for ConnectionMachPort, ConnectionSharedMemory, Also fixed up some documentation in Connection::Write Renamed ConnectionFileDescriptorPosix::SocketListen to ConnectionFileDescriptorPosix::SocketListenAndAccept Fixed a log message in Socket.cpp Differential Review: http://reviews.llvm.org/D7026 llvm-svn: 226362
* Add Socket::Get[Remote/Local]IpAddress and unit testsVince Harron2015-01-161-9/+57
| | | | | | Differential Revision: http://reviews.llvm.org/D6917 llvm-svn: 226234
OpenPOWER on IntegriCloud