Commit Graph

21 Commits

Author SHA1 Message Date
Daniel Rodríguez Troitiño
309ad399c0 [backtracing] Mark two tests with REQUIRES (#67074)
The test were enabled even if Backtracing was not enabled in the build
settings. Backtracing is enabled with the build script, but not in the
default CMake configuration.
2023-07-01 11:06:05 -07:00
Yuta Saito
059bbf51ef [test][Backtracing] Fix crash message pattern for single threaded mode
With libdispatch executor, `level` function is called on non-main thread
because it does not specify main executor explicitly. Therefore, the
crash message from swift-backtrace says `Thread 1 crashed: ...`.
However, with single threaded executor, all jobs are executed on the
main thread, and main thread always has its name, so the message can be
thread name 'Thread 0 "CrashAsync" crashed:'.
2023-06-22 08:06:29 +00:00
Alastair Houghton
fe0c14fe42 [Backtracing] Make StackOverflow test less sensitive.
Depending on the platform, architecture and stack layout, we may or
may not have line numbers for the very first frame.

rdar://110418951
2023-06-07 21:52:07 +01:00
Alastair Houghton
646c2212c9 [Backtracing][Tests] Fix a test I missed.
Apparently I missed a redirection in `Crash.swift`.

rdar://110371557
2023-06-07 13:55:17 +01:00
Alastair Houghton
210ca2a067 [Backtracing][Tests] Fix tests to redirect output from stderr.
Some of the backtracing tests expected output on stdout.

rdar://110371557
2023-06-07 13:55:15 +01:00
Alastair Houghton
ee5596428f [Backtracing][Linux] Enable Linux backtracing, add tests.
Turn on the Linux backtracing implementation and update the tests.

rdar://101623265
2023-06-07 09:08:18 +01:00
Adrian Prantl
158772c2ab Rebase SILScope generation on top of ASTScope.
This patch replaces the stateful generation of SILScope information in
SILGenFunction with data derived from the ASTScope hierarchy, which should be
100% in sync with the scopes needed for local variables. The goal is to
eliminate the surprising effects that the stack of cleanup operations can have
on the current state of SILBuilder leading to a fully deterministic (in the
sense of: predictible by a human) association of SILDebugScopes with
SILInstructions. The patch also eliminates the need to many workarounds. There
are still some accomodations for several Sema transformation passes such as
ResultBuilders, which don't correctly update the source locations when moving
around nodes. If these were implemented as macros, this problem would disappear.

This necessary rewrite of the macro scope handling included in this patch also
adds proper support nested macro expansions.

This fixes

rdar://88274783

and either fixes or at least partially addresses the following:

rdar://89252827
rdar://105186946
rdar://105757810
rdar://105997826
rdar://105102288
2023-04-04 15:20:11 -07:00
Alastair Houghton
3e78f840f6 [Backtracing][Tests] Disable crashing tests under ASAN.
If ASAN is enabled, it will catch the crashes and the backtracing code
won't, so in that case the tests will fail.  Fix by disabling them for
ASAN.

rdar://107129465
2023-03-23 12:09:21 +00:00
Alastair Houghton
fc9d0a02c5 [Backtracing][Tests] Don't fail CrashAsync for missing line numbers.
If libswift_Concurrency.dylib's line numbers couldn't be resolved, we'd
end up failing this test for no good reason.

rdar://106502985
2023-03-09 16:51:57 +00:00
Alastair Houghton
9061d4e874 [Backtracing][Tests] Don't demangle in CrashAsync.
The CI nodes currently run an older macOS version that can't demangle the
async function names.  So, to pass PR testing and CI, we'll need to turn
demangling off for this test for now.  No big deal.

rdar://106363539
2023-03-08 10:56:17 +00:00
Alastair Houghton
43375e7a23 [Backtracing] Fix out-of-process async backtraces.
These weren't working correctly because I made the unwinder call
`_swift_task_getCurrent()`, but of course when out-of-process, it calls
that in `swift-backtrace`, which is wrong.  Remove that for now.

While I'm here, I also tweaked the formatting slightly, and I noticed
that we were saying that all thunks were also system functions, which
seemed unnecessary and odd.

Plus there were a couple of extra system functions I added to make the
async crash backtraces nicer in friendly mode.

rdar://106363539
2023-03-08 09:35:18 +00:00
Alastair Houghton
2043498a39 [Backtracing] Don't run tests when testing OS stdlib.
We need a symbol from the standard library that isn't in the older
versions of the stdlib.

rdar://106293913
2023-03-07 14:42:28 +00:00
Alastair Houghton
106dd1956e [Backtracing] Fix test failures.
I'd inserted an extra line, which upset the line numbers in the backtracing
tests.

Also tweak the Python build script tests slightly so they work.

rdar://106234311
2023-03-06 11:28:16 +00:00
Alastair Houghton
1258d45152 [Backtracing] Build work.
Additional shimming required for some builds, as well as a few other build
related tweaks.

rdar://106234311
2023-03-04 15:46:30 +00:00
Alastair Houghton
eac93f9d2a [Backtracing][Tests] Apparently we don't see the dyld frame in CI.
For some reason we don't see the dyld frames in CI.  That's fine, don't
check for them.

Also turn NotImportedByDefault off for Windows as it needs a better
shell than the support provided there.
2023-03-04 08:00:09 +00:00
Alastair Houghton
3ec2e6723d [Backtracing] Really only build for OS X.
Added some extra code to AddSwiftStdlib.cmake so executable targets can
specify target SDKs the same way libraries currently can.

Updated the Backtracing targets to specify just OS X for now.
2023-03-04 08:00:09 +00:00
Alastair Houghton
43ac069ad0 [Backtracing] Add control over symbol caching.
Some symbolication frameworks have a symbol cache; we probably don't want
to use that for test cases, to avoid running into problems where the cache
holds stale information.

rdar://105409147
2023-03-04 08:00:09 +00:00
Alastair Houghton
f15011f4d0 [Backtracing] Tweak output slightly.
Fixed the colours so that they work with all of the default Terminal
presets.  Also changed things so that when colour is off, we only use
ASCII characters in our source code displays.

rdar://105452194
2023-03-04 08:00:09 +00:00
Alastair Houghton
65a6aae04e [Backtracing] Add swift-backtrace to the build.
This is Swift's external backtracer.  It's written in Swift, and it's
responsible for generating nice backtraces when Swift programs crash.
It makes use of the new `_Backtracing` library, which is also (mostly,
aside from some assembly language) implemented in Swift.

rdar://103442000
2023-03-04 08:00:09 +00:00
Alastair Houghton
44783e72c6 [Frontend] Add support for implicit import of _Backtracing
Once the API has gone through Swift Evolution, we will want to implicitly
import the _Backtracing module.  Add code to do that, but set it to off
by default for now.

rdar://105394140
2023-03-04 08:00:06 +00:00
Alastair Houghton
6caea5386b [Backtracing] Add _Backtracing library to the build.
Adds a new swift_Backtracing library, with a corresponding _Backtracing
module, to the build.  Also add some tests.

This is not public API at this point, but will be used by the external
backtracing program, `swift-backtrace`.

rdar://104336548
2023-03-04 07:56:03 +00:00