Skip to content

Commit ab295db

Browse files
committed
Add remaining doc comments
1 parent f628219 commit ab295db

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

Sources/GDBRemoteProtocol/GDBHostCommand.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/// * https://sourceware.org/gdb/current/onlinedocs/gdb.html/General-Query-Packets.html
1717
/// * https://lldb.llvm.org/resources/lldbgdbremote.html
1818
package struct GDBHostCommand: Equatable {
19+
/// Kind of the command sent from the debugger host to the debugger target.
1920
package enum Kind: String, Equatable {
2021
// Currently listed in the order that LLDB sends them in.
2122
case startNoAckMode

Sources/GDBRemoteProtocol/GDBHostCommandDecoder.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,17 @@ package struct GDBHostCommandDecoder: ByteToMessageDecoder {
6868
package var accummulatedChecksum: UInt8 {
6969
UInt8(self.accummulatedSum % 256)
7070
}
71-
71+
72+
/// Whether `QStartNoAckMode` command was sent. Note that this is separate
73+
/// from ``isNoAckModeActive``. This mode is "activated" for the subsequent
74+
/// host command, which is when `isNoAckModeActive` is set by the decoder to
75+
/// `false`, but not for the immediate response.
76+
/// See https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packet-Acknowledgment.html#Packet-Acknowledgment
7277
private var isNoAckModeRequested = false
78+
79+
/// Whether `QStartNoAckMode` command was sent and this mode has been
80+
/// subsequently activated.
81+
/// See https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packet-Acknowledgment.html#Packet-Acknowledgment
7382
private var isNoAckModeActive = false
7483

7584
package mutating func decode(

Sources/GDBRemoteProtocol/GDBTargetResponse.swift

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,43 @@ package enum VContActions: String {
1010
case stepInRange = "r"
1111
}
1212

13+
/// A response sent from a debugger target (a device
14+
/// or a virtual machine being debugged) to a debugger host (GDB or LLDB).
15+
/// See GDB remote protocol documentation for more details:
16+
/// * https://sourceware.org/gdb/current/onlinedocs/gdb.html/General-Query-Packets.html
1317
package struct GDBTargetResponse {
18+
/// Kind of the response sent from the debugger target to the debugger host.
1419
package enum Kind {
20+
/// Standard `OK` response.
1521
case ok
22+
23+
/// A list of key-value pairs, with keys delimited from values by a colon `:`
24+
/// character, and pairs in the list delimited by the semicolon `;` character.
1625
case keyValuePairs(KeyValuePairs<String, String>)
26+
27+
/// List of ``VContActions`` values delimited by the semicolon `;` character.
1728
case vContSupportedActions([VContActions])
29+
30+
/// Raw string included as is in the response.
1831
case string(String)
32+
33+
/// Binary buffer hex-encoded in the response.
1934
case hexEncodedBinary(ByteBufferView)
35+
36+
/// Standard empty response (no content is sent).
2037
case empty
2138
}
2239

2340
package let kind: Kind
24-
package let isNoAckModeActivated: Bool
2541

26-
package init(kind: Kind, isNoAckModeActivated: Bool) {
42+
/// Whether `QStartNoAckMode` is activated and no ack `+` symbol should be sent
43+
/// before encoding this response.
44+
/// See https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packet-Acknowledgment.html#Packet-Acknowledgment
45+
package let isNoAckModeActivate: Bool
46+
47+
/// Member-wise initializer for the debugger response.
48+
package init(kind: Kind, isNoAckModeActivate: Bool) {
2749
self.kind = kind
28-
self.isNoAckModeActivated = isNoAckModeActivated
50+
self.isNoAckModeActivate = isNoAckModeActivate
2951
}
3052
}

Sources/GDBRemoteProtocol/GDBTargetResponseEncoder.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ import Foundation
22
import NIOCore
33

44
extension String {
5+
/// Computes a GDB RP checksum of characters in a given string.
56
fileprivate var appendedChecksum: String {
67
"\(self)#\(String(format:"%02X", self.utf8.reduce(0, { $0 + Int($1) }) % 256))"
78
}
89
}
910

11+
/// Encoder of GDB RP target responses, that takes ``GDBTargetResponse`` as an input
12+
/// and encodes it per https://sourceware.org/gdb/current/onlinedocs/gdb.html/Overview.html#Overview
13+
/// format in a `ByteBuffer` value as output. This encoder is compatible with NIO channel pipelines,
14+
/// making it easy to integrate with different I/O configurations.
1015
package class GDBTargetResponseEncoder: MessageToByteEncoder {
1116
private var isNoAckModeActive = false
1217

@@ -15,7 +20,7 @@ package class GDBTargetResponseEncoder: MessageToByteEncoder {
1520
if !isNoAckModeActive {
1621
out.writeInteger(UInt8(ascii: "+"))
1722
}
18-
if data.isNoAckModeActivated {
23+
if data.isNoAckModeActivate {
1924
self.isNoAckModeActive = true
2025
}
2126
out.writeInteger(UInt8(ascii: "$"))

0 commit comments

Comments
 (0)