Skip to content

Commit fc740e5

Browse files
committed
Add remaining doc comments
1 parent 3b2e30f commit fc740e5

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
@@ -80,8 +80,17 @@ package struct GDBHostCommandDecoder: ByteToMessageDecoder {
8080
package var accummulatedChecksum: UInt8 {
8181
UInt8(self.accummulatedSum % 256)
8282
}
83-
83+
84+
/// Whether `QStartNoAckMode` command was sent. Note that this is separate
85+
/// from ``isNoAckModeActive``. This mode is "activated" for the subsequent
86+
/// host command, which is when `isNoAckModeActive` is set by the decoder to
87+
/// `false`, but not for the immediate response.
88+
/// See https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packet-Acknowledgment.html#Packet-Acknowledgment
8489
private var isNoAckModeRequested = false
90+
91+
/// Whether `QStartNoAckMode` command was sent and this mode has been
92+
/// subsequently activated.
93+
/// See https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packet-Acknowledgment.html#Packet-Acknowledgment
8594
private var isNoAckModeActive = false
8695

8796
package mutating func decode(

Sources/GDBRemoteProtocol/GDBTargetResponse.swift

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,43 @@ package enum VContActions: String {
2222
case stepInRange = "r"
2323
}
2424

25+
/// A response sent from a debugger target (a device
26+
/// or a virtual machine being debugged) to a debugger host (GDB or LLDB).
27+
/// See GDB remote protocol documentation for more details:
28+
/// * https://sourceware.org/gdb/current/onlinedocs/gdb.html/General-Query-Packets.html
2529
package struct GDBTargetResponse {
30+
/// Kind of the response sent from the debugger target to the debugger host.
2631
package enum Kind {
32+
/// Standard `OK` response.
2733
case ok
34+
35+
/// A list of key-value pairs, with keys delimited from values by a colon `:`
36+
/// character, and pairs in the list delimited by the semicolon `;` character.
2837
case keyValuePairs(KeyValuePairs<String, String>)
38+
39+
/// List of ``VContActions`` values delimited by the semicolon `;` character.
2940
case vContSupportedActions([VContActions])
41+
42+
/// Raw string included as is in the response.
3043
case string(String)
44+
45+
/// Binary buffer hex-encoded in the response.
3146
case hexEncodedBinary(ByteBufferView)
47+
48+
/// Standard empty response (no content is sent).
3249
case empty
3350
}
3451

3552
package let kind: Kind
36-
package let isNoAckModeActivated: Bool
3753

38-
package init(kind: Kind, isNoAckModeActivated: Bool) {
54+
/// Whether `QStartNoAckMode` is activated and no ack `+` symbol should be sent
55+
/// before encoding this response.
56+
/// See https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packet-Acknowledgment.html#Packet-Acknowledgment
57+
package let isNoAckModeActivate: Bool
58+
59+
/// Member-wise initializer for the debugger response.
60+
package init(kind: Kind, isNoAckModeActivate: Bool) {
3961
self.kind = kind
40-
self.isNoAckModeActivated = isNoAckModeActivated
62+
self.isNoAckModeActivate = isNoAckModeActivate
4163
}
4264
}

Sources/GDBRemoteProtocol/GDBTargetResponseEncoder.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@ import Foundation
1414
import NIOCore
1515

1616
extension String {
17+
/// Computes a GDB RP checksum of characters in a given string.
1718
fileprivate var appendedChecksum: String {
1819
"\(self)#\(String(format:"%02X", self.utf8.reduce(0, { $0 + Int($1) }) % 256))"
1920
}
2021
}
2122

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

@@ -27,7 +32,7 @@ package class GDBTargetResponseEncoder: MessageToByteEncoder {
2732
if !isNoAckModeActive {
2833
out.writeInteger(UInt8(ascii: "+"))
2934
}
30-
if data.isNoAckModeActivated {
35+
if data.isNoAckModeActivate {
3136
self.isNoAckModeActive = true
3237
}
3338
out.writeInteger(UInt8(ascii: "$"))

0 commit comments

Comments
 (0)