summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host
Commit message (Collapse)AuthorAgeFilesLines
...
* [Host] File::GetWaitableHandle() should call fileno()Jonas Devlieghere2019-09-231-1/+1
| | | | | | | | | | | | 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] Check for _WIN32 instead of _MSC_VER for code specific to windows in ↵Martin Storsjo2019-09-232-2/+2
| | | | | | | | | | | general These ifdefs contain code that isn't specific to MSVC but useful for any windows target, like MinGW. Differential Revision: https://reviews.llvm.org/D67893 llvm-svn: 372592
* [LLDB] Remove a now redundant windows specific workaroundMartin Storsjo2019-09-231-5/+0
| | | | | | | | | | | | | | | | vsnprintf(NULL, 0, ...) works for measuring the needed string size on all supported Windows variants; it's supported since at least MSVC 2015 (and LLVM requires a newer version than that), and works on both msvcrt.dll (since at least XP) and UCRT with MinGW. The previous use of ifdefs was wrong as well, as __MINGW64__ only is defined for 64 bit targets, and the define without trailing underscores is never defined automatically (neither by clang nor by gcc). Differential Revision: https://reviews.llvm.org/D67861 llvm-svn: 372591
* [LLDB] Add a void* cast when passing object pointers to printf %pMartin Storsjo2019-09-231-14/+10
| | | | | | | | | | This fixes build warnings in MinGW mode. Also remove leftover if (log) {} around the log macro. Differential Revision: https://reviews.llvm.org/D67896 llvm-svn: 372590
* [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
* Fix error in ProcessLauncherWindows.cppAdrian McCarthy2019-09-131-1/+1
| | | | | | Restored missing parens on a function call. llvm-svn: 371882
* [lldb][NFC] Make ArgEntry::quote private and provide a getterRaphael Isemann2019-09-131-1/+1
| | | | llvm-svn: 371823
* [LLDB] Do not try to canonicalize gethostname() resultDavid Zarzycki2019-09-111-12/+1
| | | | | | | | | | | | | | | | This code is trying too hard and failing. Either the result of gethostname() is canonical or it is not. If it is not, then trying to canonicalize it is – for various reasons – a lost cause. For example, a given machine might have multiple network interfaces with multiple addresses per interface, each with a different canonical name. Separably, the result of HostInfoPosix::GetHostname() and latency thereof shouldn't depend on whether networking is up or down or what network the machine happened to be attached to at any given moment (like a laptop that travels between work and home). https://reviews.llvm.org/D67230 llvm-svn: 371596
* [LLDB] FreeBSD fix new SetFile call.David Carlier2019-09-101-1/+1
| | | | llvm-svn: 371491
* [Utility] Replace `lldb_private::CleanUp` by `llvm::scope_exit`Jonas Devlieghere2019-09-101-4/+6
| | | | | | | | | This removes the CleanUp class and replaces its usages with llvm's ScopeExit, which has similar semantics. Differential revision: https://reviews.llvm.org/D67378 llvm-svn: 371474
* LLDB - Simplify GetProgramFileSpecDavid Carlier2019-09-091-7/+4
| | | | | | | | | | Reviewers: zturner, emaste Reviewed By: emaste Differential Revision: https://reviews.llvm.org/D46518 llvm-svn: 371417
* Remove call to obsolete gethostbyname, using getaddrinfoSerge Guelton2019-09-061-4/+10
| | | | | | Differential Revision: https://reviews.llvm.org/D67230 llvm-svn: 371195
* Upstream macCatalyst support in debugserver and the macOS dynamic loaderAdrian Prantl2019-09-041-11/+20
| | | | | | | | | | | plugin. Unfortunately the test is currently XFAILed because of missing changes to the clang driver. Differential Revision: https://reviews.llvm.org/D67124 llvm-svn: 370931
* [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
* [lldb][NFC] Remove unused overload of File::ReadRaphael Isemann2019-09-031-44/+0
| | | | | | | | | | | | | | | | Summary: It's neither used or tested here and in swift-lldb, so let's get rid of it. Reviewers: #lldb, davide Reviewed By: #lldb, davide Subscribers: davide, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67116 llvm-svn: 370802
* [lldb] Allow partial completions to fix directory completion.Raphael Isemann2019-08-271-0/+6
| | | | | | | | | | | | On the command line we usually insert a space after a completion to indicate that the completion was successful. After the completion API refactoring, this also happens with directories which essentially breaks file path completion (as adding a space terminates the path and starts a new arg). This patch restores the old behavior by again allowing partial completions. Also extends the iohandler and SB API tests as the implementation for this is different in Editline and SB API. llvm-svn: 370043
* Fix an unused variable warning in no-assert buildsPavel Labath2019-08-271-0/+1
| | | | llvm-svn: 370026
* [ConnectionFileDescriptor] Add shutdown check in ::Write.Jonas Devlieghere2019-08-271-3/+12
| | | | | | | | | | | | The disconnect method sets the shutdown flag to true. This currently only prevents any reads from happening, but not writes, which is incorrect. Presumably this was just an oversight when adding synchronization to the class. This adds the same shutdown check to the Write method. Over-the-shoulder reviewed by Jim! llvm-svn: 370002
* [lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and ↵Raphael Isemann2019-08-221-72/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | remove any undocumented/redundant return values Summary: We still have some leftovers of the old completion API in the internals of LLDB that haven't been replaced by the new CompletionRequest. These leftovers are: * The return values (int/size_t) in all completion functions. * Our result array that starts indexing at 1. * `WordComplete` mode. I didn't replace them back then because it's tricky to figure out what exactly they are used for and the completion code is relatively untested. I finally got around to writing more tests for the API and understanding the semantics, so I think it's a good time to get rid of them. A few words why those things should be removed/replaced: * The return values are really cryptic, partly redundant and rarely documented. They are also completely ignored by Xcode, so whatever information they contain will end up breaking Xcode's completion mechanism. They are also partly impossible to even implement as we assign negative values special meaning and our completion API sometimes returns size_t. Completion functions are supposed to return -2 to rewrite the current line. We seem to use this in some untested code path to expand the history repeat character to the full command, but I haven't figured out why that doesn't work at the moment. Completion functions return -1 to 'insert the completion character', but that isn't implemented (even though we seem to activate this feature in LLDB sometimes). All positive values have to match the number of results. This is obviously just redundant information as the user can just look at the result list to get that information (which is what Xcode does). * The result array that starts indexing at 1 is obviously unexpected. The first element of the array is reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is that we calculate this to make the life of the API caller easier, but obviously forcing people to have 1-based indices is not helpful (or even worse, forces them to manually copy the results to make it 0-based like Xcode has to do). * The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The idea is that we let the top-level API know that we just provided a full completion. Interestingly we `WordComplete` is just a single bool that somehow represents all N completions. And we always provide full completions in LLDB, so in theory it should always be true. The only use it currently serves is providing redundant information about whether we have a single definitive completion or not (which we already know from the number of results we get). This patch essentially removes `WordComplete` mode and makes the result array indexed from 0. It also removes all return values from all internal completion functions. The only non-redundant information they contain is about rewriting the current line (which is broken), so that functionality was moved to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)` to do the same. For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we didn't even implement them in the Editline handler (e.g. -1). I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code, but I would prefer doing this in follow-up NFC commits Reviewers: JDevlieghere Reviewed By: JDevlieghere Subscribers: arphaman, abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D66536 llvm-svn: 369624
* [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][NFC] Refactor remaining completion logic to use CompletionRequestsRaphael Isemann2019-08-151-3/+12
| | | | | | | | | | | | | | | | | | | | This patch moves the remaining completion functions from the old completion API (that used several variables) to just passing a single CompletionRequest. This is for the most part a simple change as we just replace the old arguments with a single CompletionRequest argument. There are a few places where I had to create new CompletionRequests in the called functions as CompletionRequests itself are immutable and don't expose their internal match list anymore. This means that if a function wanted to change the CompletionRequest or directly access the result list, we need to work around this by creating a new CompletionRequest and a temporary match/description list. Preparation work for rdar://53769355 llvm-svn: 369000
* [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
* Enable lldb-server on WindowsAaron Smith2019-08-131-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This commit contains three small changes to enable lldb-server on Windows. - Add lldb-server for Windows to the build - Disable pty redirection on Windows for the initial lldb-server bring up - Add a support to get the parent pid for a process on Windows - Ifdef some signals which aren't supported on Windows Thanks to Hui Huang for the help with this patch! Reviewers: labath Reviewed By: labath Subscribers: JDevlieghere, compnerd, Hui, amccarth, xiaobai, srhines, mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D61686 llvm-svn: 368774
* Various build fixes for lldb on MinGWHaibo Huang2019-08-061-0/+1
| | | | | | | | | | Subscribers: mstorsjo, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D65691 llvm-svn: 368069
* Remove usage of usleep in generic codePavel Labath2019-08-051-5/+0
| | | | | | | | This function is not portable, and there are only a handful of usages of it anyway. Replacing it with std::this_thread::sleep_for enables us to get rid of the compatibility code in PosixApi.h. llvm-svn: 367814
* [CompletionRequest] Remove unimplemented members.Jonas Devlieghere2019-07-311-2/+0
| | | | | | | | | | Completion requests have two fields that are essentially unimplemented: `m_match_start_point` and `m_max_return_elements`. This would've been okay, if it wasn't for the fact that this caused a bunch of useless parameters to be passed around. Occasionally there would be a comment or assert saying that they are not supported. This patch removes them. llvm-svn: 367385
* [Reproducers] Pass FileCollector around as a shared_ptr (NFC)Jonas Devlieghere2019-07-291-1/+1
| | | | | | | | | | | Instead of passing the FileCollector around as a reference or raw pointer, use a shared_ptr. This change's motivation is twofold. First it adds compatibility for the newly added `FileCollectorFileSystem`. Secondly, it addresses a lifetime issue we only see when LLDB is used from Xcode, where a reference to the FileCollector outlives the reproducer instance. llvm-svn: 367258
* [FileCollector] Remove LLDB shim around llvm::FileCollector (NFC)Jonas Devlieghere2019-07-251-2/+2
| | | | | | | | The FileCollector got lifted into LLVM and a shim was introduced in LLDB to keep the old API that takes FileSpecs. This patch removes that shim and converts the arguments in place. llvm-svn: 366975
* [FileSystem] Fix ambiguous symbol on Windows.Jonas Devlieghere2019-07-251-1/+1
| | | | | | | The using declarations make FileCollector ambiguous. Specify that FileSystem takes an lldb_private::FileCollector. llvm-svn: 366974
* [FileCollector] Change coding style from LLDB to LLVM (NFC)Jonas Devlieghere2019-07-251-2/+2
| | | | | | | | This patch changes the coding style of the FileCollector from the LLDB to the LLVM coding style. Alex recently lifted it into LLVM and I volunteered to do the conversion. llvm-svn: 366966
* [Logging] Replace Log::Printf with LLDB_LOG macro (NFC)Jonas Devlieghere2019-07-2413-218/+192
| | | | | | | | | | | | | | | | | | | | | | | | | | 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/+54
| | | | | | This reverts commit 9c10b620c0619611dfe062216459431955ac4801. llvm-svn: 366848
* Options: Reduce code duplicationPavel Labath2019-07-101-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: While investigating breakages caused by D63110, I noticed we were building the short options strings in three places. Some of them used a leading ':' to detect missing arguments, and some didn't. This was the indirect cause of D63110. Here, I move the common code into a utility function. Also, unify the code which appends the sentinel value at the end of the option vector, and make it harder for users to pass invalid argc-argv combos to getopt (another component of D63110) by having the OptionParser::Parse function take a (Mutable)ArrayRef. This unification has uncovered that we don't handle missing arguments while building aliases, However, it's not possible to write an effective test for this, as right now it is not possible to return an error out of the alias parsing code (which means we are printing the generic "failure" message even after this patch). Reviewers: mgorny, aprantl Reviewed By: mgorny Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D63770 llvm-svn: 365665
* [lldb, windows] Include WindowsError instead of ErrorHandling in ThreadLauncherStella Stamenova2019-07-091-1/+1
| | | | | | ErrorHandling.h does not include WindowsError.h which is needed for mapWindowsError llvm-svn: 365533
* [lldb, windows] Update two more locations that use LaunchThread to the new ↵Stella Stamenova2019-07-091-2/+2
| | | | | | function signature llvm-svn: 365526
* Fix ASCII art headerJonas Devlieghere2019-07-091-2/+1
| | | | llvm-svn: 365421
* [Windows] Include ErrorHandling.hJonas Devlieghere2019-07-091-0/+2
| | | | | | Include ErrorHandling.h for mapWindowsError. llvm-svn: 365420
* [ThreadLauncher] Use mapWindowsError and LLDB_INVALID_HOST_THREADJonas Devlieghere2019-07-081-4/+2
| | | | | | Address post-commit feedback from Pavel and Jim. llvm-svn: 365403
* [lldb, windows] When StartMonitoring fails, return a proper errorStella Stamenova2019-07-081-7/+8
| | | | | | This is possible now that the function returns an llvm::Expected llvm-svn: 365400
* [Windows] Convert GetLastError to std::error_codeJonas Devlieghere2019-07-081-2/+4
| | | | | | | Create a std::error_code from the result of GetLastError, which in turn we can use to return an llvm::Error. llvm-svn: 365390
* [lldb] Fix two more issues in Windows following rL365226: Change ↵Stella Stamenova2019-07-081-1/+1
| | | | | | | | LaunchThread interface to return an expected A couple of the function signatures changed and they were not updated in the Windows HostProcess llvm-svn: 365388
* [Host] Fix out-of-line definition on WindowsJonas Devlieghere2019-07-082-2/+2
| | | | | | Add missing interface changes after r365295. llvm-svn: 365358
* [Host] Fix out-of-line definition of StartMonitoringChildProcessJonas Devlieghere2019-07-081-1/+1
| | | | llvm-svn: 365344
* Change LaunchThread interface to return an Expected for non-Apple-non-WindowsFangrui Song2019-07-085-6/+15
| | | | | | Fixes Linux build errors after D64163/r365226 llvm-svn: 365295
* Change LaunchThread interface to return an expected.Jonas Devlieghere2019-07-053-21/+24
| | | | | | | | | Change the interface to return an expected, instead of taking a Status pointer. Differential revision: https://reviews.llvm.org/D64163 llvm-svn: 365226
* Revert "Add ReadCStringFromMemory for faster string reads"Antonio Afonso2019-06-251-54/+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/+54
| | | | | | | | | | | | | | | | | | | | | | | 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
* [Reproducers] Make reproducer relocatableJonas Devlieghere2019-06-181-2/+3
| | | | | | | | | | | | | | Before this patch, reproducers weren't relocatable. The reproducer contained hard coded paths in the VFS mapping, as well in the yaml file listing the different input files for the command interpreter. This patch changes that: - Use relative paths for the DataCollector. - Use an overlay prefix for the FileCollector. Differential revision: https://reviews.llvm.org/D63467 llvm-svn: 363697
* Silence 'warning: extra ‘;’ [-Wpedantic]' with GCC 7.3Alexandre Ganea2019-06-011-1/+1
| | | | llvm-svn: 362306
* Fix problem with r362192Richard Trieu2019-05-311-5/+8
| | | | | | | The string returned only sometimes ends in NULL. Explicitly check for the NULL and pop off the NULL if it is there. llvm-svn: 362194
OpenPOWER on IntegriCloud