Skip to content

Commit a1d5183

Browse files
committed
Merge branch 'maxd/lldb-remote-protocol' of github.com:swiftwasm/WasmKit into maxd/debugging-breakpoints
2 parents f33dc82 + f6bab20 commit a1d5183

23 files changed

+97
-392
lines changed

[email protected]

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,6 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
178178
exclude: ["Fixtures"]
179179
),
180180

181-
.executableTarget(
182-
name: "wasmkit-gdb-tool",
183-
dependencies: [
184-
.product(name: "ArgumentParser", package: "swift-argument-parser"),
185-
.product(name: "Logging", package: "swift-log"),
186-
.product(name: "NIOCore", package: "swift-nio"),
187-
.product(name: "NIOPosix", package: "swift-nio"),
188-
.product(name: "SystemPackage", package: "swift-system"),
189-
"GDBRemoteProtocol",
190-
"WasmKitGDBHandler",
191-
]
192-
),
193-
194181
.target(
195182
name: "WasmKitGDBHandler",
196183
dependencies: [

Sources/GDBRemoteProtocol/GDBHostCommandDecoder.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
113
import Logging
214
import NIOCore
315

Sources/GDBRemoteProtocol/GDBTargetResponse.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
113
import NIOCore
214

315
/// Actions supported in the `vCont` host command.

Sources/GDBRemoteProtocol/GDBTargetResponseEncoder.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
113
import Foundation
214
import NIOCore
315

Sources/WAT/Encoder.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ extension TableType: WasmEncodable {
158158
struct ElementExprCollector: AnyInstructionVisitor {
159159
typealias Output = Void
160160

161-
var binaryOffset: Int = 0
162161
var isAllRefFunc: Bool = true
163162
var instructions: [Instruction] = []
164163

@@ -444,7 +443,6 @@ extension WatParser.DataSegmentDecl {
444443
}
445444

446445
struct ExpressionEncoder: BinaryInstructionEncoder {
447-
var binaryOffset: Int = 0
448446
var encoder = Encoder()
449447
var hasDataSegmentInstruction: Bool = false
450448

Sources/WAT/Parser/WastParser.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ struct WastParser {
5454
}
5555

5656
struct ConstExpressionCollector: WastConstInstructionVisitor {
57-
var binaryOffset: Int = 0
5857
let addValue: (Value) -> Void
5958

6059
mutating func visitI32Const(value: Int32) throws { addValue(.i32(UInt32(bitPattern: value))) }

Sources/WasmKit/Execution/Debugger.swift

Lines changed: 0 additions & 110 deletions
This file was deleted.

Sources/WasmKit/Execution/Errors.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@ import struct WasmParser.Import
55
/// The backtrace of the trap.
66
struct Backtrace: CustomStringConvertible, Sendable {
77
/// A symbol in the backtrace.
8-
struct Symbol: @unchecked Sendable {
8+
struct Symbol {
99
/// The name of the symbol.
1010
let name: String?
11-
let address: Pc
1211
}
1312

1413
/// The symbols in the backtrace.
15-
let symbols: [Symbol]
14+
let symbols: [Symbol?]
1615

1716
/// Textual description of the backtrace.
1817
var description: String {
19-
print("backtrace contains \(symbols.count) symbols")
20-
return symbols.enumerated().map { (index, symbol) in
21-
let name = symbol.name ?? "unknown"
22-
return " \(index): (\(symbol.address)) \(name)"
18+
symbols.enumerated().map { (index, symbol) in
19+
let name = symbol?.name ?? "unknown"
20+
return " \(index): \(name)"
2321
}.joined(separator: "\n")
2422
}
2523
}

Sources/WasmKit/Execution/Execution.swift

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import _CWasmKit
44
///
55
/// Each new invocation through exported function has a separate ``Execution``
66
/// even though the invocation happens during another invocation.
7-
struct Execution: ~Copyable {
7+
struct Execution {
88
/// The reference to the ``Store`` associated with the execution.
99
let store: StoreRef
1010
/// The end of the VM stack space.
@@ -14,13 +14,6 @@ struct Execution: ~Copyable {
1414
/// - Note: If the trap is set, it must be released manually.
1515
private var trap: (error: UnsafeRawPointer, sp: Sp)? = nil
1616

17-
#if WasmDebuggingSupport
18-
package init(store: StoreRef, stackEnd: UnsafeMutablePointer<StackSlot>) {
19-
self.store = store
20-
self.stackEnd = stackEnd
21-
}
22-
#endif
23-
2417
/// Executes the given closure with a new execution state associated with
2518
/// the given ``Store`` instance.
2619
static func with<T>(
@@ -68,15 +61,18 @@ struct Execution: ~Copyable {
6861

6962
static func captureBacktrace(sp: Sp, store: Store) -> Backtrace {
7063
var frames = FrameIterator(sp: sp)
71-
var symbols: [Backtrace.Symbol] = []
72-
64+
var symbols: [Backtrace.Symbol?] = []
7365
while let frame = frames.next() {
7466
guard let function = frame.function else {
75-
symbols.append(.init(name: nil, address: frame.pc))
67+
symbols.append(nil)
7668
continue
7769
}
7870
let symbolName = store.nameRegistry.symbolicate(.wasm(function))
79-
symbols.append(.init(name: symbolName, address: frame.pc))
71+
symbols.append(
72+
Backtrace.Symbol(
73+
name: symbolName
74+
)
75+
)
8076
}
8177
return Backtrace(symbols: symbols)
8278
}
@@ -252,7 +248,7 @@ extension Sp {
252248
nonmutating set { self[-1] = UInt64(UInt(bitPattern: newValue)) }
253249
}
254250

255-
var currentInstance: InternalInstance? {
251+
fileprivate var currentInstance: InternalInstance? {
256252
currentFunction?.instance
257253
}
258254
}

Sources/WasmKit/Execution/Function.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ struct WasmFunctionEntity {
243243
switch code {
244244
case .uncompiled(let code):
245245
return try compile(store: store, code: code)
246-
case .compiled(let iseq), .debuggable(_, let iseq):
246+
case .compiled(let iseq), .compiledAndPatchable(_, let iseq):
247247
return iseq
248248
}
249249
}
@@ -280,14 +280,10 @@ extension EntityHandle<WasmFunctionEntity> {
280280
case .uncompiled(let code):
281281
return try self.withValue {
282282
let iseq = try $0.compile(store: store, code: code)
283-
if $0.instance.isDebuggable {
284-
$0.code = .debuggable(code, iseq)
285-
} else {
286-
$0.code = .compiled(iseq)
287-
}
283+
$0.code = .compiled(iseq)
288284
return iseq
289285
}
290-
case .compiled(let iseq), .debuggable(_, let iseq):
286+
case .compiled(let iseq), .compiledAndPatchable(_, let iseq):
291287
return iseq
292288
}
293289
}
@@ -320,7 +316,7 @@ struct InstructionSequence {
320316
enum CodeBody {
321317
case uncompiled(InternalUncompiledCode)
322318
case compiled(InstructionSequence)
323-
case debuggable(InternalUncompiledCode, InstructionSequence)
319+
case compiledAndPatchable(InternalUncompiledCode, InstructionSequence)
324320
}
325321

326322
extension Reference {

0 commit comments

Comments
 (0)