-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[RemoteMirror][swift-inspect] Add a command to inspect the state of the concurrency runtime. #41160
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
Conversation
Here's an example of what this tool prints: https://gist.github.com/mikeash/80750c2f26ee13e5e60fdbc65da2c8c1 |
This is AMAZING. It's going to be our best favoritist debugging tool for concurrency runtime issues. |
@swift-ci please test |
Build failed |
fb9550c
to
fea6767
Compare
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of little things to look at, but looking good.
tools/swift-inspect/Sources/swift-inspect/DumpConcurrency.swift
Outdated
Show resolved
Hide resolved
tools/swift-inspect/Sources/swift-inspect/DumpConcurrency.swift
Outdated
Show resolved
Hide resolved
…he concurrency runtime. Most of the new inspection logic is in Remote Mirror. New code in swift-inspect calls the new Remote Mirror functions and formats the resulting information for display. Specific Remote Mirror changes: * Add a call to check if a given metadata is an actor. * Add calls to get information about actors and tasks. * Add a `readObj` call to MemoryReader that combines the read and the cast, greatly simplifying code chasing pointers in the remote process. * Add a generalized facility to the C shims that can allocate a temporary object that remains valid until at least the next call, which is used to return various temporary arrays from the new calls. Remove the existing `lastString` and `lastChunks` member variables in favor of this new facility. Swift-inspect changes: * Add a new dump-concurrency command. * Add a new `ConcurrencyDumper.swift` file with the implementation. The dumper needs to do some additional work with the results from Remote Mirror to build up the task tree and this keeps it all organized. * Extend `Inspector` to query the target's threads and fetch each thread's current task. Concurrency runtime changes: * Add `_swift_concurrency_debug` variables pointing to the various future adapters. Remote Mirror uses these to provide a better view of a tasks's resume pointer. rdar://85231338
fea6767
to
a82ea12
Compare
@al45tair Thanks much for the review, pushed fixes now. |
@swift-ci please smoke test |
Most of the new inspection logic is in Remote Mirror. New code in swift-inspect calls the new Remote Mirror functions and formats the resulting information for display.
Specific Remote Mirror changes:
readObj
call to MemoryReader that combines the read and the cast, greatly simplifying code chasing pointers in the remote process.lastString
andlastChunks
member variables in favor of this new facility.Swift-inspect changes:
ConcurrencyDumper.swift
file with the implementation. The dumper needs to do some additional work with the results from Remote Mirror to build up the task tree and this keeps it all organized.Inspector
to query the target's threads and fetch each thread's current task.Concurrency runtime changes:
_swift_concurrency_debug
variables pointing to the various future adapters. Remote Mirror uses these to provide a better view of a tasks's resume pointer.A note on testing: I've been testing this manually. Automatic tests are difficult because the remote process inspection calls require root. I plan to work around this by having a
swift-inspect
mode that can inspect itself without root, either using the current calls (which may be able to inspect the current process without special privileges) or having a separate implemenattion ofInspector
that uses in-process calls. That's going to be a bunch more work, though, so I'll do that in a separate PR afterwards.rdar://88493833