summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Signals.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove Support/Options.h, it is unusedReid Kleckner2019-11-151-2/+2
| | | | | | | | | | | | | | | | | It was added in 2014 in 732e0aa9fb84f1 with one use in Scalarizer.cpp. That one use was then removed when porting to the new pass manager in 2018 in b6f76002d9158628e78. While the RFC and the desire to get off of static initializers for cl::opt all still stand, this code is now dead, and I think we should delete this code until someone is ready to do the migration. There were many clients of CommandLine.h that were it transitively through LLVMContext.h, so I cleaned that up in 4c1a1d3cf97e1ede466. Reviewers: beanz Differential Revision: https://reviews.llvm.org/D70280
* Only use argv[0] as the main executable name if it exists.Sean Silva2019-04-151-2/+2
| | | | | | | | | | | | Under some environments, argv[0] doesn't hold a valid file name, but sys::fs::getMainExecutable will find the main executable properly. This patch tweaks the logic to fall back to sys::fs::getMainExecutable in more situations. Differential Revision: https://reviews.llvm.org/D60730 llvm-svn: 358455
* 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
* Buildfix for r345516 (Clang compilation failing).Alexandre Ganea2018-12-181-1/+1
| | | | llvm-svn: 349518
* [llvm-symbolizer] Omit stderr output when symbolizing a crashAlexandre Ganea2018-12-181-3/+11
| | | | | | Differential revision: https://reviews.llvm.org/D55723 llvm-svn: 349516
* Refactor ExecuteAndWait to take StringRefs.Zachary Turner2018-06-121-8/+9
| | | | | | | | | | | | | | | | | | | This simplifies some code which had StringRefs to begin with, and makes other code more complicated which had const char* to begin with. In the end, I think this makes for a more idiomatic and platform agnostic API. Not all platforms launch process with null terminated c-string arrays for the environment pointer and argv, but the api was designed that way because it allowed easy pass-through for posix-based platforms. There's a little additional overhead now since on posix based platforms we'll be takign StringRefs which were constructed from null terminated strings and then copying them to null terminate them again, but from a readability and usability standpoint of the API user, I think this API signature is strictly better. llvm-svn: 334518
* Signal handling should be signal-safeJF Bastien2018-05-161-9/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Before this patch, signal handling wasn't signal safe. This leads to real-world crashes. It used ManagedStatic inside of signals, this can allocate and can lead to unexpected state when a signal occurs during llvm_shutdown (because llvm_shutdown destroys the ManagedStatic). It also used cl::opt without custom backing storage. Some de-allocation was performed as well. Acquiring a lock in a signal handler is also a great way to deadlock. We can't just disable signals on llvm_shutdown because the signals might do useful work during that shutdown. We also can't just disable llvm_shutdown for programs (instead of library uses of clang) because we'd have to then mark the pointers as not leaked and make sure all the ManagedStatic uses are OK to leak and remain so. Move all of the code to lock-free datastructures instead, and avoid having any of them in an inconsistent state. I'm not trying to be fancy, I'm not using any explicit memory order because this code isn't hot. The only purpose of the atomics is to guarantee that a signal firing on the same or a different thread doesn't see an inconsistent state and crash. In some cases we might miss some state (for example, we might fail to delete a temporary file), but that's fine. Note that I haven't touched any of the backtrace support despite it not technically being totally signal-safe. When that code is called we know something bad is up and we don't expect to continue execution, so calling something that e.g. sets errno is the least of our problems. A similar patch should be applied to lib/Support/Windows/Signals.inc, but that can be done separately. Fix r332428 which I reverted in r332429. I originally used double-wide CAS because I was lazy, but some platforms use a runtime function for that which thankfully failed to link (it would have been bad for signal handlers otherwise). I use a separate flag to guard the data instead. <rdar://problem/28010281> Reviewers: dexonsmith Subscribers: steven_wu, llvm-commits llvm-svn: 332496
* Revert "Signal handling should be signal-safe"JF Bastien2018-05-161-35/+12
| | | | | | Some bots don't have double-pointer width compare-and-exchange. Revert for now.q llvm-svn: 332429
* Signal handling should be signal-safeJF Bastien2018-05-161-12/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Before this patch, signal handling wasn't signal safe. This leads to real-world crashes. It used ManagedStatic inside of signals, this can allocate and can lead to unexpected state when a signal occurs during llvm_shutdown (because llvm_shutdown destroys the ManagedStatic). It also used cl::opt without custom backing storage. Some de-allocation was performed as well. Acquiring a lock in a signal handler is also a great way to deadlock. We can't just disable signals on llvm_shutdown because the signals might do useful work during that shutdown. We also can't just disable llvm_shutdown for programs (instead of library uses of clang) because we'd have to then mark the pointers as not leaked and make sure all the ManagedStatic uses are OK to leak and remain so. Move all of the code to lock-free datastructures instead, and avoid having any of them in an inconsistent state. I'm not trying to be fancy, I'm not using any explicit memory order because this code isn't hot. The only purpose of the atomics is to guarantee that a signal firing on the same or a different thread doesn't see an inconsistent state and crash. In some cases we might miss some state (for example, we might fail to delete a temporary file), but that's fine. Note that I haven't touched any of the backtrace support despite it not technically being totally signal-safe. When that code is called we know something bad is up and we don't expect to continue execution, so calling something that e.g. sets errno is the least of our problems. A similar patch should be applied to lib/Support/Windows/Signals.inc, but that can be done separately. <rdar://problem/28010281> Reviewers: dexonsmith Subscribers: aheejin, llvm-commits Differential Revision: https://reviews.llvm.org/D46858 llvm-svn: 332428
* Simplify LLVM_ATTRIBUTE_USED call sites.Fangrui Song2018-05-051-8/+3
| | | | llvm-svn: 331599
* IWYU for llvm-config.h in llvm, additions.Nico Weber2018-04-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See r331124 for how I made a list of files missing the include. I then ran this Python script: for f in open('filelist.txt'): f = f.strip() fl = open(f).readlines() found = False for i in xrange(len(fl)): p = '#include "llvm/' if not fl[i].startswith(p): continue if fl[i][len(p):] > 'Config': fl.insert(i, '#include "llvm/Config/llvm-config.h"\n') found = True break if not found: print 'not found', f else: open(f, 'w').write(''.join(fl)) and then looked through everything with `svn diff | diffstat -l | xargs -n 1000 gvim -p` and tried to fix include ordering and whatnot. No intended behavior change. llvm-svn: 331184
* s/LLVM_ON_WIN32/_WIN32/, llvmNico Weber2018-04-291-2/+2
| | | | | | | | | | | | | | LLVM_ON_WIN32 is set exactly with MSVC and MinGW (but not Cygwin) in HandleLLVMOptions.cmake, which is where _WIN32 defined too. Just use the default macro instead of a reinvented one. See thread "Replacing LLVM_ON_WIN32 with just _WIN32" on llvm-dev and cfe-dev. No intended behavior change. This moves over all uses of the macro, but doesn't remove the definition of it in (llvm-)config.h yet. llvm-svn: 331127
* Convenience/safety fix for llvm::sys::Execute(And|No)WaitAlexander Kornienko2017-09-131-5/+1
| | | | | | | | | | | | | | | | | | | | Summary: Change the type of the Redirects parameter of llvm::sys::ExecuteAndWait, ExecuteNoWait and other APIs that wrap them from `const StringRef **` to `ArrayRef<Optional<StringRef>>`, which is safer and simplifies the use of these APIs (no more local StringRef variables just to get a pointer to). Corresponding clang changes will be posted as a separate patch. Reviewers: bkramer Reviewed By: bkramer Subscribers: vsk, llvm-commits Differential Revision: https://reviews.llvm.org/D37563 llvm-svn: 313155
* bugpoint: disabling symbolication of bugpoint-executed programsDavid Blaikie2017-06-091-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Initial implementation - needs similar work/testing for other tools bugpoint invokes (llc, lli I think, maybe more). Alternatively (as suggested by chandlerc@) an environment variable could be used. This would allow the option to pass transparently through user scripts, pass to compilers if they happened to be LLVM-ish, etc. I worry a bit about using cl::opt in the crash handling code - LLVM might crash early, perhaps before the cl::opt is properly initialized? Or at least before arguments have been parsed? - should be OK since it defaults to "pretty", so if the crash is very early in opt parsing, etc, then crash reports will still be symbolized. I shyed away from doing this with an environment variable when I realized that would require copying the existing environment and appending the env variable of interest. But it seems there's no existing LLVM API for accessing the environment (even the Support tests for process launching have their own ifdefs for getting the environment). It could be added, but seemed like a higher bar/untested codepath to actually add environment variables. Most importantly, this reduces the runtime of test/BugPoint/metadata.ll in a split-dwarf Debug build from 1m34s to 6.5s by avoiding a lot of symbolication. (this wasn't a problem for non-split-dwarf builds only because the executable was too large to map into memory (due to bugpoint setting a 400MB memory (including address space - not sure why? Going to remove that) limit on the child process) so symbolication would fail fast & wouldn't spend all that time parsing DWARF, etc) Reviewers: chandlerc, dannyb Differential Revision: https://reviews.llvm.org/D33804 llvm-svn: 305056
* Sort the remaining #include lines in include/... and lib/....Chandler Carruth2017-06-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | I did this a long time ago with a janky python script, but now clang-format has built-in support for this. I fed clang-format every line with a #include and let it re-sort things according to the precise LLVM rules for include ordering baked into clang-format these days. I've reverted a number of files where the results of sorting includes isn't healthy. Either places where we have legacy code relying on particular include ordering (where possible, I'll fix these separately) or where we have particular formatting around #include lines that I didn't want to disturb in this patch. This patch is *entirely* mechanical. If you get merge conflicts or anything, just ignore the changes in this patch and run clang-format over your #include lines in the files. Sorry for any noise here, but it is important to keep these things stable. I was seeing an increasing number of patches with irrelevant re-ordering of #include lines because clang-format was used. This patch at least isolates that churn, makes it easy to skip when resolving conflicts, and gets us to a clean baseline (again). llvm-svn: 304787
* Remove name space pollution from Signals.cppKristof Beyls2017-03-311-1/+0
| | | | llvm-svn: 299224
* Search for llvm-symbolizer binary in the same directory as argv[0], beforeRichard Smith2016-06-091-11/+23
| | | | | | | looking for it along $PATH. This allows installs of LLVM tools outside of $PATH to find the symbolizer and produce pretty backtraces if they crash. llvm-svn: 272232
* Appease hosts without HAVE_BACKTRACE nor ENABLE_BACKTRACES.NAKAMURA Takumi2015-11-081-0/+4
| | | | | | | llvm/lib/Support/Signals.cpp:66:13: warning: unused function 'printSymbolizedStackTrace' [-Wunused-function] llvm/lib/Support/Signals.cpp:52:13: warning: function 'findModulesAndOffsets' has internal linkage but is not defined [-Wundefined-internal] llvm-svn: 252418
* [Windows] Symbolize with llvm-symbolizer instead of dbghelp in a self-hostReid Kleckner2015-11-051-1/+123
| | | | | | | | | | | | | | | | Summary: llvm-symbolizer understands both PDBs and DWARF, so it is more likely to succeed at symbolization. If llvm-symbolizer is unavailable, we will fall back to dbghelp. This also makes our crash traces more similar between Windows and Linux. Reviewers: Bigcheese, zturner, chapuni Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12884 llvm-svn: 252118
* Rename RunCallBacksToRun to llvm::sys::RunSignalHandlersYaron Keren2015-07-221-1/+1
| | | | | | | | | | | | And expose it in Signals.h, allowing clients to call it directly, possibly LLVMErrorHandler which currently calls RunInterruptHandlers but not RunSignalHandlers, thus for example not printing the stack backtrace on Unixish OSes. On Windows it does happen because RunInterruptHandlers ends up calling the callbacks as well via Cleanup(). This difference in behaviour and code structures in */Signals.inc should be patched in the future. llvm-svn: 242936
* De-duplicate Unix & Windows CallBacksToRunYaron Keren2015-07-221-1/+13
| | | | | | | | | Move CallBacksToRun into the common Signals.cpp, create RunCallBacksToRun() and use these in both Unix/Signals.inc and Windows/Signals.inc. Lots of potential code to be merged here. llvm-svn: 242925
* Fix a ton of comment typos found by codespell. Patch byChris Lattner2011-04-151-1/+1
| | | | | | Luis Felipe Strano Moraes! llvm-svn: 129558
* Merge System into Support.Michael J. Spencer2010-11-291-0/+34
| | | | llvm-svn: 120298
* Signals support has been moved to lib/SystemReid Spencer2004-08-291-138/+0
| | | | llvm-svn: 16097
* It is not possible to catch SIGKILL, don't bother trying.Chris Lattner2004-08-041-1/+1
| | | | llvm-svn: 15496
* Signals.h header moved. Eventually this should move into a lib/System library,Chris Lattner2004-05-271-1/+1
| | | | | | but not right now. llvm-svn: 13811
* `cat' is usually in /bin, not /usr/bin, at least on our systems.Misha Brukman2004-02-211-1/+1
| | | | llvm-svn: 11690
* When printing a stack trace, demangle it if possible. Since we are potentiallyChris Lattner2004-02-211-5/+61
| | | | | | | in a signal handler, allocating memory or doing other unsafe things is bad, which means we should do it in a different process. llvm-svn: 11689
* Use backtrace() and include execinfo.h, if they were detected by autoconf.Brian Gaeke2004-02-201-5/+10
| | | | llvm-svn: 11658
* Disable the stack trace thing until we can get an autoconf test for it. ThisChris Lattner2004-02-191-3/+3
| | | | | | call breaks on sparcs llvm-svn: 11635
* Implement new functionChris Lattner2004-02-191-0/+6
| | | | llvm-svn: 11631
* Print stacktrace in STDERR before dying on a fatal signal. CurrentlyAlkis Evlogimenos2004-02-191-1/+7
| | | | | | the symbols are not demangled. llvm-svn: 11620
* Finegrainify namespacificationChris Lattner2003-12-141-5/+2
| | | | llvm-svn: 10464
* Put all LLVM code into the llvm namespace, as per bug 109.Brian Gaeke2003-11-111-0/+4
| | | | llvm-svn: 9903
* Added LLVM project notice to the top of every C++ source file.John Criswell2003-10-201-0/+7
| | | | | | Header files will be on the way. llvm-svn: 9298
* Fixed spelling & grammar.Misha Brukman2003-09-161-1/+1
| | | | llvm-svn: 8559
* Move #include from a header to hereChris Lattner2003-08-011-0/+1
| | | | llvm-svn: 7480
* Merged in autoconf branch. This provides configuration via the autoconfJohn Criswell2003-06-301-1/+1
| | | | | | system. llvm-svn: 7014
* Make _sure_ we don't go into an infinite loop if a signal happens!Chris Lattner2003-05-271-0/+1
| | | | llvm-svn: 6351
* Add using declarationsChris Lattner2003-05-221-3/+2
| | | | llvm-svn: 6305
* Submitted by Casey Carter:Chris Lattner2002-09-131-2/+4
| | | | | | | | ISSUE: Linux doesn't have any steenking SIGEMT signal, as referred to in lib/Support/Signals.cpp. ACTION: Wrap the use with a #ifdef SIGEMT / #endif. llvm-svn: 3700
* changes to make it compatible with 64bit gccAnand Shukla2002-06-251-4/+5
| | | | llvm-svn: 2791
* Add new api for basic signal handling for toolsChris Lattner2002-04-181-0/+53
llvm-svn: 2302
OpenPOWER on IntegriCloud