Skip to content

Commit 164b453

Browse files
committed
Rename DebuggerExecution to Debugger, hide behind a trait
1 parent a5d0b1d commit 164b453

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

Sources/WasmKit/Execution/Debugging.swift renamed to Sources/WasmKit/Execution/Debugger.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
package struct DebuggerExecution: ~Copyable {
1+
#if WasmDebuggingSupport
2+
3+
package struct Debugger: ~Copyable {
24
let valueStack: Sp
35
let execution: Execution
46
let store: Store
@@ -22,3 +24,5 @@ package struct DebuggerExecution: ~Copyable {
2224
valueStack.deallocate()
2325
}
2426
}
27+
28+
#endif

Sources/WasmKitGDBHandler/WasmKitGDBHandler.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if WasmDebuggingSupport
2+
13
import GDBRemoteProtocol
24
import Logging
35
import NIOCore
@@ -30,7 +32,7 @@ package actor WasmKitGDBHandler {
3032
private let module: Module
3133
private let moduleFilePath: FilePath
3234
private let logger: Logger
33-
private let debuggerExecution: DebuggerExecution
35+
private let debugger: Debugger
3436
private let instance: Instance
3537
private let entrypointFunction: Function
3638
private let functionsRLE: [(wasmAddress: Int, iSeqAddress: Int)] = []
@@ -45,7 +47,7 @@ package actor WasmKitGDBHandler {
4547
self.module = try parseWasm(bytes: .init(buffer: self.wasmBinary))
4648
self.moduleFilePath = moduleFilePath
4749
let store = Store(engine: Engine())
48-
self.debuggerExecution = DebuggerExecution(store: store)
50+
self.debugger = Debugger(store: store)
4951

5052
var imports = Imports()
5153
let wasi = try WASIBridgeToHost()
@@ -150,7 +152,7 @@ package actor WasmKitGDBHandler {
150152
var length = Int(hexEncoded: argumentsArray[1])
151153
else { throw Error.unknownReadMemoryArguments }
152154

153-
let binaryOffset = Int(address - 0x4000_0000_0000_0000)
155+
let binaryOffset = Int(address - 0x4000000000000000)
154156

155157
if binaryOffset + length > wasmBinary.readableBytes {
156158
length = wasmBinary.readableBytes - binaryOffset
@@ -159,7 +161,7 @@ package actor WasmKitGDBHandler {
159161
responseKind = .hexEncodedBinary(wasmBinary.readableBytesView[binaryOffset..<(binaryOffset + length)])
160162

161163
case .wasmCallStack:
162-
print(self.debuggerExecution.captureBacktrace())
164+
print(self.debugger.captureBacktrace())
163165
responseKind = .empty
164166

165167
case .generalRegisters:
@@ -172,3 +174,5 @@ package actor WasmKitGDBHandler {
172174
}
173175

174176
}
177+
178+
#endif

Sources/wasmkit-gdb-tool/Entrypoint.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ struct Entrypoint: AsyncParsableCommand {
4040
var wasmModulePath: FilePath
4141

4242
func run() async throws {
43+
#if WasmDebuggingSupport
4344
let logger = {
4445
var result = Logger(label: "org.swiftwasm.WasmKit")
4546
result.logLevel = self.logLevel
@@ -102,5 +103,8 @@ struct Entrypoint: AsyncParsableCommand {
102103
}
103104
}
104105
}
106+
#else
107+
fatalError("Build WasmKit with `WasmDebuggingSupport` trait")
108+
#endif
105109
}
106110
}

0 commit comments

Comments
 (0)