aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorJose E. Marchesi <jose.marchesi@oracle.com>2021-05-08 18:11:12 +0200
committerJose E. Marchesi <jose.marchesi@oracle.com>2023-04-29 14:55:08 +0200
commitbdeccf733122b02319516e72dd225c916a216d2c (patch)
treebfa6891dac65050b4ecb628469ad2f29fb16ad29 /gdb/testsuite
parent2b8c7766ea357ff9b22531d6fdf0c3bd69cc044f (diff)
downloadgdb-users/jemarch/poke-gdb.zip
gdb-users/jemarch/poke-gdb.tar.gz
gdb-users/jemarch/poke-gdb.tar.bz2
Integrate GNU poke in GDBusers/jemarch/poke-gdb
This patch integrates GNU poke (http://jemarch.net/poke) in GDB by mean of libpoke. It allows the GDB user to execute Poke code from within the debugger with access to the target memory, types and values. How this stuff works: - GDB links with libpoke.so and uses the interface in libpoke.h. This is also how the GNU poke application (the command-line editor) is implemented. - There are three commands: poke STR poke-add-type EXPR poke-add-types REGEXP poke-dump-types All three commands make sure to start the poke incremental compiler if it isn't running already. - Access to the target's memory is provided by GDB by installing a Foreign IO device in the incremental compiler. This is `iod_if' in poke.c. - Access to the terminal is provided by GDB by providing a pk_term_if implementation to the incremental compiler. This is `poke_term_if' in poke.c. - Access to GDB values is provided by GDB by installing an alien token handler in the incremental compiler. This is `poke_alien_token_handler' in poke.c. gdb/ChangeLog: 2021-05-10 Jose E. Marchesi <jose.marchesi@oracle.com> * configure.ac: Support --enable-poke. * configure: Regenerate. * Makefile.in (POKE_OBS): Define based on @POKE_OBS@. (DEPFILES): Add POKE_OBS. * poke.c: New file. gdb/doc/ChangeLog: 2021-05-10 Jose E. Marchesi <jose.marchesi@oracle.com> * Makefile.in (GDB_DOC_FILES): Add poke.texi. * poke.texi: New file. * gdb.texinfo (Data): Add meny entry for Poke and @include poke.texi.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.poke/poke-types.c29
-rw-r--r--gdb/testsuite/gdb.poke/poke-types.exp36
-rw-r--r--gdb/testsuite/lib/gdb.exp7
3 files changed, 72 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.poke/poke-types.c b/gdb/testsuite/gdb.poke/poke-types.c
new file mode 100644
index 0000000..8ab5774
--- /dev/null
+++ b/gdb/testsuite/gdb.poke/poke-types.c
@@ -0,0 +1,29 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2023 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/>. */
+
+#include <stdint.h>
+
+int32_t i32;
+int16_t i16;
+uint64_t u64;
+char *pointer;
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.poke/poke-types.exp b/gdb/testsuite/gdb.poke/poke-types.exp
new file mode 100644
index 0000000..01c086e
--- /dev/null
+++ b/gdb/testsuite/gdb.poke/poke-types.exp
@@ -0,0 +1,36 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2023 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/>.
+
+require allow_poke_tests
+
+global GDB_DATA_DIRECTORY
+if ![info exists GDB_DATA_DIRECTORY] {
+ set GDB_DATA_DIRECTORY [file normalize "$srcdir/.."]
+}
+
+standard_testfile
+if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
+ return -1
+}
+
+if ![runto_main] {
+ return -1
+}
+
+# Add all types
+gdb_test "poke-add-type int" "added type int"
+gdb_test "poke-dump-types" "type int = int<\[0-9\]*>;"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index aed7e2d..80ed3fb 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2537,6 +2537,13 @@ proc allow_rust_tests {} {
return 1
}
+# Return a 1 fo rconfigurations that support GNU poke integration.
+
+proc allow_poke_tests {} {
+ set output [remote_exec host $::GDB "$::INTERNAL_GDBFLAGS --configuration"]
+ return [expr {[string first "--with-poke" $output] != -1}]
+}
+
# Return a 1 for configurations that support Python scripting.
gdb_caching_proc allow_python_tests {} {