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:21 (GMT) |
commit | 7417495de5e3c15ea5043f3192859f9eeabf546a (patch) | |
tree | fb4d668be09d713706dac4634803880d296e66ca /Tests | |
parent | 5496b8dc91b2418f05f21563130dd6318c4bc2f7 (diff) | |
parent | 764258771afb92067dd4b2c044d8d19abc6f932c (diff) | |
download | CMake-7417495de5e3c15ea5043f3192859f9eeabf546a.zip CMake-7417495de5e3c15ea5043f3192859f9eeabf546a.tar.gz CMake-7417495de5e3c15ea5043f3192859f9eeabf546a.tar.bz2 |
Merge topic 'debugger-segfault'
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, }); } |