@@ -30,27 +30,32 @@ namespace lldb_dap::protocol {
3030
3131// MARK: Base Protocol
3232
33+ // / Message unique identifier type.
3334using Id = int64_t ;
3435
36+ // / A unique identifier that indicates the `seq` field should be calculated by
37+ // / the current session.
38+ static constexpr Id kCalculateSeq = INT64_MAX;
39+
3540// / A client or debug adapter initiated request.
3641struct Request {
37- // / Sequence number of the message (also known as message ID). The `seq` for
38- // / the first message sent by a client or debug adapter is 1, and for each
39- // / subsequent message is 1 greater than the previous message sent by that
40- // / actor. `seq` can be used to order requests, responses, and events, and to
41- // / associate requests with their corresponding responses. For protocol
42- // / messages of type `request` the sequence number can be used to cancel the
43- // / request.
44- Id seq;
45-
4642 // / The command to execute.
4743 std::string command;
4844
4945 // / Object containing arguments for the command.
5046 // /
5147 // / Request handlers are expected to validate the arguments, which is handled
5248 // / by `RequestHandler`.
53- std::optional<llvm::json::Value> arguments;
49+ std::optional<llvm::json::Value> arguments = std::nullopt ;
50+
51+ // / Sequence number of the message (also known as message ID). The `seq` for
52+ // / the first message sent by a client or debug adapter is 1, and for each
53+ // / subsequent message is 1 greater than the previous message sent by that
54+ // / actor. `seq` can be used to order requests, responses, and events, and to
55+ // / associate requests with their corresponding responses. For protocol
56+ // / messages of type `request` the sequence number can be used to cancel the
57+ // / request.
58+ Id seq = kCalculateSeq ;
5459};
5560llvm::json::Value toJSON (const Request &);
5661bool fromJSON (const llvm::json::Value &, Request &, llvm::json::Path);
@@ -62,7 +67,16 @@ struct Event {
6267 std::string event;
6368
6469 // / Event-specific information.
65- std::optional<llvm::json::Value> body;
70+ std::optional<llvm::json::Value> body = std::nullopt ;
71+
72+ // / Sequence number of the message (also known as message ID). The `seq` for
73+ // / the first message sent by a client or debug adapter is 1, and for each
74+ // / subsequent message is 1 greater than the previous message sent by that
75+ // / actor. `seq` can be used to order requests, responses, and events, and to
76+ // / associate requests with their corresponding responses. For protocol
77+ // / messages of type `request` the sequence number can be used to cancel the
78+ // / request.
79+ Id seq = kCalculateSeq ;
6680};
6781llvm::json::Value toJSON (const Event &);
6882bool fromJSON (const llvm::json::Value &, Event &, llvm::json::Path);
@@ -78,7 +92,7 @@ enum ResponseMessage : unsigned {
7892// / Response for a request.
7993struct Response {
8094 // / Sequence number of the corresponding request.
81- Id request_seq;
95+ Id request_seq = 0 ;
8296
8397 // / The command requested.
8498 std::string command;
@@ -87,21 +101,31 @@ struct Response {
87101 // / attribute may contain the result of the request. If the value is false,
88102 // / the attribute `message` contains the error in short form and the `body`
89103 // / may contain additional information (see `ErrorMessage`).
90- bool success;
104+ bool success = false ;
91105
92106 // FIXME: Migrate usage of fallback string to ErrorMessage
93107
94108 // / Contains the raw error in short form if `success` is false. This raw error
95109 // / might be interpreted by the client and is not shown in the UI. Some
96110 // / predefined values exist.
97- std::optional<std::variant<ResponseMessage, std::string>> message;
111+ std::optional<std::variant<ResponseMessage, std::string>> message =
112+ std::nullopt ;
98113
99114 // / Contains request result if success is true and error details if success is
100115 // / false.
101116 // /
102117 // / Request handlers are expected to build an appropriate body, see
103118 // / `RequestHandler`.
104- std::optional<llvm::json::Value> body;
119+ std::optional<llvm::json::Value> body = std::nullopt ;
120+
121+ // / Sequence number of the message (also known as message ID). The `seq` for
122+ // / the first message sent by a client or debug adapter is 1, and for each
123+ // / subsequent message is 1 greater than the previous message sent by that
124+ // / actor. `seq` can be used to order requests, responses, and events, and to
125+ // / associate requests with their corresponding responses. For protocol
126+ // / messages of type `request` the sequence number can be used to cancel the
127+ // / request.
128+ Id seq = kCalculateSeq ;
105129};
106130bool fromJSON (const llvm::json::Value &, Response &, llvm::json::Path);
107131llvm::json::Value toJSON (const Response &);
0 commit comments