https://github.com/ashgti created https://github.com/llvm/llvm-project/pull/130454
Per the DAP spec, the event 'body' field should contain any additional data related to the event. I updated the lldb-dap 'statistics' extension into the terminated event's body like: ``` { "type": "event", "seq": 0, "event": "terminated", "body": { "$__lldb_statistics": {...} } } ``` This allows us to more uniformly handle event messages. >From 7d2d7c27de92a1e6193fade6ea776526337b91b9 Mon Sep 17 00:00:00 2001 From: John Harrison <harj...@google.com> Date: Sat, 8 Mar 2025 18:47:04 -0800 Subject: [PATCH] [lldb-dap] Migrating terminated statistics to the event body. Per the DAP spec, the event 'body' field should contain any additional data related to the event. I updated the lldb-dap 'statistics' extension into the terminated event's body like: ``` { "type": "event", "seq": 0, "event": "terminated", "body": { "$__lldb_statistics": {...} } } ``` This allows us to more uniformly handle event messages. --- .../tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py | 2 +- lldb/tools/lldb-dap/JSONUtils.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py b/lldb/test/API/tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py index 6d1c25e8e4534..b0abe2a38dac4 100644 --- a/lldb/test/API/tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py +++ b/lldb/test/API/tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py @@ -43,7 +43,7 @@ def test_terminated_event(self): self.continue_to_breakpoints(breakpoint_ids) self.continue_to_exit() - statistics = self.dap_server.wait_for_terminated()["statistics"] + statistics = self.dap_server.wait_for_terminated()["body"]["$__lldb_statistics"] self.assertGreater(statistics["totalDebugInfoByteSize"], 0) self.assertGreater(statistics["totalDebugInfoEnabled"], 0) self.assertGreater(statistics["totalModuleCountHasDebugInfo"], 0) diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp index 7094bf60bfbc2..932145b1799bd 100644 --- a/lldb/tools/lldb-dap/JSONUtils.cpp +++ b/lldb/tools/lldb-dap/JSONUtils.cpp @@ -1526,7 +1526,8 @@ static void addStatistic(lldb::SBTarget &target, llvm::json::Object &event) { const char *key = keys.GetStringAtIndex(i); FilterAndGetValueForKey(statistics, key, stats_body); } - event.try_emplace("statistics", std::move(stats_body)); + llvm::json::Object body{{"$__lldb_statistics", std::move(stats_body)}}; + event.try_emplace("body", std::move(body)); } llvm::json::Object CreateTerminatedEventObject(lldb::SBTarget &target) { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits