-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[tool] Implement initial support for swift-inspect
under Linux 64-bit
#63576
base: main
Are you sure you want to change the base?
[tool] Implement initial support for swift-inspect
under Linux 64-bit
#63576
Conversation
@swift-ci smoke test |
The external package dependency is a bit problematic I guess... What do you think @mikeash ? The actual goal here is to implement this all "in swift itself"... though that leaves me wondering what to do with this PR, perhaps we can view it as an incremental step 🤔 |
Oh, this looks sweet. I'm OK with doing whatever we need to get an initial version running on Linux, and we can refine it over time. If the initial version involves an external dependency you build manually, that's fine, it'll be way easier to eventually transition that to having everything built in. @al45tair this is relevant to your interests as well. |
:-) Making it work on Linux is/was on my TODO list. Probably without the external dependency though. |
My initial goal was to implement the Linux support within the However, the implementation of One future direction I've been thinking about is hooking at the |
My understanding is that internal layout of glibc's memory allocator is well documented, so I think we probably would accept code that walked that, particularly in What's "the issue with |
For the sake of this discussion, the chunks could be divided into two kinds:
I have therefore decided to ignore
It is unfortunately not that easy. For example, some pointers are obfuscated. Also, the documentation talks about Thread Local Cache (tcache), but locating the I'm not trying to convince you to reject this Pull Request :) (it took me a lot of free time to self-study and implement this :) ). But at the same time, I don't feel confident proposing to "merge" |
Adding a reference to radar rdar:https://107360568 |
swift-inspect
swift-inspect
is a tool inapple/swift
that allows users to debug Swift programs by dumping various information. Theswift-inspect
usesSwiftRemoteMirror
. It is available on macOS and Windows.This Pull Request
This Pull Request adds an initial support for Linux, specifically for x86-64 architecture. Since the
swift-inspect
requires the ability to enumerate heap and such functionality is not natively available inGlibc
, this functionality is provided by stand-alone tool calledmemtool
.memtool
The
memtool
is a Swift Package created and maintained by the creator of this Pull Request. It usesptrace
andbash
in order to provideswift-inspect
with all the information it requires.Since
memtool
is not maintained by Swift maintainers, I have decided against using it as a Swift Package dependency. Users are expected to read README, where thememtool
is linked, and advised to review thememtool
before downloading or executing it.Related discussions
https://forums.swift.org/t/building-swift-inspect-on-linux/56858
https://forums.swift.org/t/tool-for-analyzing-heap-of-linux-glibc-swift-process-in-swift/62017
https://forums.swift.org/t/is-there-a-way-to-differentiate-swift-types-and-c-types-at-runtime/61950