diff options
author | Brad King <brad.king@kitware.com> | 2023-06-30 13:30:02 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-06-30 13:30:20 (GMT) |
commit | 1cc4e97e87e93cece10da4441d40e7f13d72c91a (patch) | |
tree | a55f945b7b747afde0e89ddb792eef4a6959e665 /Tests | |
parent | 1ac0dea4c8343d3f3a95b4a143fa47e4a785ff32 (diff) | |
parent | 764258771afb92067dd4b2c044d8d19abc6f932c (diff) | |
download | CMake-1cc4e97e87e93cece10da4441d40e7f13d72c91a.zip CMake-1cc4e97e87e93cece10da4441d40e7f13d72c91a.tar.gz CMake-1cc4e97e87e93cece10da4441d40e7f13d72c91a.tar.bz2 |
Merge topic 'debugger-segfault' into release-3.27
764258771a Debugger: Fix threads request segfault after thread exited event
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8604
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLib/testDebuggerAdapter.cxx | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/Tests/CMakeLib/testDebuggerAdapter.cxx b/Tests/CMakeLib/testDebuggerAdapter.cxx index 394986b..e66d990 100644 --- a/Tests/CMakeLib/testDebuggerAdapter.cxx +++ b/Tests/CMakeLib/testDebuggerAdapter.cxx @@ -53,7 +53,7 @@ public: std::shared_ptr<dap::ReaderWriter> DebuggerToClient; }; -bool testBasicProtocol() +bool runTest(std::function<bool(dap::Session&)> onThreadExitedEvent) { std::promise<bool> debuggerAdapterInitializedPromise; std::future<bool> debuggerAdapterInitializedFuture = @@ -152,6 +152,11 @@ bool testBasicProtocol() std::future_status::ready); ASSERT_TRUE(threadExitedFuture.wait_for(futureTimeout) == std::future_status::ready); + + if (onThreadExitedEvent) { + ASSERT_TRUE(onThreadExitedEvent(*client)); + } + ASSERT_TRUE(exitedEventReceivedFuture.wait_for(futureTimeout) == std::future_status::ready); ASSERT_TRUE(terminatedEventReceivedFuture.wait_for(futureTimeout) == @@ -165,9 +170,32 @@ bool testBasicProtocol() return true; } +bool testBasicProtocol() +{ + return runTest(nullptr); +} + +bool testThreadsRequestAfterThreadExitedEvent() +{ + return runTest([](dap::Session& session) -> bool { + // Try requesting threads again after receiving the thread exited event. + // Some clients do this to ensure that their thread list is up-to-date. + dap::ThreadsRequest threadsRequest; + auto threadsResponse = session.send(threadsRequest).get(); + ASSERT_TRUE(!threadsResponse.error); + + // CMake only has one DAP thread. Once that thread exits, there should be + // no threads left. + ASSERT_TRUE(threadsResponse.response.threads.empty()); + + return true; + }); +} + int testDebuggerAdapter(int, char*[]) { return runTests(std::vector<std::function<bool()>>{ testBasicProtocol, + testThreadsRequestAfterThreadExitedEvent, }); } |