Skip to content

Commit c5ecdec

Browse files
authored
[lldb-dap] start all sent protocol message from number one. (#170378)
This aligns with the DAP [specification](https://microsoft.github.io/debug-adapter-protocol//specification.html#Base_Protocol_ProtocolMessage) Force it to be an error in test cases.
1 parent cd86b2a commit c5ecdec

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def _process_recv_packets(self) -> None:
391391
with self._recv_condition:
392392
for packet in self._recv_packets:
393393
if packet and ("seq" not in packet or packet["seq"] == 0):
394-
warnings.warn(
394+
raise ValueError(
395395
f"received a malformed packet, expected 'seq != 0' for {packet!r}"
396396
)
397397
# Handle events that may modify any stateful properties of

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,11 @@ Id DAP::Send(const Message &message) {
274274
std::lock_guard<std::mutex> guard(call_mutex);
275275
Message msg = std::visit(
276276
[this](auto &&msg) -> Message {
277-
if (msg.seq == kCalculateSeq)
278-
msg.seq = seq++;
277+
if (msg.seq == kCalculateSeq) {
278+
seq++;
279+
msg.seq = seq;
280+
}
281+
assert(msg.seq > 0 && "message sequence must be greater than zero.");
279282
return msg;
280283
},
281284
Message(message));

lldb/tools/lldb-dap/Protocol/ProtocolBase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ namespace lldb_dap::protocol {
3131
// MARK: Base Protocol
3232

3333
/// Message unique identifier type.
34-
using Id = int64_t;
34+
using Id = uint64_t;
3535

3636
/// A unique identifier that indicates the `seq` field should be calculated by
3737
/// the current session.
38-
static constexpr Id kCalculateSeq = INT64_MAX;
38+
static constexpr Id kCalculateSeq = UINT64_MAX;
3939

4040
/// A client or debug adapter initiated request.
4141
struct Request {

0 commit comments

Comments
 (0)