aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.dap/hover.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-06-01 11:54:17 -0600
committerTom Tromey <tromey@adacore.com>2023-06-22 09:46:24 -0600
commitd8a001f57016eff05977e9699c7aabdf4302c71b (patch)
tree8f52cf811c7b40b9168be6bd7f51e9dfa9e418fc /gdb/testsuite/gdb.dap/hover.c
parent0aafd5d038581b1eaf7f37b185f9d2c9be47386d (diff)
downloadbinutils-d8a001f57016eff05977e9699c7aabdf4302c71b.zip
binutils-d8a001f57016eff05977e9699c7aabdf4302c71b.tar.gz
binutils-d8a001f57016eff05977e9699c7aabdf4302c71b.tar.bz2
Implement DAP "hover" context
A DAP client can request that an expression be evaluated in "hover" context, meaning that it should not cause side effects. In gdb, this can be implemented by temporarily setting a few "may-" parameters to "off". In order to make this work, I had to also change "may-write-registers" so that it can be changed while the program is running. I don't think there was any reason for this prohibition in the first place. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30476
Diffstat (limited to 'gdb/testsuite/gdb.dap/hover.c')
-rw-r--r--gdb/testsuite/gdb.dap/hover.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.dap/hover.c b/gdb/testsuite/gdb.dap/hover.c
new file mode 100644
index 0000000..f853396
--- /dev/null
+++ b/gdb/testsuite/gdb.dap/hover.c
@@ -0,0 +1,30 @@
+/* Copyright 2023 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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/>. */
+
+int global_variable = 23;
+
+int
+increment ()
+{
+ return ++global_variable;
+}
+
+int
+main ()
+{
+ return 0; /* BREAK */
+}