Skip to content

Commit 06c6ea6

Browse files
authored
GDB RP: support D detach command (#234)
In our case it behaves similarly to the `kill` command, but finishes execution before stopping the debugger server.
1 parent 2aade13 commit 06c6ea6

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Sources/GDBRemoteProtocol/GDBHostCommand.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ package struct GDBHostCommand: Equatable {
4949
case removeSoftwareBreakpoint
5050
case wasmLocal
5151
case memoryRegionInfo
52+
case detach
5253

5354
case generalRegisters
5455

@@ -103,6 +104,8 @@ package struct GDBHostCommand: Equatable {
103104
self = .wasmLocal
104105
case "qMemoryRegionInfo":
105106
self = .memoryRegionInfo
107+
case "D":
108+
self = .detach
106109

107110
default:
108111
return nil

Sources/WasmKit/Execution/Debugger.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
/// Threading model of the Wasm engine configuration, cached for a potentially hot path.
4545
private let threadingModel: EngineConfiguration.ThreadingModel
4646

47-
private(set) var breakpoints = [Int: CodeSlot]()
47+
/// Mapping from a Wasm address of a breakpoint to a corresponding iseq code slot.
48+
package private(set) var breakpoints = [Int: UInt64]()
4849

4950
package private(set) var state: State
5051

Sources/WasmKitGDBHandler/WasmKitGDBHandler.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,14 @@
281281
case .kill:
282282
throw Error.killRequestReceived
283283

284+
case .detach:
285+
for address in self.debugger.breakpoints.keys {
286+
try self.debugger.disableBreakpoint(address: address)
287+
}
288+
289+
try self.debugger.run()
290+
throw Error.killRequestReceived
291+
284292
case .insertSoftwareBreakpoint:
285293
try self.debugger.enableBreakpoint(
286294
address: Int(

0 commit comments

Comments
 (0)