aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r--gdb/testsuite/gdb.python/lookup-type-block.exp68
-rw-r--r--gdb/testsuite/gdb.python/lookup1.c44
-rw-r--r--gdb/testsuite/gdb.python/lookup2.c46
-rw-r--r--gdb/testsuite/gdb.python/py-connection-removed.exp13
-rw-r--r--gdb/testsuite/gdb.python/py-record-btrace.exp4
-rw-r--r--gdb/testsuite/gdb.python/py-section-script.exp2
6 files changed, 172 insertions, 5 deletions
diff --git a/gdb/testsuite/gdb.python/lookup-type-block.exp b/gdb/testsuite/gdb.python/lookup-type-block.exp
new file mode 100644
index 0000000..7d04eb6
--- /dev/null
+++ b/gdb/testsuite/gdb.python/lookup-type-block.exp
@@ -0,0 +1,68 @@
+# Copyright (C) 2025 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 the 'block' argument to gdb.lookup_type.
+
+load_lib gdb-python.exp
+
+require allow_python_tests
+
+standard_testfile lookup1.c lookup2.c
+
+if {[prepare_for_testing "failed to prepare" ${testfile} \
+ [list $srcfile $srcfile2]]} {
+ return
+}
+
+proc check_type {which type_name} {
+ if {$which == "one"} {
+ set fn_name function
+ } else {
+ set fn_name main
+ }
+
+ gdb_test_no_output \
+ "python block = gdb.decode_line(\"$fn_name\")\[1\]\[0\].symtab.static_block()" \
+ "compute block"
+ gdb_test_no_output \
+ "python ty = gdb.lookup_type(\"$type_name\", block).strip_typedefs()" \
+ "find the type"
+ gdb_test "python print(ty.fields()\[0\].name)" \
+ "$which" \
+ "examine first field"
+}
+
+proc check_all_types {} {
+ foreach_with_prefix which {one two} {
+ foreach_with_prefix type_name {
+ "struct the_struct"
+ "enum the_enum"
+ "union the_union"
+ "the_typedef"
+ } {
+ check_type $which $type_name
+ }
+ }
+}
+
+check_all_types
+
+if {![runto_main]} {
+ return
+}
+
+with_test_prefix "while running" {
+ check_all_types
+}
diff --git a/gdb/testsuite/gdb.python/lookup1.c b/gdb/testsuite/gdb.python/lookup1.c
new file mode 100644
index 0000000..488ffcb
--- /dev/null
+++ b/gdb/testsuite/gdb.python/lookup1.c
@@ -0,0 +1,44 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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/>. */
+
+struct the_struct {
+ int one;
+};
+
+struct the_struct struct1;
+
+enum the_enum {
+ one
+};
+
+enum the_enum enum1;
+
+union the_union {
+ int one;
+ void *ptr;
+};
+
+union the_union union1;
+
+typedef struct the_struct the_typedef;
+
+the_typedef typedef1;
+
+int function (void)
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.python/lookup2.c b/gdb/testsuite/gdb.python/lookup2.c
new file mode 100644
index 0000000..63d1030
--- /dev/null
+++ b/gdb/testsuite/gdb.python/lookup2.c
@@ -0,0 +1,46 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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/>. */
+
+struct the_struct {
+ int two;
+};
+
+struct the_struct struct2;
+
+enum the_enum {
+ two
+};
+
+enum the_enum enum2;
+
+union the_union {
+ int two;
+ void *ptr;
+};
+
+union the_union union2;
+
+typedef struct the_struct the_typedef;
+
+the_typedef typedef2;
+
+extern int function (void);
+
+int main (void)
+{
+ return function ();
+}
diff --git a/gdb/testsuite/gdb.python/py-connection-removed.exp b/gdb/testsuite/gdb.python/py-connection-removed.exp
index d60ebb0..5056eb1 100644
--- a/gdb/testsuite/gdb.python/py-connection-removed.exp
+++ b/gdb/testsuite/gdb.python/py-connection-removed.exp
@@ -58,8 +58,17 @@ if { [target_info exists gdb_protocol] } {
set connection_type "native"
}
-# Add an inferior that shares a connection with inferior 1.
-gdb_test "add-inferior" "Added inferior 2 on connection 1 \[^\r\n\]+"
+# Add an inferior that shares a connection with inferior 1. If we are
+# using a 'remote' connection then this cannot be shared with the new
+# inferior, so we get a warning, and a new inferior with no connection.
+if { $connection_type == "remote" } {
+ gdb_test "add-inferior" \
+ [multi_line \
+ "warning: can't share connection 1 \\(remote \[^\r\n\]+\\) between inferiors" \
+ "Added inferior 2"]
+} else {
+ gdb_test "add-inferior" "Added inferior 2 on connection 1 \[^\r\n\]+"
+}
# Add an inferior with no connection.
gdb_test "add-inferior -no-connection" "Added inferior 3"
diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp b/gdb/testsuite/gdb.python/py-record-btrace.exp
index 6dd3ae1..207161d 100644
--- a/gdb/testsuite/gdb.python/py-record-btrace.exp
+++ b/gdb/testsuite/gdb.python/py-record-btrace.exp
@@ -66,8 +66,8 @@ with_test_prefix "prepare record" {
set v [linux_kernel_version]
if { $v != {} } {
set have_xfail \
- [expr [version_compare [list 5 5 0] <= $v] \
- && [version_compare $v < [list 6 1 0]]]
+ [expr {[version_compare [list 5 5 0] <= $v] \
+ && [version_compare $v < [list 6 1 0]]}]
}
set nonl_re \[^\r\n\]
set xfail_re \
diff --git a/gdb/testsuite/gdb.python/py-section-script.exp b/gdb/testsuite/gdb.python/py-section-script.exp
index 9d4e48c..369c887 100644
--- a/gdb/testsuite/gdb.python/py-section-script.exp
+++ b/gdb/testsuite/gdb.python/py-section-script.exp
@@ -126,7 +126,7 @@ gdb_test "test-cmd 1 2 3" "test-cmd output, arg = 1 2 3"
with_test_prefix "sepdebug" {
gdb_exit
- set result [catch "exec eu-strip -g -f ${binfile}.debug ${binfile}" output]
+ set result [catch {exec eu-strip -g -f ${binfile}.debug ${binfile}} output]
verbose "result is $result"
verbose "output is $output"
if {$result != 0 || $output != ""} {