Commit Graph

15 Commits

Author SHA1 Message Date
Alastair Houghton
8269bf72eb [Runtime] Add an option to produce non-symbolicated backtraces.
Symbolication can take some time, depending on the binaries involved.
In certain contexts it's better for the backtrace to finish quickly,
and then symbolication could be done offline.

rdar://122302117
2024-02-05 12:56:47 +00:00
Alastair Houghton
c9abb0bc61 [Backtracing] Improve warning message about thread suspension failure.
In the event that the backtracer fails to suspend a thread, it emits a
warning message.  Unfortunately the exact meaning of this message isn't
obvious and it doesn't make clear that it's a secondary problem (that is,
you've already crashed at this point).

Update the message to make things clearer.

rdar://116593541
2023-12-08 13:53:38 +00:00
Finagolfin
d9d6356f3b [Backtracing][Android] Fix armv7 build 2023-11-16 20:26:09 +05:30
Alastair Houghton
1667378e73 [Backtracing] Make sure we print the program counter on ARM64 linux.
On Linux, the right macro for detecting ARM64 is `__aarch64__`, not
`__arm64__`.

rdar://118379429
2023-11-14 08:27:24 +00:00
Alastair Houghton
9ca81c63b1 [Backtracing] Massage the output a little in various cases.
We shouldn't try to erase the message when in non-color mode; mostly
that's intended for redirected output scenarios anyway, and in that case
we don't really want garbage in the output.

Also, improve the failure messages when the backtracer itself goes
wrong or can't be executed.

Finally, change the behaviour slightly so that *if* we're explicitly
enabled, *and* the backtracer path wasn't explicitly specified, *and*
we can't find the backtracer, we print a warning on start-up.  We
don't do that in any other case because we don't want spurious warnings
everywhere.

rdar://118055527
2023-11-09 18:12:18 +00:00
Alastair Houghton
9d462a7b69 [Backtracing] Add an indication that we're working on a backtrace.
When we crash, emit a message straight away that says we're working
on a backtrace.  If starting the backtracer fails, report that also.

Finally, add a duration to the messages output by the backtracer, so
that we can see how long it took.

rdar://118055527
2023-11-09 18:12:18 +00:00
Alastair Houghton
7c71d0b98c [Backtracing][Linux] Handle inaccessible memory properly in Docker.
Thanks to a missing `-` sign, we were returning garbage rather than
indicating that the memory region in question was inaccessible.  This
mainly affects register dumps (since that's the time we expect to have
to cope with out-of-bounds reads).

rdar://117900760
2023-11-03 11:13:23 +00:00
Finagolfin
4cbbb33dbf [Backtracing][Linux] Disable invoking process_vm_readv() for older Android APIs 2023-07-23 20:11:26 +05:30
Alastair Houghton
dd7acb1739 [Backtracing][Linux] Properly align the stacks.
We have two stacks that we set up during crash handling, both of
which were potentially misaligned.  This only tripped us up on
Ubuntu 20.04 on aarch64 - my guess is that maybe `clone()` aligns
the stack pointer on newer kernels which is why we didn't see it
on 22.04.

rdar://110743884
2023-06-14 13:40:51 +01:00
Alastair Houghton
7e632c0ee0 [Backtracing][Linux] Fix Ubuntu 20.04-aarch64 CI failures.
These seem to be related to signal handling issues in threads that
have been started presumably by the C library or some other library.

Primarily this appears to affect Ubuntu 20.04 on aarch64, though I
have seen sporadic issues on 18.04 as well.

We address the problem by making the thread suspension mechanism
more robust in the face of threads with masked signals.

rdar://110653167
2023-06-12 18:54:05 +01:00
Alastair Houghton
be7725f0fd [Backtracing][Linux] Include declarations for gettid() and tgkill().
Older glibc doesn't include these.  Nor does Musl, it seems.  The
previous fix put the gettid() declaration too far down the file.

rdar://110417355
2023-06-09 09:04:27 +01:00
Alastair Houghton
77de53b944 [Backtracing][Linux] Use syscall() to call gettid().
Older versions of Linux don't have gettid() in their headers, so
use syscall() to call it instead.

rdar://110417355
2023-06-07 21:24:32 +01:00
Alastair Houghton
0b9747e77a [Backtracing] Also update the Linux crash handler, now it's merged.
The Linux crash handler should have the same `output-to` behaviour
as on macOS.

rdar://110371557
2023-06-07 13:55:17 +01:00
Alastair Houghton
14fcdbd389 [Backtracing][Linux] Tidy a few things up after review.
Mike and Max made various helpful suggestions, so I've added and updated
various comments and amended the code to cope with partial reads and
writes.

rdar://110261430
2023-06-06 16:06:21 +01:00
Alastair Houghton
2dcaa6f14f [Backtracing][Linux] Add Linux crash handler to the runtime.
This also adds a function to demangle a symbol, and a way for the
backtracing code to report warning messages to the same place as
the main runtime.

I'd like to rename the _swift_isThunkFunction() SPI also, but we
can't do that until we've made the changes to the _Backtracing
library, so we'll do that there instead.

rdar://110261430
2023-06-05 15:39:50 +01:00