Commit Graph

119 Commits

Author SHA1 Message Date
Adrian Prantl
1d5518236d Add missing include for PRIxPTR (NFC) 2019-11-22 13:18:01 -08:00
Daniel Rodríguez Troitiño
a7025522a4 [android] Basic support for backtraces.
Android doesn't support the GNU backtrace call, but unwind.h is there to
help. The code is a little bit more complicated than a simple backtrace
call, but it is just a callback and the context struct.

Sadly, it seems that -funwind-tables is needed in every piece of code
that the backtrace needs to traverse, which means that at least the
runtime and the stubs need -funwind-tables. However, the flag has been
enabled for all targets (only on Android), just in case some other code
ends up being in the stack. This might only be necessary for ARM
targets, but currently we only build ARM targets in Android. The Swift
parts of the stack seems to have unwind information and can be unwind.

Another problem at the moment is the symbols from the executable are
normally missing. To get symbol names two things need to happen: the
symbol has to be public (so it is an exported symbol, and not just a
local symbol that dladdr seems to not provide the name), and the linker
has to be invoked with -export-dynamic. Without those two pieces, the
addresses are returned (and match the binary just fine), but no names
are printed.
2019-06-05 13:12:04 -07:00
Saleem Abdulrasool
618d525b91 runtime: enable stack traces on Windows
We would not previously symbolicate the stack trace and as a result
would not display the stack trace.  Add symbolication support to the
runtime to actually make use of the captured stack trace.  This allows
us to get a stack trace when the standard library or swift code reports
a fatal error.
2019-03-04 10:39:10 -08:00
Jason Mittertreiner
1abe971a16 Fix StackTraces on Windows 2019-02-20 12:59:54 -08:00
Arnold Schwaighofer
152e8db8bb IRGen and runtime implementation for dynamic replacements 2018-11-06 09:58:36 -08:00
Joe Groff
e9b45178a0 Make runtime warnings about missing metadata more descriptive.
Describe the consequences of missing metadata instead of just posting a scary
message about a bug.  Furthermore, since these warnings tend to show up in
playgrounds, and probably aren't relevant to the user of a playground, suppress
them when running in a playground. rdar://problem/44642942
2018-09-20 13:03:54 -07:00
Bob Wilson
740c4d0782 [master-next] Avoid use of StringRef::split and rsplit
LLVM r334283 changed StringRef::split(char) to be implemented using
StringRef::split(StringRef), which is not defined inline. Because Swift
uses StringRef without linking LLVM's libSupport.a, we can only use
functions that are defined inline in the headers. Swift currently only
builds LLVM for the host, so we cannot link libSupport.a without building
it for every target, which would be a big change. Instead, this changes
a few places in Swift to avoid using those split and rsplit functions.

rdar://problem/41029268
2018-06-18 12:57:59 -07:00
Mike Ash
9638cb8f6e [Runtime] Fix format string warnings in Errors.cpp and Exclusivity.cpp when built for 32-bit.
rdar://problem/40345076
2018-05-25 16:16:02 -04:00
Arnold Schwaighofer
e106161d8f Speculative fix for linux bot linker failure 2018-03-09 17:55:39 -08:00
Mike Ash
406ebaddfc [Runtime] Implement overflow check for weak refcounts (#14023)
* Check for overflow in incrementWeak().

This mirrors what is currently done for unowned reference counts, where overflowing the side table field produces a fatal error. Without this, the count silently wrapped from 2^31-1 to 0, which then caused breakage when the balancing releases happened (possibly including use-after-free bugs).

* Fix the implementation of RefCounts::getWeakCount().

The previous implementation was only appropriate for heap objects, but not side tables. This resulted in the weak count always returning 0 or 1. This change specializes the implementation for the two different cases and returns the correct count for side tables.

* Test large weak retain counts.

This tests the largest allowed weak retain count, as well as the overflow check when that count is exceeded.
2018-01-19 19:13:47 -08:00
Saleem Abdulrasool
d7fc6a0359 stdlib: initialize va_list variables (NFC)
This silences `-Wuninitialized` warnings from clang when building the
swift stdlib for Windows ARM.  NFC.
2017-10-06 15:33:43 -07:00
Calvin Hill
aee81d272f Add Initial platform support for Haiku. (#11583) 2017-09-22 21:06:56 -04:00
Saleem Abdulrasool
8bf538cab1 Merge pull request #11947 from compnerd/windows-demangling
runtime: add undecoration support for Windows
2017-09-18 14:50:33 -07:00
Saleem Abdulrasool
a22fc82535 runtime: clean up -Wformat warning
Add explicit casts to convert the `void *` to an integral value to
convert via printf.  NFC.
2017-09-15 17:52:37 -07:00
Saleem Abdulrasool
fb68207f0c runtime: add undecoration support for Windows
Use the Windows API `UnDecorateSymbolName` rather than `__cxa_demangle`
to undecorate the C++ symbols.  `__cxa_demangle` is only available in
the itanium ABI, not under MS ABI.  This allows us to properly
undecorate symbols on Windows.
2017-09-15 17:48:43 -07:00
Saleem Abdulrasool
d0a6131b53 runtime: clean up -Wunused-function warning
This function is only used when backtracing is enabled.  Use a
preprocessor guard to avoid defining the function when not used.  This
prevents a -Wunused-function warning.  NFC.
2017-09-15 10:12:34 -07:00
Kuba (Brecka) Mracek
d03a575279 Unify the capitalization across all user-visible error messages (#11599)
* Unify the capitalization across all user-visible error messages (fatal errors, assertion failures, precondition failures) produced by the runtime, standard library and the compiler.

* Update some more tests to the new expectations.
2017-08-29 12:16:04 -07:00
Arnold Schwaighofer
d8abd2fed9 runtime: Fix overflow of swift_unownedRetain reference counts
On 32bit platforms there are 7 bits reserved for the unowned retain count. This
makes overflow a likely scenario. Implement overflow into the side table.

rdar://33495003
2017-08-02 07:12:47 -07:00
Jordan Rose
9c10398514 [runtime] Expose reportToDebugger as swift_reportToDebugger.
...so that the overlays can use it. See next commit.
2017-07-13 11:18:41 -07:00
Kuba (Brecka) Mracek
150696f8f6 On Linux, make swift_reportError always print backtraces (#10638)
On Linux, make swift_reportError always print backtraces.
2017-06-27 21:53:55 -07:00
Kuba (Brecka) Mracek
d29557bd24 Change the signature of reportToDebugger and _swift_runtime_on_report to avoid using 'bool'. It's much easier to work with native-width integers only in LLDB. (#10523) 2017-06-22 21:22:27 -07:00
Kuba (Brecka) Mracek
dc3e6c1116 Prevent _swift_runtime_on_report from having its arguments optimized out. Turns out an empty "asm volatile" isn't enough and we need to explicitly ask that the arguments are also not optimized out. (#10456) 2017-06-21 16:54:54 -07:00
Kuba (Brecka) Mracek
fec8d72ea3 Debugger hook/breakpoint for issue reporting from the Swift runtime (#10293)
* Implements a debugger hook (breakpoint) API and data structure. This structure is passed to the debugger and describes extra information about a fatal error or a non-fatal warning, which should be logged as a runtime issue.

This debugger hook is then used from two places, which currently only log to stderr:
- Runtime exclusivity violations.
- Swift 3 implicit Obj-C entrypoints.

A subsequent LLDB support will be able to catch these callbacks and show the runtime issues in a better way than just logging them to stderr.  When the debugger is not attached, this shouldn't have any effect.
2017-06-19 14:28:19 -07:00
John Holdsworth
d600e7581d Use #elif 2017-05-30 20:16:40 +01:00
John Holdsworth
e45ddc8955 Ensure fatalError message logged on Android 2017-05-23 01:47:07 +01:00
Kuba (Brecka) Mracek
a5a59f5aed [runtime] Enhance output from dynamic exclusivity violations. Print current stacktrace and the symbolicated frame of the previous conflicting access. (#9501) 2017-05-12 20:28:28 -07:00
Kuba (Brecka) Mracek
fc7dbefcf8 Revert backtrace ban and start printing backtraces from the runtime again (#9528)
* Revert "[strip -ST] Disable runtime stack trace dumping on Darwin when asserts are disabled."
This reverts commit 6bc28ff1c9.
* Bring back important fixes from the revert of 6bc28ff1c9.
* Change swift::swift_reportError to only print the backtrace in assert builds (swift::warning prints backtrace always).
2017-05-12 15:46:35 -07:00
Michael Gottesman
6bc28ff1c9 [strip -ST] Disable runtime stack trace dumping on Darwin when asserts are disabled.
This commit disables runtime stack trace dumping via dladdr on Darwin when
asserts are disabled.

This stack trace dumping was added as a way to improve the ability to debug the
compiler for compiler developers. This is all well and good but having such a
feature always enabled prevents us from reducing the size of the swift standard
library by eliminating the swift nlist.

rdar://31372220
2017-05-04 16:46:26 -06:00
Doug Gregor
cd811edb14 [Runtime] Add a “swift::warning” entrypoint for runtime warnings.
Like swift::fatalError(), but without the abort or crash logging.
2017-03-31 21:22:16 -07:00
Erik Eckstein
5e80555c9b demangler: put the demangler into a separate library
Previously it was part of swiftBasic.

The demangler library does not depend on llvm (except some header-only utilities like StringRef). Putting it into its own library makes sure that no llvm stuff will be linked into clients which use the demangler library.

This change also contains other refactoring, like moving demangler code into different files. This makes it easier to remove the old demangler from the runtime library when we switch to the new symbol mangling.

Also in this commit: remove some unused API functions from the demangler Context.

fixes rdar://problem/30503344
2017-03-09 13:42:43 -08:00
Greg Parker
ae1c984920 New refcount representation (#5282)
New refcount representation and weak variable implementation. See SwiftShims/RefCount.h for details.
2017-02-24 14:19:11 -08:00
Hugh Bellamy
63cf2d561e Remove extern "C" from uses of SWIFT_RUNTIME_EXPORT 2017-01-22 18:32:17 +00:00
Hugh Bellamy
4e55214c18 Remove CRASH_REPORTER_CLIENT_HIDDEN in favour of equivilent LLVM macro 2017-01-20 13:48:56 +00:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Hugh Bellamy
61c83ab5eb Change _MSC_VER conditions to _WIN32 in runtime 2016-12-19 15:54:49 +00:00
practicalswift
76f0fdd670 [gardening] NULL → nullptr 2016-12-09 23:17:54 +01:00
Simon Evans
c17ca759aa [runtime] Add platform independent version of dladdr() / Dl_info
- Win32 does not support dlfcn.h, Dl_info or dladdr() so add
  lookupSymbol() as a wrapper for ELF/MachO/Win32

- Win32 version needs an implementation, currently it just returns
  an error for `cannot lookup address'
2016-11-29 00:05:11 +00:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
John Holdsworth
a430c40303 Bug in Windows swift_vasprintf() 2016-09-23 06:50:22 +01:00
Grzegorz Miłoś
201c19dc98 Review comments, round 3. 2016-09-07 12:14:48 +01:00
Grzegorz Miłoś
dc3369dffe Review comments. Mostly python improvements in symbolicate-linux-fatal(.py). 2016-09-07 12:14:48 +01:00
Grzegorz Miłoś
f068b1eb33 [SR-755] Tool for re-symbolicating fatal stacktraces on Linux. 2016-09-07 12:14:48 +01:00
Han Sangjin
e6ecc9a3ec Modified for some reviews 2016-06-10 06:26:47 +09:00
Han Sangjin
198441bee9 stdlib/msvc: Runtime with MSVC library
This patch is for libswiftCore.lib, linking with the library set of Visual Studio 2015. Clang with the option -fms-extension is used to build.
2016-06-04 05:16:41 +09:00
Dmitri Gribenko
8ac074687d runtime: remove unused includes 2016-05-30 19:36:26 -07:00
Michael Gottesman
8308ad85e2 Merge pull request #2485 from gottesmm/change-backtrace-to-use-dladdr-directly-instead-of-backtrace_symbol
When producing backtraces, do not use backtrace_symbol, invoke dladdr…
2016-05-11 17:28:36 -07:00
Michael Gottesman
7523d1a60b When producing backtraces, do not use backtrace_symbol, invoke dladdr directly.
Previously, we were using backtrace_symbol and then parsing/modifying its
output. By just using dladdr directly, we have a cleaner and more robust
solution.

rdar://25064742
2016-05-11 15:40:10 -07:00
Saleem Abdulrasool
81661fca61 stdlib: use the reserved attribute spellings
This is a purely mechanical change replacing the attributes with the reserved
spelling.  Compilers are to not error when they encounter a reserved spelling
for an attribute which they do not support.
2016-05-11 11:30:24 -07:00
Jacob Mizraji
f8a79282f2 Resolve ambiguity in mutex declaration 2016-05-05 12:01:23 -07:00
Jacob Mizraji
880026194e Changed StaticUnsafeMutex to have the swift:: namespace
to fix upstream clang build errors.
2016-05-02 18:14:21 -07:00