Commit Graph

146 Commits

Author SHA1 Message Date
Mike Ash
3869cb50ea Fix integer type mismatches in swift-inspect when building 32-bit. 2025-10-07 14:00:01 -04:00
Mike Ash
513f5fb17a [swift-inspect] Add a mode to search for and dump generic metadata without metadata iteration enabled.
We scan the target's initial allocation pool, and all 16kB heap allocations. We check each pointer-aligned offset within those areas, and try to read it as Swift metadata and get a name from it. If that fails, quietly move on. It's very unlikely for some random memory to look enough like Swift metadata for this to produce a name, so this works very well to print the generic metadata instantiated in the remote process without requiring `SWIFT_DEBUG_ENABLE_METADATA_ALLOCATION_ITERATION`.

rdar://161120936
2025-09-26 10:52:35 -04:00
Mike Ash
0ed232aff0 Merge pull request #81457 from mikeash/swift-inspect-corpse-leak
[swift-inspect] Fix corpse leaks when target doesn't have libswiftCore loaded.
2025-05-16 18:29:12 -04:00
Mike Ash
9671d6b37c [swift-inspect] Fix corpse leaks when target doesn't have libswiftCore loaded.
In DarwinRemoteProcess's early return when libswiftCore.dylib isn't loaded in the process, we hadn't initialized all stored properties yet, which means our deinit didn't run. This leaked the task. This is especially bad when forking a corpse, as the system has a very limited number of corpses available.

Add a Cleanup helper to manage resources that need explicit cleanup. This is a noncopyable struct which takes a cleanup function and calls it whenever a new value is set or when the struct is destroyed. Use this for the DarwinRemoteProcess properties that need explicit cleanup. This allows us to remove DarwinRemoteProcess's deinit and always run these cleanups regardless of how we exit the initializer.

While we're here, fix the truncations of buffer in getAllProcesses.

rdar://151170155
2025-05-13 13:53:14 -04:00
Jabryl Guy
b9fa070c63 [swift-inspect] Add json and summary options to DumpRawMetadata 2025-04-29 16:03:20 -07:00
Saleem Abdulrasool
0b953adb44 SwiftInspectLinux: re-order initialization
It seems that a recent change to the compiler will now optimize the
initializer and then the SIL verifier will fail due to the unintialized
member when the initializer is throwing and will never return without
initializing the member unless the initialization fails.
2025-04-22 11:15:14 -07:00
Dave Lee
115b2b7bcb [swift-inspect] Use decimal format for Task ID (#80309)
Use decimal to display Task IDs. This matches changes being done else where to use decimal consistently for Task IDs. For example https://github.com/swiftlang/swift/pull/80154 and https://github.com/swiftlang/llvm-project/pull/10308.
2025-03-27 12:39:19 -07:00
Konrad `ktoso` Malawski
92ead521b8 [Concurrency] Fix swift-inspect and remote mirror build (#79715) 2025-03-04 07:04:42 +09:00
Konrad `ktoso` Malawski
f55964df26 [Concurrency] Initial steps for startSynchronously for Task (#79608)
* [Concurrency] Initial steps for startSynchronously for Task

* [Concurrency] Rename to _startSynchronously while in development

* [Concurrency] StartSynchronously special executor to avoid switching

* startSynchronously bring back more info output

* [Concurrency] startSynchronously with more custom executor tests

* add missing ABI additions to test for x86

* [Concurrency] gyb generate _startSynchronously

* [Concurrency] %import dispatch for Linux startSynchronously test

* [Concurrency] Add TaskGroup.startTaskSynchronously funcs

* [Concurrency] DispatchSerialQueue does not exist on linux still
2025-02-27 02:34:33 -08:00
Mike Ash
b3a430d175 [swift-inspect] On Darwin, don't try to inspect processes that don't have Swift.
When we locate libswiftCore.dylib in the remote process, check for failure and give up immediately if we don't find one. If the process doesn't have Swift, there's no point in trying to inspect anything in it.

rdar://143978694
2025-02-24 14:37:43 -05:00
Saleem Abdulrasool
18fa490721 Merge pull request #78827 from andrurogerz/swift-inspect-cmake
[swift-inspect] use CMake FetchContent to fetch ArgumentParser when not provided
2025-01-28 14:40:34 -08:00
Andrew Rogers
92dea69b7e [swift-inspect] build swift-argument-parser as shared lib when fetched remotely 2025-01-22 15:53:07 -08:00
Andrew Rogers
7b1c4dc461 [swift-inspect] clarify CMake use block() to scope ArgumentParser properties 2025-01-22 15:20:23 -08:00
Saleem Abdulrasool
c9019d6a9c swift-inspect: mark some conformances as retroactive
This silences a couple of warnings in the swift-inspect build.
2025-01-22 15:17:12 -08:00
Andrew Rogers
b0bae6355b [swift-inspect] clarify CMake properties set for ArgumentParser 2025-01-22 14:52:07 -08:00
Andrew Rogers
ba9be84a8a [swift-inspect] update CMake documentation 2025-01-22 14:50:40 -08:00
Andrew Rogers
9792a07b66 [swift-inspect] bump swift-argument-parser version to 1.5.0 2025-01-22 14:30:23 -08:00
Andrew Rogers
509a07767b [swift-inspect] use FetchContent to fetch ArgumentParser in CMake build 2025-01-22 14:29:50 -08:00
Andrew Rogers
f2649f20c8 PR Feedback: make PTrace.init fileprivate 2025-01-15 10:55:31 -08:00
Andrew Rogers
6381de4434 PR feedback: fix incorrect comment 2025-01-15 10:55:12 -08:00
Andrew Rogers
4a9087c950 update Android build command in README.md for newst Swift Android SDK 2025-01-14 15:45:43 -08:00
Andrew Rogers
e6dc4596d6 remove custom linker script in favor of implicit section maker symbols 2025-01-13 10:27:46 -08:00
Andrew Rogers
a4a7384de4 add CMake build support for Android 2025-01-13 08:56:01 -08:00
Andrew Rogers
b997bdbf55 Define a new text section and use a linker script to safely calculating remote callback length 2025-01-13 08:56:01 -08:00
Andrew Rogers
5dd761a4f3 force 8-byte alignment on heap_iterate_callback_end 2025-01-08 13:36:37 -08:00
Andrew Rogers
21d139d24c missed a __volatile__ 2025-01-06 19:55:18 -08:00
Andrew Rogers
0ca4971113 Merge branch 'swift-inspect-android' of github.com:andrurogerz/swift into swift-inspect-android 2025-01-06 19:45:53 -08:00
Andrew Rogers
61cb0c3bcc PR Feedback 2025-01-06 19:45:36 -08:00
Andrew Rogers
5cc83ccd88 Merge branch 'main' into swift-inspect-android 2025-01-06 13:40:26 -08:00
Andrew Rogers
9604994645 PR Feedback: make PTrace a non-copyable struct 2025-01-06 13:09:41 -08:00
Andrew Rogers
5488f2fa88 PR Feedback: improve PTrace implementation 2025-01-06 12:46:39 -08:00
Andrew Rogers
48d62378d0 PR Feedback: use __builtin_debugtrap and safe function size calculation 2025-01-06 11:03:36 -08:00
Andrew Rogers
7b10cc88e4 PR feedback: README.md updates 2025-01-06 07:57:58 -08:00
Andrew Rogers
b73c54b645 PR feedback: CMakeLists.txt improvements 2024-12-18 14:07:14 -08:00
Andrew Rogers
4018056a58 [swift-inspect] update README.md for Linux CMake build 2024-12-18 13:45:42 -08:00
Andrew Rogers
5b4b86e038 [swift-inspect] support CMake build for Linux 2024-12-18 13:21:26 -08:00
Andrew Rogers
d965cc6612 [swift-inspect] add #pragma once to system header wrappers 2024-12-18 13:20:44 -08:00
Andrew Rogers
9fdd46f3fb refactor remote function calls to their own methods 2024-12-18 11:51:08 -08:00
Andrew Rogers
c0257d8f53 add missing copyright header to RegisterSet.swift 2024-12-18 11:51:08 -08:00
Andrew Rogers
03dae5d175 [swift-inspect] minor cleanup and documentation 2024-12-18 11:51:08 -08:00
Andrew Rogers
0a436ba32f [swift-inspect] minor cleanup 2024-12-18 11:51:08 -08:00
Andrew Rogers
ac3fec1abe [swift-inspect] move Android-specific memory region naming to Android
class
2024-12-18 11:51:08 -08:00
Andrew Rogers
25da1a9a18 [swift-inspect] use malloc_disable/malloc_enable when iterating the heap
on Android
2024-12-18 11:51:08 -08:00
Andrew Rogers
714ce52eeb [swift-inspect] indent RegisterSet.swift 2024-12-18 11:51:08 -08:00
Andrew Rogers
21ea119121 [swift-inspect] fix Android README.md 2024-12-18 11:51:07 -08:00
Andrew Rogers
d7e8c74616 [swift-inspect] add ptrace retries 2024-12-18 11:51:07 -08:00
Andrew Rogers
43c9623d2c [swift-inspect] misc cleanup 2024-12-18 11:51:07 -08:00
Andrew Rogers
e90f5c5d4b [swift-inspect] refactor heap iteration 2024-12-18 11:51:07 -08:00
Andrew Rogers
f981f35fb5 [swift-inspect] full Android implementation including heap iteration 2024-12-18 11:51:07 -08:00
Saleem Abdulrasool
ea000d6edf Merge pull request #77938 from andrurogerz/swift-inspect-linux
[swift-inspect] implement basic GNU/Linux support
2024-12-18 08:29:12 -08:00