This addition will allow us to cross-compile swift-inspect to Windows
ARM64. Enabling the Windows ARM64 build permits the toolchain to become
more similar across the architectures.
Various processes, such as launchd, are unsafe to inspect directly. Inspecting them pauses them and the system does not like it when they're paused. Forking a corpse avoids this, as the original process continues running while we inspect the forked corpse.
VMUProcInfo provides a shouldAnalyzeWithCorpse call which tells us whether we're inspecting one of those processes. When we are, then we force the forkCorpse option even when it's not specified.
Add shims to Symbolication+Extensions.swift to allow calls to VMUProcInfo and use it to force forkCorpse when appropriate.
rdar://124720793
After the C standard library headers are split out of Darwin, DumpConcurrency.swift no longer sees string.h. Explicitly import <string.h>'s new module when it's available.
rdar://127076885
This was briefly failing to build because of an ambiguous initializer
while making other changes, it's better to be explicit with method names
anyway.
rdar://127548384
Add some vertical whitespace to the code ejection process. Alter the
logic to clean up the memory allocation first, ignoring the error as the
subsequent run will perform a new allocation and this will leak a fixed
amount of memory without interrupting the process or use of the tool.
No longer check the exit code of the thread as that is always guaranteed
to be 0 as the module unloading path does not report any error code in
the injected code (DLL).
Use the opportunity to do some simple renaming to improve the
readability and create an overload for avoiding unnecessary ceremony
around use of a shared constant.
Redo Mike's changes which were reverted: Convert integers to to `swift_reflection_ptr_t` instead of `UInt64` since watchOS uses `UInt` as its pointer type.
rdar://118458631
With this change swift-inspect can inspect all processes to see if metadata allocation iteration is enabled. We also added summary option that sorts metadata to popularity.
With this change we make --json flag to toggle between JSON and text output. If --output-file option is given, then the output stream is forwarded to the file specified.
If the `SWIFTCI_USE_LOCAL_DEPS` environment variable is set, we're building in the Swift.org CI system alongside other projects in the Swift toolchain and we can depend on local versions of our dependencies instead of fetching them remotely.
This allows an ARM64 swift-inspect to correctly read from an ARM64e target process. We compute a ptrauth mask by stripping all bits above MACH_VM_MAX_ADDRESS. This strips more than we strictly need, but it works.
If we encounter bad data in the target, we could end up trying to print an infinite list of jobs. Clamp it to 1,000 so we fail more gracefully.
rdar://113417637
Update the version of swift-argument-parser used by swift-inspect to
be compatible with the package description version.
Add compiler flags for a LLVM bug workaround.
We would previously fail to eject the injected code on a failure. This
would prevent a future introspection into the process as well as leave
the file open with an incremented retain count in the kernel space which
would prevent the file from being deleted.
In the future, when the application is able to treat the injected code
as a resource, this resource would be temporarily extracted, but would
no longer be possible to delete until a reboot (with a registration of
the deletion) due to the retained code.
Take the opportunity to rename some functions to take advantage of
labelled parameters and trailing function syntax. This makes the code a
small amount easier to read.
Clean up the incorrect memory binding in swift-inspect introduced in
PR#66973. This fixes the incorrect memory usage to mutate the `context`
parameter.