aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.dap
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-01-10 12:51:10 -0700
committerTom Tromey <tromey@adacore.com>2024-01-22 08:54:27 -0700
commit46bdb641642d20307521f5db2e1f1c7dcc49d5a7 (patch)
treeb110f2297893f23939972947289584d8081610be /gdb/testsuite/gdb.dap
parent8f42049a8230baf871ccb66b4e607bd2ebcd99ab (diff)
downloadgdb-46bdb641642d20307521f5db2e1f1c7dcc49d5a7.zip
gdb-46bdb641642d20307521f5db2e1f1c7dcc49d5a7.tar.gz
gdb-46bdb641642d20307521f5db2e1f1c7dcc49d5a7.tar.bz2
Handle EOF more gracefully in DAP
A user pointed out that gdb will print a Python exception when it gets an EOF in DAP mode. And, it turns out that an EOF like this also causes gdb not to exit. This is due to the refactoring that moved the JSON reader to its own thread -- previously this caused an exception to propagate and cause an exit, but now it just leaves the reader hung. This patch fixes these problems by arranging to handle EOF more gracefully. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31217
Diffstat (limited to 'gdb/testsuite/gdb.dap')
-rw-r--r--gdb/testsuite/gdb.dap/eof.exp37
1 files changed, 37 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.dap/eof.exp b/gdb/testsuite/gdb.dap/eof.exp
new file mode 100644
index 0000000..139c17a
--- /dev/null
+++ b/gdb/testsuite/gdb.dap/eof.exp
@@ -0,0 +1,37 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test that EOF is handled gracefully.
+
+require allow_dap_tests
+
+load_lib dap-support.exp
+
+# The test doesn't matter much.
+standard_testfile scopes.c
+
+if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} {
+ return
+}
+
+if {[dap_launch $testfile] == ""} {
+ return
+}
+
+catch "close -i $gdb_spawn_id"
+catch "wait -i $gdb_spawn_id"
+unset gdb_spawn_id
+
+dap_check_log_file