summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix file names in file headers. NFCFangrui Song2019-05-131-1/+1
| | | | llvm-svn: 360554
* [lldb] Add missing EINTR handlingMichal Gorny2019-03-211-2/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D59606 llvm-svn: 356703
* Move FileAction, ProcessInfo and ProcessLaunchInfo from Target to HostPavel Labath2019-02-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 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-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
* Fix typos.Bruce Mitchener2018-10-041-1/+1
| | | | | | | | | | Reviewers: lldb-commits Subscribers: srhines, ki.stfu Differential Revision: https://reviews.llvm.org/D52884 llvm-svn: 343825
* ProcessLauncherPosixFork: move setgid call into the if(debug) branchPavel Labath2018-05-231-4/+4
| | | | | | | | | | | | | | | | This call was originally being only made when launching for debug (as an attempt to make sure we don't impart extra privileges on the launched process), but after the debug and non-debug paths were merged, it made it's way into generic code. This was causing problems in locked down android environments which disallowed calling setgid even if it would be a no-op. This prevented launching llgs from lldb-server platform. Overall I'm not sure we should be calling setgid in the first place (it seems random -- e.g. why don't we call setuid then as well). However, all our other copies of launch code have it, so I choose to keep it for now. llvm-svn: 333073
* Reflow paragraphs in comments.Adrian Prantl2018-04-301-16/+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
* Add Utility/Environment class for handling... environmentsPavel Labath2018-01-101-13/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: There was some confusion in the code about how to represent process environment. Most of the code (ab)used the Args class for this purpose, but some of it used a more basic StringList class instead. In either case, the fact that the underlying abstraction did not provide primitive operations for the typical environment operations meant that even a simple operation like checking for an environment variable value was several lines of code. This patch adds a separate Environment class, which is essentialy a llvm::StringMap<std::string> in disguise. To standard StringMap functionality, it adds a couple of new functions, which are specific to the environment use case: - (most important) envp conversion for passing into execve() and likes. Instead of trying to maintain a constantly up-to-date envp view, it provides a function which creates a envp view on demand, with the expectation that this will be called as the very last thing before handing the value to the system function. - insert(StringRef KeyEqValue) - splits KeyEqValue into (key, value) pair and inserts it into the environment map. - compose(value_type KeyValue) - takes a map entry and converts in back into "KEY=VALUE" representation. With this interface most of the environment-manipulating code becomes one-liners. The only tricky part was maintaining compatibility in SBLaunchInfo, which expects that the environment entries are accessible by index and that the returned const char* is backed by the launch info object (random access into maps is hard and the map stores the entry in a deconstructed form, so we cannot just return a .c_str() value). To solve this, I have the SBLaunchInfo convert the environment into the "envp" form, and use it to answer the environment queries. Extra code is added to make sure the envp version is always in sync. (This also improves the layering situation as Args was in the Interpreter module whereas Environment is in Utility.) Reviewers: zturner, davide, jingham, clayborg Subscribers: emaste, lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D41359 llvm-svn: 322174
* Logging: Disable logging after fork()Pavel Labath2017-10-231-4/+0
| | | | | | | | | | | | | | | | | | | | | | | Summary: We had a bug where if we had forked (in the ProcessLauncherPosixFork) while another thread was writing a log message, we would deadlock. This happened because the fork child inherited the locked log rwmutex, which would never get unlocked. This meant the child got stuck trying to disable all log channels. The bug existed for a while but only started being apparent after D37930, which started using ThreadLauncher (which uses logging) instead of std::thread (which does not) for launching TaskPool threads. The fix is to use pthread_atfork to disable logging in the forked child. Reviewers: zturner, eugene, clayborg Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D38938 llvm-svn: 316368
* More precise c library feature detection for Android.Eugene Zemtsov2017-09-161-1/+1
| | | | llvm-svn: 313436
* Fix NetBSD/FreeBSD build after r308304Pavel Labath2017-07-181-0/+1
| | | | llvm-svn: 308307
* 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
* ProcessLauncherPosixFork: Fetch errno earlyPavel Labath2017-06-201-4/+4
| | | | | | | | I was seeing some unlikely errno values here. I am not sure if this will help, but it nontheless seems like a good idea to stash errno value before issuing other syscalls. llvm-svn: 305778
* replace uses of strerror with llvm::sys::StrErrorPavel Labath2017-06-061-2/+3
| | | | | | | | 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
* Rename Error -> Status.Zachary Turner2017-05-121-1/+1
| | | | | | | | | | | | | | | 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
* Move FileSpec from Host -> Utility.Zachary Turner2017-03-221-1/+1
| | | | llvm-svn: 298536
* Remove lldb streams from the Log class completelyPavel Labath2017-03-151-3/+2
| | | | | | | | | | | | | | | | | | | | | Summary: previously we switched to llvm streams for log output, this completes the switch for the error streams. I also clean up the includes and remove the unused argument from DisableAllLogChannels(). This required adding a bit of boiler plate to convert the output in the command interpreter, but that should go away when we switch command results to use llvm streams as well. Reviewers: zturner, eugene Subscribers: lldb-commits, emaste Differential Revision: https://reviews.llvm.org/D30894 llvm-svn: 297812
* 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
* Fix android build of the new process launcherPavel Labath2017-02-011-0/+1
| | | | | | | Android does not define the "cross-platform" symbol PT_TRACE_ME. Define it ourselves, so we can keep the rest of the code generic. llvm-svn: 293779
* Transform ProcessLauncherLinux to ProcessLauncherPosixForkKamil Rytarowski2017-02-011-0/+231
Summary: Use ProcessLauncherPosixFork in Linux and NetBSD. Changes to ProcessLauncherLinux: - Limit personality.h and ASLR code to Linux. - Reuse portable ptrace(2) PT_TRACE_ME operation available on Linux and BSDs. - Limit ETXTBSY error path from execve(2) to Linux. - In LaunchProcess declaration change virtual to override. This code should be readily available for FreeBSD. Sponsored by <The NetBSD Foundation> Reviewers: joerg, clayborg, labath, emaste Reviewed By: labath Subscribers: danalbert, srhines, mgorny, #lldb Tags: #lldb Differential Revision: https://reviews.llvm.org/D29347 llvm-svn: 293768
OpenPOWER on IntegriCloud