@@ -194,4 +194,45 @@ void SendTerminatedEvent(DAP &dap) {
194
194
});
195
195
}
196
196
197
+ // Grab any STDOUT and STDERR from the process and send it up to VS Code
198
+ // via an "output" event to the "stdout" and "stderr" categories.
199
+ void SendStdOutStdErr (DAP &dap, lldb::SBProcess &process) {
200
+ char buffer[OutputBufferSize];
201
+ size_t count;
202
+ while ((count = process.GetSTDOUT (buffer, sizeof (buffer))) > 0 )
203
+ dap.SendOutput (OutputType::Stdout, llvm::StringRef (buffer, count));
204
+ while ((count = process.GetSTDERR (buffer, sizeof (buffer))) > 0 )
205
+ dap.SendOutput (OutputType::Stderr, llvm::StringRef (buffer, count));
206
+ }
207
+
208
+ // Send a "continued" event to indicate the process is in the running state.
209
+ void SendContinuedEvent (DAP &dap) {
210
+ lldb::SBProcess process = dap.target .GetProcess ();
211
+ if (!process.IsValid ()) {
212
+ return ;
213
+ }
214
+
215
+ // If the focus thread is not set then we haven't reported any thread status
216
+ // to the client, so nothing to report.
217
+ if (!dap.configuration_done_sent || dap.focus_tid == LLDB_INVALID_THREAD_ID) {
218
+ return ;
219
+ }
220
+
221
+ llvm::json::Object event (CreateEventObject (" continued" ));
222
+ llvm::json::Object body;
223
+ body.try_emplace (" threadId" , (int64_t )dap.focus_tid );
224
+ body.try_emplace (" allThreadsContinued" , true );
225
+ event.try_emplace (" body" , std::move (body));
226
+ dap.SendJSON (llvm::json::Value (std::move (event)));
227
+ }
228
+
229
+ // Send a "exited" event to indicate the process has exited.
230
+ void SendProcessExitedEvent (DAP &dap, lldb::SBProcess &process) {
231
+ llvm::json::Object event (CreateEventObject (" exited" ));
232
+ llvm::json::Object body;
233
+ body.try_emplace (" exitCode" , (int64_t )process.GetExitStatus ());
234
+ event.try_emplace (" body" , std::move (body));
235
+ dap.SendJSON (llvm::json::Value (std::move (event)));
236
+ }
237
+
197
238
} // namespace lldb_dap
0 commit comments