This test fused both the CHECK directives and the
source code into one file, and is sensitive to the line numbers
that source code appears on in that file. Thus, any attempts to
add new lines to this test would break it.
This refactoring moves the source code to a separate file so
its line numbers stay stable.
Linux gives the main thread a name based on the process name, and also
we need to tolerate an extra slash on the `<compiler-generated>` filename
for some reason.
rdar://121430255
Always put `registers` in the thread record, and always use the `threads`
top level key, even if we ask for only the crashed thread. Also add an
`omittedThreads` key.
rdar://121430255
Add the ability to specify a filename or directory name as the output-to
setting in `SWIFT_BACKTRACE`. If the option is set to a directory name,
generate a unique filename in that directory using the process name,
process ID and timestamp.
rdar://136977833
Also removed a spurious `print()` that got left in by accident,
and disabled the `CodableBacktrace.swift` test on Linux since we
need Foundation and we don't have it there.
rdar://124913332
`JSONEncoder` by default will escape slashes, which results in a string
that isn't technically valid Base64. Since that behaviour is optional,
turn it off, and at the same time tell it to output in lexical key
order, which makes the test slightly simpler (no `CHECK-DAG` needed).
Also fixed a typo in `test_swift.py`
rdar://124913332
We want to be able to efficiently serialise lists of images, and to do so
it makes most sense to create a separate `ImageMap` type. This also provides
a useful place to put methods to e.g. find an image by address or by build
ID.
rdar://124913332
Move the backtracing code into a new Runtime module. This means renaming
the Swift Runtime's CMake target because otherwise there will be a name
clash.
rdar://124913332
Prior to this commit, when lowering SIL instructions that should are
"hidden" for the purposes of debugging, the compiler just attaches the
location of the previous instruction in the name of keeping a simpler
line table.
However, this is wrong for many reasons. One such reason is this: at the
start of a basic block, inheriting the previous debug location will
almost certainly cause the instruction to have a random location in the
code, as it will depend on whatever BB was visited previously.
Other examples can be seen in the tests affect by this commit, which
changes lowering to use Line 0 instead of the line number of the
previous instruction.
CodeView doesn't handle line 0 the same way DWARF does, so this commit
preserves the old behavior for the CodeView path.
The test changes here are effectively undoing some of the diffs from
158772c2ab.
rdar://139826231&110187845
We've been building up this exponential explosion of task-creation
builtins because it's not currently possible to overload builtins.
As long as all of the operands are scalar, though, it's pretty easy
to peephole optional injections in IRGen, which means we can at
least just use a single builtin in SIL and then break it apart in
IRGen to decide which options to set.
I also eliminated the metadata argument, which can easily be recreated
from the substitutions. I also added proper verification for the builtin,
which required (1) getting `@Sendable` right more consistently and (2)
updating a bunch of tests checking for things that are not actually
valid, like passing a function that returns an Int directly.
Don't delete the OS declaration of `exit` because the concurrency shims aren't always imported, and so the shim declaration might not always be available.
Don't override the OS declaration of `exit` in the concurrency shims since we can't just delete the OS one. Instead, set up internal shims just for building Concurrency that forward declares `exit`.
There's no need for fatalError() to try to generate its own backtraces
when the runtime's backtracer is enabled. Not only is the code it uses
more fragile but it also doesn't support async or inline frames and it
can't look-up symbols properly either.
rdar://117470489
Turn on frame pointers for the Swift runtime libraries. This makes
backtraces that go through the runtimes more reliable without having
to parse DWARF data.
rdar://116112040
This adds a new binary, `swift-backtrace-static`, to the build. The runtime
will not by default use this binary as the backtracer, but if you want to
statically link your own binaries against the standard library you can copy
`swift-backtrace-static` rather than `swift-backtrace` alongside your binary,
naming it `swift-backtrace`, and the runtime should find and use it, which
will mean you don't need to have `libswiftCore.so` et al installed.
rdar://115278959
We want the static version of Dispatch here. If we don't use that version,
we'll fail the tests on the release branches (but strangely not on main
for some reason).
rdar://115774613
When we're statically linking the standard library, we need to force
the inclusion of the backtracing code in the runtime, otherwise we don't
get on-crash backtraces.
Also, add a test to make sure that this works.
rdar://115774613
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.
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:'.
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
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
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
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
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
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.