Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backtracing] Implement API per SE-0419 #78516

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

al45tair
Copy link
Contributor

@al45tair al45tair commented Jan 9, 2025

Implement the API described in SE-0419, in a new module Runtime that you can import from your Swift program.

Additionally, made symbolicated backtraces approximately 5x faster on Linux.

rdar://124913332

@al45tair
Copy link
Contributor Author

al45tair commented Jan 9, 2025

@swift-ci Please test

@al45tair
Copy link
Contributor Author

al45tair commented Jan 9, 2025

The first changeset, "Update module maps", is the subject of a separate PR.

@ahoppen ahoppen removed their request for review January 9, 2025 13:08
@al45tair
Copy link
Contributor Author

al45tair commented Jan 9, 2025

Hmmm. Looks like maybe my change to add swift-backtrace as an explicit dependency in test/CMakeLists.txt was incorrect.

Now that Darwin is provided by the system, we no longer need to disable the
system module maps in favour of our own, which also resolves a few other
problems that doing that was creating.

rdar://137201928
We're going to rename the module to Runtime, and it isn't going to be an
implicit import, so we don't need any of this.

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
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
…String`s.

We already try using `CFStringGetCStringPtr` to see if we can get ASCII;
we should also try `CFStringGetCharactersPtr` as the native encoding of
`CFNSString` is very often UTF-16.  While we're at it, try asking explicitly
for UTF-8 as well.  That won't work for `CFNSString` because AFAIK it's
currently never encoded that way, but it might work if something hands us
a Swift-backed string or if some future implementation of `CFString`
happens to support UTF-8 encoded data.

rdar://124913332
The Runtime module is using C++ interop, which doesn't seem to play nicely
with MemberImportVisibility.

rdar://124913332
This lets us repeat a frame over and over; it only works for a single
frame, but that's the common case for infinite recursions.

rdar://124913332
Add support for Codable to Bactkrace.

rdar://124913332
Because it's a target executable, the name of the dependency is suffixed
with the SDK.

rdar://124913332
@al45tair
Copy link
Contributor Author

al45tair commented Jan 9, 2025

@swift-ci Please test

@rintaro rintaro removed their request for review January 9, 2025 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant