summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common
Commit message (Collapse)AuthorAgeFilesLines
...
* Signal polling is supported with pselect (re-land r313704 without a Windows ↵Eugene Zemtsov2017-09-201-4/+0
| | | | | | | | | breakage) Older Android API levels don't have ppoll, but LLDB works just fine, since on Android it always uses pselect anyway. llvm-svn: 313726
* Rollback r313704 because of the Windows build breakEugene Zemtsov2017-09-201-0/+4
| | | | llvm-svn: 313707
* Signal polling is supported with pselectEugene Zemtsov2017-09-201-4/+0
| | | | | | | Older Android API levels don't have ppoll, but LLDB works just fine, since on Android it always uses pselect anyway. llvm-svn: 313704
* Use ThreadLauncher to launch TaskPool threadsFrancis Ricci2017-09-191-0/+109
| | | | | | | | | | | | | | | | | | Summary: This allows for the stack size to be configured, which isn't possible with std::thread. Prevents overflowing the stack when performing complex operations in the task pool on darwin, where the default pthread stack size is only 512kb. This also moves TaskPool from Utility to Host. Reviewers: labath, tberghammer, clayborg Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D37930 llvm-svn: 313637
* More precise c library feature detection for Android.Eugene Zemtsov2017-09-161-1/+1
| | | | llvm-svn: 313436
* [IPv6] Fix a bug in the IPv6 listen behaviorChris Bieneman2017-08-291-3/+8
| | | | | | | | | | The socket bind address should either be localhost or anyaddress. This bug in the listen behavior was preventing lldb-server from opening sockets for non-localhost connections. The added test verifies that opening an anyaddress socket works and has a non-zero port assignment. This should resolve PR34183. llvm-svn: 312008
* Fix NetBSD/FreeBSD build after r308304Pavel Labath2017-07-182-0/+2
| | | | llvm-svn: 308307
* Clean up lldb-types.hPavel Labath2017-07-183-0/+3
| | | | | | | | | | | | | | | | | | | | 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
* Remove shared pointer from NativeProcessProtocolPavel Labath2017-07-182-44/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The usage of shared_from_this forces us to separate construction and initialization phases, because shared_from_this() is not available in the constructor (or destructor). The shared semantics are not necessary, as we always have a clear owner of the native process class (GDBRemoteCommunicationServerLLDB object). Even if we need shared semantics in the future (which I think we should strongly avoid), reverting this will not be necessary -- the owners can still easily store the native process object in a shared pointer if they really want to -- this just prevents the knowledge of that from leaking into the class implementation. After this a NativeThread object will hold a reference to the parent process (instead of a weak_ptr) -- having a process instance always available allows us to simplify some logic in this class (some of it was already simplified because we were asserting that the process is available, but this makes it obvious). Reviewers: krytarowski, eugene, zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D35123 llvm-svn: 308282
* Fix debugserver accepting remote connectionsChris Bieneman2017-07-131-0/+7
| | | | | | | | While adding IPv6 support to debugserver I broke handling wildcard addresses and fully qualified address filtering. This patch resolves that bug and adds a test for matching the address "*". <rdar://problem/32947613> llvm-svn: 307957
* [MainLoop] Fix possible use of an invalid iteratorPetr Pavlu2017-07-121-9/+18
| | | | | | | | | | | | | | | | Store file descriptors from loop.m_read_fds (if FORCE_PSELECT is defined) and signals from loop.m_signals that need to be processed in MainLoop::RunImpl::ProcessEvents() into a separate vector and then iterate over this container to invoke the callbacks. This prevents a problem where when the code iterated directly over m_read_fds/m_signals, a callback invoked from within the loop could modify these variables and invalidate the loop iterator. This would then result in an assertion failure in llvm::DenseMapIterator::operator++(). Differential Revision: https://reviews.llvm.org/D35298 llvm-svn: 307782
* Add a NativeProcessProtocol Factory classPavel Labath2017-07-071-25/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This replaces the static functions used for creating NativeProcessProtocol instances with a factory pattern, and modernizes the interface of the new class in the process -- I use llvm::Expected instead of the Status+value combo. I also move some of the common code (like the Delegate registration into the base class). The new arrangement has multiple benefits: - it removes the NativeProcess*** dependency from Process/gdb-remote (which for example means that liblldb no longer pulls in this code). - it enables unit testing of the GDBRemoteCommunicationServerLLGS class (by providing a mock Native Process). - serves as another example on how to use the llvm::Expected class (I couldn't get rid of the Initialize-type functions completely here because of the use of shared_from_this, but that's the next thing on my list here) Tests still pass on Linux and I've made sure NetBSD compiles after this. Reviewers: zturner, eugene, krytarowski Subscribers: srhines, lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D33778 llvm-svn: 307390
* Fix assorted compiler warnings (mismatched signedness and printf specifiers)Pavel Labath2017-07-051-1/+1
| | | | llvm-svn: 307161
* Fix typo/unbreak windows build broken by r307009Pavel Labath2017-07-031-1/+1
| | | | llvm-svn: 307018
* Use llvm::sys::RetryAfterSignal instead of a manual while errno!=EINTR loopPavel Labath2017-07-031-47/+27
| | | | | | | | | | Reviewers: zturner, eugene, krytarowski Subscribers: emaste, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D33831 llvm-svn: 307009
* Move Timer and TraceOptions from Core to UtilityPavel Labath2017-06-291-1/+1
| | | | | | | | | | | | | | Summary: The classes have no dependencies, and they are used both by lldb and lldb-server, so it makes sense for them to live in the lowest layers. Reviewers: zturner, jingham Subscribers: emaste, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D34746 llvm-svn: 306682
* Move Connection and IOObject interfaces to Utility modulePavel Labath2017-06-272-14/+10
| | | | | | | | | | | | | | | | | | | Summary: These interfaces have no dependencies, so it makes sense for them to be in the lowest level modules, to make sure that other parts of the codebase can use them without introducing loops. The only exception here is the Connection::CreateDefaultConnection method, which I've moved to Host, as it instantiates concrete implementations, and that's where the implementations live. Reviewers: jingham, zturner Subscribers: lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D34400 llvm-svn: 306391
* Remove home-grown thread-local storage wrappersPavel Labath2017-06-201-19/+0
| | | | | | | | | | | | | | Summary: Use c++11 thread_local variables instead. As far as I am aware, they are supported by all compilers/targets we care about. Reviewers: zturner, jingham Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D34274 llvm-svn: 305779
* Add pretty-printer for wait(2) statuses and modernize the code handling themPavel Labath2017-06-192-28/+59
| | | | | | | | | | | | | | | Summary: A number of places were trying to decode the result of wait(). Add a simple utility function that does that and a struct that encapsulates the decoded result. Then also provide a pretty-printer for that class. Reviewers: zturner, krytarowski, eugene Subscribers: lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D33998 llvm-svn: 305689
* Delete ProcessLauncherPosixPavel Labath2017-06-191-351/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: ProcessLauncherPosix was using posix_spawn for launching the process, but this function is not available on all platforms we support, and even where it was avaialable, it did not support the full range of options we require for launching (most importantly, launching in stop-on-entry mode). For these reasons, the set of ifdefs around these functions has grown untractably large, and we were forced to implement our own launcher from more basic primitives anyway (ProcessLauncherPosixFork -- used on Linux, Android, and NetBSD). Therefore, I remove this class, and move the relevant parts of the code to the darwin-specific Host.mm file. This is the platform that code was originally written for anyway, and it's the only platform where this implementation makes sense (e.g. the lack of the "thread-specific working directory" concept makes these functions racy on all other platforms). This allows us to remove a lot of ifdefs and simplify the code. Effectively, the only change this introduces is that FreeBSD will now use the fork-based launcher instead of posix_spawnp. That sholdn't be a problem as this approach works at least on one other BSD-based system already. Reviewers: krytarowski, emaste, jingham Subscribers: srhines, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D34236 llvm-svn: 305686
* Change the code I added to LocateDSYMInVincinityOfExecutable to useJason Molenda2017-06-161-20/+34
| | | | | | | | | the FileSpec methods for adding/removing file path components instead of using std::strings; feedback from Sean on the change I added in r305441. <rdar://problem/31825940> llvm-svn: 305547
* Change how LocateDSYMInVincinityOfExecutable strips off pathJason Molenda2017-06-151-32/+34
| | | | | | | | | | | | | | | | | | components to not depend on "." characters in the fileanme (e.g. "Foundation.framework") but instead to just use path separators. The names of the files themselves may have dots in them ("com.apple.sbd") which would break the old scheme. Also add a test case for this (macosx/find-dsym/bundle-with-dot-in-filename) as well as a test case for r304520 (macosx/find-dsym/deep-bundle) which needed a similar setup to test correctly on a single machine. (both of these are really testing remote debug session situations where the binary can't be found on the system where lldb is running, complicating the test case a bit.) <rdar://problem/31825940> llvm-svn: 305441
* replace uses of strerror with llvm::sys::StrErrorPavel Labath2017-06-061-4/+4
| | | | | | | | strerror is not thread-safe. llvm's StrError tries hard to retrieve the string in a thread-safe way and falls back to strerror only if it does not have another way. llvm-svn: 304795
* Fix bug #28898Kamil Rytarowski2017-05-251-4/+4
| | | | | | | | | | | | | lldb: libedit produces garbled, unusable input on Linux Apply patch from Christos Zoulas, upstream libedit developer. It has been tested on NetBSD/amd64. New code supports combination of wide libedit and disabled LLDB_EDITLINE_USE_WCHAR, which was the popular case on Linux systems. llvm-svn: 303907
* Remove an expensive lock from TimerPavel Labath2017-05-151-3/+4
| | | | | | | | | | | | | The Timer destructor would grab a global mutex in order to update execution time. Add a class to define a category once, statically; the class adds itself to an atomic singly linked list, and thus subsequent updates only need to use an atomic rather than grab a lock and perform a hashtable lookup. Differential Revision: https://reviews.llvm.org/D32823 Patch by Scott Smith <scott.smith@purestorage.com>. llvm-svn: 303058
* Rename Error -> Status.Zachary Turner2017-05-1221-299/+305
| | | | | | | | | | | | | | | 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
* Fix UDP Socket connectionsChris Bieneman2017-05-051-48/+34
| | | | | | Some of the refactoring in r301492 broke UDP socket connections. This is a partial revert of that refactoring. At some point I'll spend more time diagnosing where the refactoring went wrong and how to better clean up this code, but I don't have time to do that today. llvm-svn: 302282
* Fix segfault resulting from empty print promptPavel Labath2017-05-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: I have found a way to segfault lldb in 7 keystrokes! Steps to reproduce: 1) Launch lldb 2) Type `print` and hit enter. lldb will now prompt you to type a list of expressions, followed by an empty line. 3) Hit enter, indicating the end of your input. 4) Segfault! After some investigation, I've found the issue in Host/common/Editline.cpp. Editline::MoveCursor() relies on m_input_lines not being empty when the `to` argument is CursorPosition::BlockEnd. This scenario, as far as I can tell, occurs in one specific instance: In Editline::EndOrAddLineCommand() when the list of lines being processed contains exactly one string (""). Meeting this condition is fairly simple, I have posted steps to reproduce above. Reviewers: krytarowski, zturner, labath Reviewed By: labath Subscribers: scott.smith, lldb-commits Differential Revision: https://reviews.llvm.org/D32421 Patch by Alex Langford. llvm-svn: 302225
* MainLoop: Add unit testsPavel Labath2017-05-041-105/+101
| | | | | | | | | | | | | | | | | | | | Summary: This adds a couple of unit tests to the MainLoop class. To get the kqueue based version of the signal handling passing, I needed to modify the implementation a bit to make the queue object persistent. Otherwise, only the signals which are send during the Run call would get processed, which did not match the ppoll behaviour. I also took the opportunity to remove the ForEach template functions and replace them with something more reasonable. Reviewers: beanz, eugene Subscribers: lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D32753 llvm-svn: 302133
* Resurrect pselect MainLoop implementationPavel Labath2017-04-281-94/+208
| | | | | | | | | | | | | | | | | | | | Summary: It turns out that even though ppoll is available on all the android devices we support, it does not seem to be working properly on all of them -- MainLoop just does a busy loop with ppoll returning EINTR and not making any progress. This brings back the pselect implementation and makes it available on android. I could not do any cmake checks for this as the ppoll symbol is actually avaiable -- it just does not work. Reviewers: beanz, eugene Subscribers: srhines, lldb-commits Differential Revision: https://reviews.llvm.org/D32600 llvm-svn: 301636
* Resurrect the standalone build of LLDBKamil Rytarowski2017-04-282-2/+2
| | | | | | | | Switch includes "llvm/Config/config.h" to "llvm/Config/llvm-config.h". Tested on NetBSD 7.99.70 amd64 llvm-svn: 301603
* NFC. Add comment about debugserver usageChris Bieneman2017-04-271-0/+6
| | | | | | | | This just adds a comment to SocketAddress about it being used by debugserver and the implications of that. If we need to make changes to this class that make it unsuitable for debugserver we can re-implement the minimal abstractions we need from this file in debugserver. I would prefer not to do that because code duplication is bad. Nuff said. llvm-svn: 301580
* TCPSocket: add back support for "*" addressPavel Labath2017-04-271-0/+2
| | | | | | | | | | | | | before r301492, we could specify "*:1234" as an address to lldb-server and it would interpret that as "any". I am not sure that's a good idea, but we have usages of that in the test suite, and without this the remote test suite fails. I'm adding that back, as it does not seem it was an intended side-effect of that change, but I am open to removing it in the future, after discussion and test suite fixup. llvm-svn: 301534
* One more try at the whole compiling thing...Chris Bieneman2017-04-271-1/+1
| | | | | | Need to actually use the right type in both parts of the cast. llvm-svn: 301506
* One more attempt to fix the broken bots.Chris Bieneman2017-04-271-0/+2
| | | | llvm-svn: 301504
* Fix Windows bots broken by r301492Chris Bieneman2017-04-271-1/+3
| | | | | | http://lab.llvm.org:8011/builders/lldb-x86-windows-msvc2015/builds/8644/ llvm-svn: 301502
* Re-landing IPv6 support for LLDB HostChris Bieneman2017-04-265-159/+484
| | | | | | | | | | | | | | | | | | | | | | 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
* Add more arguments to SocketAddress::GetAddressInfoPavel Labath2017-04-241-19/+13
| | | | | | | | | | | | | | | | | | | Summary: the reason for this is two-fold: - getaddrinfo without the extra arguments will return the same (network-level) address multiple times, once for each supported transport protocol, which is not what is usually intended (it certainly wasn't in D31823) - it enables us to rewrite the getaddrinfo member function in terms of the static GetAddressInfo function. Reviewers: beanz, tberghammer Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D32357 llvm-svn: 301168
* Revert yesterdays IPv6 patchesPavel Labath2017-04-194-477/+158
| | | | | | | | | | | | | 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
* One more attempt and WindowsChris Bieneman2017-04-191-0/+1
| | | | | | This is the last Windows compile error, so... Hit me with your best shot. llvm-svn: 300647
* Another netbsd build failure...Chris Bieneman2017-04-191-1/+0
| | | | llvm-svn: 300640
* Buildbot wack-a-mole!Chris Bieneman2017-04-191-1/+1
| | | | | | This should fix the netbsd bot I just broke. llvm-svn: 300638
* ifdefing out the signal handling code on WindowsChris Bieneman2017-04-191-6/+17
| | | | | | | | *fingers crossed* This might fix the Window bots, but I really don't know... llvm-svn: 300636
* Include time.h, and fix a Darwin warningChris Bieneman2017-04-181-8/+2
| | | | | | This is a little more cleanup from r300579. llvm-svn: 300615
* Fix Windows bot failureChris Bieneman2017-04-181-1/+8
| | | | | | timespec is not available on Windows, and we should use size_t instead of nfds_t. llvm-svn: 300610
* Fixing error on Android build (-Werror)Chris Bieneman2017-04-181-2/+2
| | | | | | This is fallout from r300579. llvm-svn: 300606
* Removing unused includeChris Bieneman2017-04-181-1/+0
| | | | | | This is causing the Windows bot failures. llvm-svn: 300605
* Writing multi-platform code is hard...Chris Bieneman2017-04-181-1/+1
| | | | | | Fixing another error from r300579. llvm-svn: 300589
* Fix broken windows build.Chris Bieneman2017-04-181-1/+0
| | | | | | This is not ideal, but it should get the bot going again. I'll need to revisit this if we want to get signal handling working on Windows. llvm-svn: 300587
* Fixing bot failure caused by r300579Chris Bieneman2017-04-181-1/+1
| | | | llvm-svn: 300582
OpenPOWER on IntegriCloud