From 85b789abddc6cd479bbd488b030b42536448c6e0 Mon Sep 17 00:00:00 2001 From: ZhangTingan Date: Wed, 14 May 2025 16:42:00 +0800 Subject: [PATCH] Fix the issue where terminated events cannot be handled. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When debugging Python applications via cppdap and debugpy, after the application finishes running, the following request {... body:{} ...} is sent. cppdap incorrectly processes it—the body field is optional and can be empty. However, cppdap treats it as an error and throws an exception, which is unreasonable. --- src/session.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/session.cpp b/src/session.cpp index ffc7775..9b3b8ad 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -30,6 +30,7 @@ #include #include #include +#include namespace { @@ -410,7 +411,9 @@ class Impl : public dap::Session { // "body" is an optional field for some events, such as "Terminated Event". bool body_ok = true; d->field("body", [&](dap::Deserializer* d) { - if (!typeinfo->deserialize(d, data)) { + // todo: to completed event list + std::set bodyCanBeEmpty { "terminated" }; + if (!typeinfo->deserialize(d, data) && bodyCanBeEmpty.find(event) == bodyCanBeEmpty.end()) { body_ok = false; } return true;