Commit Graph

115 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Saleem Abdulrasool
53f16be795 Merge pull request #78125 from andrurogerz/swift-inspect-windows
[swift-inspect] incorrect error logged by `swift-inspect dump-arrays` on Windows
2024-12-16 14:18:39 -08:00
Andrew Rogers
627f7876b5 PR feedback in ElfFile.init 2024-12-16 13:49:05 -08:00
Andrew Rogers
b12188296f use memory-mapped IO instead of file reads 2024-12-16 12:54:18 -08:00
Andrew Rogers
b7dff4232e PR feedback 2024-12-16 11:41:00 -08:00
Andrew Rogers
f6b1fca949 [swift-inspect] remove default RemoteProcess.Free property 2024-12-12 10:51:39 -08:00
Andrew Rogers
c6e34bf92a PR feedback 2024-12-12 08:37:18 -08:00
Andrew Rogers
76c2719e47 Update tools/swift-inspect/Sources/swift-inspect/WindowsRemoteProcess.swift
Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
2024-12-11 16:01:18 -08:00
Andrew Rogers
f9db32c292 [swift-inspect] stop leaking memory in Windows heap iteration 2024-12-11 15:47:16 -08:00
Andrew Rogers
1ce1956d8a [swift-inspect] FreeLibrary returns 0 on failure not success 2024-12-11 15:30:30 -08:00
Andrew Rogers
3aef500131 formatting fixes and missed copyright date updates 2024-12-10 10:34:18 -08:00
Andrew Rogers
61f6b0e704 PR Feedback: make ProcFS an enum instead of a class 2024-12-05 09:57:57 -08:00
Andrew Rogers
f669299572 properly override the Free property in LinuxRemoteProcess 2024-12-05 09:57:46 -08:00
Andrew Rogers
278f90cf93 PR feedback: fix typo 2024-12-04 13:52:03 -08:00
Andrew Rogers
e702be9cdc PR feedback: rework error definitions 2024-12-04 13:50:34 -08:00
Andrew Rogers
6e466c44e1 minimize ELF parsing support to ELF64 only 2024-12-04 13:10:56 -08:00