Skip to content

[Backtracing] Implement API per SE-0419 #78516

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

Merged
merged 17 commits into from
Jan 28, 2025

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.

@al45tair al45tair force-pushed the eng/PR-124913332 branch 2 times, most recently from 468f648 to 01e2468 Compare January 9, 2025 16:27
@rintaro rintaro removed their request for review January 9, 2025 23:11
@al45tair
Copy link
Contributor Author

@swift-ci Please test

@al45tair al45tair force-pushed the eng/PR-124913332 branch 3 times, most recently from 7a1fdfc to e360d99 Compare January 16, 2025 15:43
@al45tair
Copy link
Contributor Author

@swift-ci Please test

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
@al45tair
Copy link
Contributor Author

@swift-ci Please test

Remove a `-disable-implicit-backtracing-module-import` that was added
in `Runtimes/Core/CMakeLists.txt`, and also remove the reference to
`swiftCxxStdlib` from `RuntimeModule` as that causes the build to fail
when attempting to build the static version of `swift-backtrace` on
Linux.

rdar://124913332
@al45tair
Copy link
Contributor Author

@swift-ci Please test

1 similar comment
@al45tair
Copy link
Contributor Author

@swift-ci Please test

We needed to add `--enable-runtime-module` in the Python test scripts.

rdar://124913332
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
@al45tair
Copy link
Contributor Author

@swift-ci Please test

@al45tair
Copy link
Contributor Author

This is still going to break because of the -disable-implicit-backtracing-import problem (since that's coming from other repos), but let's see how far we get otherwise.

@al45tair
Copy link
Contributor Author

@swift-ci Please test

If this test fails in CI, we could do with being able to see the
output from the test program in full.

rdar://124913332
@al45tair
Copy link
Contributor Author

@swift-ci Please test

If we ended up with a `/` at the beginning of a string segment, we
were erroneously not adding to the expansion dictionary when we
should have been.

rdar://124913332
@al45tair
Copy link
Contributor Author

@swift-ci Please test

We only want to add the `swift-backtrace` binary dependency when the
SDK we're looking at actually has `swift-backtrace` enabled.

rdar://124913332
@al45tair
Copy link
Contributor Author

@swift-ci Please test

@al45tair al45tair requested a review from weissi January 24, 2025 10:54
It's useful to capture the platform and platform version with the image map.
Also, display both the platform and architecture information when generating
a crash log.

rdar://124913332
Added some explanatory text to the Compact Backtrace Format
documentation, and also to the `CMakeLists.txt` for the runtime.

Tweaked the conversions for `Backtrace.Address` to truncate, which
should result in reasonable behaviour for negative fixed-width
integers.

Use a constant for the ASCII values for `/` and `\` in the Compact
Image Format encoder/decoder.

Make the TSD key for `ElfImageCache` non-optional, and call
`fatalError()` if we don't get one.

rdar://124913332
@al45tair
Copy link
Contributor Author

@swift-ci Please test

Copy link
Contributor

@edymtt edymtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me regarding the build system changes.

@al45tair al45tair merged commit ab8e561 into swiftlang:main Jan 28, 2025
5 checks passed
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.

4 participants