summaryrefslogtreecommitdiffstats
path: root/lldb/unittests/Host
Commit message (Collapse)AuthorAgeFilesLines
* [lldb] Add a SubsystemRAII that takes care of calling Initialize and ↵Raphael Isemann2019-12-235-28/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Terminate in the unit tests Summary: Many of our tests need to initialize certain subsystems/plugins of LLDB such as `FileSystem` or `HostInfo` by calling their static `Initialize` functions before the test starts and then calling `::Terminate` after the test is done (in reverse order). This adds a lot of error-prone boilerplate code to our testing code. This patch adds a RAII called SubsystemRAII that ensures that we always call ::Initialize and then call ::Terminate after the test is done (and that the Terminate calls are always in the reverse order of the ::Initialize calls). It also gets rid of all of the boilerplate that we had for these calls. Per-fixture initialization is still not very nice with this approach as it would require some kind of static unique_ptr that gets manually assigned/reseted from the gtest SetUpTestCase/TearDownTestCase functions. Because of that I changed all per-fixture setup to now do per-test setup which can be done by just having the SubsystemRAII as a member of the test fixture. This change doesn't influence our normal test runtime as LIT anyway runs each test case separately (and the Initialize/Terminate calls are anyway not very expensive). It will however make running all tests in a single executable slightly slower. Reviewers: labath, JDevlieghere, martong, espindola, shafik Reviewed By: labath Subscribers: mgorny, rnkovacs, emaste, MaskRay, abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71630
* [lldb/Host] Use cmakedefine01 for LLDB_ENABLE_POSIXJonas Devlieghere2019-12-133-5/+7
| | | | | Rename LLDB_DISABLE_POSIX to LLDB_ENABLE_POSIX and use cmakedefine01 for consistency.
* [lldb] [unittest] Reenable MainLoopTest.DetectsEOF on NetBSDMichał Górny2019-11-181-4/+0
| | | | | The underlying issue is already fixed in the NetBSD kernel for some time, so we can finally reenable the test.
* factor out an abstract base class for FileLawrence D'Anna2019-10-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch factors out File as an abstract base class and moves most of its actual functionality into a subclass called NativeFile. In the next patch, I'm going to be adding subclasses of File that don't necessarily have any connection to actual OS files, so they will not inherit from NativeFile. This patch was split out as a prerequisite for https://reviews.llvm.org/D68188 Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68317 llvm-svn: 373564
* Convert FileSystem::Open() to return Expected<FileUP>Lawrence D'Anna2019-09-261-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch converts FileSystem::Open from this prototype: Status Open(File &File, const FileSpec &file_spec, ...); to this one: llvm::Expected<std::unique_ptr<File>> Open(const FileSpec &file_spec, ...); This is beneficial on its own, as llvm::Expected is a more modern and recommended error type than Status. It is also a necessary step towards https://reviews.llvm.org/D67891, and further developments for lldb_private::File. Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67996 llvm-svn: 373003
* [unittest] Skip the socket tests if we $TMPDIR is too long.Jonas Devlieghere2019-09-241-4/+8
| | | | | | | | | | | | | Adrian added a sanity check to the socket tests to ensure the $TMPDIR is not too long for a socket. While this is great for diagnosing the problem it doesn't really solve the problem for environment where you have no control over that variable such as in CI. I propose to just skip the test in that case similar to what we do for tests that rely on targets that are not currently build, etc. Differential revision: https://reviews.llvm.org/D67972 llvm-svn: 372774
* File::SetDescriptor() should require optionsJonas Devlieghere2019-09-231-0/+21
| | | | | | | | | | | | | | | | | | | | | | lvm_private::File::GetStream() can fail if m_options == 0 It's not clear from the header a File created with a descriptor will be not be usable by many parts of LLDB unless SetOptions is also called, but it is. This is because those parts of LLDB rely on GetStream() to use the file, and that in turn relies on calling fdopen on the descriptor. When calling fdopen, GetStream relies on m_options to determine the access mode. If m_options has never been set, GetStream() will fail. This patch adds options as a required argument to File::SetDescriptor and the corresponding constructor. Patch by: Lawrence D'Anna Differential revision: https://reviews.llvm.org/D67792 llvm-svn: 372652
* [Host] File::GetWaitableHandle() should call fileno()Jonas Devlieghere2019-09-232-0/+37
| | | | | | | | | | | | If the file has m_stream, it may not have a m_descriptor. GetWaitableHandle() should call GetDescriptor(), which will call fileno(), so it will get waitable descriptor whenever one is available. Patch by: Lawrence D'Anna Differential revision: https://reviews.llvm.org/D67789 llvm-svn: 372644
* [LLDB] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-1/+1
| | | | | | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert "Revert "Add ReadCStringFromMemory for faster string reads""Antonio Afonso2019-07-231-0/+51
| | | | | | This reverts commit 9c10b620c0619611dfe062216459431955ac4801. llvm-svn: 366848
* Add a sanity check to the domain socket tests.Adrian Prantl2019-06-271-1/+5
| | | | | | rdar://problem/52062631 llvm-svn: 364562
* Revert "Add ReadCStringFromMemory for faster string reads"Antonio Afonso2019-06-251-51/+0
| | | | | | | | This reverts commit a7335393f50246b59db450dc6005f7c8f29e73a6. It seems this is breaking a bunch of tests (https://reviews.llvm.org/D62503#1549874) so reverting until I find the time to repro and fix. llvm-svn: 364355
* Add ReadCStringFromMemory for faster string readsAntonio Afonso2019-06-181-0/+51
| | | | | | | | | | | | | | | | | | | | | | | Summary: This is the fifth patch to improve module loading in a series that started here (where I explain the motivation and solution): D62499 Reading strings with ReadMemory is really slow when reading the path of the shared library. This is because we don't know the length of the path so use PATH_MAX (4096) and these strings are actually super close to the boundary of an unreadable page. So even though we use process_vm_readv it will usually fail because the read size spans to the unreadable page and we then default to read the string word by word with ptrace. This new function is very similar to another ReadCStringFromMemory that already exists in lldb that makes sure it never reads cross page boundaries and checks if we already read the entire string by finding '\0'. I was able to reduce the GetLoadedSharedLibraries call from 30ms to 4ms (or something of that order). Reviewers: clayborg, xiaobai, labath Reviewed By: labath Subscribers: emaste, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D62503 llvm-svn: 363750
* Implement GetSharedLibraryInfoAddressAntonio Afonso2019-06-141-138/+12
| | | | | | | | | | | | | | | | | | | | | Summary: This is the third patch to improve module loading in a series that started here (where I explain the motivation and solution): D62499 Add functions to read the r_debug location to know where the linked list of loaded libraries are so I can generate the `xfer:libraries-svr4` packet. I'm also using this function to implement `GetSharedLibraryInfoAddress` that was "not implemented" for linux. Most of this code was inspired by the current ds2 implementation here: https://github.com/facebook/ds2/blob/master/Sources/Target/POSIX/ELFProcess.cpp. Reviewers: clayborg, xiaobai, labath Reviewed By: clayborg, labath Subscribers: emaste, krytarowski, mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D62501 llvm-svn: 363458
* Make ConnectionFileDescription work with all socketsAntonio Afonso2019-05-301-0/+62
| | | | | | | | | | | | | | | | | | | | | Summary: My main goal here is to make lldb-server work with Android Studio. This is currently not the case because lldb-server is started in platform mode listening on a domain socket. When Android Studio connects to it lldb-server crashes because even though it's listening on a domain socket as soon as it gets a connection it asserts that it's a TCP connection, which will obviously fails for any non-tcp connection. To do this I came up with a new method called GetConnectURI() in Socket that returns the URI needed to connect to the connected portion of the socket. Reviewers: labath, clayborg, xiaobai Reviewed By: labath Subscribers: mgorny, jfb, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D62089 llvm-svn: 362173
* Fix IPv6 support on lldb-server platformAntonio Afonso2019-05-285-86/+211
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is a general fix for the ConnectionFileDescriptor class but my main motivation was to make lldb-server working with IPv6. The connect URI can use square brackets ([]) to wrap the interface part of the URI (e.g.: <scheme>://[<interface>]:<port>). For IPv6 addresses this is a must since its ip can include colons and it will overlap with the port colon otherwise. The URIParser class parses the square brackets correctly but the ConnectionFileDescriptor doesn't generate them for IPv6 addresses making it impossible to connect to the gdb server when using this protocol. How to reproduce the issue: ``` $ lldb-server p --server --listen [::1]:8080 ... $ lldb (lldb) platform select remote-macosx (lldb) platform connect connect://[::1]:8080 (lldb) platform process -p <pid> error: unable to launch a GDB server on 'computer' ``` The server was actually launched we were just not able to connect to it. With this fix lldb will correctly connect. I fixed this by wrapping the ip portion with []. Reviewers: labath Reviewed By: labath Subscribers: xiaobai, mgorny, jfb, lldb-commits, labath Tags: #lldb Differential Revision: https://reviews.llvm.org/D61833 llvm-svn: 361898
* Revert "Fix IPv6 support on lldb-server platform"Alex Langford2019-05-185-211/+86
| | | | | | | | | | | This reverts commit c28f81797084b8416ff5be4f9e79000a9741ca6a. This reverts commit 7e79b64642486f510f7872174eb831df68d65b84. Looks like there is more work to be done on this patch. I've spoken to the author and for the time being we will revert to keep the buildbots green. llvm-svn: 361086
* Unbreak windows build botAlex Langford2019-05-181-0/+6
| | | | | | | Commit c28f81797084b8416ff5be4f9e79000a9741ca6a (svn r361079) broke the windows buildbot. This should fix it. llvm-svn: 361083
* Fix IPv6 support on lldb-server platformAlex Langford2019-05-175-86/+205
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a general fix for the ConnectionFileDescriptor class but my main motivation was to make lldb-server working with IPv6. The connect URI can use square brackets ([]) to wrap the interface part of the URI (e.g.: <scheme>://[<interface>]:<port>). For IPv6 addresses this is a must since its ip can include colons and it will overlap with the port colon otherwise. The URIParser class parses the square brackets correctly but the ConnectionFileDescriptor doesn't generate them for IPv6 addresses making it impossible to connect to the gdb server when using this protocol. How to reproduce the issue: $ lldb-server p --server --listen [::1]:8080 ... $ lldb (lldb) platform select remote-macosx (lldb) platform connect connect://[::1]:8080 (lldb) platform process -p <pid> error: unable to launch a GDB server on 'computer' The server was actually launched we were just not able to connect to it. With this fix lldb will correctly connect. I fixed this by wrapping the ip portion with []. Differential Revision: https://reviews.llvm.org/D61833 Patch by António Afonso <antonio.afonso@gmail.com> llvm-svn: 361079
* Clear the output string passed to GetHostName()Aaron Smith2019-04-171-0/+6
| | | | | | | | LLVM's wchar to UTF8 conversion routine expects an empty string to store the output. GetHostName() on Windows is sometimes called with a non-empty string which triggers an assert. The simple fix is to clear the output string before the conversion. llvm-svn: 358550
* [lldb-server] Introduce Socket::Initialize and Terminate to simply WSASocket ↵Aaron Smith2019-04-103-30/+13
| | | | | | | | | | | | | | | | setup Reviewers: zturner, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D60440 llvm-svn: 358044
* Remove dependency edges from Host to Target/Core.Zachary Turner2019-03-081-1/+0
| | | | | | After recent changes, Host is now dependency-free. llvm-svn: 355730
* Move ProcessInfo from Host to Utility.Zachary Turner2019-03-042-20/+0
| | | | | | | | | | | | | | | | | | | | | There are set of classes in Target that describe the parameters of a process - e.g. it's PID, name, user id, and similar. However, since it is a bare description of a process and contains no actual functionality, there's nothing specifically that makes this appropriate for being in Target -- it could just as well be describing a process on the host, or some hypothetical virtual process that doesn't even exist. To cement this, I'm moving these classes to Utility. It's possible that we can find a better place for it in the future, but as it is neither Host specific nor Target specific, Utility seems like the most appropriate place for the time being. After this there is only 2 remaining references to Target from Host, which I'll address in a followup. Differential Revision: https://reviews.llvm.org/D58842 llvm-svn: 355342
* Move Host/Symbols.cpp to Symbols/LocateSymbolFile.cppZachary Turner2019-02-272-49/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Given that we have a target named Symbols, one wonders why a file named Symbols.cpp is not in this target. To be clear, the functions exposed from this file are really focused on *locating* a symbol file on a given host, which is where the ambiguity comes in. However, it makes more sense conceptually to be in the Symbols target. While some of the specific places to search for symbol files might change depending on the Host, this is not inherently true in the same way that, for example, "accessing the file system" or "starting threads" is fundamentally dependent on the Host. PDBs, for example, recently became a reality on non-Windows platforms, and it's theoretically possible that DSYMs could become a thing on non MacOSX platforms (maybe in a remote debugging scenario). Other types of symbol files, such as DWO, DWP, etc have never been tied to any Host platform anyway. After this patch, there is only one remaining dependency from Host to Target. Differential Revision: https://reviews.llvm.org/D58730 llvm-svn: 355032
* Revert "Don't include UnixSignals.h from Host."Davide Italiano2019-02-151-7/+2
| | | | | | It broke the modules green dragon buildbot. llvm-svn: 354177
* Don't include UnixSignals.h from Host.Zachary Turner2019-02-151-2/+7
| | | | | | | | | | | | | | | | | Host had a function to get the UnixSignals instance corresponding to the current host architecture. This means that Host had to include a file from Target. To break this dependency, just make this a static function directly in UnixSignals. We already have the function UnixSignals::Create(ArchSpec) anyway, so we just need to have UnixSignals::CreateForHost() which determines which value to pass for the ArchSpec. The goal here is to eventually break the Host->Target->Host circular dependency. Differential Revision: https://reviews.llvm.org/D57780 llvm-svn: 354168
* [lldb] [MainLoop] Add kevent() EINTR handlingMichal Gorny2019-02-151-0/+24
| | | | | | | | | | | | | Add missing EINTR handling for kevent() calls. If the call is interrupted, return from Poll() as if zero events were returned and let the polling resume on next iteration. This fixes test flakiness on NetBSD. Includes a test case suggested by Pavel Labath on D42206. Differential Revision: https://reviews.llvm.org/D58230 llvm-svn: 354122
* [lldb] [unittest] Avoid mixing '127.0.0.1' and 'localhost'Michal Gorny2019-02-121-2/+2
| | | | | | | | | | | | | | | | | | | Fix the tests not to use '127.0.0.1' and 'localhost' interchangeably. More specifically, since tests bind specifically to 127.0.0.1, connect to that address as well; using 'localhost' can resolve to IPv6 address which can cause issues -- for example, if the matching port happens to be used by some other process, the tests hang forever waiting for the client to connect. While technically the case of randomly selected IPv4 port being taken on IPv6 loopback is not very likely, NetBSD happens to be suffering from some weird kernel issue where connection to that port succeeds nevertheless. Until we can really figure out what goes wrong there, this saves us from the tests hanging randomly. Differential Revision: https://reviews.llvm.org/D58131 llvm-svn: 353868
* [lldb] [unittests] Disable MainLoopTest::DetectsEOF on NetBSDMichal Gorny2019-02-081-0/+5
| | | | | | | | | | The NetBSD kernel currently does not support detecting closed slave pty via kevent on master pty. This causes the test to hang forever. To avoid that, disable the test until the kernel is fixed. Differential Revision: https://reviews.llvm.org/D57912 llvm-svn: 353545
* Fix headers for files added in r353047Pavel Labath2019-02-073-12/+9
| | | | | | | I started working on that patch before the headers were updated. Since they were new files, I didn't get any conflicts during rebase. llvm-svn: 353429
* Fix signed/unsigned mismatches in ProcessInfoTest.cppPavel Labath2019-02-071-1/+1
| | | | llvm-svn: 353420
* Move FileAction, ProcessInfo and ProcessLaunchInfo from Target to HostPavel Labath2019-02-044-0/+71
| | | | | | | | | | | | | | | | | | | | | | | Summary: These classes describe the details of the process we are about to launch, and so they are naturally used by the launching code in the Host module. Previously they were present in Target because that is the most important (but by far not the only) user of the launching code. Since the launching code has other customers, must of which do not care about Targets, it makes sense to move these classes to the Host layer, next to the launching code. This move reduces the number of times that Target is included from host to 8 (it used to be 14). Reviewers: zturner, clayborg, jingham, davide, teemperor Subscribers: emaste, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D56602 llvm-svn: 353047
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1910-40/+30
| | | | | | | | | | | | | | | | | 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
* NativeProcessProtocolTest: fix -Winconsistent-missing-override warningPavel Labath2019-01-021-4/+7
| | | | | | | | The warning comes from the fact that the MOCK_METHOD macros don't use the override keyword internally. This makes us not use it in the manually overriden methods either, to be consistent. llvm-svn: 350209
* Fix assertion failure in NativeProcessProtocolTestPavel Labath2018-12-271-1/+2
| | | | | | | | | The assertion fired (with a debug visual studio STL) because we tried to dereference the end of a vector (although it was only to take its address again and form an end iterator). Rewrite this logic to avoid the questionable code. llvm-svn: 350091
* Fix the "dangerous use of tempnam" warning in Host/SocketTest.cppPavel Labath2018-12-181-9/+10
| | | | | | | instead, create a unique temporary directory, and place the socket file there. llvm-svn: 349495
* [unittests] Fix the File System Test on WindowsStella Stamenova2018-11-281-8/+0
| | | | | | Two of the file system tests are failing on Windows - this updates them to expect the correct values after the refactor of the file system code. llvm-svn: 347796
* [unittest] Fix the FileSystem test on Windows. (Attempt #2)Jonas Devlieghere2018-11-281-5/+5
| | | | | | | This fixes the double escaping and compares FileSpecs instead of strings. llvm-svn: 347725
* [unittest] Fix the FileSystem test on Windows.Jonas Devlieghere2018-11-271-0/+8
| | | | | | | | On Windows, when using the VFS without going through FileSpec, the absolute path to `/foo` is `\\foo`. This updates the unittest to expect that. llvm-svn: 347712
* Remove header grouping comments.Jonas Devlieghere2018-11-111-1/+1
| | | | | | | | This patch removes the comments grouping header includes. They were added after running IWYU over the LLDB codebase. However they add little value, are often outdates and burdensome to maintain. llvm-svn: 346626
* revert rL346478Kadir Cetinkaya2018-11-091-2/+2
| | | | | | | | | | Summary: Reviewers: Subscribers: llvm-svn: 346502
* [lldb] Fix signature in test to match rL346453Kadir Cetinkaya2018-11-091-2/+2
| | | | llvm-svn: 346478
* Revert "[FileSystem] Make use of FS in TildeExpressionResolver"Jonas Devlieghere2018-11-091-2/+2
| | | | | | | | The whole point of this change was making it possible to resolve paths without depending on the FileSystem, which is not what I did here. Not sure what I was thinking... llvm-svn: 346466
* [FileSystem] Make use of FS in TildeExpressionResolverJonas Devlieghere2018-11-091-2/+2
| | | | | | | | In order to call real_path from the TildeExpressionResolver we need access to the FileSystem. Since the resolver lives under utility we have to pass in the FS. llvm-svn: 346457
* [FileSystem] Move path resolution logic out of FileSpecJonas Devlieghere2018-11-013-17/+23
| | | | | | | | | This patch removes the logic for resolving paths out of FileSpec and updates call sites to rely on the FileSystem class instead. Differential revision: https://reviews.llvm.org/D53915 llvm-svn: 345890
* [FileSystem] Re-add EnumerateDirectoryJonas Devlieghere2018-11-011-0/+24
| | | | | | Re-enable EnumerateDirectory now that no_push is available in llvm (r345793). llvm-svn: 345799
* [FileSystem] Remove EnumerateDirectoryJonas Devlieghere2018-10-311-24/+0
| | | | | | | | The new implementation of EnumerateDirectory relies on `::no_push()` being implemented for the VFS recursive directory iterators. However this patch (D53465) hasn't been landed yet. llvm-svn: 345787
* [FileSystem] Extend file system and have it use the VFS.Jonas Devlieghere2018-10-313-13/+296
| | | | | | | | | | | | | | | | This patch extends the FileSystem class with a bunch of functions that are currently implemented as methods of the FileSpec class. These methods will be removed in future commits and replaced by calls to the file system. The new functions are operated in terms of the virtual file system which was recently moved from clang into LLVM so it could be reused in lldb. Because the VFS is stateful, we turned the FileSystem class into a singleton. Differential revision: https://reviews.llvm.org/D53532 llvm-svn: 345783
* [unittest] Fix NativeProcessProtocolTest.cpp (NFC)Jonas Devlieghere2018-09-261-2/+2
| | | | | | | Cast std::min's second argument to size_t to prevent conflicting types for parameter deduction. llvm-svn: 343087
OpenPOWER on IntegriCloud