* [PATCH v2 1/4] [gdb/testsuite] Add gdb.testsuite/gdb-caching-proc.exp
@ 2023-03-04 9:35 Tom de Vries
2023-03-04 9:35 ` [PATCH v2 2/4] [gdb/testsuite] Use regular proc syntax for gdb_caching_proc Tom de Vries
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Tom de Vries @ 2023-03-04 9:35 UTC (permalink / raw)
To: gdb-patches
Add test-case gdb.testsuite/gdb-caching-proc.exp that excercises
gdb_caching_proc.
Tested on x86_64-linux.
---
.../gdb.testsuite/gdb-caching-proc.exp | 38 +++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp
diff --git a/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp b/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp
new file mode 100644
index 00000000000..de35c046185
--- /dev/null
+++ b/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp
@@ -0,0 +1,38 @@
+# 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/>.
+
+gdb_caching_proc gdb_testsuite_gdb_caching_proc_exp_noarg {
+ incr ::count
+ return 1
+}
+
+set assertions {
+ { [gdb_testsuite_gdb_caching_proc_exp_noarg] == 1 }
+}
+
+set assertion_nr 0
+foreach assertion $assertions {
+ with_test_prefix $assertion_nr {
+ set ::count 0
+
+ gdb_assert $assertion
+ gdb_assert { $::count == 1 }
+
+ with_test_prefix cached {
+ gdb_assert $assertion
+ gdb_assert { $::count == 1 }
+ }
+ }
+ incr assertion_nr
+}
base-commit: 9c2c346137eeca000840023b6d9340274da7a905
--
2.35.3
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 2/4] [gdb/testsuite] Use regular proc syntax for gdb_caching_proc
2023-03-04 9:35 [PATCH v2 1/4] [gdb/testsuite] Add gdb.testsuite/gdb-caching-proc.exp Tom de Vries
@ 2023-03-04 9:35 ` Tom de Vries
2023-03-06 14:20 ` Tom Tromey
2023-03-04 9:35 ` [PATCH v2 3/4] [gdb/testsuite] Allow args in gdb_caching_proc Tom de Vries
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Tom de Vries @ 2023-03-04 9:35 UTC (permalink / raw)
To: gdb-patches
A regular tcl proc with no args looks like:
...
proc foo {} {
return 1
}
...
but a gdb_caching_proc deviates from that syntax by dropping the explicit no
args bit:
...
gdb_caching_proc foo {
return 1
}
...
Make the gdb_caching_proc use the same syntax as regular procs, such that we
have instead:
...
gdb_caching_proc foo {} {
return 1
}
...
Tested on x86_64-linux.
---
.../gdb.testsuite/gdb-caching-proc.exp | 2 +-
gdb/testsuite/lib/ada.exp | 2 +-
gdb/testsuite/lib/cache.exp | 5 +-
gdb/testsuite/lib/gdb-guile.exp | 2 +-
gdb/testsuite/lib/gdb.exp | 104 +++++++++---------
gdb/testsuite/lib/opencl.exp | 2 +-
gdb/testsuite/lib/rocm.exp | 2 +-
gdb/testsuite/lib/rust-support.exp | 4 +-
8 files changed, 63 insertions(+), 60 deletions(-)
diff --git a/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp b/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp
index de35c046185..33a21df8f13 100644
--- a/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp
+++ b/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp
@@ -12,7 +12,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-gdb_caching_proc gdb_testsuite_gdb_caching_proc_exp_noarg {
+gdb_caching_proc gdb_testsuite_gdb_caching_proc_exp_noarg {} {
incr ::count
return 1
}
diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp
index f5bf2dcbb71..02a5d1ad271 100644
--- a/gdb/testsuite/lib/ada.exp
+++ b/gdb/testsuite/lib/ada.exp
@@ -166,7 +166,7 @@ proc gnatmake_version_at_least { major } {
# Return 1 if the GNAT runtime appears to have debug info.
-gdb_caching_proc gnat_runtime_has_debug_info {
+gdb_caching_proc gnat_runtime_has_debug_info {} {
global srcdir
set src "$srcdir/lib/gnat_debug_info_test.adb"
diff --git a/gdb/testsuite/lib/cache.exp b/gdb/testsuite/lib/cache.exp
index b9f64837e66..5c44ed8dcf7 100644
--- a/gdb/testsuite/lib/cache.exp
+++ b/gdb/testsuite/lib/cache.exp
@@ -121,7 +121,10 @@ proc gdb_do_cache {name} {
# results, both in memory and, if GDB_PARALLEL is defined, in the
# filesystem for use across invocations of dejagnu.
-proc gdb_caching_proc {name body} {
+proc gdb_caching_proc {name arglist body} {
+ if { [llength $arglist] != 0 } {
+ error "gdb_caching_proc with non-empty args list"
+ }
# Define the underlying proc that we'll call.
set real_name gdb_real__$name
proc $real_name {} $body
diff --git a/gdb/testsuite/lib/gdb-guile.exp b/gdb/testsuite/lib/gdb-guile.exp
index 50189c8ed90..3451022c3e9 100644
--- a/gdb/testsuite/lib/gdb-guile.exp
+++ b/gdb/testsuite/lib/gdb-guile.exp
@@ -20,7 +20,7 @@ set ghex {[0-9a-f]+}
# Return a 1 for configurations that support Guile scripting.
-gdb_caching_proc allow_guile_tests {
+gdb_caching_proc allow_guile_tests {} {
set output [remote_exec host $::GDB "$::INTERNAL_GDBFLAGS --configuration"]
return [expr {[string first "--with-guile" $output] != -1}]
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 19c782bea46..04d49e658ba 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2448,7 +2448,7 @@ proc allow_rust_tests {} {
# Return a 1 for configurations that support Python scripting.
-gdb_caching_proc allow_python_tests {
+gdb_caching_proc allow_python_tests {} {
set output [remote_exec host $::GDB "$::INTERNAL_GDBFLAGS --configuration"]
return [expr {[string first "--with-python" $output] != -1}]
}
@@ -2477,7 +2477,7 @@ proc allow_shlib_tests {} {
# Return 1 if we should run dlmopen tests, 0 if we should not.
-gdb_caching_proc allow_dlmopen_tests {
+gdb_caching_proc allow_dlmopen_tests {} {
global srcdir subdir gdb_prompt inferior_exited_re
# We need shared library support.
@@ -2573,7 +2573,7 @@ gdb_caching_proc allow_dlmopen_tests {
# Return 1 if we should allow TUI-related tests.
-gdb_caching_proc allow_tui_tests {
+gdb_caching_proc allow_tui_tests {} {
set output [remote_exec host $::GDB "$::INTERNAL_GDBFLAGS --configuration"]
return [expr {[string first "--enable-tui" $output] != -1}]
}
@@ -3164,7 +3164,7 @@ proc with_read1_timeout_factor { factor body } {
# Return 1 if _Complex types are supported, otherwise, return 0.
-gdb_caching_proc support_complex_tests {
+gdb_caching_proc support_complex_tests {} {
if { ![allow_float_test] } {
# If floating point is not supported, _Complex is not
@@ -3185,7 +3185,7 @@ gdb_caching_proc support_complex_tests {
}
# Return 1 if compiling go is supported.
-gdb_caching_proc support_go_compile {
+gdb_caching_proc support_go_compile {} {
return [gdb_can_simple_compile go-hello {
package main
@@ -3209,7 +3209,7 @@ proc supports_get_siginfo_type {} {
# Return 1 if memory tagging is supported at runtime, otherwise return 0.
-gdb_caching_proc supports_memtag {
+gdb_caching_proc supports_memtag {} {
global gdb_prompt
gdb_test_multiple "memory-tag check" "" {
@@ -3301,7 +3301,7 @@ proc readline_is_used { } {
}
# Return 1 if target is ELF.
-gdb_caching_proc is_elf_target {
+gdb_caching_proc is_elf_target {} {
set me "is_elf_target"
set src { int foo () {return 0;} }
@@ -3329,7 +3329,7 @@ gdb_caching_proc is_elf_target {
# Return 1 if the memory at address zero is readable.
-gdb_caching_proc is_address_zero_readable {
+gdb_caching_proc is_address_zero_readable {} {
global gdb_prompt
set ret 0
@@ -3358,7 +3358,7 @@ proc gdb_produce_source { name sources } {
# Return 1 if target is ILP32.
# This cannot be decided simply from looking at the target string,
# as it might depend on externally passed compiler options like -m64.
-gdb_caching_proc is_ilp32_target {
+gdb_caching_proc is_ilp32_target {} {
return [gdb_can_simple_compile is_ilp32_target {
int dummy[sizeof (int) == 4
&& sizeof (void *) == 4
@@ -3369,7 +3369,7 @@ gdb_caching_proc is_ilp32_target {
# Return 1 if target is LP64.
# This cannot be decided simply from looking at the target string,
# as it might depend on externally passed compiler options like -m64.
-gdb_caching_proc is_lp64_target {
+gdb_caching_proc is_lp64_target {} {
return [gdb_can_simple_compile is_lp64_target {
int dummy[sizeof (int) == 4
&& sizeof (void *) == 8
@@ -3380,7 +3380,7 @@ gdb_caching_proc is_lp64_target {
# Return 1 if target has 64 bit addresses.
# This cannot be decided simply from looking at the target string,
# as it might depend on externally passed compiler options like -m64.
-gdb_caching_proc is_64_target {
+gdb_caching_proc is_64_target {} {
return [gdb_can_simple_compile is_64_target {
int function(void) { return 3; }
int dummy[sizeof (&function) == 8 ? 1 : -1];
@@ -3390,7 +3390,7 @@ gdb_caching_proc is_64_target {
# Return 1 if target has x86_64 registers - either amd64 or x32.
# x32 target identifies as x86_64-*-linux*, therefore it cannot be determined
# just from the target string.
-gdb_caching_proc is_amd64_regs_target {
+gdb_caching_proc is_amd64_regs_target {} {
if {![istarget "x86_64-*-*"] && ![istarget "i?86-*"]} {
return 0
}
@@ -3420,7 +3420,7 @@ proc is_x86_64_m64_target {} {
# Return 1 if this target is an arm or aarch32 on aarch64.
-gdb_caching_proc is_aarch32_target {
+gdb_caching_proc is_aarch32_target {} {
if { [istarget "arm*-*-*"] } {
return 1
}
@@ -3464,7 +3464,7 @@ proc support_displaced_stepping {} {
# Run a test on the target to see if it supports vmx hardware. Return 1 if so,
# 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
-gdb_caching_proc allow_altivec_tests {
+gdb_caching_proc allow_altivec_tests {} {
global srcdir subdir gdb_prompt inferior_exited_re
set me "allow_altivec_tests"
@@ -3534,7 +3534,7 @@ gdb_caching_proc allow_altivec_tests {
}
# Run a test on the power target to see if it supports ISA 3.1 instructions
-gdb_caching_proc allow_power_isa_3_1_tests {
+gdb_caching_proc allow_power_isa_3_1_tests {} {
global srcdir subdir gdb_prompt inferior_exited_re
set me "allow_power_isa_3_1_tests"
@@ -3583,7 +3583,7 @@ gdb_caching_proc allow_power_isa_3_1_tests {
# Run a test on the target to see if it supports vmx hardware. Return 1 if so,
# 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
-gdb_caching_proc allow_vsx_tests {
+gdb_caching_proc allow_vsx_tests {} {
global srcdir subdir gdb_prompt inferior_exited_re
set me "allow_vsx_tests"
@@ -3652,7 +3652,7 @@ gdb_caching_proc allow_vsx_tests {
# Run a test on the target to see if it supports TSX hardware. Return 1 if so,
# 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
-gdb_caching_proc allow_tsx_tests {
+gdb_caching_proc allow_tsx_tests {} {
global srcdir subdir gdb_prompt inferior_exited_re
set me "allow_tsx_tests"
@@ -3701,7 +3701,7 @@ gdb_caching_proc allow_tsx_tests {
# Run a test on the target to see if it supports avx512bf16. Return 1 if so,
# 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
-gdb_caching_proc allow_avx512bf16_tests {
+gdb_caching_proc allow_avx512bf16_tests {} {
global srcdir subdir gdb_prompt inferior_exited_re
set me "allow_avx512bf16_tests"
@@ -3752,7 +3752,7 @@ gdb_caching_proc allow_avx512bf16_tests {
# Run a test on the target to see if it supports avx512fp16. Return 1 if so,
# 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
-gdb_caching_proc allow_avx512fp16_tests {
+gdb_caching_proc allow_avx512fp16_tests {} {
global srcdir subdir gdb_prompt inferior_exited_re
set me "allow_avx512fp16_tests"
@@ -3803,7 +3803,7 @@ gdb_caching_proc allow_avx512fp16_tests {
# Run a test on the target to see if it supports btrace hardware. Return 1 if so,
# 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
-gdb_caching_proc allow_btrace_tests {
+gdb_caching_proc allow_btrace_tests {} {
global srcdir subdir gdb_prompt inferior_exited_re
set me "allow_btrace_tests"
@@ -3854,7 +3854,7 @@ gdb_caching_proc allow_btrace_tests {
# Return 1 if so, 0 if it does not. Based on 'check_vmx_hw_available'
# from the GCC testsuite.
-gdb_caching_proc allow_btrace_pt_tests {
+gdb_caching_proc allow_btrace_pt_tests {} {
global srcdir subdir gdb_prompt inferior_exited_re
set me "allow_btrace_pt_tests"
@@ -3907,7 +3907,7 @@ gdb_caching_proc allow_btrace_pt_tests {
# Run a test on the target to see if it supports Aarch64 SVE hardware.
# Return 1 if so, 0 if it does not. Note this causes a restart of GDB.
-gdb_caching_proc allow_aarch64_sve_tests {
+gdb_caching_proc allow_aarch64_sve_tests {} {
global srcdir subdir gdb_prompt inferior_exited_re
set me "allow_aarch64_sve_tests"
@@ -3963,17 +3963,17 @@ proc gdb_int128_helper {lang} {
}
# Return true if the C compiler understands the __int128 type.
-gdb_caching_proc has_int128_c {
+gdb_caching_proc has_int128_c {} {
return [gdb_int128_helper c]
}
# Return true if the C++ compiler understands the __int128 type.
-gdb_caching_proc has_int128_cxx {
+gdb_caching_proc has_int128_cxx {} {
return [gdb_int128_helper c++]
}
# Return true if the IFUNC feature is supported.
-gdb_caching_proc allow_ifunc_tests {
+gdb_caching_proc allow_ifunc_tests {} {
if [gdb_can_simple_compile ifunc {
extern void f_ ();
typedef void F (void);
@@ -4246,7 +4246,7 @@ proc use_gdb_stub {} {
# Return 1 if the current remote target is an instance of our GDBserver, 0
# otherwise. Return -1 if there was an error and we can't tell.
-gdb_caching_proc target_is_gdbserver {
+gdb_caching_proc target_is_gdbserver {} {
global gdb_prompt
set is_gdbserver -1
@@ -4525,7 +4525,7 @@ proc gdb_wrapper_init { args } {
}
# Determine options that we always want to pass to the compiler.
-gdb_caching_proc universal_compile_options {
+gdb_caching_proc universal_compile_options {} {
set me "universal_compile_options"
set options {}
@@ -6821,7 +6821,7 @@ proc exec_has_index_section { executable } {
}
# Return list with major and minor version of readelf, or an empty list.
-gdb_caching_proc readelf_version {
+gdb_caching_proc readelf_version {} {
set readelf_program [gdb_find_readelf]
set res [catch {exec $readelf_program --version} output]
if { $res != 0 } {
@@ -6880,7 +6880,7 @@ proc exec_is_pie { executable } {
# point support or GDB can't fetch the contents from floating point
# registers.
-gdb_caching_proc allow_float_test {
+gdb_caching_proc allow_float_test {} {
if [target_info exists gdb,skip_float_tests] {
return 0
}
@@ -6993,7 +6993,7 @@ proc gdb_skip_bogus_test { msg } {
# Return true if XML support is enabled in the host GDB.
# NOTE: This must be called while gdb is *not* running.
-gdb_caching_proc allow_xml_test {
+gdb_caching_proc allow_xml_test {} {
global gdb_spawn_id
global gdb_prompt
global srcdir
@@ -7018,7 +7018,7 @@ gdb_caching_proc allow_xml_test {
# Return true if argv[0] is available.
-gdb_caching_proc gdb_has_argv0 {
+gdb_caching_proc gdb_has_argv0 {} {
set result 0
# Compile and execute a test program to check whether argv[0] is available.
@@ -7729,7 +7729,7 @@ proc get_endianness { } {
}
# Get the target's default endianness and return it.
-gdb_caching_proc target_endianness {
+gdb_caching_proc target_endianness {} {
global gdb_prompt
set me "target_endianness"
@@ -7938,7 +7938,7 @@ proc core_find {binfile {deletefiles {}} {arg ""}} {
# the output from objdump to determine the prefix (such as underscore)
# for linker symbol prefixes.
-gdb_caching_proc gdb_target_symbol_prefix {
+gdb_caching_proc gdb_target_symbol_prefix {} {
# Compile a simple test program...
set src { int main() { return 0; } }
if {![gdb_simple_compile target_symbol_prefix $src executable]} {
@@ -7963,7 +7963,7 @@ gdb_caching_proc gdb_target_symbol_prefix {
# Return 1 if target supports scheduler locking, otherwise return 0.
-gdb_caching_proc target_supports_scheduler_locking {
+gdb_caching_proc target_supports_scheduler_locking {} {
global gdb_prompt
set me "gdb_target_supports_scheduler_locking"
@@ -8022,7 +8022,7 @@ gdb_caching_proc target_supports_scheduler_locking {
# Return 1 if compiler supports use of nested functions. Otherwise,
# return 0.
-gdb_caching_proc support_nested_function_tests {
+gdb_caching_proc support_nested_function_tests {} {
# Compile a test program containing a nested function
return [gdb_can_simple_compile nested_func {
int main () {
@@ -8550,7 +8550,7 @@ proc cmp_binary_files { file1 file2 } {
# flag? If not then we should skip these tests. We should also
# skip them if libctf was explicitly disabled.
-gdb_caching_proc allow_ctf_tests {
+gdb_caching_proc allow_ctf_tests {} {
global enable_libctf
if {$enable_libctf eq "no"} {
@@ -8569,7 +8569,7 @@ gdb_caching_proc allow_ctf_tests {
# Return 1 if compiler supports -gstatement-frontiers. Otherwise,
# return 0.
-gdb_caching_proc supports_statement_frontiers {
+gdb_caching_proc supports_statement_frontiers {} {
return [gdb_can_simple_compile supports_statement_frontiers {
int main () {
return 0;
@@ -8580,7 +8580,7 @@ gdb_caching_proc supports_statement_frontiers {
# Return 1 if compiler supports -mmpx -fcheck-pointer-bounds. Otherwise,
# return 0.
-gdb_caching_proc supports_mpx_check_pointer_bounds {
+gdb_caching_proc supports_mpx_check_pointer_bounds {} {
set flags "additional_flags=-mmpx additional_flags=-fcheck-pointer-bounds"
return [gdb_can_simple_compile supports_mpx_check_pointer_bounds {
int main () {
@@ -8592,7 +8592,7 @@ gdb_caching_proc supports_mpx_check_pointer_bounds {
# Return 1 if compiler supports -fcf-protection=. Otherwise,
# return 0.
-gdb_caching_proc supports_fcf_protection {
+gdb_caching_proc supports_fcf_protection {} {
return [gdb_can_simple_compile supports_fcf_protection {
int main () {
return 0;
@@ -8864,7 +8864,7 @@ proc gdb_note { message } {
}
# Return 1 if compiler supports -fuse-ld=gold, otherwise return 0.
-gdb_caching_proc have_fuse_ld_gold {
+gdb_caching_proc have_fuse_ld_gold {} {
set me "have_fuse_ld_gold"
set flags "additional_flags=-fuse-ld=gold"
set src { int main() { return 0; } }
@@ -8872,7 +8872,7 @@ gdb_caching_proc have_fuse_ld_gold {
}
# Return 1 if compiler supports fvar-tracking, otherwise return 0.
-gdb_caching_proc have_fvar_tracking {
+gdb_caching_proc have_fvar_tracking {} {
set me "have_fvar_tracking"
set flags "additional_flags=-fvar-tracking"
set src { int main() { return 0; } }
@@ -8880,7 +8880,7 @@ gdb_caching_proc have_fvar_tracking {
}
# Return 1 if linker supports -Ttext-segment, otherwise return 0.
-gdb_caching_proc linker_supports_Ttext_segment_flag {
+gdb_caching_proc linker_supports_Ttext_segment_flag {} {
set me "linker_supports_Ttext_segment_flag"
set flags ldflags="-Wl,-Ttext-segment=0x7000000"
set src { int main() { return 0; } }
@@ -8888,7 +8888,7 @@ gdb_caching_proc linker_supports_Ttext_segment_flag {
}
# Return 1 if linker supports -Ttext, otherwise return 0.
-gdb_caching_proc linker_supports_Ttext_flag {
+gdb_caching_proc linker_supports_Ttext_flag {} {
set me "linker_supports_Ttext_flag"
set flags ldflags="-Wl,-Ttext=0x7000000"
set src { int main() { return 0; } }
@@ -8896,7 +8896,7 @@ gdb_caching_proc linker_supports_Ttext_flag {
}
# Return 1 if linker supports --image-base, otherwise 0.
-gdb_caching_proc linker_supports_image_base_flag {
+gdb_caching_proc linker_supports_image_base_flag {} {
set me "linker_supports_image_base_flag"
set flags ldflags="-Wl,--image-base=0x7000000"
set src { int main() { return 0; } }
@@ -8906,7 +8906,7 @@ gdb_caching_proc linker_supports_image_base_flag {
# Return 1 if compiler supports scalar_storage_order attribute, otherwise
# return 0.
-gdb_caching_proc supports_scalar_storage_order_attribute {
+gdb_caching_proc supports_scalar_storage_order_attribute {} {
set me "supports_scalar_storage_order_attribute"
set src {
#include <string.h>
@@ -8940,7 +8940,7 @@ gdb_caching_proc supports_scalar_storage_order_attribute {
}
# Return 1 if compiler supports __GNUC__, otherwise return 0.
-gdb_caching_proc supports_gnuc {
+gdb_caching_proc supports_gnuc {} {
set me "supports_gnuc"
set src {
#ifndef __GNUC__
@@ -8951,7 +8951,7 @@ gdb_caching_proc supports_gnuc {
}
# Return 1 if target supports mpx, otherwise return 0.
-gdb_caching_proc have_mpx {
+gdb_caching_proc have_mpx {} {
global srcdir
set me "have_mpx"
@@ -9026,7 +9026,7 @@ gdb_caching_proc have_mpx {
}
# Return 1 if target supports avx, otherwise return 0.
-gdb_caching_proc have_avx {
+gdb_caching_proc have_avx {} {
global srcdir
set me "have_avx"
@@ -9110,7 +9110,7 @@ proc target_file_exists_with_timeout { path } {
return 0
}
-gdb_caching_proc has_hw_wp_support {
+gdb_caching_proc has_hw_wp_support {} {
# Power 9, proc rev 2.2 does not support HW watchpoints due to HW bug.
# Need to use a runtime test to determine if the Power processor has
# support for HW watchpoints.
@@ -9218,7 +9218,7 @@ proc get_set_option_choices { set_cmd {set_arg ""} } {
# set, use that. If not, try a few common compiler names, making sure
# that the executable they produce can run.
-gdb_caching_proc arm_cc_for_target {
+gdb_caching_proc arm_cc_for_target {} {
if {[info exists ::ARM_CC_FOR_TARGET]} {
# If the user specified the compiler explicitly, then don't
# check whether the resulting binary runs outside GDB. Assume
@@ -9327,7 +9327,7 @@ proc is_target_non_stop { {testname ""} } {
#
# Returns True if it is associated with the closing brace,
# False if it is the last statement
-gdb_caching_proc have_epilogue_line_info {
+gdb_caching_proc have_epilogue_line_info {} {
set main {
int
@@ -9394,7 +9394,7 @@ proc has_dependency { file dep } {
# Detect linux kernel version and return as list of 3 numbers: major, minor,
# and patchlevel. On failure, return an empty list.
-gdb_caching_proc linux_kernel_version {
+gdb_caching_proc linux_kernel_version {} {
if { ![istarget *-*-linux*] } {
return {}
}
diff --git a/gdb/testsuite/lib/opencl.exp b/gdb/testsuite/lib/opencl.exp
index 4c66d2a9ecd..dc7966443d5 100644
--- a/gdb/testsuite/lib/opencl.exp
+++ b/gdb/testsuite/lib/opencl.exp
@@ -29,7 +29,7 @@ proc gdb_compile_opencl_hostapp {clsource executable options} {
# Run a test on the target to check if it supports OpenCL. Return 1 if so, 0 if
# it does not.
-gdb_caching_proc allow_opencl_tests {
+gdb_caching_proc allow_opencl_tests {} {
global srcdir objdir subdir gdb_prompt
global inferior_exited_re
diff --git a/gdb/testsuite/lib/rocm.exp b/gdb/testsuite/lib/rocm.exp
index 92e8221b772..b3e435339db 100644
--- a/gdb/testsuite/lib/rocm.exp
+++ b/gdb/testsuite/lib/rocm.exp
@@ -59,7 +59,7 @@ proc hcc_amdgpu_targets {} {
return $targets
}
-gdb_caching_proc allow_hipcc_tests {
+gdb_caching_proc allow_hipcc_tests {} {
# Only the native target supports ROCm debugging. E.g., when
# testing against GDBserver, there's no point in running the ROCm
# tests.
diff --git a/gdb/testsuite/lib/rust-support.exp b/gdb/testsuite/lib/rust-support.exp
index df517647ce9..f3739e2ce02 100644
--- a/gdb/testsuite/lib/rust-support.exp
+++ b/gdb/testsuite/lib/rust-support.exp
@@ -80,7 +80,7 @@ proc gdb_compile_rust {sources dest options} {
# Return the version of LLVM used by the Rust compiler. Note that
# older versions of rustc don't print this -- in this case the
# returned version is "0.0".
-gdb_caching_proc rust_llvm_version {
+gdb_caching_proc rust_llvm_version {} {
set rustc [find_rustc]
if {$rustc == ""} {
verbose "could not find rustc"
@@ -97,7 +97,7 @@ gdb_caching_proc rust_llvm_version {
}
# Return the version of the Rust compiler.
-gdb_caching_proc rust_compiler_version {
+gdb_caching_proc rust_compiler_version {} {
set rustc [find_rustc]
if {$rustc == ""} {
verbose "could not find rustc"
--
2.35.3
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 3/4] [gdb/testsuite] Allow args in gdb_caching_proc
2023-03-04 9:35 [PATCH v2 1/4] [gdb/testsuite] Add gdb.testsuite/gdb-caching-proc.exp Tom de Vries
2023-03-04 9:35 ` [PATCH v2 2/4] [gdb/testsuite] Use regular proc syntax for gdb_caching_proc Tom de Vries
@ 2023-03-04 9:35 ` Tom de Vries
2023-03-06 14:23 ` Tom Tromey
2023-03-04 9:35 ` [PATCH v2 4/4] [gdb/testsuite] Move gdb.base/gdb-caching-proc.exp to gdb.testsuite Tom de Vries
2023-03-06 14:47 ` [PATCH v2 1/4] [gdb/testsuite] Add gdb.testsuite/gdb-caching-proc.exp Tom Tromey
3 siblings, 1 reply; 9+ messages in thread
From: Tom de Vries @ 2023-03-04 9:35 UTC (permalink / raw)
To: gdb-patches
Test-case gdb.base/morestack.exp contains:
...
require {have_compile_flag -fsplit-stack}
...
and I want to cache the result of have_compile_flag.
Currently gdb_caching_proc doesn't allow args, so I could add:
...
gdb_caching_proc have_compile_flag_fsplit_stack {
return [have_compile_flag -fsplit-stack]
}
...
and then use that proc instead, but I find this cumbersome and
maintenance-unfriendly.
Instead, allow args in a gdb_caching_proc, such that I can simply do:
...
-proc have_compile_flag { flag } {
+gdb_caching_proc have_compile_flag { flag } {
...
Note that gdb_caching_procs with args do not work with the
gdb.base/gdb-caching-procs.exp test-case, so those procs are skipped.
Tested on x86_64-linux.
---
gdb/testsuite/gdb.base/gdb-caching-proc.exp | 4 +++
.../gdb.testsuite/gdb-caching-proc.exp | 7 +++++
gdb/testsuite/lib/cache.exp | 31 ++++++++++---------
gdb/testsuite/lib/gdb.exp | 2 +-
4 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/gdb/testsuite/gdb.base/gdb-caching-proc.exp b/gdb/testsuite/gdb.base/gdb-caching-proc.exp
index 6610c25157a..df7715f9c24 100644
--- a/gdb/testsuite/gdb.base/gdb-caching-proc.exp
+++ b/gdb/testsuite/gdb.base/gdb-caching-proc.exp
@@ -81,6 +81,10 @@ proc test_file { file } {
}
foreach procname $procnames {
+ if { [info args $procname] != "" } {
+ # With args.
+ continue
+ }
with_test_prefix $procname {
switch $procname {
"is_address_zero_readable" { set setup_gdb 1 }
diff --git a/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp b/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp
index 33a21df8f13..6112b409022 100644
--- a/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp
+++ b/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp
@@ -17,8 +17,15 @@ gdb_caching_proc gdb_testsuite_gdb_caching_proc_exp_noarg {} {
return 1
}
+gdb_caching_proc gdb_testsuite_gdb_caching_proc_exp_arg { arg } {
+ incr ::count
+ return $arg
+}
+
set assertions {
{ [gdb_testsuite_gdb_caching_proc_exp_noarg] == 1 }
+ { [gdb_testsuite_gdb_caching_proc_exp_arg 1] == 1 }
+ { [gdb_testsuite_gdb_caching_proc_exp_arg "foo foo"] == "foo foo" }
}
set assertion_nr 0
diff --git a/gdb/testsuite/lib/cache.exp b/gdb/testsuite/lib/cache.exp
index 5c44ed8dcf7..d221858e0d7 100644
--- a/gdb/testsuite/lib/cache.exp
+++ b/gdb/testsuite/lib/cache.exp
@@ -23,7 +23,7 @@ proc ignore_pass { msg } {
}
# Call proc real_name and return the result, while ignoring calls to pass.
-proc gdb_do_cache_wrap {real_name} {
+proc gdb_do_cache_wrap {real_name args} {
if { [info procs save_pass] != "" } {
return [uplevel 2 $real_name]
}
@@ -31,7 +31,7 @@ proc gdb_do_cache_wrap {real_name} {
rename pass save_pass
rename ignore_pass pass
- set code [catch {uplevel 2 $real_name} result]
+ set code [catch {uplevel 2 [list $real_name {*}$args]} result]
rename pass ignore_pass
rename save_pass pass
@@ -48,7 +48,7 @@ proc gdb_do_cache_wrap {real_name} {
# A helper for gdb_caching_proc that handles the caching.
-proc gdb_do_cache {name} {
+proc gdb_do_cache {name args} {
global gdb_data_cache objdir
global GDB_PARALLEL
@@ -67,7 +67,7 @@ proc gdb_do_cache {name} {
# "board" to handle runs with multiple options
# (e.g. unix/{-m32,-64}) correctly. We use "file join" here
# because we later use this in a real filename.
- set cache_name [file join [target_info name] $name]
+ set cache_name [file join [target_info name] $name {*}$args]
set is_cached 0
if {[info exists gdb_data_cache($cache_name)]} {
@@ -95,7 +95,7 @@ proc gdb_do_cache {name} {
}
set real_name gdb_real__$name
- set gdb_data_cache($cache_name) [gdb_do_cache_wrap $real_name]
+ set gdb_data_cache($cache_name) [gdb_do_cache_wrap $real_name {*}$args]
if { $cache_verify == 1 && $is_cached == 1 } {
set computed $gdb_data_cache($cache_name)
if { $cached != $computed } {
@@ -116,19 +116,22 @@ proc gdb_do_cache {name} {
return $gdb_data_cache($cache_name)
}
-# Define a new proc named NAME that takes no arguments. BODY is the
-# body of the proc. The proc will evaluate BODY and cache the
-# results, both in memory and, if GDB_PARALLEL is defined, in the
-# filesystem for use across invocations of dejagnu.
+# Define a new proc named NAME, with optional args ARGS. BODY is the body of
+# the proc. The proc will evaluate BODY and cache the results, both in memory
+# and, if GDB_PARALLEL is defined, in the filesystem for use across
+# invocations of dejagnu.
+#
proc gdb_caching_proc {name arglist body} {
- if { [llength $arglist] != 0 } {
- error "gdb_caching_proc with non-empty args list"
- }
# Define the underlying proc that we'll call.
set real_name gdb_real__$name
- proc $real_name {} $body
+ proc $real_name $arglist $body
# Define the advertised proc.
- proc $name {} [list gdb_do_cache $name]
+ set caching_proc_body [list gdb_do_cache $name]
+ foreach arg $arglist {
+ lappend caching_proc_body $$arg
+ }
+ set caching_proc_body [join $caching_proc_body]
+ proc $name $arglist $caching_proc_body
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 04d49e658ba..e2b08c64eae 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -9427,7 +9427,7 @@ proc have_syscall { name } {
# Return 1 if compile flag FLAG is supported.
-proc have_compile_flag { flag } {
+gdb_caching_proc have_compile_flag { flag } {
set src { void foo () {} }
return [gdb_can_simple_compile have_compile_flag_$flag $src object \
additional_flags=$flag]
--
2.35.3
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 4/4] [gdb/testsuite] Move gdb.base/gdb-caching-proc.exp to gdb.testsuite
2023-03-04 9:35 [PATCH v2 1/4] [gdb/testsuite] Add gdb.testsuite/gdb-caching-proc.exp Tom de Vries
2023-03-04 9:35 ` [PATCH v2 2/4] [gdb/testsuite] Use regular proc syntax for gdb_caching_proc Tom de Vries
2023-03-04 9:35 ` [PATCH v2 3/4] [gdb/testsuite] Allow args in gdb_caching_proc Tom de Vries
@ 2023-03-04 9:35 ` Tom de Vries
2023-03-06 14:48 ` Tom Tromey
2023-03-06 14:47 ` [PATCH v2 1/4] [gdb/testsuite] Add gdb.testsuite/gdb-caching-proc.exp Tom Tromey
3 siblings, 1 reply; 9+ messages in thread
From: Tom de Vries @ 2023-03-04 9:35 UTC (permalink / raw)
To: gdb-patches
Test-case gdb.base/gdb-caching-proc.exp doesn't really test gdb, but it tests
the gdb_caching_procs in the testsuite, so it belongs in gdb.testsuite rather
than gdb.base.
Move test-case gdb.base/gdb-caching-proc.exp to gdb.testsuite, renaming it to
gdb.testsuite/gdb-caching-proc-consistency.exp to not clash with
recently added gdb.testsuite/gdb-caching-proc.exp.
Tested on x86_64-linux.
---
.../gdb-caching-proc-consistency.exp} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename gdb/testsuite/{gdb.base/gdb-caching-proc.exp => gdb.testsuite/gdb-caching-proc-consistency.exp} (100%)
diff --git a/gdb/testsuite/gdb.base/gdb-caching-proc.exp b/gdb/testsuite/gdb.testsuite/gdb-caching-proc-consistency.exp
similarity index 100%
rename from gdb/testsuite/gdb.base/gdb-caching-proc.exp
rename to gdb/testsuite/gdb.testsuite/gdb-caching-proc-consistency.exp
--
2.35.3
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/4] [gdb/testsuite] Use regular proc syntax for gdb_caching_proc
2023-03-04 9:35 ` [PATCH v2 2/4] [gdb/testsuite] Use regular proc syntax for gdb_caching_proc Tom de Vries
@ 2023-03-06 14:20 ` Tom Tromey
0 siblings, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2023-03-06 14:20 UTC (permalink / raw)
To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> Make the gdb_caching_proc use the same syntax as regular procs, such that we
Tom> have instead:
Tom> ...
Tom> gdb_caching_proc foo {} {
Tom> return 1
Tom> }
Tom> ...
Looks good, thank you.
Reviewed-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/4] [gdb/testsuite] Allow args in gdb_caching_proc
2023-03-04 9:35 ` [PATCH v2 3/4] [gdb/testsuite] Allow args in gdb_caching_proc Tom de Vries
@ 2023-03-06 14:23 ` Tom Tromey
0 siblings, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2023-03-06 14:23 UTC (permalink / raw)
To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> Instead, allow args in a gdb_caching_proc, such that I can simply do:
Tom> ...
Tom> -proc have_compile_flag { flag } {
Tom> +gdb_caching_proc have_compile_flag { flag } {
Tom> ...
Tom> Note that gdb_caching_procs with args do not work with the
Tom> gdb.base/gdb-caching-procs.exp test-case, so those procs are skipped.
Thank you for doing this.
Reviewed-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/4] [gdb/testsuite] Add gdb.testsuite/gdb-caching-proc.exp
2023-03-04 9:35 [PATCH v2 1/4] [gdb/testsuite] Add gdb.testsuite/gdb-caching-proc.exp Tom de Vries
` (2 preceding siblings ...)
2023-03-04 9:35 ` [PATCH v2 4/4] [gdb/testsuite] Move gdb.base/gdb-caching-proc.exp to gdb.testsuite Tom de Vries
@ 2023-03-06 14:47 ` Tom Tromey
3 siblings, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2023-03-06 14:47 UTC (permalink / raw)
To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> Add test-case gdb.testsuite/gdb-caching-proc.exp that excercises
Tom> gdb_caching_proc.
Tom> Tested on x86_64-linux.
Looks good, thanks
Reviewed-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 4/4] [gdb/testsuite] Move gdb.base/gdb-caching-proc.exp to gdb.testsuite
2023-03-04 9:35 ` [PATCH v2 4/4] [gdb/testsuite] Move gdb.base/gdb-caching-proc.exp to gdb.testsuite Tom de Vries
@ 2023-03-06 14:48 ` Tom Tromey
2023-03-06 15:45 ` Tom de Vries
0 siblings, 1 reply; 9+ messages in thread
From: Tom Tromey @ 2023-03-06 14:48 UTC (permalink / raw)
To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> Test-case gdb.base/gdb-caching-proc.exp doesn't really test gdb, but it tests
Tom> the gdb_caching_procs in the testsuite, so it belongs in gdb.testsuite rather
Tom> than gdb.base.
Tom> Move test-case gdb.base/gdb-caching-proc.exp to gdb.testsuite, renaming it to
Tom> gdb.testsuite/gdb-caching-proc-consistency.exp to not clash with
Tom> recently added gdb.testsuite/gdb-caching-proc.exp.
Tom> Tested on x86_64-linux.
I agree, seems fine, though I don't understand why it wasn't just
created there?
Reviewed-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 4/4] [gdb/testsuite] Move gdb.base/gdb-caching-proc.exp to gdb.testsuite
2023-03-06 14:48 ` Tom Tromey
@ 2023-03-06 15:45 ` Tom de Vries
0 siblings, 0 replies; 9+ messages in thread
From: Tom de Vries @ 2023-03-06 15:45 UTC (permalink / raw)
To: Tom Tromey, Tom de Vries via Gdb-patches
On 3/6/23 15:48, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Tom> Test-case gdb.base/gdb-caching-proc.exp doesn't really test gdb, but it tests
> Tom> the gdb_caching_procs in the testsuite, so it belongs in gdb.testsuite rather
> Tom> than gdb.base.
>
> Tom> Move test-case gdb.base/gdb-caching-proc.exp to gdb.testsuite, renaming it to
> Tom> gdb.testsuite/gdb-caching-proc-consistency.exp to not clash with
> Tom> recently added gdb.testsuite/gdb-caching-proc.exp.
>
> Tom> Tested on x86_64-linux.
>
> I agree, seems fine, though I don't understand why it wasn't just
> created there?
The test-case gdb.base/gdb-caching-proc.exp was by added by this commit:
...
commit 64d27cfc97f5b865019f0b7293ff2b9565db427c
Author: Tom de Vries <tdevries@suse.de>
Date: Sat Dec 1 08:56:56 2018 +0100
...
The dir gdb.testsuite was added by this commit:
...
commit 213fd9faf563ce5726ce66c8104cbaba44ba9c09
Author: Pedro Alves <palves@redhat.com>
Date: Thu Jul 4 16:45:23 2019 +0100
...
In other words, the test-case wasn't created in gdb.testsuite because it
predates gdb.testsuite.
Thanks for the reviews, I'll commit shortly.
Thanks,
- Tom
> Reviewed-By: Tom Tromey <tom@tromey.com>
>
> Tom
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-03-06 15:45 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-04 9:35 [PATCH v2 1/4] [gdb/testsuite] Add gdb.testsuite/gdb-caching-proc.exp Tom de Vries
2023-03-04 9:35 ` [PATCH v2 2/4] [gdb/testsuite] Use regular proc syntax for gdb_caching_proc Tom de Vries
2023-03-06 14:20 ` Tom Tromey
2023-03-04 9:35 ` [PATCH v2 3/4] [gdb/testsuite] Allow args in gdb_caching_proc Tom de Vries
2023-03-06 14:23 ` Tom Tromey
2023-03-04 9:35 ` [PATCH v2 4/4] [gdb/testsuite] Move gdb.base/gdb-caching-proc.exp to gdb.testsuite Tom de Vries
2023-03-06 14:48 ` Tom Tromey
2023-03-06 15:45 ` Tom de Vries
2023-03-06 14:47 ` [PATCH v2 1/4] [gdb/testsuite] Add gdb.testsuite/gdb-caching-proc.exp Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).