23 Commits
Author SHA1 Message Date
Euan Harris d4f33e71ca Do not build Demangle on Swift 5.9 or above
Pull request #68 prevents Backtrace from being built on Swift 5.9 and above,
but Demangle is still built and fails when the importing project uses musl.
2024-06-13 17:51:30 +01:00
Alastair Houghton 80746bdd0a Disable this library for Swift 5.9 and above. (#68) 2023-09-05 06:47:22 -07:00
Yim Lee 1809e7963b DocC setup 2022-08-10 21:53:01 -07:00
tom doron 3bd448574b flush stderr after printing back traces
motivation: make sure stderr buffered is printed out before program exits

changes: explicitly call fflush after writing the backtraces
2022-06-13 21:05:40 -07:00
tomer doron baf9597d12 trap SIGSEGV, SIGBUS and SIGFPE by default, in addition to SIGILL (#58)
motivation: print crash trace on segmentation faults and other common failures beyond illegal instructions

changes:
* include SIGSEGV, SIGBUS and SIGFPE in the default signals trapped
* update and improve tests
2022-06-08 09:06:33 -07:00
Fabio1988 ad485ae151 exit after printing stacktrace #51 2022-03-17 12:17:02 +01:00
Johannes Weiss b3b195e0e6 forgot other platforms 2021-07-16 19:34:47 +01:00
Johannes Weiss ceaaf36f0f allow other signals 2021-07-15 19:40:14 +01:00
tomer doron 54a65d6391 recent changes to support windows broke macos (#44)
motivation: unbreak macos

changes: make _stdlib_demangleName only available on macOS and Windows where it is fully supported
2021-04-20 11:04:11 -07:00
Saleem Abdulrasool 5b47490c74 Backtrace: adjust style (NFC)
Adjust the style for the linter.
2021-04-19 13:13:09 -07:00
Saleem Abdulrasool b097912943 Backtrace: enable support for Windows
Add an implementation across all architectures supported by Windows:
- x86
- x86_64
- ARM
- ARM64

This relies on DbgHlp32.dll which makes this unfriendly to store
applications.  We can investigate improvements to that in the future.
This sketches out an implementation which allows building and using the
interface for providing backtraces.  This requires that the programs be
built with debug information in CodeView format.  Without the additional
debug information, the stack traces will be limited to symbolication and
resolution to export only symbols.

Resolves: #34
2021-04-18 11:16:45 -07:00
Saleem Abdulrasool a4f7b4204e Backtrace: make _stdlib_demangleName part of all platforms (#41) 2021-04-17 21:45:37 -07:00
Johannes Weiss 4353fd38d5 Merge branch 'main' into jw-error 2021-02-22 11:09:50 +00:00
Johannes Weiss 566d2454b2 determine the executable path automatically
Motivation:

Previously, we would use
`CommandLine.arguments[0]`/`argv[0]`/`getexecname()` as the preferred
ways to find the main binary. That sounds sensible, especially given
the fact that we'd fall back onto other methods (such as
`/proc/self/exe`) when the previous ones don't work.

There is however an unfortunate edge case. If you for example have your
app binary at `/app/app` and you start it with a relative path `./app`
from within `/app`, then `CommandLine.arguments[0]` will only contain
`./app`. If now the app changes its working directory to `/`, `./app`
would mean `/app` which is the directory. This would mean we will find
the target but instead of the binary we'd find the directory `/app`.
From then on, everything else fails.

A similar problem is if `argv[0]` was actually set incorrectly when
`exec*`ing the process. This has happened at least in one instance.

Modification:

Given that we only target Linux here, we can actually here, we can
change the order in which we try to find the main binary. We can start
by using `/proc/self/exe` which is a very high quality and almost
guaranteed to work way to find the main binary, nevermind the
information in `argv`.

Result:

More robust symbolications, especially in environments like Heroku/Dokku
where we've seen `argv` not being set correctly.
2021-02-21 18:28:38 +00:00
Johannes Weiss c8d8ddd88b better distinguish mmap errors & print errno
Motivation:

In case SwiftBacktrace fails, we get only very little output.
Unfortunately, some crucial information (like the errno) is missing and
in case `mmap` fails, we don't know if the problem is file I/O or
allocating memory.

Modification:

- print errnos
- distinguish the two mmaps

Result:

Easier debugging
2021-02-20 23:12:33 +00:00
tomer doron 7faa1c401b remove print from public API (#25)
motivation: reduce public API surface area given the plan is to abosrb this library in the language runtime eventually

changes:
* make print function private
* remove explicit swift-server file
2020-03-25 12:06:04 -07:00
tomer doron 1afd60a0bb ci setup (#23)
motivation: setup ci for the project

changes:
* add docker setup for testing 5.0, 5.1 and 5.2
* fix license headers
* add sanity script
* format
* regenerate tests to match convention
2020-03-20 16:20:00 -07:00
Ian Partridge f244ad1074 feat: add Backtrace.print() function (#15) 2019-07-22 08:19:56 +01:00
Ian Partridge 4f9b59d324 fix: use backtrace_full() to get better stacks in release mode (#11) 2019-07-18 13:02:37 +01:00
Ian Partridge 932f170ce0 feat: add demangling (#10) 2019-07-18 09:35:45 +01:00
Ian Partridge fabd575ba5 feat: use libbacktrace (#8) 2019-07-09 15:30:38 +01:00
Zsolt Váradi c5b4501408 Fix backtrace prints on Heroku by using stderr (#7)
* Use backtrace_symbols_fd to write the stacktrace to stderr
2019-06-26 13:00:22 +01:00
Ian Partridge dd4aad9a1a Initial commit 2019-04-19 21:02:35 +01:00