-
Notifications
You must be signed in to change notification settings - Fork 19
Basic GDB remote protocol scaffolding #204
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
Draft
MaxDesiatov
wants to merge
16
commits into
main
Choose a base branch
from
maxd/lldb-remote-protocol
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c5a5b35
Basic LLDB remote protocol scaffolding
MaxDesiatov f89a842
Implement more packet handling, update naming
MaxDesiatov 3601dae
Provide original license notice in `wasmkit-gdb-tool/Entrypoint.swift`
MaxDesiatov 7439bb7
Apply formatter
MaxDesiatov a94257c
Make naming of types more specific to avoid future collisions
MaxDesiatov c652f64
More cleanups for type naming
MaxDesiatov 6395039
Remove unused `import struct Foundation.Date`
MaxDesiatov c6ea692
Remove unused `else` clause from command decoder
MaxDesiatov 2b74e4a
Add `swift-nio` in `SWIFTCI_USE_LOCAL_DEPS` clause
MaxDesiatov 0b8c293
Add FIXME note for `.supportedFeatures` response
MaxDesiatov 6cdf164
Use `Logger`, `NIOAsyncChannel`
MaxDesiatov 345ddb3
Add required dependencies to `[email protected]`
MaxDesiatov 1309bae
Add `iSeqToWasmMapping` to `InstanceEntity`
MaxDesiatov 4f17bf5
Fix formatting and iOS compatibility
MaxDesiatov b1f54cd
Update [email protected]
MaxDesiatov 838381d
Update doc comment of `func instantiate` in `Module.swift`
MaxDesiatov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
// swift-tools-version:6.1 | ||
|
||
import PackageDescription | ||
|
||
import class Foundation.ProcessInfo | ||
|
||
let DarwinPlatforms: [Platform] = [.macOS, .iOS, .watchOS, .tvOS, .visionOS] | ||
|
||
let package = Package( | ||
name: "WasmKit", | ||
platforms: [.macOS(.v14), .iOS(.v17)], | ||
products: [ | ||
.executable(name: "wasmkit-cli", targets: ["CLI"]), | ||
.library(name: "WasmKit", targets: ["WasmKit"]), | ||
.library(name: "WasmKitWASI", targets: ["WasmKitWASI"]), | ||
.library(name: "WASI", targets: ["WASI"]), | ||
.library(name: "WasmParser", targets: ["WasmParser"]), | ||
.library(name: "WAT", targets: ["WAT"]), | ||
.library(name: "WIT", targets: ["WIT"]), | ||
.library(name: "_CabiShims", targets: ["_CabiShims"]), | ||
], | ||
traits: [ | ||
.default(enabledTraits: []), | ||
"WasmDebuggingSupport" | ||
], | ||
targets: [ | ||
.executableTarget( | ||
name: "CLI", | ||
dependencies: [ | ||
"WAT", | ||
"WasmKit", | ||
"WasmKitWASI", | ||
.product(name: "ArgumentParser", package: "swift-argument-parser"), | ||
.product(name: "SystemPackage", package: "swift-system"), | ||
], | ||
exclude: ["CMakeLists.txt"] | ||
), | ||
|
||
.target( | ||
name: "WasmKit", | ||
dependencies: [ | ||
"_CWasmKit", | ||
"WasmParser", | ||
"WasmTypes", | ||
"SystemExtras", | ||
.product(name: "SystemPackage", package: "swift-system"), | ||
], | ||
exclude: ["CMakeLists.txt"] | ||
), | ||
.target(name: "_CWasmKit"), | ||
.target( | ||
name: "WasmKitFuzzing", | ||
dependencies: ["WasmKit"], | ||
path: "FuzzTesting/Sources/WasmKitFuzzing" | ||
), | ||
.testTarget( | ||
name: "WasmKitTests", | ||
dependencies: ["WasmKit", "WAT", "WasmKitFuzzing"], | ||
exclude: ["ExtraSuite"] | ||
), | ||
|
||
.target( | ||
name: "WAT", | ||
dependencies: ["WasmParser"], | ||
exclude: ["CMakeLists.txt"] | ||
), | ||
.testTarget(name: "WATTests", dependencies: ["WAT"]), | ||
|
||
.target( | ||
name: "WasmParser", | ||
dependencies: [ | ||
"WasmTypes", | ||
.product(name: "SystemPackage", package: "swift-system"), | ||
], | ||
exclude: ["CMakeLists.txt"] | ||
), | ||
.testTarget(name: "WasmParserTests", dependencies: ["WasmParser"]), | ||
|
||
.target(name: "WasmTypes", exclude: ["CMakeLists.txt"]), | ||
|
||
.target( | ||
name: "WasmKitWASI", | ||
dependencies: ["WasmKit", "WASI"], | ||
exclude: ["CMakeLists.txt"] | ||
), | ||
.target( | ||
name: "WASI", | ||
dependencies: ["WasmTypes", "SystemExtras"], | ||
exclude: ["CMakeLists.txt"] | ||
), | ||
.testTarget(name: "WASITests", dependencies: ["WASI", "WasmKitWASI"]), | ||
|
||
.target( | ||
name: "SystemExtras", | ||
dependencies: [ | ||
.product(name: "SystemPackage", package: "swift-system") | ||
], | ||
exclude: ["CMakeLists.txt"], | ||
swiftSettings: [ | ||
.define("SYSTEM_PACKAGE_DARWIN", .when(platforms: DarwinPlatforms)) | ||
] | ||
), | ||
|
||
.executableTarget( | ||
name: "WITTool", | ||
dependencies: [ | ||
"WIT", | ||
"WITOverlayGenerator", | ||
"WITExtractor", | ||
.product(name: "ArgumentParser", package: "swift-argument-parser"), | ||
] | ||
), | ||
|
||
.target(name: "WIT"), | ||
.testTarget(name: "WITTests", dependencies: ["WIT"]), | ||
|
||
.target(name: "WITOverlayGenerator", dependencies: ["WIT"]), | ||
.target(name: "_CabiShims"), | ||
|
||
.target(name: "WITExtractor"), | ||
.testTarget(name: "WITExtractorTests", dependencies: ["WITExtractor", "WIT"]), | ||
|
||
.target(name: "GDBRemoteProtocol", | ||
dependencies: [ | ||
.product(name: "Logging", package: "swift-log"), | ||
.product(name: "NIOCore", package: "swift-nio"), | ||
] | ||
), | ||
.testTarget(name: "GDBRemoteProtocolTests", dependencies: ["GDBRemoteProtocol"]), | ||
|
||
.target( | ||
name: "WasmKitGDBHandler", | ||
dependencies: [ | ||
.product(name: "NIOCore", package: "swift-nio"), | ||
.product(name: "SystemPackage", package: "swift-system"), | ||
"WasmKit", | ||
"GDBRemoteProtocol", | ||
], | ||
), | ||
|
||
.executableTarget( | ||
name: "wasmkit-gdb-tool", | ||
dependencies: [ | ||
.product(name: "ArgumentParser", package: "swift-argument-parser"), | ||
.product(name: "Logging", package: "swift-log"), | ||
.product(name: "NIOCore", package: "swift-nio"), | ||
.product(name: "NIOPosix", package: "swift-nio"), | ||
.product(name: "SystemPackage", package: "swift-system"), | ||
"GDBRemoteProtocol", | ||
"WasmKitGDBHandler", | ||
] | ||
), | ||
], | ||
) | ||
|
||
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { | ||
package.dependencies += [ | ||
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.1"), | ||
.package(url: "https://github.com/apple/swift-system", from: "1.5.0"), | ||
.package(url: "https://github.com/apple/swift-nio", from: "2.86.2"), | ||
.package(url: "https://github.com/apple/swift-log", from: "1.6.4"), | ||
] | ||
} else { | ||
package.dependencies += [ | ||
.package(path: "../swift-argument-parser"), | ||
.package(path: "../swift-system"), | ||
MaxDesiatov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.package(path: "../swift-nio"), | ||
.package(path: "../swift-log"), | ||
] | ||
} | ||
|
||
#if !os(Windows) | ||
// Add build tool plugins only for non-Windows platforms | ||
package.products.append(contentsOf: [ | ||
.plugin(name: "WITOverlayPlugin", targets: ["WITOverlayPlugin"]), | ||
.plugin(name: "WITExtractorPlugin", targets: ["WITExtractorPlugin"]), | ||
]) | ||
|
||
package.targets.append(contentsOf: [ | ||
.plugin(name: "WITOverlayPlugin", capability: .buildTool(), dependencies: ["WITTool"]), | ||
.plugin(name: "GenerateOverlayForTesting", capability: .buildTool(), dependencies: ["WITTool"]), | ||
.testTarget( | ||
name: "WITOverlayGeneratorTests", | ||
dependencies: ["WITOverlayGenerator", "WasmKit", "WasmKitWASI"], | ||
exclude: ["Fixtures", "Compiled", "Generated", "EmbeddedSupport"], | ||
plugins: [.plugin(name: "GenerateOverlayForTesting")] | ||
), | ||
.plugin( | ||
name: "WITExtractorPlugin", | ||
capability: .command( | ||
intent: .custom(verb: "extract-wit", description: "Extract WIT definition from Swift module"), | ||
permissions: [] | ||
), | ||
dependencies: ["WITTool"] | ||
), | ||
.testTarget( | ||
name: "WITExtractorPluginTests", | ||
exclude: ["Fixtures"] | ||
), | ||
]) | ||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/// See GDB and LLDB remote protocol documentation for more details: | ||
/// * https://sourceware.org/gdb/current/onlinedocs/gdb.html/General-Query-Packets.html | ||
/// * https://lldb.llvm.org/resources/lldbgdbremote.html | ||
package struct GDBHostCommand: Equatable { | ||
package enum Kind: String, Equatable { | ||
// Currently listed in the order that LLDB sends them in. | ||
case startNoAckMode | ||
case supportedFeatures | ||
case isThreadSuffixSupported | ||
case listThreadsInStopReply | ||
case hostInfo | ||
case vContSupportedActions | ||
case isVAttachOrWaitSupported | ||
case enableErrorStrings | ||
case processInfo | ||
case currentThreadID | ||
case firstThreadInfo | ||
case subsequentThreadInfo | ||
|
||
case generalRegisters | ||
|
||
package init?(rawValue: String) { | ||
switch rawValue { | ||
case "g": | ||
self = .generalRegisters | ||
case "QStartNoAckMode": | ||
self = .startNoAckMode | ||
case "qSupported": | ||
self = .supportedFeatures | ||
case "QThreadSuffixSupported": | ||
self = .isThreadSuffixSupported | ||
case "QListThreadsInStopReply": | ||
self = .listThreadsInStopReply | ||
case "qHostInfo": | ||
self = .hostInfo | ||
case "vCont?": | ||
self = .vContSupportedActions | ||
case "qVAttachOrWaitSupported": | ||
self = .isVAttachOrWaitSupported | ||
case "QEnableErrorStrings": | ||
self = .enableErrorStrings | ||
case "qProcessInfo": | ||
self = .processInfo | ||
case "qC": | ||
self = .currentThreadID | ||
case "qfThreadInfo": | ||
self = .firstThreadInfo | ||
case "qsThreadInfo": | ||
self = .subsequentThreadInfo | ||
default: | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
package let kind: Kind | ||
|
||
package let arguments: String | ||
|
||
package init(kind: Kind, arguments: String) { | ||
self.kind = kind | ||
self.arguments = arguments | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Added separate
Package.swift
manifest to hide debugger support behind a trait for now, and traits aren't supported in 6.0.