diff options
Diffstat (limited to 'gdb/testsuite/gdb.base')
1333 files changed, 11577 insertions, 5651 deletions
diff --git a/gdb/testsuite/gdb.base/a2-run.exp b/gdb/testsuite/gdb.base/a2-run.exp index f366144..0df7558 100644 --- a/gdb/testsuite/gdb.base/a2-run.exp +++ b/gdb/testsuite/gdb.base/a2-run.exp @@ -1,4 +1,4 @@ -# Copyright 1988-2024 Free Software Foundation, Inc. +# Copyright 1988-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 @@ -18,6 +18,8 @@ # Can't do this test without stdio support. require {!gdb_skip_stdio_test "a2run.exp"} +set have_startup_shell [have_startup_shell] + # # test running programs # @@ -153,7 +155,7 @@ gdb_test_stdio "" "usage: factorial <number>" "" "run after setting args to nil # work with stub targets, where GDB connects to debug an already started # process. -if [use_gdb_stub] { +if {[use_gdb_stub]} { verbose "Skipping rest of a2-run.exp because target is a stub." return } @@ -166,9 +168,8 @@ gdb_run_cmd setup_xfail "arm-*-coff" gdb_test_stdio "" "720" "" "run \"$testfile\" again after setting args" -# GOAL: Test that shell is being used with "run". For remote debugging -# targets, there is no guarantee that a "shell" (whatever that is) is used. -if {![is_remote target]} { +# GOAL: Test that shell is being used with "run". +if { $have_startup_shell == 1 } { gdb_test_stdio "run `echo 8`" \ "40320" "" "run \"$testfile\" with shell" } diff --git a/gdb/testsuite/gdb.base/access-mem-running.c b/gdb/testsuite/gdb.base/access-mem-running.c index 51f94c6..8408efb 100644 --- a/gdb/testsuite/gdb.base/access-mem-running.c +++ b/gdb/testsuite/gdb.base/access-mem-running.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/access-mem-running.exp b/gdb/testsuite/gdb.base/access-mem-running.exp index 821cdd0..3aafb53 100644 --- a/gdb/testsuite/gdb.base/access-mem-running.exp +++ b/gdb/testsuite/gdb.base/access-mem-running.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2021-2024 Free Software Foundation, Inc. +# Copyright (C) 2021-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 @@ -25,17 +25,17 @@ if {[build_executable "failed to prepare" $testfile $srcfile {debug}] == -1} { # non-stop, or all-stop mode. proc test { non_stop } { - global srcfile binfile + global srcfile global gdb_prompt global GDBFLAGS global decimal save_vars { GDBFLAGS } { append GDBFLAGS " -ex \"set non-stop $non_stop\"" - clean_restart ${binfile} + clean_restart $::testfile } - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -113,7 +113,7 @@ proc test { non_stop } { } foreach non_stop { "off" "on" } { - set stop_mode [expr ($non_stop=="off")?"all-stop":"non-stop"] + set stop_mode [expr {($non_stop=="off")?"all-stop":"non-stop"}] with_test_prefix "$stop_mode" { test $non_stop } diff --git a/gdb/testsuite/gdb.base/add-symbol-file-attach.c b/gdb/testsuite/gdb.base/add-symbol-file-attach.c index 3ebd468..109e712 100644 --- a/gdb/testsuite/gdb.base/add-symbol-file-attach.c +++ b/gdb/testsuite/gdb.base/add-symbol-file-attach.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/add-symbol-file-attach.exp b/gdb/testsuite/gdb.base/add-symbol-file-attach.exp index e39a26a..9039249 100644 --- a/gdb/testsuite/gdb.base/add-symbol-file-attach.exp +++ b/gdb/testsuite/gdb.base/add-symbol-file-attach.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2021-2024 Free Software Foundation, Inc. +# Copyright (C) 2021-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 diff --git a/gdb/testsuite/gdb.base/address_space_qualifier.exp b/gdb/testsuite/gdb.base/address_space_qualifier.exp index b067e8d..dc91162 100644 --- a/gdb/testsuite/gdb.base/address_space_qualifier.exp +++ b/gdb/testsuite/gdb.base/address_space_qualifier.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/advance-until-multiple-locations.cc b/gdb/testsuite/gdb.base/advance-until-multiple-locations.cc index 159377c..d092f8d 100644 --- a/gdb/testsuite/gdb.base/advance-until-multiple-locations.cc +++ b/gdb/testsuite/gdb.base/advance-until-multiple-locations.cc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/advance-until-multiple-locations.exp b/gdb/testsuite/gdb.base/advance-until-multiple-locations.exp index 88a4b0d..86b8e0d 100644 --- a/gdb/testsuite/gdb.base/advance-until-multiple-locations.exp +++ b/gdb/testsuite/gdb.base/advance-until-multiple-locations.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -33,14 +33,14 @@ set lineno [gdb_get_line_number "multiple locations here"] proc_with_prefix until_advance_lineno_from_inlined {cmd} { global lineno - if ![runto test] { + if {![runto test]} { return } gdb_breakpoint $lineno gdb_continue_to_breakpoint "break here" - set lineno2 [expr $lineno + 1] + set lineno2 [expr {$lineno + 1}] gdb_test "$cmd $lineno2" \ "inline_func .* at .*:$lineno2.*return i.*" \ @@ -53,7 +53,7 @@ proc_with_prefix until_advance_lineno_from_inlined {cmd} { proc_with_prefix until_advance_lineno_from_non_inlined {cmd} { global lineno - if ![runto test] { + if {![runto test]} { return } @@ -68,7 +68,7 @@ proc_with_prefix until_advance_lineno_from_non_inlined {cmd} { proc_with_prefix until_advance_inline_func {cmd} { global lineno - if ![runto test] { + if {![runto test]} { return } @@ -83,7 +83,7 @@ proc_with_prefix until_advance_inline_func {cmd} { proc_with_prefix advance_overload {} { global lineno - if ![runto test] { + if {![runto test]} { return } @@ -117,7 +117,7 @@ proc_with_prefix advance_overload {} { proc_with_prefix until_overload {} { global lineno - if ![runto test] { + if {![runto test]} { return } diff --git a/gdb/testsuite/gdb.base/advance.c b/gdb/testsuite/gdb.base/advance.c index a72cb13..55e181d 100644 --- a/gdb/testsuite/gdb.base/advance.c +++ b/gdb/testsuite/gdb.base/advance.c @@ -42,11 +42,10 @@ main () int b, c; c = 5; b = 3; /* advance this location */ - + func (c); /* stop here after leaving current frame */ marker1 (); /* stop here after leaving current frame */ func3 (); /* break here */ result = bar (b + foo (c)); return 0; /* advance malformed */ } - diff --git a/gdb/testsuite/gdb.base/advance.exp b/gdb/testsuite/gdb.base/advance.exp index 040e0d9..3239b66 100644 --- a/gdb/testsuite/gdb.base/advance.exp +++ b/gdb/testsuite/gdb.base/advance.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 @@ -63,7 +63,7 @@ gdb_test "continue" \ ".*Breakpoint ${decimal}, main.*func3.*break here.*" \ "continue to call to func3 in main" -# Verify that "advance <funcname>" when funcname is called as parameter to +# Verify that "advance <funcname>" when funcname is called as parameter to # another function works. # gdb_test "advance foo" \ @@ -75,4 +75,3 @@ gdb_test "advance foo" \ gdb_test "advance" \ "Argument required \\(a location\\)."\ "advance with no argument" - diff --git a/gdb/testsuite/gdb.base/alias.exp b/gdb/testsuite/gdb.base/alias.exp index 23a7166..593a830 100644 --- a/gdb/testsuite/gdb.base/alias.exp +++ b/gdb/testsuite/gdb.base/alias.exp @@ -1,5 +1,5 @@ # Test the alias command. -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/align-c++.exp b/gdb/testsuite/gdb.base/align-c++.exp index 48455e1..57af0be 100644 --- a/gdb/testsuite/gdb.base/align-c++.exp +++ b/gdb/testsuite/gdb.base/align-c++.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/align-c.exp b/gdb/testsuite/gdb.base/align-c.exp index be0a5f4..f5b779d 100644 --- a/gdb/testsuite/gdb.base/align-c.exp +++ b/gdb/testsuite/gdb.base/align-c.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/align.exp.tcl b/gdb/testsuite/gdb.base/align.exp.tcl index 3f08e8b..6b6ceec 100644 --- a/gdb/testsuite/gdb.base/align.exp.tcl +++ b/gdb/testsuite/gdb.base/align.exp.tcl @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/all-architectures-0.exp b/gdb/testsuite/gdb.base/all-architectures-0.exp index cf532a9..2ba8d22 100644 --- a/gdb/testsuite/gdb.base/all-architectures-0.exp +++ b/gdb/testsuite/gdb.base/all-architectures-0.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/all-architectures-1.exp b/gdb/testsuite/gdb.base/all-architectures-1.exp index eb25564..e43e652 100644 --- a/gdb/testsuite/gdb.base/all-architectures-1.exp +++ b/gdb/testsuite/gdb.base/all-architectures-1.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/all-architectures-2.exp b/gdb/testsuite/gdb.base/all-architectures-2.exp index fcc1069..553501d 100644 --- a/gdb/testsuite/gdb.base/all-architectures-2.exp +++ b/gdb/testsuite/gdb.base/all-architectures-2.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/all-architectures-3.exp b/gdb/testsuite/gdb.base/all-architectures-3.exp index 24030b3..4a81c20 100644 --- a/gdb/testsuite/gdb.base/all-architectures-3.exp +++ b/gdb/testsuite/gdb.base/all-architectures-3.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/all-architectures-4.exp b/gdb/testsuite/gdb.base/all-architectures-4.exp index 79b6b49..c4d45e4 100644 --- a/gdb/testsuite/gdb.base/all-architectures-4.exp +++ b/gdb/testsuite/gdb.base/all-architectures-4.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/all-architectures-5.exp b/gdb/testsuite/gdb.base/all-architectures-5.exp index 3a9d1d9..6a756f0 100644 --- a/gdb/testsuite/gdb.base/all-architectures-5.exp +++ b/gdb/testsuite/gdb.base/all-architectures-5.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/all-architectures-6.exp b/gdb/testsuite/gdb.base/all-architectures-6.exp index 2c3277a..cdf9955 100644 --- a/gdb/testsuite/gdb.base/all-architectures-6.exp +++ b/gdb/testsuite/gdb.base/all-architectures-6.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/all-architectures-7.exp b/gdb/testsuite/gdb.base/all-architectures-7.exp index 52405c0..01961d1 100644 --- a/gdb/testsuite/gdb.base/all-architectures-7.exp +++ b/gdb/testsuite/gdb.base/all-architectures-7.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/all-architectures.exp.tcl b/gdb/testsuite/gdb.base/all-architectures.exp.tcl index f97387f..5892ab7 100644 --- a/gdb/testsuite/gdb.base/all-architectures.exp.tcl +++ b/gdb/testsuite/gdb.base/all-architectures.exp.tcl @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2024 Free Software Foundation, Inc. +# Copyright (C) 2016-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 @@ -187,7 +187,7 @@ proc gdb_test_no_output_osabi {cmd test} { set num_slices 8 set num_archs [llength $supported_archs] -set archs_per_slice [expr (($num_archs + $num_slices - 1) / $num_slices)] +set archs_per_slice [expr {(($num_archs + $num_slices - 1) / $num_slices)}] with_test_prefix "tests" { foreach_with_prefix osabi $supported_osabis { @@ -201,10 +201,10 @@ with_test_prefix "tests" { incr arch_count # Skip architectures outside our slice. - if {$arch_count < [expr $test_slice * $archs_per_slice]} { + if {$arch_count < $test_slice * $archs_per_slice} { continue } - if {$arch_count >= [expr ($test_slice + 1) * $archs_per_slice]} { + if {$arch_count >= ($test_slice + 1) * $archs_per_slice} { continue } @@ -312,7 +312,7 @@ with_test_prefix "tests" { foreach v $options { with_test_prefix "$var=$v" { gdb_test_no_output_osabi "$cmd $v" "$cmd" - run_axis $all_axes [expr $cur_axis + 1] $arch + run_axis $all_axes [expr {$cur_axis + 1}] $arch } } } diff --git a/gdb/testsuite/gdb.base/all-bin.exp b/gdb/testsuite/gdb.base/all-bin.exp index af973b2..ac2e498 100644 --- a/gdb/testsuite/gdb.base/all-bin.exp +++ b/gdb/testsuite/gdb.base/all-bin.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -19,7 +19,7 @@ # # tests for arithmetic, logical and relational operators # with mixed types -# +# @@ -166,8 +166,3 @@ gdb_test "print v_int && v_float" " = $true" "print value of v_int&&v_float" gdb_test "print v_int && v_double" " = $false" \ "print value of v_int&&v_double" - - - - - diff --git a/gdb/testsuite/gdb.base/all-types.c b/gdb/testsuite/gdb.base/all-types.c index 570fd43..fa1208e 100644 --- a/gdb/testsuite/gdb.base/all-types.c +++ b/gdb/testsuite/gdb.base/all-types.c @@ -30,7 +30,7 @@ int main () extern void dummy(); dummy(); return 0; - + } void dummy() @@ -43,16 +43,16 @@ void dummy() v_short = 3; v_signed_short = 4; - v_unsigned_short = 5; + v_unsigned_short = 5; v_int = 6; v_signed_int = 7; - v_unsigned_int = 8; + v_unsigned_int = 8; v_long = 9; v_signed_long = 10; - v_unsigned_long = 11; - + v_unsigned_long = 11; + v_float = 100.343434; v_double = 200.565656; } diff --git a/gdb/testsuite/gdb.base/annota-input-while-running.c b/gdb/testsuite/gdb.base/annota-input-while-running.c index 25b4cab..a0d83ae 100644 --- a/gdb/testsuite/gdb.base/annota-input-while-running.c +++ b/gdb/testsuite/gdb.base/annota-input-while-running.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/annota-input-while-running.exp b/gdb/testsuite/gdb.base/annota-input-while-running.exp index 4625622..2b8d3b9 100644 --- a/gdb/testsuite/gdb.base/annota-input-while-running.exp +++ b/gdb/testsuite/gdb.base/annota-input-while-running.exp @@ -1,4 +1,4 @@ -# Copyright 1999-2024 Free Software Foundation, Inc. +# Copyright 1999-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 diff --git a/gdb/testsuite/gdb.base/annota1.c b/gdb/testsuite/gdb.base/annota1.c index 424e1b8..b7cf98e 100644 --- a/gdb/testsuite/gdb.base/annota1.c +++ b/gdb/testsuite/gdb.base/annota1.c @@ -13,16 +13,16 @@ int main (void) { int my_array[3] = { 1, 2, 3 }; /* break main */ - + value = 7; - + #ifdef SIGUSR1 signal (SIGUSR1, handle_USR1); #endif printf ("value is %d\n", value); printf ("my_array[2] is %d\n", my_array[2]); - + { int i; for (i = 0; i < 5; i++) @@ -31,4 +31,3 @@ main (void) return 0; /* after loop */ } - diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp index 927e8a7..c7cd1e8 100644 --- a/gdb/testsuite/gdb.base/annota1.exp +++ b/gdb/testsuite/gdb.base/annota1.exp @@ -1,4 +1,4 @@ -# Copyright 1999-2024 Free Software Foundation, Inc. +# Copyright 1999-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 @@ -60,7 +60,7 @@ set old_gdb_prompt $gdb_prompt set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n" # -# Escape all the characters in the path that need it. For instance +# Escape all the characters in the path that need it. For instance # the directory name could contain '+'. # set escapedsrcfile [string_to_regexp ${srcdir}/${subdir}/${srcfile}] @@ -244,7 +244,7 @@ gdb_test_multiple "break handle_USR1" "break handle_USR1" { } # -# break at printf. When we are stopped at printf, we can test +# break at printf. When we are stopped at printf, we can test # gdb_test_multiple "break printf" "break printf" { -re "\r\n\032\032post-prompt\r\nBreakpoint.*at $hex.*\032\032breakpoints-invalid\r\n.*$gdb_prompt$" { @@ -336,14 +336,14 @@ gdb_test_multiple "backtrace" "backtrace from shlibrary" { # -# test printing a frame with some arguments: +# test printing a frame with some arguments: # annotate-arg-begin # annotate-arg-name-end # annotate-arg-value # annotate-arg-end # -if [target_info exists gdb,nosignals] { +if {[target_info exists gdb,nosignals]} { unsupported "send SIGUSR1" unsupported "backtrace @ signal handler" } else { @@ -434,8 +434,8 @@ set y_or_n [string_to_regexp "(y or n)"] send_gdb "run\n" gdb_expect { -re "pre-query.*already.*$y_or_n.*query\r\n" { - send_gdb "y\n" - gdb_expect { + send_gdb "y\n" + gdb_expect { -re ".*post-query.*$gdb_prompt$" \ { pass "re-run" } -re ".*$gdb_prompt$" { fail "re-run" } @@ -507,10 +507,10 @@ gdb_test_multiple "info inferior 1" "get inferior pid" { # annotate-signal-name-end # annotate-signal-string # annotate-signal-string-end -# FIXME: annotate-signal not tested (requires that the inferior be +# FIXME: annotate-signal not tested (requires that the inferior be # stopped by a "random" signal) -if [target_info exists gdb,nosignals] { +if {[target_info exists gdb,nosignals]} { unsupported "signal sent" } else { gdb_test_multiple "signal SIGTRAP" "signal sent" { @@ -528,12 +528,13 @@ proc thread_test {} { global gdb_prompt old_gdb_prompt global decimal set srcfile watch_thread_num.c - set binfile [standard_output_file ${testfile}-watch_thread_num] + set filename ${testfile}-watch_thread_num + set binfile [standard_output_file $filename] set gdb_prompt $old_gdb_prompt - if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] == "" } { + if { [prepare_for_testing "prepare" $filename $srcfile \ + {debug nowarnings pthreads}] == 0 } { - clean_restart $binfile if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/annota3.c b/gdb/testsuite/gdb.base/annota3.c index 424e1b8..b7cf98e 100644 --- a/gdb/testsuite/gdb.base/annota3.c +++ b/gdb/testsuite/gdb.base/annota3.c @@ -13,16 +13,16 @@ int main (void) { int my_array[3] = { 1, 2, 3 }; /* break main */ - + value = 7; - + #ifdef SIGUSR1 signal (SIGUSR1, handle_USR1); #endif printf ("value is %d\n", value); printf ("my_array[2] is %d\n", my_array[2]); - + { int i; for (i = 0; i < 5; i++) @@ -31,4 +31,3 @@ main (void) return 0; /* after loop */ } - diff --git a/gdb/testsuite/gdb.base/annota3.exp b/gdb/testsuite/gdb.base/annota3.exp index 134a3d3..62f1d43 100644 --- a/gdb/testsuite/gdb.base/annota3.exp +++ b/gdb/testsuite/gdb.base/annota3.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 @@ -78,14 +78,14 @@ gdb_test_multiple "if 1" "start if construct" { gdb_test_multiple "end" "end if construct" { -re "^end\r\n\r\n\032\032post-commands\r\n$gdb_prompt$" { - pass "end if construct" + pass "end if construct" } } # # info break: # -send_gdb "info break\n" +send_gdb "info break\n" gdb_expect_list "breakpoint info" "$gdb_prompt$" [concat { "\r\n\032\032post-prompt\r\n" "Num Type Disp Enb Address +What\r\n" } [list \ @@ -114,7 +114,7 @@ gdb_expect_list "run until main breakpoint" "$gdb_prompt$" [concat { # We don't care about the annotated output for this operation, it is the same as # the one produced by run above # -send_gdb "next\n" +send_gdb "next\n" gdb_expect_list "go after array init line" "$gdb_prompt$" { "\r\n\032\032post-prompt\r\n" "\r\n\032\032starting\r\n" @@ -183,10 +183,10 @@ gdb_expect_list "backtrace from shlibrary" "$gdb_prompt$" { # -# test printing a frame with some arguments: +# test printing a frame with some arguments: # -if [target_info exists gdb,nosignals] { +if {[target_info exists gdb,nosignals]} { unsupported "send SIGUSR1" unsupported "backtrace @ signal handler" } else { @@ -264,8 +264,8 @@ if {![is_remote host]} { send_gdb "run\n" gdb_expect { -re "pre-query.*already.*\\(y or n\\).*query\r\n" { - send_gdb "y\n" - gdb_expect { + send_gdb "y\n" + gdb_expect { -re ".*post-query.*$gdb_prompt$" \ { pass "re-run" } -re ".*$gdb_prompt$" { fail "re-run" } @@ -345,7 +345,7 @@ gdb_test_multiple "info inferior 1" "$test" { # Send a signal that is not handled -if [target_info exists gdb,nosignals] { +if {[target_info exists gdb,nosignals]} { unsupported "signal sent" } else { send_gdb "signal SIGTRAP\n" diff --git a/gdb/testsuite/gdb.base/annotate-symlink.exp b/gdb/testsuite/gdb.base/annotate-symlink.exp index 67f5841..a5d431e 100644 --- a/gdb/testsuite/gdb.base/annotate-symlink.exp +++ b/gdb/testsuite/gdb.base/annotate-symlink.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2019-2024 Free Software Foundation, Inc. +# Copyright (C) 2019-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 @@ -20,7 +20,7 @@ standard_testfile realname-expand.c realname-expand-real.c require {!is_remote host} set srcdirabs [file join [pwd] $srcdir] -set srcfilelink [standard_output_file realname-expand-link.c] +set srcfilelink [build_standard_output_file realname-expand-link.c] remote_exec build "ln -sf ${srcdirabs}/${subdir}/${srcfile2} $srcfilelink" diff --git a/gdb/testsuite/gdb.base/anon.exp b/gdb/testsuite/gdb.base/anon.exp index a6433f5..8f9e44b 100644 --- a/gdb/testsuite/gdb.base/anon.exp +++ b/gdb/testsuite/gdb.base/anon.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/args.exp b/gdb/testsuite/gdb.base/args.exp index 363d74a..07101da 100644 --- a/gdb/testsuite/gdb.base/args.exp +++ b/gdb/testsuite/gdb.base/args.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 @@ -21,6 +21,7 @@ require {!target_info exists noargs} # This test requires starting new inferior processes, skip it if the target # board is a stub. require !use_gdb_stub +require {expr {[have_startup_shell] != -1}} standard_testfile @@ -29,74 +30,187 @@ if {[build_executable $testfile.exp $testfile $srcfile] == -1} { return -1 } -# NAME is the name to use for the tests and ARGLIST is the list of -# arguments that are passed to GDB when it is started. +# Assuming a running GDB. Check the status of the single inferior +# argument feature. When this feature is on GDB passes inferior +# arguments as a single combined string. When this feature is off GDB +# will split the inferior arguments into multiple separate strings. # -# The optional RE_LIST is the list of patterns to check the arguments -# against, these patterns should match ARGLIST. If the arguments are -# expected to show up unmodified in the test output then RE_LIST can -# be dropped, and this proc will reuse ARGLIST. - -proc args_test { name arglist {re_list {}} } { - - # If RE_LIST is not supplied then we can reuse ARGLIST, this - # implies that the arguments will appear unmodified in the test - # output. - if {[llength $re_list] == 0} { - set re_list $arglist +# Return true when arguments are being split, or false when a single +# combined string is being sent. + +proc is_argument_splitting_on {} { + set arg_splitting true + + gdb_test_multiple "show remote single-inferior-argument-feature-packet" "" { + -re -wrap "Support for the 'single-inferior-argument-feature' packet on the current remote target is \"(on|off)\"\\.(.*)" { + set value $expect_out(1,string) + pass $gdb_test_name + if { $value eq "on" } { + set arg_splitting false + } + } + -re -wrap "Support for the 'single-inferior-argument-feature' packet on the current remote target is \"auto\", currently (enabled|disabled)\\.(.*)" { + set value $expect_out(1,string) + pass $gdb_test_name + if { $value eq "enabled" } { + set arg_splitting false + } + } } - foreach_with_prefix startup_with_shell { on off } { - save_vars { ::GDBFLAGS } { - set ::GDBFLAGS "$::GDBFLAGS --args $::binfile $arglist" - - clean_restart $::binfile - - gdb_test_no_output "set startup-with-shell ${startup_with_shell}" \ - "set startup-with-shell for $name" + return $arg_splitting +} - runto_main - gdb_breakpoint [gdb_get_line_number "set breakpoint here"] - gdb_continue_to_breakpoint "breakpoint for $name" +# NAME is the name to use for the tests and ARGLIST is the list of +# arguments that are passed to GDB when it is started. +# +# The optional RE_ESC_LIST is the list of patterns to check the +# inferior arguments against when GDB is started using --args. If +# RE_ESC_LIST is not given then ARGLIST is reused, this implies that +# the inferior arguments appear unchanged in the test output. +# +# The optional RE_NO_ESC_LIST is the list of patterns to check the +# inferior arguments against when GDB is started using +# --no-escape-args. If RE_NO_ESC_LIST is not given then RE_ESC_LIST +# is reused, this implies that there's no difference between the test +# output when the arguments are escaped or not. + +proc args_test { name arglist {re_esc_list {}} {re_no_esc_list {}} } { + + # If either of the two regexp lists are not specificed then we can + # use an earlier argument value instead. + # + # For the first regexp list, if this is missing then we use the + # argument list, this assumes that the arguments will appear + # unmodified in the output. + if {[llength $re_esc_list] == 0} { + set re_esc_list $arglist + } - set expected_len [expr 1 + [llength $re_list]] - gdb_test "print argc" "\\\$$::decimal = $expected_len" "argc for $name" + # If the second regexp list is missing then we reuse the first + # regexp list. This assumes there's no difference between escaped + # and unescaped arguments in the output. + if {[llength $re_no_esc_list] == 0} { + set re_no_esc_list $re_esc_list + } - set i 1 - foreach arg $re_list { - gdb_test "print argv\[$i\]" "\\\$$::decimal = $::hex \"$arg\"" \ - "argv\[$i\] for $name" - set i [expr $i + 1] + foreach_with_prefix startup_with_shell { on off } { + foreach_with_prefix arg_flag { args no-escape-args } { + save_vars { ::GDBFLAGS } { + set ::GDBFLAGS "$::GDBFLAGS --${arg_flag} $::binfile $arglist" + + clean_restart $::testfile + + gdb_test_no_output \ + "set startup-with-shell ${startup_with_shell}" \ + "set startup-with-shell for $name" + + runto_main + gdb_breakpoint [gdb_get_line_number "set breakpoint here"] + gdb_continue_to_breakpoint "breakpoint for $name" + + if { $arg_flag eq "args" || $startup_with_shell eq "off" } { + set re_list $re_esc_list + } else { + set re_list $re_no_esc_list + } + + set expected_len [expr {1 + [llength $re_list]}] + gdb_test "print argc" \ + "\\\$$::decimal = $expected_len" "argc for $name" + + set i 1 + foreach arg $re_list { + if { $arg eq "\n" } { + set arg {\\n} + } elseif { $arg eq "\"" } { + set arg {\\\"} + } + + # If we are starting with a shell, we're not escaping + # special shell characters in arguments passed to GDB, + # we're using a remote target, and the arguments contain + # a shell variable (indicated with a '$'), then this + # test will currently fail if we are splitting the + # arguments. + if { $startup_with_shell eq "on" + && $arg_flag eq "no-escape-args" + && [gdb_protocol_is_remote] + && [string first "\$" $arglist] != -1 + && [is_argument_splitting_on] } { + setup_xfail "*-*-*" gdb/28392 + } + + gdb_test "print argv\[$i\]" \ + "\\\$$::decimal = $::hex \"$arg\"" \ + "argv\[$i\] for $name" + set i [expr {$i + 1}] + } } } } } -# Test that the --args are processed correctly. +# Run all the tests. +proc run_all_tests {} { + # Test that the --args are processed correctly. + + args_test basic {{1} {3}} -args_test basic {{1} {3}} + # Test that the --args are processed correctly even if one of them is + # empty. -# Test that the --args are processed correctly even if one of them is -# empty. + args_test "one empty" {{1} {} {3}} -args_test "one empty" {{1} {} {3}} + # Try with 2 empty args. -# Try with 2 empty args. + args_test "two empty" {{1} {} {} 3} -args_test "two empty" {{1} {} {} 3} + # Try with arguments containing literal single quotes. -# Try with arguments containing literal single quotes. + args_test "one empty with single quotes" {{1} {''} {3}} -args_test "one empty with single quotes" {{1} {''} {3}} + args_test "two empty with single quotes" {{1} {''} {''} {3}} -args_test "two empty with single quotes" {{1} {''} {''} {3}} + # Try with arguments containing literal newlines. -# Try with arguments containing literal newlines. + args_test "one newline" {{1} "\n" {3}} {1 \\\\n 3} -args_test "one newline" {{1} "\n" {3}} {1 \\\\n 3} + args_test "two newlines" {{1} "\n" "\n" {3}} {1 \\\\n \\\\n 3} -args_test "two newlines" {{1} "\n" "\n" {3}} {1 \\\\n \\\\n 3} + args_test "lone single quote" {{1} \' {3}} -args_test "lone single quote" {{1} \' {3}} + args_test "lone double quote" {{1} \" {3}} {1 \\\\\" 3} -args_test "lone double quote" {{1} \" {3}} {1 \\\\\" 3} + save_vars { ::env(TEST) } { + set ::env(TEST) "ABCD" + args_test "shell variable" {{$TEST}} {\\$TEST} {{ABCD}} + } + + # At one point we had a bug where, if the last inferior argument, + # appearing after --args, looked like an option GDB might be able + # to process, e.g. started with a dash, then GDB would try to + # process it. This would leave GDB in a broken state, and so GDB + # would fail to start. A example of a failing GDB command line: + # $ gdb --args /bin/ls --all + foreach_with_prefix flag { args no-escape-args } { + args_test "with trailing GDB flag" [list "--${flag}"] + } + args_test "with trailing GDB option and value" [list "--ex" "start"] + args_test "with trailing double dash option" [list "--foo"] + args_test "with trailing single dash option" [list "-foo"] +} + +run_all_tests + +# For extended-remote targets, disable the packet which passes +# inferior arguments as a single string. This changes how the vRun +# (extended-remote only) packet works. +if {[target_info gdb_protocol] == "extended-remote"} { + with_test_prefix "single-inferior-arg disabled" { + save_vars { GDBFLAGS } { + append GDBFLAGS " -ex \"set remote single-inferior-argument-feature-packet off\"" + run_all_tests + } + } +} diff --git a/gdb/testsuite/gdb.base/argv0-symlink.c b/gdb/testsuite/gdb.base/argv0-symlink.c index 3fb9313..a950f3c 100644 --- a/gdb/testsuite/gdb.base/argv0-symlink.c +++ b/gdb/testsuite/gdb.base/argv0-symlink.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/argv0-symlink.exp b/gdb/testsuite/gdb.base/argv0-symlink.exp index 27ea8d9..6edaea8 100644 --- a/gdb/testsuite/gdb.base/argv0-symlink.exp +++ b/gdb/testsuite/gdb.base/argv0-symlink.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 @@ -17,7 +17,7 @@ # command expanding symlinks in the name of the program being run. # This test uses pathnames on build to create symbolic links on host and # expects the test program running on target to see those symbolic links. -# Therefore, it can't work reliably on anything other than configurations +# Therefore, it can't work reliably on anything other than configurations # where build/host/target are all the same. require isnative @@ -47,7 +47,7 @@ with_test_prefix "file symlink" { clean_restart "$filelink" - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -87,7 +87,7 @@ with_test_prefix "dir symlink" { clean_restart "$dirlink/$filelink" - if ![runto_main] { + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/arithmet.exp b/gdb/testsuite/gdb.base/arithmet.exp index c4a7f35..4e0ea12 100644 --- a/gdb/testsuite/gdb.base/arithmet.exp +++ b/gdb/testsuite/gdb.base/arithmet.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -20,7 +20,7 @@ # # tests for correctness of arithmetic operators, associativity and precedence # with integer type variables -# +# # # test running programs @@ -54,7 +54,7 @@ gdb_test "print x" "14" gdb_test "print y" "2" gdb_test "print z" "2" gdb_test "print w" "3" - + gdb_test "print x+y" "16" gdb_test "print x-y" "12" gdb_test "print x*y" "28" diff --git a/gdb/testsuite/gdb.base/array-indices.exp b/gdb/testsuite/gdb.base/array-indices.exp index 84f7191..4c16179 100644 --- a/gdb/testsuite/gdb.base/array-indices.exp +++ b/gdb/testsuite/gdb.base/array-indices.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/array-indices.exp.tcl b/gdb/testsuite/gdb.base/array-indices.exp.tcl index 7374753..e2a8613 100644 --- a/gdb/testsuite/gdb.base/array-indices.exp.tcl +++ b/gdb/testsuite/gdb.base/array-indices.exp.tcl @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/array-repeat.c b/gdb/testsuite/gdb.base/array-repeat.c index ec509f4..bf6daf5 100644 --- a/gdb/testsuite/gdb.base/array-repeat.c +++ b/gdb/testsuite/gdb.base/array-repeat.c @@ -1,4 +1,4 @@ -/* Copyright 2022-2024 Free Software Foundation, Inc. +/* Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/array-repeat.exp b/gdb/testsuite/gdb.base/array-repeat.exp index 1379ae7..368ab28 100644 --- a/gdb/testsuite/gdb.base/array-repeat.exp +++ b/gdb/testsuite/gdb.base/array-repeat.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/array-repeat.exp.tcl b/gdb/testsuite/gdb.base/array-repeat.exp.tcl index b4a656e..e2ae5a2 100644 --- a/gdb/testsuite/gdb.base/array-repeat.exp.tcl +++ b/gdb/testsuite/gdb.base/array-repeat.exp.tcl @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c index e44256b..719087b 100644 --- a/gdb/testsuite/gdb.base/arrayidx.c +++ b/gdb/testsuite/gdb.base/arrayidx.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2005-2024 Free Software Foundation, Inc. + Copyright 2005-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 diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp index e279c9c..07ce4d9 100644 --- a/gdb/testsuite/gdb.base/arrayidx.exp +++ b/gdb/testsuite/gdb.base/arrayidx.exp @@ -1,4 +1,4 @@ -# Copyright 2005-2024 Free Software Foundation, Inc. +# Copyright 2005-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 @@ -19,13 +19,10 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart ${binfile} - if {![runto_main]} { return } @@ -33,27 +30,25 @@ if {![runto_main]} { # First, print the array without the indexes gdb_test_no_output "set print array-indexes off" \ - "set print array-indexes to off" + "set print array-indexes to off" gdb_test "show print array-indexes" \ - "Printing of array indexes is off\\." \ - "show print array-indexes is off" + "Printing of array indexes is off\\." \ + "show print array-indexes is off" gdb_test "print array" \ - "\\{1, 2, 3, 4\\}" \ - "print array with array-indexes off" + "\\{1, 2, 3, 4\\}" \ + "print array with array-indexes off" # Second, print the same array with the indexes gdb_test_no_output "set print array-indexes on" \ - "set print array-indexes to on" + "set print array-indexes to on" gdb_test "show print array-indexes" \ - "Printing of array indexes is on\\." \ - "show print array-indexes is on" + "Printing of array indexes is on\\." \ + "show print array-indexes is on" gdb_test "print array" \ - "\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \ - "print array with array-indexes on" - - + "\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \ + "print array with array-indexes on" diff --git a/gdb/testsuite/gdb.base/asmlabel.c b/gdb/testsuite/gdb.base/asmlabel.c index 1ccee4b..49a3250 100644 --- a/gdb/testsuite/gdb.base/asmlabel.c +++ b/gdb/testsuite/gdb.base/asmlabel.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/asmlabel.exp b/gdb/testsuite/gdb.base/asmlabel.exp index f3af063..6a4d2a2 100644 --- a/gdb/testsuite/gdb.base/asmlabel.exp +++ b/gdb/testsuite/gdb.base/asmlabel.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2024 Free Software Foundation, Inc. +# Copyright (C) 2015-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 @@ -37,7 +37,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.base/assign.exp b/gdb/testsuite/gdb.base/assign.exp index 38c2b2e..b624997 100644 --- a/gdb/testsuite/gdb.base/assign.exp +++ b/gdb/testsuite/gdb.base/assign.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -19,7 +19,7 @@ # # tests for all the assignemnt operators # with mixed types and with int type variables -# +# # # test running programs @@ -27,14 +27,9 @@ standard_testfile all-types.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { - untested "failed to compile" - return -1 - } - - -clean_restart ${binfile} - +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return +} # # set it up at a breakpoint so we can play with the variable values diff --git a/gdb/testsuite/gdb.base/async-shell.c b/gdb/testsuite/gdb.base/async-shell.c index 3acdee0..401cb4b 100644 --- a/gdb/testsuite/gdb.base/async-shell.c +++ b/gdb/testsuite/gdb.base/async-shell.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/async-shell.exp b/gdb/testsuite/gdb.base/async-shell.exp index 991ab7f..228ed10 100644 --- a/gdb/testsuite/gdb.base/async-shell.exp +++ b/gdb/testsuite/gdb.base/async-shell.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2024 Free Software Foundation, Inc. +# Copyright (C) 2011-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 diff --git a/gdb/testsuite/gdb.base/async.c b/gdb/testsuite/gdb.base/async.c index 9148b19..4a0e59d 100644 --- a/gdb/testsuite/gdb.base/async.c +++ b/gdb/testsuite/gdb.base/async.c @@ -22,7 +22,7 @@ int main (void) { int y, z; - + y = 2; z = 9; y = foo (); diff --git a/gdb/testsuite/gdb.base/async.exp b/gdb/testsuite/gdb.base/async.exp index f1cd569..5ce8f50 100644 --- a/gdb/testsuite/gdb.base/async.exp +++ b/gdb/testsuite/gdb.base/async.exp @@ -1,4 +1,4 @@ -# Copyright 1999-2024 Free Software Foundation, Inc. +# Copyright 1999-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 @@ -48,7 +48,7 @@ proc test_background {command before_prompt after_prompt {message ""}} { global gdb_prompt if {$message eq ""} { - set message $command + set message $command } send_gdb "$command\n" @@ -109,7 +109,7 @@ gdb_test_multiple {x/2i $pc} "$test" { } } set next_insn_is_stmt \ - [expr [lsearch -regexp $is_stmt 0x0*$next_insn_addr] != -1] + [expr {[lsearch -regexp $is_stmt 0x0*$next_insn_addr] != -1}] if { $next_insn_is_stmt } { set prefix "" diff --git a/gdb/testsuite/gdb.base/attach-deleted-exec.c b/gdb/testsuite/gdb.base/attach-deleted-exec.c index ebfae87..8b8c1be 100644 --- a/gdb/testsuite/gdb.base/attach-deleted-exec.c +++ b/gdb/testsuite/gdb.base/attach-deleted-exec.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/attach-deleted-exec.exp b/gdb/testsuite/gdb.base/attach-deleted-exec.exp index 1196115..45fac0d 100644 --- a/gdb/testsuite/gdb.base/attach-deleted-exec.exp +++ b/gdb/testsuite/gdb.base/attach-deleted-exec.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2024 Free Software Foundation, Inc. +# Copyright (C) 2024-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 @@ -67,5 +67,49 @@ if { [regexp $re_nfs $filename] } { gdb_assert { [string equal $filename /proc/${testpid}/exe] } $test } +# Restart GDB. +clean_restart + +# Setup an empty sysroot. GDB will fail to find the executable within +# the sysroot. Additionally, the presence of a sysroot should prevent +# GDB from trying to load the executable from /proc/PID/exe. +set sysroot [standard_output_file "sysroot"] +gdb_test_no_output "set sysroot $sysroot" \ + "setup sysroot" + +# Attach to the inferior. GDB should complain about failing to find +# the executable. It is the name of the executable that GDB doesn't +# find that we're interesting in here. For native targets GDB should +# be looking for BINFILE, not /proc/PID/exe. +# +# For extended-remote targets things are unfortunately harder. Native +# GDB looks for BINFILE because it understands that GDB will be +# looking in the sysroot. But remote GDB doesn't know if GDB is using +# a sysroot or not. As such, gdbserver will return /proc/PID/exe if +# it knows that the file has been deleted locally. This isn't great +# if GDB then plans to look in a sysroot, but equally, if the remote +# file has been deleted, then the name GDB will return, will have had +# " (deleted" appended, so we're unlikely to get a hit in the sysroot +# either way. +if { [target_info gdb_protocol] == "extended-remote" } { + set filename_re "/proc/$testpid/exe" +} else { + set filename_re "\[^\r\n\]+/${testfile} \\(deleted\\)" +} + +verbose -log "APB: warning: No executable has been specified, and target executable $filename_re could not be found\\. Try using the \"file\" command\\." + +gdb_test "attach $testpid" \ + [multi_line \ + "Attaching to process $decimal" \ + "warning: No executable has been specified, and target executable $filename_re could not be found\\. Try using the \"file\" command\\." \ + ".*"] \ + "attach to inferior" + +# Check GDB hasn't managed to load an executable. +gdb_test "info inferior" \ + "\\*\[^)\]+\\)\\s*" \ + "confirm no executable is loaded." + # Cleanup. kill_wait_spawned_process $test_spawn_id diff --git a/gdb/testsuite/gdb.base/attach-fail-twice.c b/gdb/testsuite/gdb.base/attach-fail-twice.c index d045e35..6bc7f6b 100644 --- a/gdb/testsuite/gdb.base/attach-fail-twice.c +++ b/gdb/testsuite/gdb.base/attach-fail-twice.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/attach-fail-twice.exp b/gdb/testsuite/gdb.base/attach-fail-twice.exp index 5902046..7c7b85d6 100644 --- a/gdb/testsuite/gdb.base/attach-fail-twice.exp +++ b/gdb/testsuite/gdb.base/attach-fail-twice.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 @@ -77,7 +77,7 @@ proc test_good_attach {test} { } proc_with_prefix test {} { - clean_restart $::binfile + clean_restart $::testfile # GDB used to have a bug on Windows where failing to attach once # made a subsequent "attach" or "run" hang. So it's important for diff --git a/gdb/testsuite/gdb.base/attach-non-pgrp-leader.c b/gdb/testsuite/gdb.base/attach-non-pgrp-leader.c index 62ceef4..eee5ee4 100644 --- a/gdb/testsuite/gdb.base/attach-non-pgrp-leader.c +++ b/gdb/testsuite/gdb.base/attach-non-pgrp-leader.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/attach-non-pgrp-leader.exp b/gdb/testsuite/gdb.base/attach-non-pgrp-leader.exp index 7d1bfe1..02142e7 100644 --- a/gdb/testsuite/gdb.base/attach-non-pgrp-leader.exp +++ b/gdb/testsuite/gdb.base/attach-non-pgrp-leader.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -36,7 +36,7 @@ proc do_test {} { # Attach to the parent, run it to a known point, extract the # child's PID, and detach. with_test_prefix "parent" { - clean_restart ${binfile} + clean_restart $::testfile gdb_test "attach $parent_pid" \ "Attaching to program.*, process $parent_pid.*" \ @@ -56,7 +56,7 @@ proc do_test {} { # Start over, and attach to the child this time. with_test_prefix "child" { - clean_restart $binfile + clean_restart $::testfile gdb_test "attach $child_pid" \ "Attaching to program.*, process $child_pid.*" \ diff --git a/gdb/testsuite/gdb.base/attach-pie-misread.c b/gdb/testsuite/gdb.base/attach-pie-misread.c index 9fd03d9..b41c18d 100644 --- a/gdb/testsuite/gdb.base/attach-pie-misread.c +++ b/gdb/testsuite/gdb.base/attach-pie-misread.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/attach-pie-misread.exp b/gdb/testsuite/gdb.base/attach-pie-misread.exp index 7943170..5f85d00 100644 --- a/gdb/testsuite/gdb.base/attach-pie-misread.exp +++ b/gdb/testsuite/gdb.base/attach-pie-misread.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -39,18 +39,18 @@ proc read_phdr {binfile test} { set readelf_program [gdb_find_readelf] set command "exec $readelf_program -Wl $binfile" verbose -log "command is $command" - set result [catch $command output] + set result [catch {{*}$command} output] verbose -log "result is $result" verbose -log "output is $output" if {$result != 0} { fail $test return } - if ![regexp {\nProgram Headers:\n *Type [^\n]* Align\n(.*?)\n\n} $output trash phdr] { + if {![regexp {\nProgram Headers:\n *Type [^\n]* Align\n(.*?)\n\n} $output trash phdr]} { fail "$test (no Program Headers)" return } - if ![regexp -line {^ *DYNAMIC +0x[0-9a-f]+ +(0x[0-9a-f]+) } $phdr trash dynamic_vaddr] { + if {![regexp -line {^ *DYNAMIC +0x[0-9a-f]+ +(0x[0-9a-f]+) } $phdr trash dynamic_vaddr]} { fail "$test (no DYNAMIC found)" return } @@ -74,7 +74,7 @@ set phdr [read_phdr $binfile "readelf initial scan"] set dynamic_vaddr [lindex $phdr 0] set align_max [lindex $phdr 1] -set stub_size [format 0x%x [expr "2 * $align_max - ($dynamic_vaddr & ($align_max - 1))"]] +set stub_size [format 0x%x [expr {2 * $align_max - ($dynamic_vaddr & ($align_max - 1))}]] verbose -log "stub_size is $stub_size" # On x86_64 it is commonly about 4MB. @@ -86,7 +86,7 @@ if {$stub_size > 25000000} { set test "generate stub" set command "exec $binfile $stub_size >$genfile" verbose -log "command is $command" -set result [catch $command output] +set result [catch {{*}$command} output] verbose -log "result is $result" verbose -log "output is $output" if {$result == 0} { @@ -109,14 +109,14 @@ file delete -- $genfile set phdr [read_phdr $binfile "readelf rebuilt with stub_size"] set dynamic_vaddr_prelinkno [lindex $phdr 0] -if ![prelink_yes $prelink_args] { +if {![prelink_yes $prelink_args]} { return -1 } set phdr [read_phdr $binfile "readelf with prelink -R"] set dynamic_vaddr_prelinkyes [lindex $phdr 0] -set first_offset [format 0x%x [expr $dynamic_vaddr_prelinkyes - $dynamic_vaddr_prelinkno]] +set first_offset [format 0x%x [expr {$dynamic_vaddr_prelinkyes - $dynamic_vaddr_prelinkno}]] verbose -log "first_offset is $first_offset" set test "first offset is non-zero" @@ -156,7 +156,7 @@ gdb_expect { foreach align_mult {1 2} { with_test_prefix "shift-by-$align_mult" { # FIXME: We believe there is enough room under FIRST_OFFSET. - set shifted_offset [format 0x%x [expr "$first_offset - $align_mult * $align_max"]] + set shifted_offset [format 0x%x [expr {$first_offset - $align_mult * $align_max}]] verbose -log "shifted_offset is $shifted_offset" # For normal prelink (prelink_yes call), we need to supply $prelink_args. @@ -165,7 +165,7 @@ foreach align_mult {1 2} { with_test_prefix "shift-by-$align_mult" { # as the libraries would also get relocated. set command "exec /usr/sbin/prelink -q -N --no-exec-shield -r $shifted_offset $binfile" verbose -log "command is $command" - set result [catch $command output] + set result [catch {{*}$command} output] verbose -log "result is $result" verbose -log "output is $output" diff --git a/gdb/testsuite/gdb.base/attach-pie-noexec.c b/gdb/testsuite/gdb.base/attach-pie-noexec.c index d9fab24..d1e431f 100644 --- a/gdb/testsuite/gdb.base/attach-pie-noexec.c +++ b/gdb/testsuite/gdb.base/attach-pie-noexec.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/attach-pie-noexec.exp b/gdb/testsuite/gdb.base/attach-pie-noexec.exp index 4e6ede1..58f1890 100644 --- a/gdb/testsuite/gdb.base/attach-pie-noexec.exp +++ b/gdb/testsuite/gdb.base/attach-pie-noexec.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2024 Free Software Foundation, Inc. +# Copyright (C) 2011-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 @@ -30,12 +30,12 @@ gdb_test_multiple $test $test { pass $test } } -if ![runto_main] { +if {![runto_main]} { return 0 } set test "sanity check info shared" gdb_test_multiple "info shared" $test { - -re "From\[ \t\]+To\[ \t\]+Syms Read\[ \t\]+Shared Object Library\r\n0x.*\r\n$gdb_prompt $" { + -re "From\[ \t\]+To(\\s+NS)?\[ \t\]+Syms Read\[ \t\]+Shared Object Library\r\n0x.*\r\n$gdb_prompt $" { pass $test } -re "No shared libraries loaded at this time\\.\r\n$gdb_prompt $" { @@ -62,6 +62,6 @@ if { ![gdb_attach $testpid] } { return } gdb_test "set architecture $arch" "The target architecture is set to \"$arch\"\\." -gdb_test "info shared" "From\[ \t\]+To\[ \t\]+Syms Read\[ \t\]+Shared Object Library\r\n0x.*" +gdb_test "info shared" "From\[ \t\]+To(\\s+NS)?\[ \t\]+Syms Read\[ \t\]+Shared Object Library\r\n0x.*" kill_wait_spawned_process $test_spawn_id diff --git a/gdb/testsuite/gdb.base/attach-twice.c b/gdb/testsuite/gdb.base/attach-twice.c index 7b0af35..41e808c 100644 --- a/gdb/testsuite/gdb.base/attach-twice.c +++ b/gdb/testsuite/gdb.base/attach-twice.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/attach-twice.exp b/gdb/testsuite/gdb.base/attach-twice.exp index 87a12dc..63205e2 100644 --- a/gdb/testsuite/gdb.base/attach-twice.exp +++ b/gdb/testsuite/gdb.base/attach-twice.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2024 Free Software Foundation, Inc. +# Copyright (C) 2012-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 @@ -45,6 +45,6 @@ gdb_test_multiple "attach $testpid" $test { } if {$parentpid != 0} { - eval exec kill -9 $parentpid + exec kill -9 $parentpid } kill_wait_spawned_process $test_spawn_id diff --git a/gdb/testsuite/gdb.base/attach-wait-input.c b/gdb/testsuite/gdb.base/attach-wait-input.c index 87219cd..8e88317 100644 --- a/gdb/testsuite/gdb.base/attach-wait-input.c +++ b/gdb/testsuite/gdb.base/attach-wait-input.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/attach-wait-input.exp b/gdb/testsuite/gdb.base/attach-wait-input.exp index bbe73d1..35c8f0c 100644 --- a/gdb/testsuite/gdb.base/attach-wait-input.exp +++ b/gdb/testsuite/gdb.base/attach-wait-input.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -39,11 +39,11 @@ if {[build_executable "failed to build" $testfile $srcfile debug]} { # Start the program running, and return its PID, ready for attaching. -proc start_program {binfile} { +proc start_program {testfile} { global gdb_prompt global decimal - clean_restart $binfile + clean_restart $testfile if {![runto setup_done]} { return 0 @@ -73,12 +73,11 @@ proc start_program {binfile} { proc test { editing } { global gdb_prompt - global binfile global decimal with_test_prefix "editing $editing" { - set testpid [start_program $binfile] + set testpid [start_program $::testfile] if {$testpid == ""} { return } diff --git a/gdb/testsuite/gdb.base/attach.c b/gdb/testsuite/gdb.base/attach.c index b3c5498..5133dd0 100644 --- a/gdb/testsuite/gdb.base/attach.c +++ b/gdb/testsuite/gdb.base/attach.c @@ -5,7 +5,7 @@ exit unless/until gdb sets the variable to non-zero.) */ #include <stdio.h> -#include <unistd.h> +#include "gdb_watchdog.h" int bidule = 0; volatile int should_exit = 0; @@ -14,7 +14,7 @@ int main () { int local_i = 0; - alarm (60); + gdb_watchdog (60); while (! should_exit) { diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp index 2b655e6..5e178c9 100644 --- a/gdb/testsuite/gdb.base/attach.exp +++ b/gdb/testsuite/gdb.base/attach.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -56,7 +56,7 @@ proc_with_prefix do_attach_failure_tests {} { global escapedbinfile global srcfile - clean_restart $binfile + clean_restart $::testfile # Figure out a regular expression that will match the sysroot, # noting that the default sysroot is "target:", and also noting @@ -83,7 +83,7 @@ proc_with_prefix do_attach_failure_tests {} { } -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $" { # Response expected from /proc-based systems. - pass "$test" + pass "$test" } -re "Can't attach to process..*$gdb_prompt $" { # Response expected on Cygwin @@ -104,7 +104,7 @@ proc_with_prefix do_attach_failure_tests {} { } -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $" { # Response expected from /proc-based systems. - pass "$test" + pass "$test" } -re "Can't attach to process..*$gdb_prompt $" { # Response expected on Cygwin @@ -156,7 +156,7 @@ proc_with_prefix do_attach_failure_tests {} { pass "$test" } } - + # Verify that we can't double attach to the process. set test "first attach" @@ -215,7 +215,7 @@ proc_with_prefix do_attach_tests {} { global timeout global decimal - clean_restart $binfile + clean_restart $::testfile # Figure out a regular expression that will match the sysroot, # noting that the default sysroot is "target:", and also noting @@ -240,7 +240,7 @@ proc_with_prefix do_attach_tests {} { # (Actually, the test system appears to do this automatically for # us. So, we must also be prepared to be asked if we want to # discard an existing set of symbols.) - + set test "set file, before attach1" gdb_test_multiple "file $binfile" "$test" { -re "Load new symbol table from.*y or n. $" { @@ -265,25 +265,25 @@ proc_with_prefix do_attach_tests {} { # Verify that we can "see" the variable "should_exit" in the # program, and that it is zero. - + gdb_test "print should_exit" " = 0" "after attach1, print should_exit" # Detach the process. - + gdb_test "detach" \ "Detaching from program: .*$escapedbinfile, process $testpid\r\n\\\[Inferior $decimal \\(.*\\) detached\\\]" \ "attach1 detach" # Wait a bit for gdb to finish detaching - + exec sleep 5 # Purge the symbols from gdb's brain. (We want to be certain the # next attach, which won't be preceded by a "file" command, is # really getting the executable file without our help.) - + set old_timeout $timeout - set timeout 15 + set timeout 15 set test "attach1, purging symbols after detach" gdb_test_multiple "file" "$test" { -re "No executable file now.*Discard symbol table.*y or n. $" { @@ -294,7 +294,7 @@ proc_with_prefix do_attach_tests {} { # Verify that we can attach to the process just by giving the # process ID. - + set test "attach2, with no file" set found_exec_file 0 gdb_test_multiple "attach $testpid" "$test" { @@ -354,7 +354,7 @@ proc_with_prefix do_attach_tests {} { # Verify that we can attach to the process, and find its a.out # when we're cd'd to some directory that doesn't contain the # a.out. (We use the source path set by the "dir" command.) - + gdb_test "dir [standard_output_file {}]" "Source directories searched: .*" \ "set source path" @@ -387,7 +387,7 @@ proc_with_prefix do_attach_tests {} { "$test" \ "Kill the program being debugged.*y or n. $" \ "y" - + # Another "don't leave a process around" kill_wait_spawned_process $test_spawn_id } @@ -404,7 +404,7 @@ proc_with_prefix do_call_attach_tests {} { set testpid [spawn_id_get_pid $test_spawn_id] # Attach - + gdb_test "file $binfile2" ".*" "load file" set test "attach call" gdb_test_multiple "attach $testpid" "$test" { @@ -420,7 +420,7 @@ proc_with_prefix do_call_attach_tests {} { } # See if other registers are problems - + set test "info other register" gdb_test_multiple "i r r3" "$test" { -re "warning: reading register.*$gdb_prompt $" { @@ -432,12 +432,12 @@ proc_with_prefix do_call_attach_tests {} { } # Get rid of the process - + gdb_test "p should_exit = 1" gdb_continue_to_end - + # Be paranoid - + kill_wait_spawned_process $test_spawn_id } @@ -519,7 +519,7 @@ proc_with_prefix do_attach_exec_mismatch_handling_tests {} { global binfile2 global binfile3 - clean_restart $binfile + clean_restart $::testfile # Start two programs that can be attached to. # The first program contains a 'int bidule' variable, the second a 'float bidule'. @@ -588,7 +588,7 @@ proc_with_prefix do_attach_exec_mismatch_handling_tests {} { gdb_test "y" "Reading symbols from .*attach.*" $gdb_test_name } } - + gdb_test "detach" "Detaching from program: .* detached\\\]" "$test detach attach initial exec-file" diff --git a/gdb/testsuite/gdb.base/attach2.c b/gdb/testsuite/gdb.base/attach2.c index d070d93..2da4888 100644 --- a/gdb/testsuite/gdb.base/attach2.c +++ b/gdb/testsuite/gdb.base/attach2.c @@ -18,7 +18,7 @@ int main () /* Cannot sleep a very long time, as attach.exp assumes the process will exit before the standard GDB timeout. */ sleep( 10 ); /* System call causes register fetch to fail */ - /* This is a known HPUX "feature" */ + /* This is a known HPUX "feature" */ while (! should_exit) { local_i++; diff --git a/gdb/testsuite/gdb.base/attach3.c b/gdb/testsuite/gdb.base/attach3.c index 09a6d88..0882e43 100644 --- a/gdb/testsuite/gdb.base/attach3.c +++ b/gdb/testsuite/gdb.base/attach3.c @@ -16,7 +16,7 @@ int main () int local_i = 0; sleep( 60 ); /* System call causes register fetch to fail */ - /* This is a known HPUX "feature" */ + /* This is a known HPUX "feature" */ while (! should_exit) { local_i++; diff --git a/gdb/testsuite/gdb.base/auto-connect-native-target.c b/gdb/testsuite/gdb.base/auto-connect-native-target.c index f63feb6..23048cb 100644 --- a/gdb/testsuite/gdb.base/auto-connect-native-target.c +++ b/gdb/testsuite/gdb.base/auto-connect-native-target.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 @@ -20,4 +20,3 @@ main () { return 0; } - diff --git a/gdb/testsuite/gdb.base/auto-connect-native-target.exp b/gdb/testsuite/gdb.base/auto-connect-native-target.exp index fe1ed2f..914e3ba 100644 --- a/gdb/testsuite/gdb.base/auto-connect-native-target.exp +++ b/gdb/testsuite/gdb.base/auto-connect-native-target.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/auto-load-script b/gdb/testsuite/gdb.base/auto-load-script index fcf3d64..6d2f1db 100644 --- a/gdb/testsuite/gdb.base/auto-load-script +++ b/gdb/testsuite/gdb.base/auto-load-script @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/auto-load.c b/gdb/testsuite/gdb.base/auto-load.c index c38538d..120c08d 100644 --- a/gdb/testsuite/gdb.base/auto-load.c +++ b/gdb/testsuite/gdb.base/auto-load.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/auto-load.exp b/gdb/testsuite/gdb.base/auto-load.exp index 1517509..2faa292 100644 --- a/gdb/testsuite/gdb.base/auto-load.exp +++ b/gdb/testsuite/gdb.base/auto-load.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/auxv.c b/gdb/testsuite/gdb.base/auxv.c index 7d434c7..c9a20ab 100644 --- a/gdb/testsuite/gdb.base/auxv.c +++ b/gdb/testsuite/gdb.base/auxv.c @@ -1,4 +1,4 @@ -/* Copyright 1992-2024 Free Software Foundation, Inc. +/* Copyright 1992-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/auxv.exp b/gdb/testsuite/gdb.base/auxv.exp index 0759a4f..fc98014 100644 --- a/gdb/testsuite/gdb.base/auxv.exp +++ b/gdb/testsuite/gdb.base/auxv.exp @@ -1,6 +1,6 @@ # Test `info auxv' and related functionality. -# Copyright (C) 1992-2024 Free Software Foundation, Inc. +# Copyright (C) 1992-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 @@ -37,11 +37,11 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \ # Make it the working directory for the inferior. set coredir [standard_output_file coredir.[getpid]] file mkdir $coredir -set core_works [expr [isnative] && ! [is_remote target]] +set core_works [expr {[isnative] && ! [is_remote target]}] # Run GDB on the test program up to where it will dump core. -clean_restart ${binfile} +clean_restart $testfile gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set width 0" diff --git a/gdb/testsuite/gdb.base/average.c b/gdb/testsuite/gdb.base/average.c index 874bb1a..b99dcf4 100644 --- a/gdb/testsuite/gdb.base/average.c +++ b/gdb/testsuite/gdb.base/average.c @@ -9,14 +9,14 @@ extern int sum(int *, int, int); static int my_list[num] = {3,4,2,0,2,1,8,3,6,7}; -void print_average(int *list, int low, int high) +void print_average(int *list, int low, int high) { - int total = 0, num_elements = 0, average = 0; - total = sum(list, low, high); - num_elements = high - low; /* note this is an off-by-one bug */ + int total = 0, num_elements = 0, average = 0; + total = sum(list, low, high); + num_elements = high - low; /* note this is an off-by-one bug */ - average = total / num_elements; - printf("%10.d\n", average); + average = total / num_elements; + printf("%10.d\n", average); } int main(void) diff --git a/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp b/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp index 53bf642..aa80442 100644 --- a/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp +++ b/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp @@ -31,7 +31,7 @@ proc prepare_test {has_cfi} { "${objcallerfile}" \ object [list {additional_flags=-fomit-frame-pointer \ -funwind-tables -fasynchronous-unwind-tables}]] != "" } { - untested "couldn't compile with cfi" + untested "couldn't compile" return false } } else { @@ -41,7 +41,7 @@ proc prepare_test {has_cfi} { object [list {additional_flags=-fomit-frame-pointer \ -fno-unwind-tables \ -fno-asynchronous-unwind-tables}]] != "" } { - untested "couldn't compile without cfi" + untested "couldn't compile" return false } } @@ -52,17 +52,14 @@ proc prepare_test {has_cfi} { return false } - clean_restart "$binfile-${extension}" + clean_restart $::testfile-$extension - with_test_prefix "${extension}" { - - if ![runto callback] then { - fail "has_cfi=$has_cfi: Can't run to callback" - return false - } - gdb_test_no_output "maint frame-unwinder disable ARCH" - return true + if { ![runto callback] } { + fail "has_cfi=$has_cfi: Can't run to callback" + return false } + gdb_test_no_output "maint frame-unwinder disable ARCH" + return true } if {[gdb_compile "${srcdir}/${subdir}/${srcfile2}" \ @@ -72,15 +69,45 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile2}" \ return } -if { [prepare_test false] } { - gdb_test "bt" \ +proc_with_prefix no-cfi {} { + if { ![prepare_test false] } { + return + } + + set re_msg \ + [string_list_to_regexp \ + "Required frame unwinder may have been disabled," \ + " see 'maint info frame-unwinders'"] + set hs {[^\r\n]} + set re_bt_line "#0\\s+[string_to_regexp {callback ()}] $hs+" + set re_bt_no_filters \ [multi_line \ - "\[^\r\n\]+Required frame unwinder may have been disabled, \[^\r\n\]+" \ - "#0\\s+callback \\(\\) \[^\r\n\]+"] \ - "verify unwind fail without CFI" + $re_bt_line \ + $re_msg] + gdb_test "bt -no-filters" \ + $re_bt_no_filters \ + "verify no-filters unwind fail" + + # Flush frame cache to retrigger the message. + gdb_test "maint flush register-cache" \ + [string_to_regexp "Register cache flushed."] + + # This output may occur when we run into the message while applying the + # frame filters. + set re_bt \ + [multi_line \ + $hs+$re_msg \ + $re_bt_line] + gdb_test "bt" \ + "($re_bt|$re_bt_no_filters)" \ + "verify unwind fail" } -if { [prepare_test true] } { +proc_with_prefix cfi {} { + if { ![prepare_test true] } { + return + } + if { [istarget "arm*-*-*"] } { setup_kfail backtrace/31950 *-*-* } @@ -89,6 +116,12 @@ if { [prepare_test true] } { # #1 0x00000000004004e9 in caller () # #2 0x00000000004004cd in main () at ... gdb_test "bt" \ - "#0 +callback $text\r\n#1 $text in caller $text\r\n#2 $text in main $text" \ - "Verify unwinding works based only on CFI information" + [multi_line \ + "#0 +callback $text" \ + "#1 $text in caller $text" \ + "#2 $text in main $text"] \ + "Verify unwinding works" } + +no-cfi +cfi diff --git a/gdb/testsuite/gdb.base/backtrace.c b/gdb/testsuite/gdb.base/backtrace.c index 50995ad..33edd39 100644 --- a/gdb/testsuite/gdb.base/backtrace.c +++ b/gdb/testsuite/gdb.base/backtrace.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/backtrace.exp b/gdb/testsuite/gdb.base/backtrace.exp index fd6b358..3020666 100644 --- a/gdb/testsuite/gdb.base/backtrace.exp +++ b/gdb/testsuite/gdb.base/backtrace.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -17,11 +17,7 @@ standard_testfile -set flags {} -lappend flags debug -lappend_include_file flags $srcdir/lib/attributes.h - -if { [prepare_for_testing "failed to prepare" $testfile $srcfile $flags] } { +if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { return -1 } diff --git a/gdb/testsuite/gdb.base/bad-file.exp b/gdb/testsuite/gdb.base/bad-file.exp index 1a9fa35..b823eaa 100644 --- a/gdb/testsuite/gdb.base/bad-file.exp +++ b/gdb/testsuite/gdb.base/bad-file.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/bang.exp b/gdb/testsuite/gdb.base/bang.exp index e8acda3..2848c6f 100644 --- a/gdb/testsuite/gdb.base/bang.exp +++ b/gdb/testsuite/gdb.base/bang.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 diff --git a/gdb/testsuite/gdb.base/basic-edit-cmd.c b/gdb/testsuite/gdb.base/basic-edit-cmd.c index fb0f70d..43e1984 100644 --- a/gdb/testsuite/gdb.base/basic-edit-cmd.c +++ b/gdb/testsuite/gdb.base/basic-edit-cmd.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/basic-edit-cmd.exp b/gdb/testsuite/gdb.base/basic-edit-cmd.exp index aa0efb5..8f7369d 100644 --- a/gdb/testsuite/gdb.base/basic-edit-cmd.exp +++ b/gdb/testsuite/gdb.base/basic-edit-cmd.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 @@ -42,7 +42,7 @@ if {![runto_main]} { # Are we using DWARF debug format? get_debug_format -set non_dwarf [expr ! [test_debug_format "DWARF \[0-9\]"]] +set non_dwarf [expr {! [test_debug_format "DWARF \[0-9\]"]}] # Find line numbers for use in tests. set line_0 [gdb_get_line_number "prologue location"] @@ -68,7 +68,7 @@ save_vars { env(EDITOR) } { "try edit when no symbol file is loaded" # Now start with a test binary. - clean_restart $binfile + clean_restart $testfile with_test_prefix "before starting inferior" { diff --git a/gdb/testsuite/gdb.base/batch-exit-status.exp b/gdb/testsuite/gdb.base/batch-exit-status.exp index 5151464..86e5fdd 100644 --- a/gdb/testsuite/gdb.base/batch-exit-status.exp +++ b/gdb/testsuite/gdb.base/batch-exit-status.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2018-2024 Free Software Foundation, Inc. +# Copyright (C) 2018-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 @@ -29,7 +29,7 @@ proc _test_exit_status {expect_status cmdline_opts {re ""}} { return } - set has_re [expr ![string equal $re ""]] + set has_re [expr {![string equal $re ""]}] if { ! $has_re } { set re "\$FOOBAR^" } diff --git a/gdb/testsuite/gdb.base/batch-preserve-term-settings.c b/gdb/testsuite/gdb.base/batch-preserve-term-settings.c index cd4a9b2..7d13022 100644 --- a/gdb/testsuite/gdb.base/batch-preserve-term-settings.c +++ b/gdb/testsuite/gdb.base/batch-preserve-term-settings.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp index d4ceba6..52b546c 100644 --- a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp +++ b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2024 Free Software Foundation, Inc. +# Copyright (C) 2015-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 @@ -23,7 +23,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} { } set file_arg $binfile -if [is_remote host] { +if {[is_remote host]} { set file_arg [remote_download host $file_arg] } @@ -46,11 +46,11 @@ proc spawn_shell {} { # Try to match: # PS1="gdb-subshell$ "^M - # $ gdb-subshell$ + # $ gdb-subshell$ # or: # PS1="gdb-subshell$ "^M # sh-4.4$ PS1="gdb-subshell$ "^M - # gdb-subshell$ + # gdb-subshell$ set gotit 0 set test "spawn shell" gdb_expect { @@ -88,7 +88,7 @@ proc exit_shell {} { pass "$test" } } - if ![is_remote host] { + if {![is_remote host]} { remote_close host } } @@ -131,7 +131,7 @@ proc test_terminal_settings_preserved {} { global gdb_prompt global shell_prompt_re - if ![spawn_shell] { + if {![spawn_shell]} { return } @@ -176,7 +176,7 @@ proc test_terminal_settings_preserved {} { } set test "terminal settings preserved" - if $stty_supported { + if {$stty_supported} { run_stty "stty after" stty_after gdb_assert [string equal $stty_before $stty_after] $test @@ -224,7 +224,7 @@ proc test_terminal_settings_preserved_after_cli_exit { cmds } { global gdb_prompt global shell_prompt_re - if ![spawn_shell] { + if {![spawn_shell]} { return } @@ -263,7 +263,7 @@ proc test_terminal_settings_preserved_after_cli_exit { cmds } { send_quit_command "quit gdb" set test "terminal settings preserved" - if $stty_supported { + if {$stty_supported} { run_stty "stty after" stty_after gdb_assert [string equal $stty_before $stty_after] $test @@ -286,11 +286,11 @@ proc test_terminal_settings_preserved_after_sigterm { } { # On Windows, GDB's "shell" command spawns cmd.exe, which does not # understand PPID. So we're out of luck even if the test harness # uses a remote_exec shell with a working "kill" command. - if [ishost *-*-mingw*] { + if {[ishost *-*-mingw*]} { return } - if ![spawn_shell] { + if {![spawn_shell]} { return } @@ -347,13 +347,13 @@ proc test_terminal_settings_preserved_after_sigterm { } { } } - if !$gdb_killed { + if {!$gdb_killed} { send_quit_command "quit gdb" } } set test "terminal settings preserved" - if $stty_supported { + if {$stty_supported} { run_stty "stty after" stty_after gdb_assert [string equal $stty_before $stty_after] $test diff --git a/gdb/testsuite/gdb.base/bfd-errors-lib.c b/gdb/testsuite/gdb.base/bfd-errors-lib.c index 9b8f311..481622a 100644 --- a/gdb/testsuite/gdb.base/bfd-errors-lib.c +++ b/gdb/testsuite/gdb.base/bfd-errors-lib.c @@ -1,4 +1,4 @@ -/* Copyright 2022-2024 Free Software Foundation, Inc. +/* Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/bfd-errors.exp b/gdb/testsuite/gdb.base/bfd-errors.exp index b611c33..2e38478 100644 --- a/gdb/testsuite/gdb.base/bfd-errors.exp +++ b/gdb/testsuite/gdb.base/bfd-errors.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -39,7 +39,7 @@ # # This test then loads the shared library's symbol table (and other # debug info) using the 'add-symbol-file' command. While doing this, -# the test observes and records the BFD errors that were output. +# the test observes and records the BFD errors that were output. # Finally, data collected while adding the shared library symbols are # examined to make sure that identical messages were suppressed while # also making sure that at least two messages have been printed. @@ -87,10 +87,10 @@ close $solib_fp set objcopy_program [gdb_find_objcopy] # Extract the .dynsym and .dynstr section from the shared object. -if { [catch "exec $objcopy_program \ - --dump-section .dynsym=${binfile_lib}.dynsym \ - --dump-section .dynstr=${binfile_lib}.dynstr \ - ${binfile_lib}" output] } { +if { [catch {exec $objcopy_program \ + --dump-section .dynsym=${binfile_lib}.dynsym \ + --dump-section .dynstr=${binfile_lib}.dynstr \ + ${binfile_lib}} output] } { untested "failed objcopy dump-section" verbose -log "objcopy output: $output" return -1 @@ -119,29 +119,29 @@ if { $is_elf64 } { } else { set sz 16 } -set cnt [expr $dynsym_len / $sz] +set cnt [expr {$dynsym_len / $sz}] # Create 32-bit patterns (bad offsets) to write into the st_name area. if { $is_big_endian } { - set pat(0) [binary format I [expr $dynstr_len + 1000]] - set pat(1) [binary format I [expr $dynstr_len + 2000]] + set pat(0) [binary format I [expr {$dynstr_len + 1000}]] + set pat(1) [binary format I [expr {$dynstr_len + 2000}]] } else { - set pat(0) [binary format i [expr $dynstr_len + 1000]] - set pat(1) [binary format i [expr $dynstr_len + 2000]] + set pat(0) [binary format i [expr {$dynstr_len + 1000}]] + set pat(1) [binary format i [expr {$dynstr_len + 2000}]] } # Mangle st_name for the symbols following the first (STN_UNDEF) entry. while { [incr cnt -1] > 0 } { seek $dynsym_fp [incr off $sz] - puts $dynsym_fp $pat([expr $cnt % 2]) + puts $dynsym_fp $pat([expr {$cnt % 2}]) } close $dynsym_fp # Replace .dynsym section in shared object with the mangled version. -if { [catch "exec $objcopy_program \ - --update-section .dynsym=${binfile_lib}.dynsym \ - ${binfile_lib}" output] } { +if { [catch {exec $objcopy_program \ + --update-section .dynsym=${binfile_lib}.dynsym \ + ${binfile_lib}} output] } { untested "failed objcopy update-section" verbose -log "objcopy output: $output" return -1 @@ -152,7 +152,7 @@ clean_restart # Count number of distinct BFD error messages via 'bfd_error_count' # array while using add-symbol-file to "load" the shared library. gdb_test_multiple "add-symbol-file -readnow $binfile_lib" \ - "load library with add-symbol-file" { + "load library with add-symbol-file" { -re "add symbol table from file.*\(y or n\)" { send_gdb "y\n" answer exp_continue diff --git a/gdb/testsuite/gdb.base/bfp-test.c b/gdb/testsuite/gdb.base/bfp-test.c index 9815584..6bfee5b 100644 --- a/gdb/testsuite/gdb.base/bfp-test.c +++ b/gdb/testsuite/gdb.base/bfp-test.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2005-2024 Free Software Foundation, Inc. + Copyright 2005-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 @@ -27,6 +27,6 @@ int main() b32 = 1.5f; b64 = 2.25; b128 = 3.375l; - + return 0; } diff --git a/gdb/testsuite/gdb.base/bfp-test.exp b/gdb/testsuite/gdb.base/bfp-test.exp index e633f90..49a1305 100644 --- a/gdb/testsuite/gdb.base/bfp-test.exp +++ b/gdb/testsuite/gdb.base/bfp-test.exp @@ -1,4 +1,4 @@ -# Copyright 2005-2024 Free Software Foundation, Inc. +# Copyright 2005-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 @@ -18,13 +18,10 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart ${binfile} - if {![runto_main]} { return } @@ -38,7 +35,7 @@ gdb_test "print b32" ".*1 = 1\.5.*" "the original value of b32 is 1.5" gdb_test "print b64" ".*2 = 2\.25.*" "the original value of b64 is 2.25" gdb_test "print b128" ".*3 = 3\.375.*" "the original value of b128 is 3.375" -# Test that gdb could correctly recognize float constant expression with a suffix. +# Test that gdb could correctly recognize float constant expression with a suffix. gdb_test "print b32=-1.5f" ".*4 = -1\.5.*" "try to change b32 to -1.5 with 'print b32=-1.5f'" gdb_test "print b64=-2.25f" ".*5 = -2\.25.*" "try to change b64 to -2.25 with 'print b64=-2.25f'" gdb_test "print b128=-3.375l" ".*6 = -3\.375.*" "try to change b128 to -3.375 with 'print b128=-3.375l'" diff --git a/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.c b/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.c index 6cbc073..ea4534e 100644 --- a/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.c +++ b/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2023-2024 Free Software Foundation, Inc. + Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp b/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp index 79e2177..dd34ce8 100644 --- a/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp +++ b/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 @@ -34,7 +34,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} { # AFTER_KILL_COND is appended to the breakpoint condition, after "kill # -SIGINT $gdb_pid". proc test { {after_kill_cond ""} } { - clean_restart $::binfile + clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/bg-execution-repeat.c b/gdb/testsuite/gdb.base/bg-execution-repeat.c index d5b48ee..3c0cc76 100644 --- a/gdb/testsuite/gdb.base/bg-execution-repeat.c +++ b/gdb/testsuite/gdb.base/bg-execution-repeat.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 @@ -37,9 +37,9 @@ main (void) { alarm (60); + do_wait = 1; foo (); - do_wait = 1; wait (); /* do_wait set to 0 externally. */ diff --git a/gdb/testsuite/gdb.base/bg-execution-repeat.exp b/gdb/testsuite/gdb.base/bg-execution-repeat.exp index 61f26f3..f45eb40 100644 --- a/gdb/testsuite/gdb.base/bg-execution-repeat.exp +++ b/gdb/testsuite/gdb.base/bg-execution-repeat.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2024 Free Software Foundation, Inc. +# Copyright (C) 2014-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 @@ -30,12 +30,11 @@ set linenum [gdb_get_line_number "set break here"] proc test {continue_cmd} { global gdb_prompt - global binfile global linenum - clean_restart $binfile + clean_restart $::testfile - if ![runto_main] { + if {![runto_main]} { return } @@ -67,6 +66,17 @@ proc test {continue_cmd} { # enable the "set var" command with an interrupt / continue& pair. gdb_test -no-prompt-anchor "interrupt" + set test "interrupt received" + set re [string_to_regexp "Program received signal SIGINT, Interrupt."] + gdb_expect { + -re $re { + pass $test + } + timeout { + fail "$test (timeout)" + } + } + # Allow the breakpoint to trigger. gdb_test -no-prompt-anchor "set var do_wait=0" diff --git a/gdb/testsuite/gdb.base/bigcore.c b/gdb/testsuite/gdb.base/bigcore.c index 8acfc0b..e50d41b 100644 --- a/gdb/testsuite/gdb.base/bigcore.c +++ b/gdb/testsuite/gdb.base/bigcore.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 @@ -192,7 +192,7 @@ main () } close (fd); } - + /* Compute an initial chunk size. The math is dodgy but it works for the moment. Perhaps there's a constant around somewhere. Limit this to max_core_size bytes - no point in trying to diff --git a/gdb/testsuite/gdb.base/bigcore.exp b/gdb/testsuite/gdb.base/bigcore.exp index 5e09d2f..ae1df76 100644 --- a/gdb/testsuite/gdb.base/bigcore.exp +++ b/gdb/testsuite/gdb.base/bigcore.exp @@ -1,4 +1,4 @@ -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -28,8 +28,8 @@ require isnative # I/O bandwidth. if { [istarget "*-*-*bsd*"] - || [istarget "*-*-solaris*"] - || [istarget "*-*-darwin*"] + || [istarget "*-*-solaris*"] + || [istarget "*-*-darwin*"] || [istarget "*-*-cygwin*"] } { untested "kernel lacks sparse corefile support (PR gdb/1551)" return @@ -113,11 +113,11 @@ proc check_heap { dir heap } { # The bulk of the testcase. DUMPER indicates who is supposed to dump # the core. It can be either "kernel", or "gdb". proc test {dumper} { - global binfile timeout corefile gdb_prompt + global timeout corefile gdb_prompt # Run GDB on the bigcore program up-to where it will dump core. - clean_restart ${binfile} + clean_restart $::testfile gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set width 0" diff --git a/gdb/testsuite/gdb.base/bitfields.exp b/gdb/testsuite/gdb.base/bitfields.exp index 6954a35..9a5eaff 100644 --- a/gdb/testsuite/gdb.base/bitfields.exp +++ b/gdb/testsuite/gdb.base/bitfields.exp @@ -1,4 +1,4 @@ -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -165,7 +165,7 @@ proc bitfield_at_offset {} { global srcfile gdb_breakpoint break5 - if [gdb_test "cont" "Break.*break5 \\(\\) at .*$srcfile:$decimal.*" "continuing to break5"] { + if {[gdb_test "cont" "Break.*break5 \\(\\) at .*$srcfile:$decimal.*" "continuing to break5"]} { return } diff --git a/gdb/testsuite/gdb.base/bitfields2.c b/gdb/testsuite/gdb.base/bitfields2.c index edb3b9f..b02a4c7 100644 --- a/gdb/testsuite/gdb.base/bitfields2.c +++ b/gdb/testsuite/gdb.base/bitfields2.c @@ -159,7 +159,7 @@ void tester () break5 (); } -int main () +int main () { int i; diff --git a/gdb/testsuite/gdb.base/bitfields2.exp b/gdb/testsuite/gdb.base/bitfields2.exp index 3bd2d5b..640f275 100644 --- a/gdb/testsuite/gdb.base/bitfields2.exp +++ b/gdb/testsuite/gdb.base/bitfields2.exp @@ -1,4 +1,4 @@ -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -13,11 +13,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# This file was adapted from bitfields.exp by Paul Hilfinger +# This file was adapted from bitfields.exp by Paul Hilfinger # (Hilfinger@gnat.com) # -# Tests for bit-fields that do not fit in type (unsigned) int, but do fit +# Tests for bit-fields that do not fit in type (unsigned) int, but do fit # in type (unsigned) long long. We perform essentially the same tests as # in bitfields.c, which considers only bit-fields that are <= 9 bits long. # @@ -33,7 +33,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb set has_signed_bitfields 1 # -# Continue to expected breakpoint at FUNCTION. Append TAG to make pass/fail +# Continue to expected breakpoint at FUNCTION. Append TAG to make pass/fail # messages (to make them unique). Suppress tests on failure. # proc continue_test { function tag } { @@ -54,7 +54,7 @@ proc start_test { function } { gdb_breakpoint $function continue_test $function "#0" } - + # # Test bitfield locating and uniqueness. @@ -161,7 +161,7 @@ proc bitfield_signedness {} { set test "most negative signed bitfield values" if {$has_signed_bitfields} { - gdb_test "print flags" "u1 = 0, u2 = 0, u3 = 0, s1 = -16384, s2 = -4294967296, s3 = -32768.*" $test + gdb_test "print flags" "u1 = 0, u2 = 0, u3 = 0, s1 = -16384, s2 = -4294967296, s3 = -32768.*" $test } else { unsupported $test } @@ -233,7 +233,7 @@ proc bitfield_set {} { } } -clean_restart ${binfile} +clean_restart $testfile gdb_test_no_output "set print sevenbit-strings" runto_main @@ -243,4 +243,3 @@ bitfield_containment bitfield_unsignedness bitfield_signedness bitfield_set - diff --git a/gdb/testsuite/gdb.base/bitops.exp b/gdb/testsuite/gdb.base/bitops.exp index e0cbd87..cabde14 100644 --- a/gdb/testsuite/gdb.base/bitops.exp +++ b/gdb/testsuite/gdb.base/bitops.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -20,7 +20,7 @@ # tests expressions with bitwise operators, and some # logical operators # Does not use a target program -# +# # @@ -106,4 +106,3 @@ gdb_test "print 0 || 1 && 0 | 0 ^ 0 == 8" ".\[0-9\]* = 0" \ gdb_test "print 0 == 8 > 128 >> 1 + 2 * 2" ".\[0-9\]* = 0" \ "print value of 0 == 8 > 128 >> 1 + 2 * 2" - diff --git a/gdb/testsuite/gdb.base/bitshift.exp b/gdb/testsuite/gdb.base/bitshift.exp index dccc36b..1e308f2 100644 --- a/gdb/testsuite/gdb.base/bitshift.exp +++ b/gdb/testsuite/gdb.base/bitshift.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -158,6 +158,7 @@ foreach signed {0 1} { set sign_prefix "u" } foreach bits {8 16 32 64} { + # tclint-disable-next-line command-args proc make_${sign_prefix}int${bits} {lang val} \ "make_val_cast \$lang $signed $bits \$val" } diff --git a/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.c b/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.c index 48246df..6751546 100644 --- a/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.c +++ b/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp b/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp index 8a1f729..7b56531 100644 --- a/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp +++ b/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -118,7 +118,7 @@ proc do_test {} { # "attach". with_test_prefix "run" { - clean_restart $binfile + clean_restart $testfile if {![runto_main]} { return -1 @@ -129,7 +129,7 @@ with_test_prefix "run" { with_test_prefix "attach" { if {[can_spawn_for_attach]} { - clean_restart $binfile + clean_restart $testfile set test_spawn_id [spawn_wait_for_attach $binfile] set testpid [spawn_id_get_pid $test_spawn_id] diff --git a/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.c b/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.c index ea18b9e..8deb8a9 100644 --- a/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.c +++ b/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.exp b/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.exp index 1d91958..e2f301c 100644 --- a/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.exp +++ b/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.gdb b/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.gdb index bc6305a..90d3e1a 100644 --- a/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.gdb +++ b/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.gdb @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/bp-cmds-run-with-ex.c b/gdb/testsuite/gdb.base/bp-cmds-run-with-ex.c index 27a14b7..65b18bc 100644 --- a/gdb/testsuite/gdb.base/bp-cmds-run-with-ex.c +++ b/gdb/testsuite/gdb.base/bp-cmds-run-with-ex.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/bp-cmds-run-with-ex.exp b/gdb/testsuite/gdb.base/bp-cmds-run-with-ex.exp index 62dd97a..37300f7 100644 --- a/gdb/testsuite/gdb.base/bp-cmds-run-with-ex.exp +++ b/gdb/testsuite/gdb.base/bp-cmds-run-with-ex.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/bp-cmds-run-with-ex.gdb b/gdb/testsuite/gdb.base/bp-cmds-run-with-ex.gdb index ed93473..a83c234 100644 --- a/gdb/testsuite/gdb.base/bp-cmds-run-with-ex.gdb +++ b/gdb/testsuite/gdb.base/bp-cmds-run-with-ex.gdb @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/bp-cmds-sourced-script.c b/gdb/testsuite/gdb.base/bp-cmds-sourced-script.c index 27a14b7..65b18bc 100644 --- a/gdb/testsuite/gdb.base/bp-cmds-sourced-script.c +++ b/gdb/testsuite/gdb.base/bp-cmds-sourced-script.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/bp-cmds-sourced-script.exp b/gdb/testsuite/gdb.base/bp-cmds-sourced-script.exp index 08df303..6ba7d10 100644 --- a/gdb/testsuite/gdb.base/bp-cmds-sourced-script.exp +++ b/gdb/testsuite/gdb.base/bp-cmds-sourced-script.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/bp-cmds-sourced-script.gdb b/gdb/testsuite/gdb.base/bp-cmds-sourced-script.gdb index 8debae9..e78cfed 100644 --- a/gdb/testsuite/gdb.base/bp-cmds-sourced-script.gdb +++ b/gdb/testsuite/gdb.base/bp-cmds-sourced-script.gdb @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/bp-cond-failure.c b/gdb/testsuite/gdb.base/bp-cond-failure.c index b742139..644d7fd 100644 --- a/gdb/testsuite/gdb.base/bp-cond-failure.c +++ b/gdb/testsuite/gdb.base/bp-cond-failure.c @@ -1,4 +1,4 @@ -/* Copyright 2022-2024 Free Software Foundation, Inc. +/* Copyright 2022-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/bp-cond-failure.exp b/gdb/testsuite/gdb.base/bp-cond-failure.exp index b4c046c..f605851 100644 --- a/gdb/testsuite/gdb.base/bp-cond-failure.exp +++ b/gdb/testsuite/gdb.base/bp-cond-failure.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -26,7 +26,7 @@ standard_testfile -if { [prepare_for_testing "failed to prepare" ${binfile} "${srcfile}" \ +if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ {debug c++}] == -1 } { return } @@ -45,7 +45,7 @@ if { [is_address_zero_readable] } { } proc run_test { cond_eval access_type bpexpr nloc } { - clean_restart ${::binfile} + clean_restart $::testfile if { ![runto_main] } { return -1 @@ -75,7 +75,7 @@ proc run_test { cond_eval access_type bpexpr nloc } { "Error in testing condition for breakpoint ${bp_num}.2:" \ "Cannot access memory at address 0x0" \ "" \ - "Breakpoint ${bp_num}.2, foo \\(c=49 ...\\) at \[^\r\n\]+:\[0-9\]+" \ + "(Thread \[^\r\n\]+ hit )?Breakpoint ${bp_num}.2, foo \\(c=49 ...\\) at \[^\r\n\]+:\[0-9\]+" \ "${::decimal}\\s+\[^\r\n\]+ breakpoint here\\. \[^\r\n\]+"] } else { gdb_test "continue" \ @@ -84,7 +84,7 @@ proc run_test { cond_eval access_type bpexpr nloc } { "Error in testing condition for breakpoint ${bp_num}:" \ "Cannot access memory at address 0x0" \ "" \ - "Breakpoint ${bp_num}, bar \\(\\) at \[^\r\n\]+:\[0-9\]+" \ + "(Thread \[^\r\n\]+ hit )?Breakpoint ${bp_num}, bar \\(\\) at \[^\r\n\]+:\[0-9\]+" \ "${::decimal}\\s+\[^\r\n\]+ breakpoint here\\. \[^\r\n\]+"] } } diff --git a/gdb/testsuite/gdb.base/bp-disabled-by-cond.exp b/gdb/testsuite/gdb.base/bp-disabled-by-cond.exp index f0bdd16..3da4601 100644 --- a/gdb/testsuite/gdb.base/bp-disabled-by-cond.exp +++ b/gdb/testsuite/gdb.base/bp-disabled-by-cond.exp @@ -52,7 +52,7 @@ set exit_bp_line [gdb_get_line_number "BP before exit" $srcfile] # Restart the inferior, which should unload the shared library, GDB # should mark the b/p as disabled due to its condition again. proc run_test { hit_cond } { - clean_restart $::binfile + clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/bp-disabled-by-cond.py b/gdb/testsuite/gdb.base/bp-disabled-by-cond.py index 9a93920..7e7bade 100644 --- a/gdb/testsuite/gdb.base/bp-disabled-by-cond.py +++ b/gdb/testsuite/gdb.base/bp-disabled-by-cond.py @@ -12,6 +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/>. +import gdb bp_modified_list = [] diff --git a/gdb/testsuite/gdb.base/bp-permanent.c b/gdb/testsuite/gdb.base/bp-permanent.c index 99f1c41..72e5e8a 100644 --- a/gdb/testsuite/gdb.base/bp-permanent.c +++ b/gdb/testsuite/gdb.base/bp-permanent.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2024 Free Software Foundation, Inc. +/* Copyright (C) 2014-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -101,7 +101,7 @@ test_signal_no_handler (void) } static void -test_signal_nested_handler () +test_signal_nested_handler (int sig) { test (); } diff --git a/gdb/testsuite/gdb.base/bp-permanent.exp b/gdb/testsuite/gdb.base/bp-permanent.exp index aa55442..47e1ef6 100644 --- a/gdb/testsuite/gdb.base/bp-permanent.exp +++ b/gdb/testsuite/gdb.base/bp-permanent.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2024 Free Software Foundation, Inc. +# Copyright (C) 2014-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 @@ -40,9 +40,9 @@ proc test {always_inserted sw_watchpoint} { global line_bp global hex decimal global gdb_prompt - global srcfile binfile + global srcfile - clean_restart $binfile + clean_restart $::testfile if {![runto_main]} { return -1 @@ -102,7 +102,7 @@ proc test {always_inserted sw_watchpoint} { # We now have the breakpoint instruction stored in 'buffer'. Poke it # to memory manually. - set count [expr $address_after_bp - $address_bp] + set count [expr {$address_after_bp - $address_bp}] for {set i 0} {$i < $count} {incr i} { set test "p /x addr_bp\[$i\] = buffer\[$i\]" gdb_test_multiple $test $test { @@ -131,11 +131,11 @@ proc test {always_inserted sw_watchpoint} { set test "permanent breakpoint causes random signal" gdb_test_multiple "continue" $test { -re "exited normally.*$gdb_prompt $" { - unsupported "failed to stop at permanent breakpoint" + unsupported "failed to stop at permanent breakpoint" return } - -re "Program received signal SIGTRAP.*$gdb_prompt $" { - pass $test + -re "received signal SIGTRAP.*$gdb_prompt $" { + pass $test } } @@ -174,7 +174,7 @@ proc test {always_inserted sw_watchpoint} { # disabled, it should act as if we hadn't created it in the first # place. IOW, we should get a random signal, and, the breakpoint's # command should not run. - gdb_test "continue" "Program received signal SIGTRAP.*" \ + gdb_test "continue" "received signal SIGTRAP.*" \ "disabled permanent breakpoint doesn't explain stop" gdb_test "info breakpoints" \ @@ -215,7 +215,7 @@ proc test {always_inserted sw_watchpoint} { gdb_test "next" "after next .*" } - if ![target_info exists gdb,nosignals] { + if {![target_info exists gdb,nosignals]} { with_test_prefix "continue trips on nested permanent bp" { delete_breakpoints @@ -241,7 +241,7 @@ proc test {always_inserted sw_watchpoint} { gdb_test "p counter" " = 2" } - if [can_single_step_to_signal_handler] { + if {[can_single_step_to_signal_handler]} { with_test_prefix "stepi signal with handler" { delete_breakpoints diff --git a/gdb/testsuite/gdb.base/branch-to-self.c b/gdb/testsuite/gdb.base/branch-to-self.c index 9647371..fc48ac2 100644 --- a/gdb/testsuite/gdb.base/branch-to-self.c +++ b/gdb/testsuite/gdb.base/branch-to-self.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/branch-to-self.exp b/gdb/testsuite/gdb.base/branch-to-self.exp index 71859d7..3f09786 100644 --- a/gdb/testsuite/gdb.base/branch-to-self.exp +++ b/gdb/testsuite/gdb.base/branch-to-self.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. # -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 @@ -27,7 +27,7 @@ with_test_prefix "single-step" { global testfile clean_restart ${testfile} - if ![runto_main] { + if {![runto_main]} { return -1 } set line_num [gdb_get_line_number "loop-line" ${testfile}.c] @@ -60,7 +60,7 @@ with_test_prefix "break-cond" { clean_restart ${testfile} - if ![runto_main] { + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/break-always.c b/gdb/testsuite/gdb.base/break-always.c index b75febc..a4b389a 100644 --- a/gdb/testsuite/gdb.base/break-always.c +++ b/gdb/testsuite/gdb.base/break-always.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/break-always.exp b/gdb/testsuite/gdb.base/break-always.exp index 5bd0527..24d8d65 100644 --- a/gdb/testsuite/gdb.base/break-always.exp +++ b/gdb/testsuite/gdb.base/break-always.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/break-caller-line.c b/gdb/testsuite/gdb.base/break-caller-line.c index 8829a1b..f3762db 100644 --- a/gdb/testsuite/gdb.base/break-caller-line.c +++ b/gdb/testsuite/gdb.base/break-caller-line.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/break-caller-line.exp b/gdb/testsuite/gdb.base/break-caller-line.exp index 13d5e55..9925a1d 100644 --- a/gdb/testsuite/gdb.base/break-caller-line.exp +++ b/gdb/testsuite/gdb.base/break-caller-line.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2024 Free Software Foundation, Inc. +# Copyright (C) 2012-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 @@ -19,7 +19,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile}] } { return -1 } -if ![runto callee] { +if {![runto callee]} { return 0 } diff --git a/gdb/testsuite/gdb.base/gold-gdb-index.c b/gdb/testsuite/gdb.base/break-dbg.cc index 5023a66..642ded0 100644 --- a/gdb/testsuite/gdb.base/gold-gdb-index.c +++ b/gdb/testsuite/gdb.base/break-dbg.cc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + 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 @@ -15,15 +15,17 @@ 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 "gold-gdb-index.h" +volatile int global_var = 0; -namespace N1 +int +foo () { - void foo () { C1::baz (); } + return global_var; } int main () { - return 0; + int res = foo (); + return res; } diff --git a/gdb/testsuite/gdb.base/break-dbg.exp b/gdb/testsuite/gdb.base/break-dbg.exp new file mode 100644 index 0000000..a7c7d92 --- /dev/null +++ b/gdb/testsuite/gdb.base/break-dbg.exp @@ -0,0 +1,80 @@ +# 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/>. */ + +# Some basic testing of 'set debug breakpoint on'. At one point a bug +# meant that some breakpoints would immediately trigger a segfault if +# GDB tried to run with breakpoint debugging turned on. +# +# Test is compiled as C++ only so 'catch catch/throw/rethrow' have a +# something to do. The original bug would trigger for any 'catch' +# style breakpoint, so C++ isn't really a hard requirement. + +standard_testfile .cc + +require allow_cplus_tests + +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ + {debug c++}] } { + return +} + +if {![runto_main]} { + return +} + +gdb_test "catch catch" "^Catchpoint $decimal \\(catch\\)" +gdb_test "catch throw" "^Catchpoint $decimal \\(throw\\)" +gdb_test "catch rethrow" "^Catchpoint $decimal \\(rethrow\\)" + +gdb_test "catch exec" "^Catchpoint $decimal \\(exec\\)" +gdb_test "catch fork" "^Catchpoint $decimal \\(fork\\)" +gdb_test "catch vfork" "^Catchpoint $decimal \\(vfork\\)" + +gdb_test "catch load" "^Catchpoint $decimal \\(load\\)" +gdb_test "catch unload" "^Catchpoint $decimal \\(unload\\)" + +gdb_test "catch signal" "^Catchpoint $decimal \\(standard signals\\)" + +set re_warning_xml_disabled \ + [string_to_regexp \ + [join \ + [list \ + "warning: Can not parse XML syscalls information;" \ + "XML support was disabled at compile time."]]] +gdb_test "catch syscall" \ + [multi_line \ + "^($re_warning_xml_disabled" \ + ")?Catchpoint $decimal [string_to_regexp {(any syscall)}]"] + +gdb_test "watch -l global_var" "\[Ww]atchpoint $decimal: -location global_var" + +gdb_test_no_output "set debug breakpoint on" + +set saw_bp_debug_line false +gdb_test_multiple "step" "" { + -re "^step\r\n" { + exp_continue + } + -re "^\\\[breakpoint\\\] \[^\r\n\]+\r\n" { + set saw_bp_debug_line true + exp_continue + } + -re "^$gdb_prompt $" { + gdb_assert { $saw_bp_debug_line } $gdb_test_name + } + -re "^\[^\r\n\]*\r\n" { + exp_continue + } +} diff --git a/gdb/testsuite/gdb.base/break-entry.exp b/gdb/testsuite/gdb.base/break-entry.exp index 709ed1a..584ddaf 100644 --- a/gdb/testsuite/gdb.base/break-entry.exp +++ b/gdb/testsuite/gdb.base/break-entry.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2010-2024 Free Software Foundation, Inc. +# Copyright (C) 2010-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 @@ -56,7 +56,7 @@ if {[istarget powerpc64-*] && [is_lp64_target]} { } } -if ![runto "*$entry"] { +if {![runto "*$entry"]} { return } gdb_test {p/x $pc} " = $entry" diff --git a/gdb/testsuite/gdb.base/break-fun-addr.exp b/gdb/testsuite/gdb.base/break-fun-addr.exp index c57b1cd..e123d94 100644 --- a/gdb/testsuite/gdb.base/break-fun-addr.exp +++ b/gdb/testsuite/gdb.base/break-fun-addr.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 @@ -33,28 +33,24 @@ set testfile1 "break-fun-addr1" set srcfile1 ${testfile1}.c -set binfile1 [standard_output_file ${testfile1}] -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug}] != "" } { - untested "failed to compile first testcase" - return -1 +if { [prepare_for_testing "prepare" $testfile1 $srcfile1] != 0 } { + return } # Start the debugger with the first executable, put a breakpoint # on the first instruction of function "main" ("*main"), then # run to that breakpoint. -clean_restart ${binfile1} - with_test_prefix "${testfile1}" { gdb_test "break *main" \ - "Breakpoint.*at.* file .*$srcfile1, line .*" \ + "Breakpoint.*at.* file .*$srcfile1, line .*" \ gdb_run_cmd gdb_test "" \ - "Breakpoint.* main \\(\\) at .*$srcfile1:.*" \ - "run to breakpoint at *main" + "Breakpoint.* main \\(\\) at .*$srcfile1:.*" \ + "run to breakpoint at *main" # Verify also that we stopped at the start of the function... gdb_test "p \$pc == main" " = 1" @@ -64,9 +60,8 @@ set testfile2 "break-fun-addr2" set srcfile2 ${testfile2}.c set binfile2 [standard_output_file ${testfile2}] -if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } { - untested "failed to compile second testcase" - return -1 +if { [build_executable "build" $testfile2 $srcfile2] != 0 } { + return } # Now, keeping the same GDB process (so as to keep the same breakpoint), @@ -77,8 +72,8 @@ with_test_prefix "${testfile2}" { gdb_run_cmd gdb_test "" \ - "Breakpoint.* main \\(\\) at .*$srcfile2:.*" \ - "run to breakpoint at *main" + "Breakpoint.* main \\(\\) at .*$srcfile2:.*" \ + "run to breakpoint at *main" gdb_test "p \$pc == main" " = 1" } diff --git a/gdb/testsuite/gdb.base/break-fun-addr1.c b/gdb/testsuite/gdb.base/break-fun-addr1.c index a3b9352..6d906ec 100644 --- a/gdb/testsuite/gdb.base/break-fun-addr1.c +++ b/gdb/testsuite/gdb.base/break-fun-addr1.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/break-fun-addr2.c b/gdb/testsuite/gdb.base/break-fun-addr2.c index 7353dc8..6e70405 100644 --- a/gdb/testsuite/gdb.base/break-fun-addr2.c +++ b/gdb/testsuite/gdb.base/break-fun-addr2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/break-idempotent.c b/gdb/testsuite/gdb.base/break-idempotent.c index b763a30..c0417fb 100644 --- a/gdb/testsuite/gdb.base/break-idempotent.c +++ b/gdb/testsuite/gdb.base/break-idempotent.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/break-idempotent.exp b/gdb/testsuite/gdb.base/break-idempotent.exp index 0903841..842ce42 100644 --- a/gdb/testsuite/gdb.base/break-idempotent.exp +++ b/gdb/testsuite/gdb.base/break-idempotent.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -161,11 +161,11 @@ foreach_with_prefix pie { "nopie" "pie" } { set binfile [standard_output_file $testfile-$pie] - if {[prepare_for_testing "failed to prepare" $binfile $srcfile $opts]} { + if {[prepare_for_testing "failed to prepare" $testfile-$pie $srcfile $opts]} { continue } - if [is_remote host] { + if {[is_remote host]} { set arg [remote_download host $binfile] if { $arg == "" } { untested "download failed" diff --git a/gdb/testsuite/gdb.base/break-include.c b/gdb/testsuite/gdb.base/break-include.c index fd92386..2b0d2dd 100644 --- a/gdb/testsuite/gdb.base/break-include.c +++ b/gdb/testsuite/gdb.base/break-include.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/break-include.exp b/gdb/testsuite/gdb.base/break-include.exp index a7fde67..a374d6b 100644 --- a/gdb/testsuite/gdb.base/break-include.exp +++ b/gdb/testsuite/gdb.base/break-include.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/break-include.inc b/gdb/testsuite/gdb.base/break-include.inc index 899ff4d..245bd65 100644 --- a/gdb/testsuite/gdb.base/break-include.inc +++ b/gdb/testsuite/gdb.base/break-include.inc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/break-inline.c b/gdb/testsuite/gdb.base/break-inline.c index a3768a6..65885ba 100644 --- a/gdb/testsuite/gdb.base/break-inline.c +++ b/gdb/testsuite/gdb.base/break-inline.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2012-2024 Free Software Foundation, Inc. + Copyright (C) 2012-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 @@ -29,4 +29,3 @@ main (int argc, char *argv[]) foo (); return g; } - diff --git a/gdb/testsuite/gdb.base/break-inline.exp b/gdb/testsuite/gdb.base/break-inline.exp index 56603f6..63e9f91 100644 --- a/gdb/testsuite/gdb.base/break-inline.exp +++ b/gdb/testsuite/gdb.base/break-inline.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2024 Free Software Foundation, Inc. +# Copyright (C) 2012-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 @@ -24,4 +24,3 @@ gdb_test "" "Temporary breakpoint.*foo\\(\\).*" # Now test 'break' with no arguments. gdb_test "break" "Breakpoint.*" - diff --git a/gdb/testsuite/gdb.base/break-interp-lib.c b/gdb/testsuite/gdb.base/break-interp-lib.c index 4cec45e..1230a5e 100644 --- a/gdb/testsuite/gdb.base/break-interp-lib.c +++ b/gdb/testsuite/gdb.base/break-interp-lib.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/break-interp-main.c b/gdb/testsuite/gdb.base/break-interp-main.c index b4c600f..b0358c2 100644 --- a/gdb/testsuite/gdb.base/break-interp-main.c +++ b/gdb/testsuite/gdb.base/break-interp-main.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp index fd8afdd..f5b6633 100644 --- a/gdb/testsuite/gdb.base/break-interp.exp +++ b/gdb/testsuite/gdb.base/break-interp.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -49,19 +49,19 @@ proc system_debug_get {exec} { # isfile returns 1 even for symlinks to files. set retval $debug_root/$exec_build_id_debug - if [file isfile $retval] { + if {[file isfile $retval]} { return $retval } set retval $exec_dir/$debug_base - if [file isfile $retval] { + if {[file isfile $retval]} { return $retval } set retval $exec_dir/.debug/$debug_base - if [file isfile $retval] { + if {[file isfile $retval]} { return $retval } set retval $debug_root/$exec_dir/$debug_base - if [file isfile $retval] { + if {[file isfile $retval]} { return $retval } return "" @@ -78,7 +78,8 @@ gdb_test_multiple $test $test { } set interp_system [section_get [standard_output_file $binfile_test] .interp] -clean_restart $interp_system +clean_restart +gdb_load $interp_system set dl_main_found 0 gdb_test_multiple "info addr dl_main" "" { -re -wrap "Symbol \"dl_main\" is a function at address $hex\\." { @@ -107,11 +108,11 @@ proc strip_debug {dest} { set strip_program [transform strip] set command "exec $strip_program --strip-debug $dest" verbose -log "command is $command" - if [catch $command] { + if {[catch {{*}$command}]} { fail $test return 0 } else { - pass $test + pass $test return 1 } } @@ -185,7 +186,7 @@ proc reach_1 {func command displacement} { } } } - if ![regexp {^(NONE|FOUND-.*)$} $displacement] { + if {![regexp {^(NONE|FOUND-.*)$} $displacement]} { fail $test_displacement } @@ -218,6 +219,7 @@ proc test_core {file displacement} { set corefile [core_find $file {} "segv"] if {$corefile == ""} { + untested "unable to create or find corefile" return } @@ -255,7 +257,7 @@ proc test_core {file displacement} { pass $test } } - if ![regexp {^(NONE|FOUND-.*)$} $displacement] { + if {![regexp {^(NONE|FOUND-.*)$} $displacement]} { fail $test_displacement } gdb_test_no_output "set verbose off" @@ -306,7 +308,7 @@ proc test_attach_gdb {file pid displacement prefix} { pass $test } } - if ![regexp {^(NONE|FOUND-.*)$} $displacement] { + if {![regexp {^(NONE|FOUND-.*)$} $displacement]} { fail $test_displacement } gdb_test_no_output "set verbose off" @@ -379,7 +381,7 @@ proc test_attach {file displacement {relink_args ""}} { # `libfunc' is present in the backtrace and therefore the # displacement has been guessed right. - if [prelink$relink $relink_args [file tail $exec]] { + if {[prelink$relink $relink_args [file tail $exec]]} { # /proc/PID/exe cannot be loaded as it is "EXECNAME (deleted)". test_attach_gdb $exec $pid $displacement "attach-relink$relink" } @@ -409,7 +411,7 @@ proc test_ld {file ifmain trynosym displacement} { # prevents that from happening. So turn it off. gdb_test "set disable-randomization off" - if $ifmain { + if {$ifmain} { gdb_test_no_output "set args segv" } else { global binfile_test @@ -448,7 +450,7 @@ proc test_ld {file ifmain trynosym displacement} { gdb_test_no_output "set verbose on" } - if $ifmain { + if {$ifmain} { reach "main" continue "NONE" reach "libfunc" continue "NONE" @@ -465,13 +467,13 @@ proc test_ld {file ifmain trynosym displacement} { reach $solib_bp "run" $displacement 2 gdb_test_no_output "set verbose off" - if $ifmain { + if {$ifmain} { test_core $file $displacement test_attach $file $displacement } - if !$trynosym { + if {!$trynosym} { return } @@ -492,7 +494,7 @@ proc test_ld {file ifmain trynosym displacement} { set escapedfile [string_to_regexp $file] gdb_test "exec-file $file" "exec-file $escapedfile" "load" - if $ifmain { + if {$ifmain} { reach $solib_bp run $displacement 3 set entrynohex "" @@ -548,7 +550,7 @@ proc test_ld {file ifmain trynosym displacement} { pass $test } } - if ![regexp {^(NONE|FOUND-.*)$} $displacement] { + if {![regexp {^(NONE|FOUND-.*)$} $displacement]} { fail $test_displacement } } @@ -587,7 +589,7 @@ foreach_with_prefix ldprelink {NO YES} { file_copy $interp_system $interp # Never call strip-debug before unprelink: # prelink: ...: Section .note.gnu.build-id created after prelinking - if ![prelinkNO $interp] { + if {![prelinkNO $interp]} { continue } strip_debug $interp @@ -603,7 +605,7 @@ foreach_with_prefix ldprelink {NO YES} { set test "eu-unstrip unprelinked:[file tail $interp_system] + [file tail $interp_system_debug] to [file tail $interp]" set command "exec eu-unstrip -o $interp $interp ${interp}.debug" verbose -log "command is $command" - if [catch $command] { + if {[catch {{*}$command}]} { setup_xfail *-*-* fail $test continue @@ -613,7 +615,7 @@ foreach_with_prefix ldprelink {NO YES} { } elseif {$ldsepdebug == "SEP" && $interp_system_debug == ""} { file_copy $interp_system $interp # eu-unstrip: DWARF data in '...' not adjusted for prelinking bias; consider prelink -u - if ![prelinkNO $interp] { + if {![prelinkNO $interp]} { continue } gdb_gnu_strip_debug $interp @@ -623,14 +625,14 @@ foreach_with_prefix ldprelink {NO YES} { } if {$ldsepdebug == "SEP"} { - if ![prelinkNO "${interp}.debug"] { + if {![prelinkNO "${interp}.debug"]} { continue } } else { file delete "${interp}.debug" } - if ![prelink$ldprelink $interp "[file tail $interp], second time"] { + if {![prelink$ldprelink $interp "[file tail $interp], second time"]} { continue } @@ -645,7 +647,7 @@ foreach_with_prefix ldprelink {NO YES} { } test_ld $interp 0 [expr {$ldsepdebug == "NO"}] $displacement - if ![file_copy $interp $interp_saved] { + if {![file_copy $interp $interp_saved]} { continue } diff --git a/gdb/testsuite/gdb.base/break-main-file-remove-fail.c b/gdb/testsuite/gdb.base/break-main-file-remove-fail.c index fa82eba..fec6526 100644 --- a/gdb/testsuite/gdb.base/break-main-file-remove-fail.c +++ b/gdb/testsuite/gdb.base/break-main-file-remove-fail.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp b/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp index 97b662c..4dd88cd 100644 --- a/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp +++ b/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -55,7 +55,7 @@ proc test_remove_bp { initial_load } { gdb_reload } - if ![runto start] { + if {![runto start]} { return } @@ -86,7 +86,7 @@ proc test_remove_bp { initial_load } { # remove the memory breakpoint afterwards should fail, and GDB # should warn the user about it. set pagesize [get_integer_valueof "pg_size" 0] - set align_addr [expr $bp_addr - $bp_addr % $pagesize] + set align_addr [expr {$bp_addr - $bp_addr % $pagesize}] set munmap_prototype "int (*) (void *, size_t)" set munmap_expr "(($munmap_prototype) munmap) ($align_addr, $pagesize)" diff --git a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.cc b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.cc index f658595..13b74a6 100644 --- a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.cc +++ b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.cc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp index cf1596a..6bd6219 100644 --- a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp +++ b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp @@ -1,4 +1,4 @@ -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/break-probes-solib.c b/gdb/testsuite/gdb.base/break-probes-solib.c index 308c738..8011b9a 100644 --- a/gdb/testsuite/gdb.base/break-probes-solib.c +++ b/gdb/testsuite/gdb.base/break-probes-solib.c @@ -1,4 +1,4 @@ -/* Copyright 2012-2024 Free Software Foundation, Inc. +/* Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/break-probes.c b/gdb/testsuite/gdb.base/break-probes.c index ce6f1c1..61fc7fc 100644 --- a/gdb/testsuite/gdb.base/break-probes.c +++ b/gdb/testsuite/gdb.base/break-probes.c @@ -1,4 +1,4 @@ -/* Copyright 2012-2024 Free Software Foundation, Inc. +/* Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/break-probes.exp b/gdb/testsuite/gdb.base/break-probes.exp index 3ebd896..d377801 100644 --- a/gdb/testsuite/gdb.base/break-probes.exp +++ b/gdb/testsuite/gdb.base/break-probes.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/break-unload-file.c b/gdb/testsuite/gdb.base/break-unload-file.c index 80a65f6..07bb943 100644 --- a/gdb/testsuite/gdb.base/break-unload-file.c +++ b/gdb/testsuite/gdb.base/break-unload-file.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/break-unload-file.exp b/gdb/testsuite/gdb.base/break-unload-file.exp index fb9874b..9eab6b9 100644 --- a/gdb/testsuite/gdb.base/break-unload-file.exp +++ b/gdb/testsuite/gdb.base/break-unload-file.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/break.c b/gdb/testsuite/gdb.base/break.c index b1c5159..51dd654 100644 --- a/gdb/testsuite/gdb.base/break.c +++ b/gdb/testsuite/gdb.base/break.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1992-2024 Free Software Foundation, Inc. + Copyright 1992-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 diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp index 34ac219..e1f4860 100644 --- a/gdb/testsuite/gdb.base/break.exp +++ b/gdb/testsuite/gdb.base/break.exp @@ -1,4 +1,4 @@ -# Copyright 1988-2024 Free Software Foundation, Inc. +# Copyright 1988-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 @@ -765,7 +765,7 @@ proc_with_prefix test_next_with_recursion {} { delete_breakpoints - if [istarget "mips*tx39-*"] { + if {[istarget "mips*tx39-*"]} { set timeout 60 } # We used to set timeout here for all other targets as well. This diff --git a/gdb/testsuite/gdb.base/break1.c b/gdb/testsuite/gdb.base/break1.c index 756e59b..94cbc0f 100644 --- a/gdb/testsuite/gdb.base/break1.c +++ b/gdb/testsuite/gdb.base/break1.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1992-2024 Free Software Foundation, Inc. + Copyright 1992-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 @@ -23,7 +23,13 @@ struct some_struct { int a_field; int b_field; - union { int z_field; }; + union + { + struct + { + int z_field; + }; + }; }; struct some_struct values[50]; @@ -49,7 +55,7 @@ int some_variable; simply as places to try setting breakpoints at. They are explicitly "one-line functions" to verify that this case works (some versions of gcc have or have had problems with this). - + These functions are in a separate source file to prevent an optimizing compiler from inlining them and optimizing them away. */ diff --git a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.c b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.c index 1e9e789..2b15698 100644 --- a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.c +++ b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp index 21cc7ff..7c6b1cb 100644 --- a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp +++ b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -25,7 +25,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } @@ -139,7 +139,7 @@ proc get_next_insn {} { set hw_step [probe_target_hardware_step] -if ![get_function_bounds "main" main_lo main_hi] { +if {![get_function_bounds "main" main_lo main_hi]} { # Can't do the following tests if main's bounds are unknown. return -1 } diff --git a/gdb/testsuite/gdb.base/breakpoint-shadow.c b/gdb/testsuite/gdb.base/breakpoint-shadow.c index 836be65..fa97e04 100644 --- a/gdb/testsuite/gdb.base/breakpoint-shadow.c +++ b/gdb/testsuite/gdb.base/breakpoint-shadow.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 @@ -19,7 +19,7 @@ int main (void) { volatile int i; - + i = 1; /* break-first */ i = 2; /* break-second */ diff --git a/gdb/testsuite/gdb.base/breakpoint-shadow.exp b/gdb/testsuite/gdb.base/breakpoint-shadow.exp index 9cf88e9..6e018f3 100644 --- a/gdb/testsuite/gdb.base/breakpoint-shadow.exp +++ b/gdb/testsuite/gdb.base/breakpoint-shadow.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -20,7 +20,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { } # We need to start the inferior to place the breakpoints in the memory at all. -if ![runto_main] { +if {![runto_main]} { return -1 } @@ -34,7 +34,7 @@ set match "\nDump of assembler code for function main:\r\n(.*)End of assembler d set test "disassembly without breakpoints" gdb_test_multiple "disass main" $test { -re $match { - set orig $expect_out(1,string) + set orig $expect_out(1,string) pass $test } } @@ -51,7 +51,7 @@ proc test_disassembly {test} { gdb_test_multiple "disass main" $test { -re $match { set got $expect_out(1,string) - if [string equal -nocase $orig $got] { + if {[string equal -nocase $orig $got]} { pass $test } else { fail $test diff --git a/gdb/testsuite/gdb.base/bt-on-error-and-warning.exp b/gdb/testsuite/gdb.base/bt-on-error-and-warning.exp index e83cc6c..8a5970a 100644 --- a/gdb/testsuite/gdb.base/bt-on-error-and-warning.exp +++ b/gdb/testsuite/gdb.base/bt-on-error-and-warning.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/bt-on-fatal-signal.c b/gdb/testsuite/gdb.base/bt-on-fatal-signal.c index 0f0e857..2a061a8 100644 --- a/gdb/testsuite/gdb.base/bt-on-fatal-signal.c +++ b/gdb/testsuite/gdb.base/bt-on-fatal-signal.c @@ -1,4 +1,4 @@ -/* Copyright 2021-2024 Free Software Foundation, Inc. +/* Copyright 2021-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp b/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp index 81a634d..5ced811 100644 --- a/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp +++ b/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 @@ -61,7 +61,7 @@ foreach test_data {{SEGV "Segmentation fault"} \ # Restart GDB. save_vars { GDB } { set GDB [gdb_no_core] - clean_restart $binfile + clean_restart $testfile } # Capture the pid of GDB. @@ -125,7 +125,7 @@ foreach test_data {{SEGV "Segmentation fault"} \ gdb_assert { $saw_fatal_msg } gdb_assert { $saw_bt_start } gdb_assert { $saw_bt_end } - gdb_assert { [expr $internal_error_msg_count == 2] } + gdb_assert { [expr {$internal_error_msg_count == 2}] } } -re "$gdb_prompt $" { # GDB should terminate, we should never get back to diff --git a/gdb/testsuite/gdb.base/bt-selected-frame.c b/gdb/testsuite/gdb.base/bt-selected-frame.c index 8ac8c33..00010cf 100644 --- a/gdb/testsuite/gdb.base/bt-selected-frame.c +++ b/gdb/testsuite/gdb.base/bt-selected-frame.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/bt-selected-frame.exp b/gdb/testsuite/gdb.base/bt-selected-frame.exp index 123cf17..99332ee 100644 --- a/gdb/testsuite/gdb.base/bt-selected-frame.exp +++ b/gdb/testsuite/gdb.base/bt-selected-frame.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -22,9 +22,7 @@ if { [build_executable "failed to prepare" $testfile $srcfile debug] } { } proc check_selected_frame_after_bt { bt_cmd stack_pattern } { - global binfile - - clean_restart $binfile + clean_restart $::testfile with_test_prefix $bt_cmd { diff --git a/gdb/testsuite/gdb.base/build-id-seqno.c b/gdb/testsuite/gdb.base/build-id-seqno.c index e2119ba7..ce81e8e 100644 --- a/gdb/testsuite/gdb.base/build-id-seqno.c +++ b/gdb/testsuite/gdb.base/build-id-seqno.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/build-id-seqno.exp b/gdb/testsuite/gdb.base/build-id-seqno.exp index 9566933..48f883c 100644 --- a/gdb/testsuite/gdb.base/build-id-seqno.exp +++ b/gdb/testsuite/gdb.base/build-id-seqno.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. # -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/c-linkage-name-2.c b/gdb/testsuite/gdb.base/c-linkage-name-2.c index a3eaa93..f12dfa5 100644 --- a/gdb/testsuite/gdb.base/c-linkage-name-2.c +++ b/gdb/testsuite/gdb.base/c-linkage-name-2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/c-linkage-name.c b/gdb/testsuite/gdb.base/c-linkage-name.c index 7c138e8..e974b7e 100644 --- a/gdb/testsuite/gdb.base/c-linkage-name.c +++ b/gdb/testsuite/gdb.base/c-linkage-name.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/c-linkage-name.exp b/gdb/testsuite/gdb.base/c-linkage-name.exp index 3d219bd..aaf2b08 100644 --- a/gdb/testsuite/gdb.base/c-linkage-name.exp +++ b/gdb/testsuite/gdb.base/c-linkage-name.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -55,7 +55,7 @@ if { $readnow } { # of the founction also provided by the same using. gdb_test "break do_something_other_cu" \ - "Breakpoint $decimal at $hex: file .*$srcfile2, line $decimal\\." + "Breakpoint $decimal at $hex: file .*$srcfile2, line $decimal\\." # Verify that partial symtab expansion has taken place for # c-linkage-name-2.c. @@ -70,5 +70,5 @@ gdb_test "maint flush symbol-cache" # symtab expansion. gdb_test "print symada__cS" \ - " = {a = 100829103}" \ - "print symada__cS after partial symtab expansion" + " = {a = 100829103}" \ + "print symada__cS after partial symtab expansion" diff --git a/gdb/testsuite/gdb.base/cached-source-file.c b/gdb/testsuite/gdb.base/cached-source-file.c index eb5319b..e352484 100644 --- a/gdb/testsuite/gdb.base/cached-source-file.c +++ b/gdb/testsuite/gdb.base/cached-source-file.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/cached-source-file.exp b/gdb/testsuite/gdb.base/cached-source-file.exp index b063362..73d9359 100644 --- a/gdb/testsuite/gdb.base/cached-source-file.exp +++ b/gdb/testsuite/gdb.base/cached-source-file.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2020-2024 Free Software Foundation, Inc. +# Copyright (C) 2020-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 diff --git a/gdb/testsuite/gdb.base/call-ar-st.c b/gdb/testsuite/gdb.base/call-ar-st.c index 4eac3f4..3df35b3 100644 --- a/gdb/testsuite/gdb.base/call-ar-st.c +++ b/gdb/testsuite/gdb.base/call-ar-st.c @@ -8,7 +8,7 @@ /************************************************************************** * TESTS : * -- function arguments that are enumerated types - * -- small structure arguments ( <= 64 bits ) + * -- small structure arguments ( <= 64 bits ) * -- stored in registers * -- stored on the stack * -- large structure arguments ( > 64 bits ) @@ -27,7 +27,7 @@ */ typedef int id_int; -typedef enum { +typedef enum { BLACK, BLUE, BROWN, @@ -52,13 +52,13 @@ typedef enum { */ struct array_rep_info_t { - int next_index[10]; + int next_index[10]; int values[10]; int head; }; /***************************************************************************** - * Small structures ( <= 64 bits). These are used to test passing small + * Small structures ( <= 64 bits). These are used to test passing small * structures as parameters and test argument size promotion. *****************************************************************************/ @@ -139,7 +139,7 @@ struct int_char_combo_t { }; /***************************************************************** - * PRINT_STUDENT_ID_SHIRT_COLOR : + * PRINT_STUDENT_ID_SHIRT_COLOR : * IN id_int student -- enumerated type * IN colors shirt -- enumerated type *****************************************************************/ @@ -149,7 +149,7 @@ void print_student_id_shirt_color (id_int student, colors shirt) printf("student id : %d\t", student); printf("shirt color : "); switch (shirt) { - case BLACK : printf("BLACK\n"); + case BLACK : printf("BLACK\n"); break; case BLUE : printf("BLUE\n"); break; @@ -189,8 +189,8 @@ void print_student_id_shirt_color (id_int student, colors shirt) } /***************************************************************** - * PRINT_CHAR_ARRAY : - * IN char array_c[] -- character array + * PRINT_CHAR_ARRAY : + * IN char array_c[] -- character array *****************************************************************/ void print_char_array (char array_c[]) { @@ -200,14 +200,14 @@ void print_char_array (char array_c[]) printf("array_c :\n"); printf("=========\n\n"); for (index = 0; index < 120; index++) { - printf("%1c", array_c[index]); + printf("%1c", array_c[index]); if ((index%50) == 0) printf("\n"); } printf("\n\n"); } /***************************************************************** - * PRINT_DOUBLE_ARRAY : + * PRINT_DOUBLE_ARRAY : * IN double array_d[] -- array of doubles *****************************************************************/ void print_double_array (double array_d[]) @@ -218,15 +218,15 @@ void print_double_array (double array_d[]) printf("array_d :\n"); printf("=========\n\n"); for (index = 0; index < 9; index++) { - printf("%f ", array_d[index]); + printf("%f ", array_d[index]); if ((index%8) == 0) printf("\n"); } printf("\n\n"); } /***************************************************************** - * PRINT_FLOAT_ARRAY: - * IN float array_f[] -- array of floats + * PRINT_FLOAT_ARRAY: + * IN float array_f[] -- array of floats *****************************************************************/ void print_float_array (float array_f[]) { @@ -236,7 +236,7 @@ void print_float_array (float array_f[]) printf("array_f :\n"); printf("=========\n\n"); for (index = 0; index < 15; index++) { - printf("%f ", array_f[index]); + printf("%f ", array_f[index]); if ((index%8) == 0) printf("\n"); } @@ -244,8 +244,8 @@ void print_float_array (float array_f[]) } /***************************************************************** - * PRINT_INT_ARRAY: - * IN int array_i[] -- array of integers + * PRINT_INT_ARRAY: + * IN int array_i[] -- array of integers *****************************************************************/ void print_int_array (int array_i[]) { @@ -255,7 +255,7 @@ void print_int_array (int array_i[]) printf("array_i :\n"); printf("=========\n\n"); for (index = 0; index < 50; index++) { - printf("%d ", array_i[index]); + printf("%d ", array_i[index]); if ((index%8) == 0) printf("\n"); } printf("\n\n"); @@ -263,11 +263,11 @@ void print_int_array (int array_i[]) } /***************************************************************** - * PRINT_ALL_ARRAYS: - * IN int array_i[] -- array of integers - * IN char array_c[] -- array of characters - * IN float array_f[] -- array of floats - * IN double array_d[] -- array of doubles + * PRINT_ALL_ARRAYS: + * IN int array_i[] -- array of integers + * IN char array_c[] -- array of characters + * IN float array_f[] -- array of floats + * IN double array_d[] -- array of doubles *****************************************************************/ void print_all_arrays(int array_i[], char array_c[], float array_f[], double array_d[]) { @@ -278,8 +278,8 @@ void print_all_arrays(int array_i[], char array_c[], float array_f[], double arr } /***************************************************************** - * LOOP_COUNT : - * A do nothing function. Used to provide a point at which calls can be made. + * LOOP_COUNT : + * A do nothing function. Used to provide a point at which calls can be made. *****************************************************************/ void loop_count () { @@ -289,8 +289,8 @@ void loop_count () { } /***************************************************************** - * COMPUTE_WITH_SMALL_STRUCTS : - * A do nothing function. Used to provide a point at which calls can be made. + * COMPUTE_WITH_SMALL_STRUCTS : + * A do nothing function. Used to provide a point at which calls can be made. * IN int seed *****************************************************************/ void compute_with_small_structs (int seed) @@ -300,7 +300,7 @@ void compute_with_small_structs (int seed) int index; for (index = 0; index < 4; index++) { - array[index].value = index*seed; + array[index].value = index*seed; array[index].head = (index+1)*seed; } @@ -316,12 +316,12 @@ void compute_with_small_structs (int seed) * the call command behavior when integer arguments do not fit into * registers and must be placed on the stack. * OUT struct bit_flags_t *bit_flags -- structure to be filled - * IN unsigned a -- 0 or 1 - * IN unsigned b -- 0 or 1 - * IN unsigned g -- 0 or 1 - * IN unsigned d -- 0 or 1 - * IN unsigned e -- 0 or 1 - * IN unsigned o -- 0 or 1 + * IN unsigned a -- 0 or 1 + * IN unsigned b -- 0 or 1 + * IN unsigned g -- 0 or 1 + * IN unsigned d -- 0 or 1 + * IN unsigned e -- 0 or 1 + * IN unsigned o -- 0 or 1 *****************************************************************/ void init_bit_flags (struct bit_flags_t *bit_flags, unsigned a, unsigned b, unsigned g, unsigned d, unsigned e, unsigned o) { @@ -340,14 +340,14 @@ void init_bit_flags (struct bit_flags_t *bit_flags, unsigned a, unsigned b, unsi * to see the call command behavior when integer and character arguments * do not fit into registers and must be placed on the stack. * OUT struct bit_flags_combo_t *bit_flags_combo -- structure to fill - * IN unsigned a -- 0 or 1 - * IN unsigned b -- 0 or 1 + * IN unsigned a -- 0 or 1 + * IN unsigned b -- 0 or 1 * IN char ch1 - * IN unsigned g -- 0 or 1 - * IN unsigned d -- 0 or 1 + * IN unsigned g -- 0 or 1 + * IN unsigned d -- 0 or 1 * IN char ch2 - * IN unsigned e -- 0 or 1 - * IN unsigned o -- 0 or 1 + * IN unsigned e -- 0 or 1 + * IN unsigned o -- 0 or 1 *****************************************************************/ void init_bit_flags_combo (struct bit_flags_combo_t *bit_flags_combo, unsigned a, unsigned b, char ch1, unsigned g, unsigned d, char ch2, unsigned e, unsigned o) { @@ -364,8 +364,8 @@ void init_bit_flags_combo (struct bit_flags_combo_t *bit_flags_combo, unsigned a /***************************************************************** - * INIT_ONE_DOUBLE : - * OUT struct one_double_t *one_double -- structure to fill + * INIT_ONE_DOUBLE : + * OUT struct one_double_t *one_double -- structure to fill * IN double init_val *****************************************************************/ void init_one_double (struct one_double_t *one_double, double init_val) @@ -375,10 +375,10 @@ void init_one_double (struct one_double_t *one_double, double init_val) } /***************************************************************** - * INIT_TWO_FLOATS : + * INIT_TWO_FLOATS : * OUT struct two_floats_t *two_floats -- structure to be filled - * IN float init_val1 - * IN float init_val2 + * IN float init_val1 + * IN float init_val2 *****************************************************************/ void init_two_floats (struct two_floats_t *two_floats, float init_val1, float init_val2) { @@ -387,10 +387,10 @@ void init_two_floats (struct two_floats_t *two_floats, float init_val1, float in } /***************************************************************** - * INIT_TWO_CHARS : + * INIT_TWO_CHARS : * OUT struct two_char_t *two_char -- structure to be filled - * IN char init_val1 - * IN char init_val2 + * IN char init_val1 + * IN char init_val2 *****************************************************************/ void init_two_chars (struct two_char_t *two_char, char init_val1, char init_val2) { @@ -400,11 +400,11 @@ void init_two_chars (struct two_char_t *two_char, char init_val1, char init_val2 } /***************************************************************** - * INIT_THREE_CHARS : + * INIT_THREE_CHARS : * OUT struct three_char_t *three_char -- structure to be filled - * IN char init_val1 - * IN char init_val2 - * IN char init_val3 + * IN char init_val1 + * IN char init_val2 + * IN char init_val3 *****************************************************************/ void init_three_chars (struct three_char_t *three_char, char init_val1, char init_val2, char init_val3) { @@ -415,13 +415,13 @@ void init_three_chars (struct three_char_t *three_char, char init_val1, char ini } /***************************************************************** - * INIT_FIVE_CHARS : + * INIT_FIVE_CHARS : * OUT struct five_char_t *five_char -- structure to be filled - * IN char init_val1 - * IN char init_val2 - * IN char init_val3 - * IN char init_val4 - * IN char init_val5 + * IN char init_val1 + * IN char init_val2 + * IN char init_val3 + * IN char init_val4 + * IN char init_val5 *****************************************************************/ void init_five_chars (struct five_char_t *five_char, char init_val1, char init_val2, char init_val3, char init_val4, char init_val5) { @@ -433,10 +433,10 @@ void init_five_chars (struct five_char_t *five_char, char init_val1, char init_v } /***************************************************************** - * INIT_INT_CHAR_COMBO : + * INIT_INT_CHAR_COMBO : * OUT struct int_char_combo_t *combo -- structure to be filled - * IN int init_val1 - * IN char init_val2 + * IN int init_val1 + * IN char init_val2 *****************************************************************/ void init_int_char_combo (struct int_char_combo_t *combo, int init_val1, char init_val2) { @@ -446,19 +446,19 @@ void init_int_char_combo (struct int_char_combo_t *combo, int init_val1, char in } /***************************************************************** - * INIT_STRUCT_REP : + * INIT_STRUCT_REP : * OUT struct small_rep_into_t *small_struct -- structure to be filled - * IN int seed + * IN int seed *****************************************************************/ void init_struct_rep(struct small_rep_info_t *small_struct, int seed) { - small_struct->value = 2 + (seed*2); - small_struct->head = 0; + small_struct->value = 2 + (seed*2); + small_struct->head = 0; } /***************************************************************** - * INIT_SMALL_STRUCTS : + * INIT_SMALL_STRUCTS : * Takes all the small structures as input and calls the appropriate * initialization routine for each structure *****************************************************************/ @@ -480,11 +480,11 @@ void init_small_structs ( struct two_floats_t *f3) { - init_bit_flags(flags, (unsigned)1, (unsigned)0, (unsigned)1, - (unsigned)0, (unsigned)1, (unsigned)0 ); + init_bit_flags(flags, (unsigned)1, (unsigned)0, (unsigned)1, + (unsigned)0, (unsigned)1, (unsigned)0 ); init_bit_flags_combo(flags_combo, (unsigned)1, (unsigned)0, 'y', (unsigned)1, (unsigned)0, 'n', - (unsigned)1, (unsigned)0 ); + (unsigned)1, (unsigned)0 ); init_three_chars(three_char, 'a', 'b', 'c'); init_five_chars(five_char, 'l', 'm', 'n', 'o', 'p'); init_int_char_combo(int_char_combo, 123, 'z'); @@ -492,16 +492,16 @@ void init_small_structs ( init_struct_rep(struct2, 4); init_struct_rep(struct3, 5); init_struct_rep(struct4, 6); - init_one_double ( d1, 10.5); - init_one_double ( d2, -3.375); - init_one_double ( d3, 675.09375); - init_two_floats ( f1, 45.234, 43.6); - init_two_floats ( f2, 78.01, 122.10); - init_two_floats ( f3, -1232.345, -199.21); + init_one_double ( d1, 10.5); + init_one_double ( d2, -3.375); + init_one_double ( d3, 675.09375); + init_two_floats ( f1, 45.234, 43.6); + init_two_floats ( f2, 78.01, 122.10); + init_two_floats ( f3, -1232.345, -199.21); } /***************************************************************** - * PRINT_TEN_DOUBLES : + * PRINT_TEN_DOUBLES : * ????????????????????????????? ****************************************************************/ void print_ten_doubles ( @@ -525,8 +525,8 @@ void print_ten_doubles ( } /***************************************************************** - * PRINT_BIT_FLAGS : - * IN struct bit_flags_t bit_flags + * PRINT_BIT_FLAGS : + * IN struct bit_flags_t bit_flags ****************************************************************/ void print_bit_flags (struct bit_flags_t bit_flags) { @@ -540,8 +540,8 @@ void print_bit_flags (struct bit_flags_t bit_flags) } /***************************************************************** - * PRINT_BIT_FLAGS_COMBO : - * IN struct bit_flags_combo_t bit_flags_combo + * PRINT_BIT_FLAGS_COMBO : + * IN struct bit_flags_combo_t bit_flags_combo ****************************************************************/ void print_bit_flags_combo (struct bit_flags_combo_t bit_flags_combo) { @@ -556,8 +556,8 @@ void print_bit_flags_combo (struct bit_flags_combo_t bit_flags_combo) } /***************************************************************** - * PRINT_ONE_DOUBLE : - * IN struct one_double_t one_double + * PRINT_ONE_DOUBLE : + * IN struct one_double_t one_double ****************************************************************/ void print_one_double (struct one_double_t one_double) { @@ -567,8 +567,8 @@ void print_one_double (struct one_double_t one_double) } /***************************************************************** - * PRINT_TWO_FLOATS : - * IN struct two_floats_t two_floats + * PRINT_TWO_FLOATS : + * IN struct two_floats_t two_floats ****************************************************************/ void print_two_floats (struct two_floats_t two_floats) { @@ -578,7 +578,7 @@ void print_two_floats (struct two_floats_t two_floats) } /***************************************************************** - * PRINT_TWO_CHARS : + * PRINT_TWO_CHARS : * IN struct two_char_t two_char ****************************************************************/ void print_two_chars (struct two_char_t two_char) @@ -589,7 +589,7 @@ void print_two_chars (struct two_char_t two_char) } /***************************************************************** - * PRINT_THREE_CHARS : + * PRINT_THREE_CHARS : * IN struct three_char_t three_char ****************************************************************/ void print_three_chars (struct three_char_t three_char) @@ -600,20 +600,20 @@ void print_three_chars (struct three_char_t three_char) } /***************************************************************** - * PRINT_FIVE_CHARS : + * PRINT_FIVE_CHARS : * IN struct five_char_t five_char ****************************************************************/ void print_five_chars (struct five_char_t five_char) { printf("Contents of five_char_t: \n\n"); - printf("%c\t%c\t%c\t%c\t%c\n", five_char.ch1, five_char.ch2, - five_char.ch3, five_char.ch4, + printf("%c\t%c\t%c\t%c\t%c\n", five_char.ch1, five_char.ch2, + five_char.ch3, five_char.ch4, five_char.ch5); } /***************************************************************** - * PRINT_INT_CHAR_COMBO : + * PRINT_INT_CHAR_COMBO : * IN struct int_char_combo_t int_char_combo ****************************************************************/ void print_int_char_combo (struct int_char_combo_t int_char_combo) @@ -621,10 +621,10 @@ void print_int_char_combo (struct int_char_combo_t int_char_combo) printf("Contents of int_char_combo_t: \n\n"); printf("%d\t%c\n", int_char_combo.int1, int_char_combo.ch1); -} +} /***************************************************************** - * PRINT_STRUCT_REP : + * PRINT_STRUCT_REP : * The last parameter must go onto the stack rather than into a register. * This is a good function to call to test small structures. * IN struct small_rep_info_t struct1 @@ -639,16 +639,16 @@ void print_struct_rep( printf("Contents of struct1: \n\n"); - printf("%10d%10d\n", struct1.value, struct1.head); + printf("%10d%10d\n", struct1.value, struct1.head); printf("Contents of struct2: \n\n"); - printf("%10d%10d\n", struct2.value, struct2.head); + printf("%10d%10d\n", struct2.value, struct2.head); printf("Contents of struct3: \n\n"); - printf("%10d%10d\n", struct3.value, struct3.head); + printf("%10d%10d\n", struct3.value, struct3.head); } /***************************************************************** - * SUM_STRUCT_PRINT : + * SUM_STRUCT_PRINT : * The last two parameters must go onto the stack rather than into a register. * This is a good function to call to test small structures. * IN struct small_rep_info_t struct1 @@ -659,7 +659,7 @@ void print_struct_rep( void sum_struct_print ( int seed, struct small_rep_info_t struct1, - struct small_rep_info_t struct2, + struct small_rep_info_t struct2, struct small_rep_info_t struct3, struct small_rep_info_t struct4) { @@ -671,7 +671,7 @@ void sum_struct_print ( } /***************************************************************** - * PRINT_SMALL_STRUCTS : + * PRINT_SMALL_STRUCTS : * This is a good function to call to test small structures. * All of the small structures of odd sizes (40 bits, 8bits, etc.) * are pushed onto the stack. @@ -709,11 +709,11 @@ void print_small_structs ( } /***************************************************************** - * PRINT_LONG_ARG_LIST : + * PRINT_LONG_ARG_LIST : * This is a good function to call to test small structures. * The first two parameters ( the doubles ) go into registers. The * remaining arguments are pushed onto the stack. Depending on where - * print_long_arg_list is called from, the size of the argument list + * print_long_arg_list is called from, the size of the argument list * may force more space to be pushed onto the stack as part of the callers * frame. ****************************************************************/ @@ -747,7 +747,7 @@ void print_long_arg_list ( printf("int : %d\n", e); printf("int : %d\n", f); print_small_structs( struct1, struct2, struct3, struct4, flags, flags_combo, - three_char, five_char, int_char_combo, d1, d2, d3, + three_char, five_char, int_char_combo, d1, d2, d3, f1, f2, f3); } @@ -761,14 +761,14 @@ void print_one_large_struct (struct array_rep_info_t linked_list1) printf(" | \n");*/ /*for (index = 0; index < 10; index++) {*/ - printf("%10d%10d\n", linked_list1.values[0], - linked_list1.next_index[0]); + printf("%10d%10d\n", linked_list1.values[0], + linked_list1.next_index[0]); /*}*/ } /***************************************************************** - * PRINT_ARRAY_REP : - * The three structure parameters should fit into registers. + * PRINT_ARRAY_REP : + * The three structure parameters should fit into registers. * IN struct array_rep_info_t linked_list1 * IN struct array_rep_info_t linked_list2 * IN struct array_rep_info_t linked_list3 @@ -787,8 +787,8 @@ void print_array_rep( printf(" | \n"); for (index = 0; index < 10; index++) { - printf("%10d%10d\n", linked_list1.values[index], - linked_list1.next_index[index]); + printf("%10d%10d\n", linked_list1.values[index], + linked_list1.next_index[index]); } printf("Contents of linked list2: \n\n"); @@ -797,8 +797,8 @@ void print_array_rep( printf(" | \n"); for (index = 0; index < 10; index++) { - printf("%10d%10d\n", linked_list2.values[index], - linked_list2.next_index[index]); + printf("%10d%10d\n", linked_list2.values[index], + linked_list2.next_index[index]); } printf("Contents of linked list3: \n\n"); @@ -807,15 +807,15 @@ void print_array_rep( printf(" | \n"); for (index = 0; index < 10; index++) { - printf("%10d%10d\n", linked_list3.values[index], - linked_list3.next_index[index]); + printf("%10d%10d\n", linked_list3.values[index], + linked_list3.next_index[index]); } } /***************************************************************** - * SUM_ARRAY_PRINT : - * The last structure parameter must be pushed onto the stack + * SUM_ARRAY_PRINT : + * The last structure parameter must be pushed onto the stack * IN int seed * IN struct array_rep_info_t linked_list1 * IN struct array_rep_info_t linked_list2 @@ -840,14 +840,14 @@ void sum_array_print ( for (index = 0; index < 10; index++) { - sum = seed + linked_list1.values[index] + linked_list2.values[index] + + sum = seed + linked_list1.values[index] + linked_list2.values[index] + linked_list3.values[index] + linked_list4.values[index]; - printf("%10d%10d\n", index, sum); + printf("%10d%10d\n", index, sum); } } /***************************************************************** - * INIT_ARRAY_REP : + * INIT_ARRAY_REP : * IN struct array_rep_info_t *linked_list * IN int seed ****************************************************************/ @@ -860,10 +860,10 @@ void init_array_rep( for (index = 0; index < 10; index++) { - linked_list->values[index] = (2*index) + (seed*2); + linked_list->values[index] = (2*index) + (seed*2); linked_list->next_index[index] = index + 1; } - linked_list->head = 0; + linked_list->head = 0; } @@ -874,11 +874,11 @@ int main () { static char char_array[121]; static double double_array[9]; static float float_array[15]; - static int integer_array[50]; + static int integer_array[50]; static int index; static id_int student_id = 23; static colors my_shirt = YELLOW; - + /* variables for large structure testing */ static int number = 10; @@ -941,18 +941,18 @@ int main () { print_char_array(char_array); print_double_array(double_array); /* -tbreak2- */ print_float_array(float_array); - print_student_id_shirt_color(student_id, my_shirt); + print_student_id_shirt_color(student_id, my_shirt); print_int_array(integer_array); print_all_arrays(integer_array, char_array, float_array, double_array); /* -tbreak3- */ - /* Allocate space for large structures + /* Allocate space for large structures */ list1 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t)); list2 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t)); list3 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t)); list4 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t)); - /* Initialize large structures + /* Initialize large structures */ init_array_rep(list1, 2); init_array_rep(list2, 4); @@ -962,13 +962,13 @@ int main () { printf("BYE BYE FOR NOW\n"); /* -tbreak4- */ printf("VERY GREEN GRASS\n"); /* -next2- */ - /* Print large structures + /* Print large structures */ sum_array_print(10, *list1, *list2, *list3, *list4); /* -tbreak5- */ print_array_rep(*list1, *list2, *list3); print_one_large_struct(*list1); - /* Allocate space for small structures + /* Allocate space for small structures */ struct1 = (struct small_rep_info_t *)malloc(sizeof(struct small_rep_info_t)); struct2 = (struct small_rep_info_t *)malloc(sizeof(struct small_rep_info_t)); @@ -988,19 +988,19 @@ int main () { f2 = (struct two_floats_t *)malloc(sizeof(struct two_floats_t)); f3 = (struct two_floats_t *)malloc(sizeof(struct two_floats_t)); - /* Initialize small structures + /* Initialize small structures */ - init_small_structs ( struct1, struct2, struct3, struct4, flags, + init_small_structs ( struct1, struct2, struct3, struct4, flags, flags_combo, three_char, five_char, int_char_combo, d1, d2, d3, f1, f2, f3); - /* Print small structures + /* Print small structures */ - print_small_structs ( *struct1, *struct2, *struct3, *struct4, *flags, + print_small_structs ( *struct1, *struct2, *struct3, *struct4, *flags, *flags_combo, *three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3); - /* Print a very long arg list + /* Print a very long arg list */ a = 22.25; b = 33.375; @@ -1013,19 +1013,19 @@ int main () { *flags, *flags_combo, *three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3); - /* Initialize small structures + /* Initialize small structures */ - init_one_double ( d1, 1.11111); - init_one_double ( d2, -345.34); - init_one_double ( d3, 546464.2); - init_two_floats ( f1, 0.234, 453.1); - init_two_floats ( f2, 78.345, 23.09); - init_two_floats ( f3, -2.345, 1.0); - init_bit_flags(flags, (unsigned)1, (unsigned)0, (unsigned)1, - (unsigned)0, (unsigned)1, (unsigned)0 ); + init_one_double ( d1, 1.11111); + init_one_double ( d2, -345.34); + init_one_double ( d3, 546464.2); + init_two_floats ( f1, 0.234, 453.1); + init_two_floats ( f2, 78.345, 23.09); + init_two_floats ( f3, -2.345, 1.0); + init_bit_flags(flags, (unsigned)1, (unsigned)0, (unsigned)1, + (unsigned)0, (unsigned)1, (unsigned)0 ); init_bit_flags_combo(flags_combo, (unsigned)1, (unsigned)0, 'y', /* -tbreak8- */ (unsigned)1, (unsigned)0, 'n', - (unsigned)1, (unsigned)0 ); + (unsigned)1, (unsigned)0 ); init_three_chars(three_char, 'x', 'y', 'z'); init_five_chars(five_char, 'h', 'e', 'l', 'l', 'o'); init_int_char_combo(int_char_combo, 13, '!'); /* -tbreak9- */ @@ -1040,7 +1040,7 @@ int main () { printf("BYE BYE FOR NOW\n"); printf("VERY GREEN GRASS\n"); - /* Print small structures + /* Print small structures */ print_one_double(*d1); print_one_double(*d2); @@ -1058,8 +1058,3 @@ int main () { return 0; } - - - - - diff --git a/gdb/testsuite/gdb.base/call-ar-st.exp b/gdb/testsuite/gdb.base/call-ar-st.exp index c0a47a7..fd1f1a0 100644 --- a/gdb/testsuite/gdb.base/call-ar-st.exp +++ b/gdb/testsuite/gdb.base/call-ar-st.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -38,7 +38,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} { set oldtimeout $timeout -set timeout [expr "$timeout + 60"] +set timeout [expr {$timeout + 60}] gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set print address off" @@ -86,7 +86,7 @@ set array_c_re \ "aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ" \ "aZaZaZaZaZaZaZaZaZa"] -if ![gdb_skip_stdio_test "print_char_array(char_array)"] { +if {![gdb_skip_stdio_test "print_char_array(char_array)"]} { gdb_test_stdio "print print_char_array(char_array)" $array_c_re } @@ -95,7 +95,7 @@ gdb_test "tbreak $stop_line" \ "Temporary breakpoint.*file.*$srcfile, line $stop_line.*" \ "tbreakpoint at tbreak2" -if ![gdb_skip_stdio_test "continue to tbreak2"] { +if {![gdb_skip_stdio_test "continue to tbreak2"]} { set gdb_re \ [multi_line \ "main.*at.*:\[0-9\]+" \ @@ -106,7 +106,7 @@ if ![gdb_skip_stdio_test "continue to tbreak2"] { } # I am disabling this test, because it takes too long. I verified by -# hand that it works, feel free to check for yourself. +# hand that it works, feel free to check for yourself. #call print_all_arrays(integer_array, char_array, float_array, double_array) #send_gdb "print print_all_arrays(integer_array, char_array, float_array, double_array)\n" #gdb_expect { @@ -165,7 +165,7 @@ gdb_test "step" \ "step inside print_all_arrays" #step -over -if ![gdb_skip_stdio_test "next over print_int_array in print_all_arrays"] { +if {![gdb_skip_stdio_test "next over print_int_array in print_all_arrays"]} { set stop_line [gdb_get_line_number "-next1-"] gdb_test_stdio "next" \ "array_i :" \ @@ -214,7 +214,7 @@ if {$allow_float_test && \ #call sum_array_print(10, *list1, *list2, *list3, *list4) -if ![gdb_skip_stdio_test "print sum_array_print(...)"] { +if {![gdb_skip_stdio_test "print sum_array_print(...)"]} { gdb_test_stdio "print sum_array_print(10, *list1, *list2, *list3, *list4)" \ [multi_line \ @@ -239,7 +239,7 @@ if ![gdb_skip_stdio_test "print sum_array_print(...)"] { #step over set stop_line [gdb_get_line_number "-next2-"] -if ![gdb_skip_stdio_test "next to next2"] { +if {![gdb_skip_stdio_test "next to next2"]} { gdb_test_stdio "next" \ "BYE BYE FOR NOW" \ "$stop_line.*printf\\(.VERY GREEN GRASS.n.\\);.*" \ @@ -250,7 +250,7 @@ if ![gdb_skip_stdio_test "next to next2"] { #call print_array_rep(\*list1, \*list2, \*list3) -if ![gdb_skip_stdio_test "print print_array_rep(...)"] { +if {![gdb_skip_stdio_test "print print_array_rep(...)"]} { gdb_test_stdio "print print_array_rep(\*list1, \*list2, \*list3)" \ "Contents of linked list3:" } @@ -300,7 +300,7 @@ gdb_test "tbreak $stop_line" \ "Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \ "tbreakpoint at tbreak6" -if ![gdb_skip_stdio_test "continuing to tbreak6"] { +if {![gdb_skip_stdio_test "continuing to tbreak6"]} { gdb_test_stdio "continue" \ "Sum of 4 arrays.*Contents of linked list1.*Contents of two_floats_t" \ "main \\(\\) at .*$srcfile:$stop_line.*c = 0.*" \ @@ -309,8 +309,8 @@ if ![gdb_skip_stdio_test "continuing to tbreak6"] { gdb_test "continue" ".*" "" } -#call print_small_structs(*struct1, *struct2, *struct3, *struct4, -# *flags, *flags_combo, *three_char, *five_char, +#call print_small_structs(*struct1, *struct2, *struct3, *struct4, +# *flags, *flags_combo, *three_char, *five_char, # *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3) if {$allow_float_test && \ @@ -373,7 +373,7 @@ gdb_test "print compute_with_small_structs(20)" \ "\[0-9\]+ = void" -#call print_ten_doubles(123.456, 123.456, -0.12, -1.23, 343434.8, 89.098, +#call print_ten_doubles(123.456, 123.456, -0.12, -1.23, 343434.8, 89.098, # 3.14, -5678.12345, -0.11111111, 216.97065) if {$allow_float_test && \ @@ -422,8 +422,8 @@ if {$allow_float_test} { set ws "\[\n\r\t \]+" -#call print_small_structs(struct1, struct2, struct3, struct4, flags, -# flags_combo, three_char, five_char, int_char_combo, +#call print_small_structs(struct1, struct2, struct3, struct4, flags, +# flags_combo, three_char, five_char, int_char_combo, # d1, d2, d3, f1, f2, f3) if {$allow_float_test && \ @@ -495,7 +495,7 @@ gdb_test "tbreak $stop_line" \ "Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \ "tbreakpoint at tbreak8" -if ![gdb_skip_stdio_test "continuing to tbreak8"] { +if {![gdb_skip_stdio_test "continuing to tbreak8"]} { gdb_test_stdio "continue" \ "Contents of two_floats_t:" \ ".*main \\(\\) at.*$srcfile:$stop_line.*$stop_line.*init_bit_flags_combo\\(flags_combo, \\(unsigned\\)1, \\(unsigned\\)0, .y.,.*" \ @@ -511,7 +511,7 @@ gdb_test "step" \ "step into init_bit_flags_combo" #call print_bit_flags_combo(*bit_flags_combo) -if ![gdb_skip_stdio_test "continuing at step3"] { +if {![gdb_skip_stdio_test "continuing at step3"]} { gdb_test_stdio "print print_bit_flags_combo(*bit_flags_combo)" \ "alpha.*gamma.*epsilon.*ch1: y.*ch2: n" } @@ -600,14 +600,14 @@ gdb_test continue "Continuing\\..*main \\(\\) at .*$srcfile:$stop_line\[ \t\n\r\ #call sum_struct_print(10, *struct1, *struct2, *struct3, *struct4) -if ![gdb_skip_stdio_test "print sum_struct_print(...)"] { +if {![gdb_skip_stdio_test "print sum_struct_print(...)"]} { gdb_test_stdio "print sum_struct_print(10,*struct1,*struct2,*struct3,*struct4)" \ "Sum of the 4 struct values and seed :\[ \t\n\r\]+218" } #call print_struct_rep(*struct1, *struct2, *struct3) -if ![gdb_skip_stdio_test "print print_struct_rep(...)"] { +if {![gdb_skip_stdio_test "print print_struct_rep(...)"]} { gdb_test_stdio "print print_struct_rep(*struct1, *struct2, *struct3)" \ [multi_line \ "Contents of struct1: " \ @@ -622,7 +622,7 @@ if ![gdb_skip_stdio_test "print print_struct_rep(...)"] { ] } -if ![gdb_skip_stdio_test "print print_one_large_struct(...)"] { +if {![gdb_skip_stdio_test "print print_one_large_struct(...)"]} { gdb_test_stdio "print print_one_large_struct(*list1)" \ " 4 1" } diff --git a/gdb/testsuite/gdb.base/call-rt-st.c b/gdb/testsuite/gdb.base/call-rt-st.c index e4bc297..7b686ea 100644 --- a/gdb/testsuite/gdb.base/call-rt-st.c +++ b/gdb/testsuite/gdb.base/call-rt-st.c @@ -16,13 +16,13 @@ */ struct array_rep_info_t { - int next_index[10]; + int next_index[10]; int values[10]; int head; }; /***************************************************************************** - * Small structures ( <= 64 bits). These are used to test passing small + * Small structures ( <= 64 bits). These are used to test passing small * structures as parameters and test argument size promotion. *****************************************************************************/ @@ -120,8 +120,8 @@ struct int_char_combo_t { /***************************************************************** - * LOOP_COUNT : - * A do nothing function. Used to provide a point at which calls can be made. + * LOOP_COUNT : + * A do nothing function. Used to provide a point at which calls can be made. *****************************************************************/ void loop_count () { @@ -136,12 +136,12 @@ void loop_count () { * the call command behavior when integer arguments do not fit into * registers and must be placed on the stack. * OUT struct bit_flags_char_t *bit_flags -- structure to be filled - * IN unsigned a -- 0 or 1 - * IN unsigned b -- 0 or 1 - * IN unsigned g -- 0 or 1 - * IN unsigned d -- 0 or 1 - * IN unsigned e -- 0 or 1 - * IN unsigned o -- 0 or 1 + * IN unsigned a -- 0 or 1 + * IN unsigned b -- 0 or 1 + * IN unsigned g -- 0 or 1 + * IN unsigned d -- 0 or 1 + * IN unsigned e -- 0 or 1 + * IN unsigned o -- 0 or 1 *****************************************************************/ void init_bit_flags_char ( struct bit_flags_char_t *bit_flags, @@ -167,12 +167,12 @@ unsigned o) * the call command behavior when integer arguments do not fit into * registers and must be placed on the stack. * OUT struct bit_flags_short_t *bit_flags -- structure to be filled - * IN unsigned a -- 0 or 1 - * IN unsigned b -- 0 or 1 - * IN unsigned g -- 0 or 1 - * IN unsigned d -- 0 or 1 - * IN unsigned e -- 0 or 1 - * IN unsigned o -- 0 or 1 + * IN unsigned a -- 0 or 1 + * IN unsigned b -- 0 or 1 + * IN unsigned g -- 0 or 1 + * IN unsigned d -- 0 or 1 + * IN unsigned e -- 0 or 1 + * IN unsigned o -- 0 or 1 *****************************************************************/ void init_bit_flags_short ( struct bit_flags_short_t *bit_flags, @@ -198,12 +198,12 @@ unsigned o) * the call command behavior when integer arguments do not fit into * registers and must be placed on the stack. * OUT struct bit_flags_t *bit_flags -- structure to be filled - * IN unsigned a -- 0 or 1 - * IN unsigned b -- 0 or 1 - * IN unsigned g -- 0 or 1 - * IN unsigned d -- 0 or 1 - * IN unsigned e -- 0 or 1 - * IN unsigned o -- 0 or 1 + * IN unsigned a -- 0 or 1 + * IN unsigned b -- 0 or 1 + * IN unsigned g -- 0 or 1 + * IN unsigned d -- 0 or 1 + * IN unsigned e -- 0 or 1 + * IN unsigned o -- 0 or 1 *****************************************************************/ void init_bit_flags ( struct bit_flags_t *bit_flags, @@ -229,14 +229,14 @@ unsigned o) * to see the call command behavior when integer and character arguments * do not fit into registers and must be placed on the stack. * OUT struct bit_flags_combo_t *bit_flags_combo -- structure to fill - * IN unsigned a -- 0 or 1 - * IN unsigned b -- 0 or 1 + * IN unsigned a -- 0 or 1 + * IN unsigned b -- 0 or 1 * IN char ch1 - * IN unsigned g -- 0 or 1 - * IN unsigned d -- 0 or 1 + * IN unsigned g -- 0 or 1 + * IN unsigned d -- 0 or 1 * IN char ch2 - * IN unsigned e -- 0 or 1 - * IN unsigned o -- 0 or 1 + * IN unsigned e -- 0 or 1 + * IN unsigned o -- 0 or 1 *****************************************************************/ void init_bit_flags_combo ( struct bit_flags_combo_t *bit_flags_combo, @@ -262,8 +262,8 @@ unsigned o) /***************************************************************** - * INIT_ONE_DOUBLE : - * OUT struct one_double_t *one_double -- structure to fill + * INIT_ONE_DOUBLE : + * OUT struct one_double_t *one_double -- structure to fill * IN double init_val *****************************************************************/ void init_one_double ( struct one_double_t *one_double, double init_val) @@ -273,10 +273,10 @@ void init_one_double ( struct one_double_t *one_double, double init_val) } /***************************************************************** - * INIT_TWO_FLOATS : + * INIT_TWO_FLOATS : * OUT struct two_floats_t *two_floats -- structure to be filled - * IN float init_val1 - * IN float init_val2 + * IN float init_val1 + * IN float init_val2 *****************************************************************/ void init_two_floats ( struct two_floats_t *two_floats, @@ -289,11 +289,11 @@ void init_two_floats ( } /***************************************************************** - * INIT_THREE_CHARS : + * INIT_THREE_CHARS : * OUT struct three_char_t *three_char -- structure to be filled - * IN char init_val1 - * IN char init_val2 - * IN char init_val3 + * IN char init_val1 + * IN char init_val2 + * IN char init_val3 *****************************************************************/ void init_three_chars ( struct three_char_t *three_char, @@ -308,13 +308,13 @@ char init_val3) } /***************************************************************** - * INIT_FIVE_CHARS : + * INIT_FIVE_CHARS : * OUT struct five_char_t *five_char -- structure to be filled - * IN char init_val1 - * IN char init_val2 - * IN char init_val3 - * IN char init_val4 - * IN char init_val5 + * IN char init_val1 + * IN char init_val2 + * IN char init_val3 + * IN char init_val4 + * IN char init_val5 *****************************************************************/ void init_five_chars ( struct five_char_t *five_char, @@ -333,10 +333,10 @@ char init_val5) } /***************************************************************** - * INIT_INT_CHAR_COMBO : + * INIT_INT_CHAR_COMBO : * OUT struct int_char_combo_t *combo -- structure to be filled - * IN int init_val1 - * IN char init_val2 + * IN int init_val1 + * IN char init_val2 *****************************************************************/ void init_int_char_combo ( struct int_char_combo_t *combo, @@ -349,22 +349,22 @@ char init_val2) } /***************************************************************** - * INIT_STRUCT_REP : + * INIT_STRUCT_REP : * OUT struct small_rep_into_t *small_struct -- structure to be filled - * IN int seed + * IN int seed *****************************************************************/ void init_struct_rep( struct small_rep_info_t *small_struct, int seed) { - small_struct->value = 2 + (seed*2); - small_struct->head = 0; + small_struct->value = 2 + (seed*2); + small_struct->head = 0; } /***************************************************************** - * PRINT_BIT_FLAGS_CHAR : - * IN struct bit_flags_char_t bit_flags + * PRINT_BIT_FLAGS_CHAR : + * IN struct bit_flags_char_t bit_flags ****************************************************************/ struct bit_flags_char_t print_bit_flags_char (struct bit_flags_char_t bit_flags) { @@ -376,12 +376,12 @@ struct bit_flags_char_t print_bit_flags_char (struct bit_flags_char_t bit_flags) if (bit_flags.epsilon) printf("epsilon\n"); if (bit_flags.omega) printf("omega\n"); return bit_flags; - + } /***************************************************************** - * PRINT_BIT_FLAGS_SHORT : - * IN struct bit_flags_short_t bit_flags + * PRINT_BIT_FLAGS_SHORT : + * IN struct bit_flags_short_t bit_flags ****************************************************************/ struct bit_flags_short_t print_bit_flags_short (struct bit_flags_short_t bit_flags) { @@ -393,12 +393,12 @@ struct bit_flags_short_t print_bit_flags_short (struct bit_flags_short_t bit_fla if (bit_flags.epsilon) printf("epsilon\n"); if (bit_flags.omega) printf("omega\n"); return bit_flags; - + } /***************************************************************** - * PRINT_BIT_FLAGS : - * IN struct bit_flags_t bit_flags + * PRINT_BIT_FLAGS : + * IN struct bit_flags_t bit_flags ****************************************************************/ struct bit_flags_t print_bit_flags (struct bit_flags_t bit_flags) { @@ -410,12 +410,12 @@ struct bit_flags_t print_bit_flags (struct bit_flags_t bit_flags) if (bit_flags.epsilon) printf("epsilon\n"); if (bit_flags.omega) printf("omega\n"); return bit_flags; - + } /***************************************************************** - * PRINT_BIT_FLAGS_COMBO : - * IN struct bit_flags_combo_t bit_flags_combo + * PRINT_BIT_FLAGS_COMBO : + * IN struct bit_flags_combo_t bit_flags_combo ****************************************************************/ struct bit_flags_combo_t print_bit_flags_combo (struct bit_flags_combo_t bit_flags_combo) { @@ -428,12 +428,12 @@ struct bit_flags_combo_t print_bit_flags_combo (struct bit_flags_combo_t bit_fla if (bit_flags_combo.omega) printf("omega\n"); printf("ch1: %c\tch2: %c\n", bit_flags_combo.ch1, bit_flags_combo.ch2); return bit_flags_combo; - + } /***************************************************************** - * PRINT_ONE_DOUBLE : - * IN struct one_double_t one_double + * PRINT_ONE_DOUBLE : + * IN struct one_double_t one_double ****************************************************************/ struct one_double_t print_one_double (struct one_double_t one_double) { @@ -441,12 +441,12 @@ struct one_double_t print_one_double (struct one_double_t one_double) printf("Contents of one_double_t: \n\n"); printf("%f\n", one_double.double1); return one_double; - + } /***************************************************************** - * PRINT_TWO_FLOATS : - * IN struct two_floats_t two_floats + * PRINT_TWO_FLOATS : + * IN struct two_floats_t two_floats ****************************************************************/ struct two_floats_t print_two_floats (struct two_floats_t two_floats) { @@ -454,11 +454,11 @@ struct two_floats_t print_two_floats (struct two_floats_t two_floats) printf("Contents of two_floats_t: \n\n"); printf("%f\t%f\n", two_floats.float1, two_floats.float2); return two_floats; - + } /***************************************************************** - * PRINT_THREE_CHARS : + * PRINT_THREE_CHARS : * IN struct three_char_t three_char ****************************************************************/ struct three_char_t print_three_chars (struct three_char_t three_char) @@ -467,26 +467,26 @@ struct three_char_t print_three_chars (struct three_char_t three_char) printf("Contents of three_char_t: \n\n"); printf("%c\t%c\t%c\n", three_char.ch1, three_char.ch2, three_char.ch3); return three_char; - + } /***************************************************************** - * PRINT_FIVE_CHARS : + * PRINT_FIVE_CHARS : * IN struct five_char_t five_char ****************************************************************/ struct five_char_t print_five_chars (struct five_char_t five_char) { printf("Contents of five_char_t: \n\n"); - printf("%c\t%c\t%c\t%c\t%c\n", five_char.ch1, five_char.ch2, - five_char.ch3, five_char.ch4, + printf("%c\t%c\t%c\t%c\t%c\n", five_char.ch1, five_char.ch2, + five_char.ch3, five_char.ch4, five_char.ch5); return five_char; - + } /***************************************************************** - * PRINT_INT_CHAR_COMBO : + * PRINT_INT_CHAR_COMBO : * IN struct int_char_combo_t int_char_combo ****************************************************************/ struct int_char_combo_t print_int_char_combo (struct int_char_combo_t int_char_combo) @@ -495,21 +495,21 @@ struct int_char_combo_t print_int_char_combo (struct int_char_combo_t int_char_c printf("Contents of int_char_combo_t: \n\n"); printf("%d\t%c\n", int_char_combo.int1, int_char_combo.ch1); return int_char_combo; - -} + +} /***************************************************************** - * PRINT_STRUCT_REP : + * PRINT_STRUCT_REP : ****************************************************************/ struct small_rep_info_t print_struct_rep(struct small_rep_info_t struct1) { printf("Contents of struct1: \n\n"); - printf("%10d%10d\n", struct1.value, struct1.head); + printf("%10d%10d\n", struct1.value, struct1.head); struct1.value =+5; - + return struct1; - + } @@ -518,11 +518,11 @@ struct array_rep_info_t print_one_large_struct(struct array_rep_info_t linked_li { - printf("%10d%10d\n", linked_list1.values[0], - linked_list1.next_index[0]); - + printf("%10d%10d\n", linked_list1.values[0], + linked_list1.next_index[0]); + return linked_list1; - + } /***************************************************************** @@ -545,7 +545,7 @@ void init_array_rep(struct array_rep_info_t *linked_list, int seed) int main () { - + /* variables for large structure testing */ int number = 10; @@ -566,19 +566,19 @@ int main () { gdb_unbuffer_output (); - /* Allocate space for large structures + /* Allocate space for large structures */ list1 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t)); - /* Initialize large structures + /* Initialize large structures */ init_array_rep(list1, 2); - /* Print large structures + /* Print large structures */ print_one_large_struct(*list1); - /* Allocate space for small structures + /* Allocate space for small structures */ struct1 = (struct small_rep_info_t *)malloc(sizeof(struct small_rep_info_t)); cflags = (struct bit_flags_char_t *)malloc(sizeof(struct bit_flags_char_t)); @@ -592,26 +592,26 @@ int main () { d1 = (struct one_double_t *)malloc(sizeof(struct one_double_t)); f3 = (struct two_floats_t *)malloc(sizeof(struct two_floats_t)); - /* Initialize small structures + /* Initialize small structures */ - init_one_double ( d1, 1.11111); - init_two_floats ( f3, -2.345, 1.0); - init_bit_flags_char(cflags, (unsigned)1, (unsigned)0, (unsigned)1, - (unsigned)0, (unsigned)1, (unsigned)0 ); - init_bit_flags_short(sflags, (unsigned)1, (unsigned)0, (unsigned)1, - (unsigned)0, (unsigned)1, (unsigned)0 ); - init_bit_flags(flags, (unsigned)1, (unsigned)0, (unsigned)1, - (unsigned)0, (unsigned)1, (unsigned)0 ); + init_one_double ( d1, 1.11111); + init_two_floats ( f3, -2.345, 1.0); + init_bit_flags_char(cflags, (unsigned)1, (unsigned)0, (unsigned)1, + (unsigned)0, (unsigned)1, (unsigned)0 ); + init_bit_flags_short(sflags, (unsigned)1, (unsigned)0, (unsigned)1, + (unsigned)0, (unsigned)1, (unsigned)0 ); + init_bit_flags(flags, (unsigned)1, (unsigned)0, (unsigned)1, + (unsigned)0, (unsigned)1, (unsigned)0 ); init_bit_flags_combo(flags_combo, (unsigned)1, (unsigned)0, 'y', (unsigned)1, (unsigned)0, 'n', - (unsigned)1, (unsigned)0 ); + (unsigned)1, (unsigned)0 ); init_three_chars(three_char, 'x', 'y', 'z'); init_five_chars(five_char, 'h', 'e', 'l', 'l', 'o'); init_int_char_combo(int_char_combo, 13, '!'); init_struct_rep(struct1, 10); - - - /* Print small structures + + + /* Print small structures */ print_one_double(*d1); print_two_floats(*f3); @@ -628,18 +628,3 @@ int main () { return 0; /* -finish1- */ } - - - - - - - - - - - - - - - diff --git a/gdb/testsuite/gdb.base/call-rt-st.exp b/gdb/testsuite/gdb.base/call-rt-st.exp index af5c576..fbe41be 100644 --- a/gdb/testsuite/gdb.base/call-rt-st.exp +++ b/gdb/testsuite/gdb.base/call-rt-st.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -25,21 +25,18 @@ require {!target_info exists gdb,cannot_call_functions} standard_testfile .c +set allow_float_test [allow_float_test] + set flags {} lappend flags debug lappend flags nowarnings lappend_include_file flags $srcdir/lib/unbuffer_output.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $flags] != "" } { - untested "failed to compile" - return -1 +# Build executable, and start GDB. +if { [prepare_for_testing "prepare" $testfile $srcfile $flags] != 0 } { + return } -set allow_float_test [allow_float_test] - -# Start with a fresh gdb. - -clean_restart ${binfile} gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set print address off" gdb_test_no_output "set width 0" @@ -97,10 +94,10 @@ proc print_struct_call { expr inf_result gdb_result } { exp_continue } } - -re "Function return value unknown.\[\r\n\]+$gdb_prompt $" { - unsupported "$command" + -re "Function return value unknown.\[\r\n\]+$gdb_prompt $" { + unsupported "$command" return - } + } } verbose -log "inferior_matched=$inferior_matched, gdb_matched=$gdb_matched" @@ -108,69 +105,69 @@ proc print_struct_call { expr inf_result gdb_result } { } -if ![gdb_skip_stdio_test "print print_struct_rep(*struct1)"] { +if {![gdb_skip_stdio_test "print print_struct_rep(*struct1)"]} { print_struct_call "print_struct_rep(*struct1)" \ ".*Contents of struct1:\[ \t\n\r\]+22\[ \t\]+0\[ \t\n\r\]+" \ ".\[0-9\]+ = \\{value = 5, head = 0\\}" } -if ![gdb_skip_stdio_test "print print_one_large_struct(...)"] { +if {![gdb_skip_stdio_test "print print_one_large_struct(...)"]} { print_struct_call "print_one_large_struct(*list1)" \ ".*\[ \t\]+4\[ \t\]+1\[ \r\n\]+" \ ".\[0-9\]+ = \\{next_index = \\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\}, values = \\{4, 6, 8, 10, 12, 14, 16, 18, 20, 22\\}, head = 0\\}" } if {$allow_float_test && \ - ![gdb_skip_stdio_test "print print_one_double(*d1)"] } { + ![gdb_skip_stdio_test "print print_one_double(*d1)"] } { print_struct_call "print_one_double(*d1)" \ ".*Contents of one_double_t:\[ \r\n\]+1\\.111110\[ \r\n\]+" \ ".\[0-9\]+ = \\{double1 = 1\\.111\[0-9\]*\\}" } if {$allow_float_test && \ - ![gdb_skip_stdio_test "print print_two_floats(*f3)"] } { + ![gdb_skip_stdio_test "print print_two_floats(*f3)"] } { print_struct_call "print_two_floats(*f3)" \ ".*Contents of two_floats_t:\[ \r\n\]+-2\\.345000\[ \t]+1\\.000000\[ \r\n\]+" \ ".\[0-9\]+ = \\{float1 = -2\\.34500003, float2 = 1\\}" } -if ![gdb_skip_stdio_test "print print_bit_flags_char(*cflags)"] { +if {![gdb_skip_stdio_test "print print_bit_flags_char(*cflags)"]} { print_struct_call "print_bit_flags_char(*cflags)" \ ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+" \ ".\[0-9\]+ = \\{alpha = 1 '\\\\001', beta = 0 '\\\\000', gamma = 1 '\\\\001', delta = 0 '\\\\000', epsilon = 1 '\\\\001', omega = 0 '\\\\000'\\}" } -if ![gdb_skip_stdio_test "print print_bit_flags_short(*sflags)"] { +if {![gdb_skip_stdio_test "print print_bit_flags_short(*sflags)"]} { print_struct_call "print_bit_flags_short(*sflags)" \ ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+" \ ".\[0-9\]+ = \\{alpha = 1, beta = 0, gamma = 1, delta = 0, epsilon = 1, omega = 0\\}" } -if ![gdb_skip_stdio_test "print print_bit_flags(*flags)"] { +if {![gdb_skip_stdio_test "print print_bit_flags(*flags)"]} { print_struct_call "print_bit_flags(*flags)" \ ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+" \ ".\[0-9\]+ = \\{alpha = 1, beta = 0, gamma = 1, delta = 0, epsilon = 1, omega = 0\\}" } -if ![gdb_skip_stdio_test "print print_bit_flags_combo(*flags_combo)"] { +if {![gdb_skip_stdio_test "print print_bit_flags_combo(*flags_combo)"]} { print_struct_call "print_bit_flags_combo(*flags_combo)" \ ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+ch1: y\[ \t\]+ch2: n\[ \r\n\]+" \ ".\[0-9\]+ = \\{alpha = 1, beta = 0, ch1 = 121 'y', gamma = 1, delta = 0, ch2 = 110 'n', epsilon = 1, omega = 0\\}" } -if ![gdb_skip_stdio_test "print print_three_chars(*three_chars)"] { +if {![gdb_skip_stdio_test "print print_three_chars(*three_chars)"]} { print_struct_call "print_three_chars(*three_char)" \ ".*Contents of three_char_t:\[ \r\n\]+x\[ \t\]+y\[ \t\]+z\[ \r\n\]+" \ ".\[0-9\]+ = \\{ch1 = 120 'x', ch2 = 121 'y', ch3 = 122 'z'\\}" } -if ![gdb_skip_stdio_test "print print_five_chars(*five_chars)"] { +if {![gdb_skip_stdio_test "print print_five_chars(*five_chars)"]} { print_struct_call "print_five_chars(*five_char)" \ ".*Contents of five_char_t:\[ \r\n\]+h\[ \t\]+e\[ \t\]+l\[ \t\]+l\[ \t\]+o\[ \r\n\]+" \ ".\[0-9\]+ = \\{ch1 = 104 'h', ch2 = 101 'e', ch3 = 108 'l', ch4 = 108 'l', ch5 = 111 'o'\\}" } -if ![gdb_skip_stdio_test "print print_int_char_combo(*int_char_combo)"] { +if {![gdb_skip_stdio_test "print print_int_char_combo(*int_char_combo)"]} { print_struct_call "print_int_char_combo(*int_char_combo)" \ ".*Contents of int_char_combo_t:\[ \r\n\]+13\[ \t\]+!\[ \r\n\]+" \ ".\[0-9\]+ = \\{int1 = 13, ch1 = 33 '!'\\}" diff --git a/gdb/testsuite/gdb.base/call-sc.c b/gdb/testsuite/gdb.base/call-sc.c index e4fd453..81a25fc 100644 --- a/gdb/testsuite/gdb.base/call-sc.c +++ b/gdb/testsuite/gdb.base/call-sc.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 @@ -39,7 +39,7 @@ T init = '9'; T fun() { - return foo; + return foo; } void Fun(T foo) @@ -69,7 +69,7 @@ int main() zed (); while (1) { - L = fun (); + L = fun (); zed (); } diff --git a/gdb/testsuite/gdb.base/call-sc.exp b/gdb/testsuite/gdb.base/call-sc.exp index 3a83d96..5f7cfe0 100644 --- a/gdb/testsuite/gdb.base/call-sc.exp +++ b/gdb/testsuite/gdb.base/call-sc.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 @@ -46,7 +46,7 @@ proc start_scalars_test { type } { set testfile "call-sc-${type}" set binfile [standard_output_file ${testfile}] - if { [prepare_for_testing "failed to prepare" $binfile $srcfile $flags] } { + if { [prepare_for_testing "failed to prepare" $testfile $srcfile $flags] } { return -1 } @@ -107,7 +107,7 @@ proc test_scalar_calls { } { # Check that GDB can always extract a scalar-return value from an # inferior function call. Since GDB always knows the location of # an inferior function call's return value these should never fail - + # Implemented by calling the parameterless function "fun" and then # examining the return value printed by GDB. @@ -228,18 +228,18 @@ proc test_scalar_returns { } { set test "return foo; synchronize pc to main() for '${testfile}'" for {set loop_count 0} {$loop_count < 2} {incr loop_count} { gdb_test_multiple "backtrace 1" $test { - -re "#0.*main \\(\\).*${gdb_prompt} $" { - pass $test - set loop_count 2 - } - -re "#0.*fun \\(\\).*${gdb_prompt} $" { - if {$loop_count < 1} { - gdb_test "finish" ".*" "" - } else { - fail $test - set loop_count 2 - } - } + -re "#0.*main \\(\\).*${gdb_prompt} $" { + pass $test + set loop_count 2 + } + -re "#0.*fun \\(\\).*${gdb_prompt} $" { + if {$loop_count < 1} { + gdb_test "finish" ".*" "" + } else { + fail $test + set loop_count 2 + } + } } } @@ -250,7 +250,7 @@ proc test_scalar_returns { } { set test "value foo returned; ${tests}" gdb_test_multiple "p/c L" "${test}" { -re " = 49 '1'.*${gdb_prompt} $" { - if $return_value_unknown { + if {$return_value_unknown} { # This contradicts the above claim that GDB didn't # know the location of the return-value. fail "${test}" @@ -259,7 +259,7 @@ proc test_scalar_returns { } { } } -re " = 90 .*${gdb_prompt} $" { - if $return_value_unknown { + if {$return_value_unknown} { # The struct return case. Since any modification # would be by reference, and that can't happen, the # value should be unmodified and hence Z is expected. @@ -272,7 +272,7 @@ proc test_scalar_returns { } { } } -re " = 57 .*${gdb_prompt} $" { - if $return_value_unknown { + if {$return_value_unknown} { # The struct return case. # The return value is stored on the stack, and since GDB # didn't override it, it still has value that was stored @@ -285,7 +285,7 @@ proc test_scalar_returns { } { } } -re ".*${gdb_prompt} $" { - if $return_value_unimplemented { + if {$return_value_unimplemented} { # What a surprise. The architecture hasn't implemented # return_value, and hence has to fail. kfail "$test" gdb/1444 @@ -293,8 +293,8 @@ proc test_scalar_returns { } { fail "$test" } } - } - + } + # Check that a "finish" works. # This is almost but not quite the same as "call struct funcs". @@ -334,7 +334,7 @@ proc test_scalar_returns { } { set test "value foo finished; ${tests}" gdb_test_multiple "p/c" "${test}" { -re " = 49 '1'\[\r\n\]+${gdb_prompt} $" { - if $finish_value_unknown { + if {$finish_value_unknown} { # This contradicts the above claim that GDB didn't # know the location of the return-value. fail "${test}" @@ -344,7 +344,7 @@ proc test_scalar_returns { } { } -re " = 90 'Z'\[\r\n\]+${gdb_prompt} $" { # The value didn't get found. This is "expected". - if $finish_value_unknown { + if {$finish_value_unknown} { pass "${test}" } else { # This contradicts the above claim that GDB did diff --git a/gdb/testsuite/gdb.base/call-signal-resume.exp b/gdb/testsuite/gdb.base/call-signal-resume.exp index a281a63..e30fb42 100644 --- a/gdb/testsuite/gdb.base/call-signal-resume.exp +++ b/gdb/testsuite/gdb.base/call-signal-resume.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -29,9 +29,8 @@ require {!target_info exists gdb,cannot_call_functions} standard_testfile call-signals.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } proc get_dummy_frame_number { } { @@ -45,10 +44,6 @@ proc get_dummy_frame_number { } { return "" } -# Start with a fresh gdb. - -clean_restart ${binfile} - if { ![runto_main] } { return 0 } diff --git a/gdb/testsuite/gdb.base/call-signals.c b/gdb/testsuite/gdb.base/call-signals.c index 071e230..fff2955 100644 --- a/gdb/testsuite/gdb.base/call-signals.c +++ b/gdb/testsuite/gdb.base/call-signals.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/call-strs.c b/gdb/testsuite/gdb.base/call-strs.c index c734936..e086835 100644 --- a/gdb/testsuite/gdb.base/call-strs.c +++ b/gdb/testsuite/gdb.base/call-strs.c @@ -16,7 +16,7 @@ char * str_func1(char *s1) } char * str_func( -char * s1, +char * s1, char * s2, char * s3, char * s4, @@ -57,4 +57,3 @@ int main() str_func1("abcd"); return 0; } - diff --git a/gdb/testsuite/gdb.base/call-strs.exp b/gdb/testsuite/gdb.base/call-strs.exp index f6a9f42..fd24094 100644 --- a/gdb/testsuite/gdb.base/call-strs.exp +++ b/gdb/testsuite/gdb.base/call-strs.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -67,70 +67,70 @@ gdb_test "print s" \ " = \"test string\".*" #print str_func1(s) -if ![gdb_skip_stdio_test "print str_func1(s)"] { +if {![gdb_skip_stdio_test "print str_func1(s)"]} { gdb_test_stdio "print str_func1(s)" \ "first string arg is: test string" \ "\"test string\".*" } #print str_func1("test string") -if ![gdb_skip_stdio_test "print str_func1(teststring)"] { +if {![gdb_skip_stdio_test "print str_func1(teststring)"]} { gdb_test_stdio "print str_func1(\"test string\")" \ "first string arg is: test string" \ "\"test string\".*" } #call str_func1(s) -if ![gdb_skip_stdio_test "call str_func1(s)"] { +if {![gdb_skip_stdio_test "call str_func1(s)"]} { gdb_test_stdio "call str_func1(s)" \ "first string arg is: test string" \ "\"test string\".*" } #call str_func1("test string") -if ![gdb_skip_stdio_test "call str_func1 (...)"] { +if {![gdb_skip_stdio_test "call str_func1 (...)"]} { gdb_test_stdio "call str_func1(\"test string\")" \ "first string arg is: test string" \ "\"test string\".*" } #print str_func1(buf) -if ![gdb_skip_stdio_test "print str_func1(buf)"] { +if {![gdb_skip_stdio_test "print str_func1(buf)"]} { gdb_test_stdio "print str_func1(buf)" \ "first string arg is: test string" \ "\"test string\".*" } #call str_func1(buf) -if ![gdb_skip_stdio_test "call str_func1(buf)"] { +if {![gdb_skip_stdio_test "call str_func1(buf)"]} { gdb_test_stdio "call str_func1(buf)" \ "first string arg is: test string" \ "\"test string\".*" } #print str_func("a","b","c","d","e","f","g") -if ![gdb_skip_stdio_test "print str_func(a,b,c,d,e,f,g)"] { +if {![gdb_skip_stdio_test "print str_func(a,b,c,d,e,f,g)"]} { gdb_test_stdio "print str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \ "first string arg is: a\[ \t\r\n\]+second string arg is: b\[ \t\r\n\]+third string arg is: c\[ \t\r\n\]+fourth string arg is: d\[ \t\r\n\]+fifth string arg is: e\[ \t\r\n\]+sixth string arg is: f\[ \t\r\n\]+seventh string arg is: g\[ \t\r\n\]+" \ "= \"abcdefg\".*" } #call str_func("a","b","c","d","e","f","g") -if ![gdb_skip_stdio_test "call str_func(a,b,c,d,e,f,g)"] { +if {![gdb_skip_stdio_test "call str_func(a,b,c,d,e,f,g)"]} { gdb_test_stdio "call str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \ "first string arg is: a\[ \t\r\n\]+second string arg is: b\[ \t\r\n\]+third string arg is: c\[ \t\r\n\]+fourth string arg is: d\[ \t\r\n\]+fifth string arg is: e\[ \t\r\n\]+sixth string arg is: f\[ \t\r\n\]+seventh string arg is: g\[ \t\r\n\]+" \ "= \"abcdefg\".*" } #print str_func(s,s,s,s,s,s,s) -if ![gdb_skip_stdio_test "print str_func(s,s,s,s,s,s,s,s)"] { +if {![gdb_skip_stdio_test "print str_func(s,s,s,s,s,s,s,s)"]} { gdb_test_stdio "print str_func(s,s,s,s,s,s,s)" \ "first string arg is: test string\[ \t\r\n\]+second string arg is: test string\[ \t\r\n\]+third string arg is: test string\[ \t\r\n\]+fourth string arg is: test string\[ \t\r\n\]+fifth string arg is: test string\[ \t\r\n\]+sixth string arg is: test string\[ \t\r\n\]+seventh string arg is: test string\[ \t\r\n\]+" \ "\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*" } #call str_func(s,s,s,s,s,s,s) -if ![gdb_skip_stdio_test "call str_func(s,s,s,s,s,s,s,s)"] { +if {![gdb_skip_stdio_test "call str_func(s,s,s,s,s,s,s,s)"]} { gdb_test_stdio "call str_func(s,s,s,s,s,s,s)" \ "first string arg is: test string\[ \t\r\n\]+second string arg is: test string\[ \t\r\n\]+third string arg is: test string\[ \t\r\n\]+fourth string arg is: test string\[ \t\r\n\]+fifth string arg is: test string\[ \t\r\n\]+sixth string arg is: test string\[ \t\r\n\]+seventh string arg is: test string\[ \t\r\n\]+" \ "\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*" @@ -139,4 +139,3 @@ if ![gdb_skip_stdio_test "call str_func(s,s,s,s,s,s,s,s)"] { gdb_exit set timeout $prev_timeout - diff --git a/gdb/testsuite/gdb.base/callexit.c b/gdb/testsuite/gdb.base/callexit.c index b1b7cd1..aecff4d 100644 --- a/gdb/testsuite/gdb.base/callexit.c +++ b/gdb/testsuite/gdb.base/callexit.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/callexit.exp b/gdb/testsuite/gdb.base/callexit.exp index f2b0838..0652bd0 100644 --- a/gdb/testsuite/gdb.base/callexit.exp +++ b/gdb/testsuite/gdb.base/callexit.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -13,21 +13,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. - -standard_testfile .c - -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 -} - # Some targets can't do function calls, so don't even bother with this # test. require {!target_info exists gdb,cannot_call_functions} -# Start with a fresh gdb. +standard_testfile .c -clean_restart ${binfile} +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return +} if { ![runto_main] } { return 0 diff --git a/gdb/testsuite/gdb.base/callfuncs.c b/gdb/testsuite/gdb.base/callfuncs.c index bb30c51..c69472e 100644 --- a/gdb/testsuite/gdb.base/callfuncs.c +++ b/gdb/testsuite/gdb.base/callfuncs.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1993-2024 Free Software Foundation, Inc. + Copyright 1993-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 @@ -266,7 +266,7 @@ cmp10 (i0, i1, i2, i3, i4, i5, i6, i7, i8, i9) (i5 == 5) && (i6 == 6) && (i7 == 7) && (i8 == 8) && (i9 == 9); } -/* Functions that expect specific values to be passed and return +/* Functions that expect specific values to be passed and return either 0 or 1, depending upon whether the values were passed incorrectly or correctly, respectively. */ @@ -335,7 +335,7 @@ long long_arg1, long_arg2; There must be one version of "t_float_values" (this one) that is not prototyped, and one (if supported) that is (following). That way GDB can be tested against both cases. */ - + int t_float_values (float_arg1, float_arg2) float float_arg1, float_arg2; { @@ -609,7 +609,7 @@ int (*func_arg2) PARAMS ((int)); #endif { return ((*func_arg1) (5,5) == (*func_val1) (5,5) - && (*func_arg2) (6) == (*func_val2) (6)); + && (*func_arg2) (6) == (*func_val2) (6)); } #ifdef PROTOTYPES diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp index 494b6df..3097c3a 100644 --- a/gdb/testsuite/gdb.base/callfuncs.exp +++ b/gdb/testsuite/gdb.base/callfuncs.exp @@ -1,4 +1,4 @@ -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -18,10 +18,20 @@ standard_testfile +set compile_flags {} +lappend compile_flags debug + # We still want to test non-prototype functions for now, which is why # we disable compilers warning about them. -set compile_flags {debug additional_flags=-Wno-deprecated-non-prototype} -if [support_complex_tests] { +lappend compile_flags additional_flags=-Wno-deprecated-non-prototype + +if {[have_compile_flag -std=c99]} { + # Gcc 15 defaults to c23, which no longer supports unprototyped functions. + # Use a c dialect that does support this. + lappend compile_flags additional_flags=-std=c99 +} + +if {[support_complex_tests]} { lappend compile_flags "additional_flags=-DTEST_COMPLEX" } @@ -132,7 +142,7 @@ proc do_function_calls {prototypes} { gdb_test "p t_int_double(99, 99.0)" " = 1" } - if [support_complex_tests] { + if {[support_complex_tests]} { gdb_test "p t_float_complex_values(fc1, fc2)" " = 1" gdb_test "p t_float_complex_values(fc3, fc4)" " = 0" @@ -221,7 +231,7 @@ proc do_function_calls {prototypes} { "call inferior func with struct - returns double" } - if [support_complex_tests] { + if {[support_complex_tests]} { gdb_test "p t_structs_fc(struct_val1)" ".*= 3 \\+ 3i" \ "call inferior func with struct - returns float _Complex" @@ -234,7 +244,7 @@ proc do_function_calls {prototypes} { } gdb_test "p t_structs_a(struct_val1)" "= (.unsigned char .. )?<.*buf.*> \"foo\"" \ - "call inferior func with struct - returns char *" + "call inferior func with struct - returns char *" # Restore default value. gdb_test_no_output "set unwind-on-signal off" @@ -257,7 +267,7 @@ proc fetch_all_registers {test} { exp_continue } -re "^bspstore\[ \t\]+\[^\r\n\]+\r\n" { - if [istarget "ia64-*-*"] { + if {[istarget "ia64-*-*"]} { # Filter out bspstore which is specially tied to bsp, # giving spurious differences. } else { @@ -266,7 +276,7 @@ proc fetch_all_registers {test} { exp_continue } -re "^pstate\[ \t\]+\[^\r\n\]+\r\n" { - if [istarget "sparc64-*-linux-gnu"] { + if {[istarget "sparc64-*-linux-gnu"]} { # Filter out the pstate register, since in sparc64 # targets the Linux kernel disables pstate.PEF when # returning from traps, giving spurious differences. @@ -276,7 +286,7 @@ proc fetch_all_registers {test} { exp_continue } -re "^last_break\[ \t\]+\[^\r\n\]+\r\n" { - if [istarget "s390*-*-*"] { + if {[istarget "s390*-*-*"]} { # Filter out last_break which is read-only, # giving spurious differences. } else { @@ -285,7 +295,7 @@ proc fetch_all_registers {test} { exp_continue } -re "^\(?:cycle\|instret\)\[ \t\]+\[^\r\n\]+\r\n" { - if [istarget "riscv*-*-*"] { + if {[istarget "riscv*-*-*"]} { # Filter out the cycle counter and instructions # retired counter CSRs which are read-only, giving # spurious differences. @@ -386,9 +396,9 @@ proc perform_all_tests {prototypes} { "The program being debugged stopped while.*" \ "stop at breakpoint in call dummy function" gdb_test "continue" "Continuing.*" "continue from call dummy breakpoint" - if ![gdb_test "bt 2" \ - "#0 main.*" \ - "bt after continuing from call dummy breakpoint"] then { + if {![gdb_test "bt 2" \ + "#0 main.*" \ + "bt after continuing from call dummy breakpoint"]} then { set new_reg_content [fetch_all_registers \ "register contents after stop in call dummy"] if {$old_reg_content == $new_reg_content} { @@ -412,9 +422,9 @@ proc perform_all_tests {prototypes} { gdb_test "finish" \ "Value returned is .* = 9" \ "finish from call dummy breakpoint returns correct value" - if ![gdb_test "bt 2" \ - "#0 main.*" \ - "bt after finishing from call dummy breakpoint"] then { + if {![gdb_test "bt 2" \ + "#0 main.*" \ + "bt after finishing from call dummy breakpoint"]} then { set new_reg_content [fetch_all_registers \ "register contents after finish in call dummy"] if {$old_reg_content == $new_reg_content} { @@ -435,11 +445,11 @@ proc perform_all_tests {prototypes} { # with a value, make sure we are back at main with the same register contents. gdb_test "print add(4,5)" "The program being debugged stopped while.*" \ "call function causing a breakpoint and then do a return" - if ![gdb_test "return 7" \ - "#0 main.*" \ - "back at main after return from call dummy breakpoint" \ - "Make add return now. .y or n.*" \ - "y"] then { + if {![gdb_test "return 7" \ + "#0 main.*" \ + "back at main after return from call dummy breakpoint" \ + "Make add return now. .y or n.*" \ + "y"]} then { set new_reg_content [fetch_all_registers \ "register contents after return in call dummy"] if {$old_reg_content == $new_reg_content} { @@ -541,8 +551,9 @@ if { ![prepare_for_testing "failed to prepare" $testfile $srcfile "$compile_flag perform_all_tests 1 } -if { ![prepare_for_testing "failed to prepare" $testfile $srcfile "$compile_flags additional_flags=-DNO_PROTOTYPES"] } { - with_test_prefix "noproto" { +with_test_prefix "noproto" { + if { ![prepare_for_testing "failed to prepare" $testfile $srcfile \ + "$compile_flags additional_flags=-DNO_PROTOTYPES"] } { perform_all_tests 0 } } diff --git a/gdb/testsuite/gdb.base/cast-call.c b/gdb/testsuite/gdb.base/cast-call.c index 41040ab..aeb3a61 100644 --- a/gdb/testsuite/gdb.base/cast-call.c +++ b/gdb/testsuite/gdb.base/cast-call.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/cast-call.exp b/gdb/testsuite/gdb.base/cast-call.exp index ab12334..5ecf1c9 100644 --- a/gdb/testsuite/gdb.base/cast-call.exp +++ b/gdb/testsuite/gdb.base/cast-call.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/cast-indirection.c b/gdb/testsuite/gdb.base/cast-indirection.c index d59c66e..5b90a49 100644 --- a/gdb/testsuite/gdb.base/cast-indirection.c +++ b/gdb/testsuite/gdb.base/cast-indirection.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/cast-indirection.exp b/gdb/testsuite/gdb.base/cast-indirection.exp index 7b9b5a5..198b0aa 100644 --- a/gdb/testsuite/gdb.base/cast-indirection.exp +++ b/gdb/testsuite/gdb.base/cast-indirection.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2024 Free Software Foundation, Inc. +# Copyright (C) 2024-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 @@ -22,7 +22,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/catch-follow-exec.c b/gdb/testsuite/gdb.base/catch-follow-exec.c index 094423b..55d2c61 100644 --- a/gdb/testsuite/gdb.base/catch-follow-exec.c +++ b/gdb/testsuite/gdb.base/catch-follow-exec.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/catch-follow-exec.exp b/gdb/testsuite/gdb.base/catch-follow-exec.exp index 911f0e3..1f5f865 100644 --- a/gdb/testsuite/gdb.base/catch-follow-exec.exp +++ b/gdb/testsuite/gdb.base/catch-follow-exec.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/catch-fork-kill.c b/gdb/testsuite/gdb.base/catch-fork-kill.c index 2ccea32..5dc0d56 100644 --- a/gdb/testsuite/gdb.base/catch-fork-kill.c +++ b/gdb/testsuite/gdb.base/catch-fork-kill.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/catch-fork-kill.exp b/gdb/testsuite/gdb.base/catch-fork-kill.exp index 086be29..e851d66 100644 --- a/gdb/testsuite/gdb.base/catch-fork-kill.exp +++ b/gdb/testsuite/gdb.base/catch-fork-kill.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 @@ -32,6 +32,8 @@ standard_testfile +require allow_fork_tests + # Build two programs -- one for fork, and another for vfork. set testfile_fork "${testfile}-fork" set testfile_vfork "${testfile}-vfork" @@ -57,7 +59,7 @@ proc do_test {fork_kind exit_kind} { with_test_prefix "$fork_kind" { clean_restart $testfile - if ![runto_main] { + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/catch-fork-static.exp b/gdb/testsuite/gdb.base/catch-fork-static.exp index 5c9d18f..9d50d5d 100644 --- a/gdb/testsuite/gdb.base/catch-fork-static.exp +++ b/gdb/testsuite/gdb.base/catch-fork-static.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2024 Free Software Foundation, Inc. +# Copyright (C) 2015-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 @@ -21,9 +21,7 @@ # ld.so probes before reaching main, and ptrace flags were set then. But a # static executable would just keep running and never catch the fork. -# Until "catch fork" is implemented on other targets... -# -require {is_any_target "*-*-linux*" "*-*-openbsd*"} +require allow_fork_tests # Reusing foll-fork.c since it's a simple forking program. standard_testfile foll-fork.c diff --git a/gdb/testsuite/gdb.base/catch-gdb-caused-signals.c b/gdb/testsuite/gdb.base/catch-gdb-caused-signals.c index 7993a40..324510c 100644 --- a/gdb/testsuite/gdb.base/catch-gdb-caused-signals.c +++ b/gdb/testsuite/gdb.base/catch-gdb-caused-signals.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/catch-gdb-caused-signals.exp b/gdb/testsuite/gdb.base/catch-gdb-caused-signals.exp index 08cee51..862cae4 100644 --- a/gdb/testsuite/gdb.base/catch-gdb-caused-signals.exp +++ b/gdb/testsuite/gdb.base/catch-gdb-caused-signals.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -36,7 +36,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } @@ -47,7 +47,7 @@ gdb_test "handle SIGILL nostop noprint" \ gdb_test "print return_one()" " = 1" -if ![target_info exists gdb,noinferiorio] { +if {![target_info exists gdb,noinferiorio]} { # Clean up the breakpoint state. delete_breakpoints diff --git a/gdb/testsuite/gdb.base/catch-load-so.c b/gdb/testsuite/gdb.base/catch-load-so.c index 29d77e0..d3c3ef2 100644 --- a/gdb/testsuite/gdb.base/catch-load-so.c +++ b/gdb/testsuite/gdb.base/catch-load-so.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/catch-load.c b/gdb/testsuite/gdb.base/catch-load.c index 21e0cb9..175084a 100644 --- a/gdb/testsuite/gdb.base/catch-load.c +++ b/gdb/testsuite/gdb.base/catch-load.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/catch-load.exp b/gdb/testsuite/gdb.base/catch-load.exp index 11ab49a..ee1ae89 100644 --- a/gdb/testsuite/gdb.base/catch-load.exp +++ b/gdb/testsuite/gdb.base/catch-load.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/catch-signal-fork.c b/gdb/testsuite/gdb.base/catch-signal-fork.c index 54cd695..2d365d8 100644 --- a/gdb/testsuite/gdb.base/catch-signal-fork.c +++ b/gdb/testsuite/gdb.base/catch-signal-fork.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 @@ -57,4 +57,3 @@ main () raise (SIGHUP); /* third HUP */ } - diff --git a/gdb/testsuite/gdb.base/catch-signal-fork.exp b/gdb/testsuite/gdb.base/catch-signal-fork.exp index 2e065df..2a33ee1 100644 --- a/gdb/testsuite/gdb.base/catch-signal-fork.exp +++ b/gdb/testsuite/gdb.base/catch-signal-fork.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -14,6 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. require {!target_info exists gdb,nosignals} +require allow_fork_tests standard_testfile diff --git a/gdb/testsuite/gdb.base/catch-signal-siginfo-cond.c b/gdb/testsuite/gdb.base/catch-signal-siginfo-cond.c index c65fb23..f3d1d1e 100644 --- a/gdb/testsuite/gdb.base/catch-signal-siginfo-cond.c +++ b/gdb/testsuite/gdb.base/catch-signal-siginfo-cond.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/catch-signal-siginfo-cond.exp b/gdb/testsuite/gdb.base/catch-signal-siginfo-cond.exp index 4598622..dd47b55 100644 --- a/gdb/testsuite/gdb.base/catch-signal-siginfo-cond.exp +++ b/gdb/testsuite/gdb.base/catch-signal-siginfo-cond.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/catch-signal.c b/gdb/testsuite/gdb.base/catch-signal.c index 85a9109..6eb0d87 100644 --- a/gdb/testsuite/gdb.base/catch-signal.c +++ b/gdb/testsuite/gdb.base/catch-signal.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 @@ -47,4 +47,3 @@ main () return 0; } - diff --git a/gdb/testsuite/gdb.base/catch-signal.exp b/gdb/testsuite/gdb.base/catch-signal.exp index 6e15da0..665058d 100644 --- a/gdb/testsuite/gdb.base/catch-signal.exp +++ b/gdb/testsuite/gdb.base/catch-signal.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -137,10 +137,10 @@ foreach {arg desc} {"" "standard signals" \ "1st line of save breakpoints for '$arg'" # Check the second line. gdb_assert {[string match "break main" [lindex $data 1]]} \ - "2nd line of save breakpoints for '$arg'" + "2nd line of save breakpoints for '$arg'" # Check the trailing newline. gdb_assert {[string match "" [lindex $data 2]]} \ - "Trailing newline of save breakpoints for '$arg'" + "Trailing newline of save breakpoints for '$arg'" incr i } diff --git a/gdb/testsuite/gdb.base/catch-syscall.c b/gdb/testsuite/gdb.base/catch-syscall.c index 070c012..d554da9 100644 --- a/gdb/testsuite/gdb.base/catch-syscall.c +++ b/gdb/testsuite/gdb.base/catch-syscall.c @@ -1,5 +1,5 @@ /* This file is used to test the 'catch syscall' feature on GDB. - + Please, if you are going to edit this file DO NOT change the syscalls being called (nor the order of them). If you really must do this, then take a look at catch-syscall.exp and modify there too. diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp index 2e20b8f..e01cda5 100644 --- a/gdb/testsuite/gdb.base/catch-syscall.exp +++ b/gdb/testsuite/gdb.base/catch-syscall.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -348,7 +348,7 @@ proc test_catch_syscall_execve {} { # Check for entry/return across the execve, making sure that the # syscall_state isn't lost when turning into a new process. insert_catch_syscall_with_arg "execve" - if [check_continue "execve"] { + if {[check_continue "execve"]} { # The check_continue test generates an XFAIL on Powerpc. In # that case, gdb is already at main so don't do the continue. @@ -588,7 +588,7 @@ proc test_catch_syscall_multi_arch_1 { } proc test_catch_syscall_multi_arch {} { - global binfile + global testfile set arch1 "i386" set arch2 "i386:x86-64" @@ -630,7 +630,7 @@ proc test_catch_syscall_multi_arch {} { test_catch_syscall_multi_arch_1 $arch1 $arch2 $syscall1_name \ $syscall2_name $syscall_number - clean_restart $binfile + clean_restart $testfile } proc do_syscall_tests_without_xml {} { @@ -801,18 +801,18 @@ fill_all_syscalls_numbers # Execute the tests, using XML support gdb_exit if { [allow_xml_test] } { - clean_restart $binfile + clean_restart $testfile do_syscall_tests # Now, we have to see if GDB displays a warning when we # don't set the data-directory but try to use catch syscall # anyway. For that, we must restart GDB first. - clean_restart $binfile + clean_restart $testfile test_catch_syscall_fail_nodatadir } # Restart gdb -clean_restart $binfile +clean_restart $testfile # Execute the tests, without XML support. In this case, GDB will # only display syscall numbers, and not syscall names. diff --git a/gdb/testsuite/gdb.base/charset-malloc.c b/gdb/testsuite/gdb.base/charset-malloc.c index 2c614ba..3009b90 100644 --- a/gdb/testsuite/gdb.base/charset-malloc.c +++ b/gdb/testsuite/gdb.base/charset-malloc.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-2025 Free Software Foundation, Inc. Contributed by Red Hat, originally written by Jim Blandy. diff --git a/gdb/testsuite/gdb.base/charset.c b/gdb/testsuite/gdb.base/charset.c index 444f9cc..9b99431 100644 --- a/gdb/testsuite/gdb.base/charset.c +++ b/gdb/testsuite/gdb.base/charset.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2001-2024 Free Software Foundation, Inc. + Copyright 2001-2025 Free Software Foundation, Inc. Contributed by Red Hat, originally written by Jim Blandy. @@ -142,30 +142,30 @@ int main () /* Initialize ascii_string. */ init_string (ascii_string, - 120, - 7, 8, 12, - 10, 13, 9, - 11, 120, 17); + 120, + 7, 8, 12, + 10, 13, 9, + 11, 120, 17); fill_run (ascii_string, 7, 26, 65); fill_run (ascii_string, 33, 26, 97); fill_run (ascii_string, 59, 10, 48); /* Initialize iso_8859_1_string. */ init_string (iso_8859_1_string, - 120, - 7, 8, 12, - 10, 13, 9, - 11, 162, 17); + 120, + 7, 8, 12, + 10, 13, 9, + 11, 162, 17); fill_run (iso_8859_1_string, 7, 26, 65); fill_run (iso_8859_1_string, 33, 26, 97); fill_run (iso_8859_1_string, 59, 10, 48); /* Initialize ebcdic_us_string. */ init_string (ebcdic_us_string, - 167, - 47, 22, 12, - 37, 13, 5, - 11, 74, 17); + 167, + 47, 22, 12, + 37, 13, 5, + 11, 74, 17); /* In EBCDIC, the upper-case letters are broken into three separate runs. */ fill_run (ebcdic_us_string, 7, 9, 193); fill_run (ebcdic_us_string, 16, 9, 209); @@ -179,10 +179,10 @@ int main () /* Initialize ibm1047_string. */ init_string (ibm1047_string, - 167, - 47, 22, 12, - 37, 13, 5, - 11, 74, 17); + 167, + 47, 22, 12, + 37, 13, 5, + 11, 74, 17); /* In IBM1047, the upper-case letters are broken into three separate runs. */ fill_run (ibm1047_string, 7, 9, 193); fill_run (ibm1047_string, 16, 9, 209); diff --git a/gdb/testsuite/gdb.base/charset.exp b/gdb/testsuite/gdb.base/charset.exp index 0d39d04..e2b543e 100644 --- a/gdb/testsuite/gdb.base/charset.exp +++ b/gdb/testsuite/gdb.base/charset.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2001-2024 Free Software Foundation, Inc. +# Copyright 2001-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 @@ -33,28 +33,28 @@ proc parse_show_charset_output {testname} { global gdb_prompt gdb_expect { - -re "The host character set is \"(.*)\"\\.\[\r\n\]+The target character set is \"(.*)\"\\.\[\r\n\]+The target wide character set is \"(.*)\"\\.\[\r\n\]+$gdb_prompt $" { - set host_charset $expect_out(1,string) - set target_charset $expect_out(2,string) + -re "The host character set is \"(.*)\"\\.\[\r\n\]+The target character set is \"(.*)\"\\.\[\r\n\]+The target wide character set is \"(.*)\"\\.\[\r\n\]+$gdb_prompt $" { + set host_charset $expect_out(1,string) + set target_charset $expect_out(2,string) set retlist [list $host_charset $target_charset] - pass $testname - } - -re "The host character set is \"(.*)\"\\.\[\r\n\]+$gdb_prompt $" { - set host_charset $expect_out(1,string) + pass $testname + } + -re "The host character set is \"(.*)\"\\.\[\r\n\]+$gdb_prompt $" { + set host_charset $expect_out(1,string) set retlist [list $host_charset] - pass $testname - } - -re "The target character set is \"(.*)\"\\.\[\r\n\]+$gdb_prompt $" { - set target_charset $expect_out(1,string) + pass $testname + } + -re "The target character set is \"(.*)\"\\.\[\r\n\]+$gdb_prompt $" { + set target_charset $expect_out(1,string) set retlist [list $target_charset] - pass $testname - } - -re ".*$gdb_prompt $" { - fail $testname - } - timeout { - fail "$testname (timeout)" - } + pass $testname + } + -re ".*$gdb_prompt $" { + fail $testname + } + timeout { + fail "$testname (timeout)" + } } return $retlist @@ -104,13 +104,13 @@ gdb_test_multiple $cmd "try malformed `set charset'" { # Try using `set host-charset' on an invalid character set. gdb_test "set host-charset my_grandma_bonnie" \ - "Undefined item: \"my_grandma_bonnie\"." \ - "try `set host-charset' with invalid charset" + "Undefined item: \"my_grandma_bonnie\"." \ + "try `set host-charset' with invalid charset" # Try using `set target-charset' on an invalid character set. gdb_test "set target-charset my_grandma_bonnie" \ - "Undefined item: \"my_grandma_bonnie\"." \ - "try `set target-charset' with invalid charset" + "Undefined item: \"my_grandma_bonnie\"." \ + "try `set target-charset' with invalid charset" # A Tcl array mapping the names of all the character sets we've seen # to "1" if the character set can be used as a host character set, or @@ -189,140 +189,140 @@ set charset_subset {ASCII ISO-8859-1 EBCDIC-US IBM1047} foreach_with_prefix host_charset $charset_subset { if {[valid_host_charset $host_charset]} { - set testname "try `set host-charset $host_charset'" - send_gdb "set host-charset $host_charset\n" - gdb_expect { - -re "GDB doesn't know of any character set named.*\[\r\n]+${gdb_prompt} $" { - # How did it get into `charsets' then? - fail "$testname (didn't recognize name)" - } - -re "GDB can't use `.*' as its host character set\\.\[\r\n]+${gdb_prompt} $" { - # Well, then why does its `charsets' entry say it can? - fail $testname - } - -re "${gdb_prompt} $" { - pass $testname - } - timeout { - fail "$testname (timeout)" - } - } - - # Check that the command actually had its intended effect: - # $host_charset should now be the host character set. - send_gdb "show charset\n" - set result [parse_show_charset_output "parse `show charset' after `set host-charset $host_charset'"] - if {! [string compare [lindex $result 0] $host_charset]} { - pass "check effect of `set host-charset $host_charset'" - } else { - fail "check effect of `set host-charset $host_charset'" - } - - # Now try setting every possible target character set, - # given that host charset. - foreach target_charset $charset_subset { + set testname "try `set host-charset $host_charset'" + send_gdb "set host-charset $host_charset\n" + gdb_expect { + -re "GDB doesn't know of any character set named.*\[\r\n]+${gdb_prompt} $" { + # How did it get into `charsets' then? + fail "$testname (didn't recognize name)" + } + -re "GDB can't use `.*' as its host character set\\.\[\r\n]+${gdb_prompt} $" { + # Well, then why does its `charsets' entry say it can? + fail $testname + } + -re "${gdb_prompt} $" { + pass $testname + } + timeout { + fail "$testname (timeout)" + } + } + + # Check that the command actually had its intended effect: + # $host_charset should now be the host character set. + send_gdb "show charset\n" + set result [parse_show_charset_output "parse `show charset' after `set host-charset $host_charset'"] + if {! [string compare [lindex $result 0] $host_charset]} { + pass "check effect of `set host-charset $host_charset'" + } else { + fail "check effect of `set host-charset $host_charset'" + } + + # Now try setting every possible target character set, + # given that host charset. + foreach target_charset $charset_subset { if {![valid_target_charset $target_charset]} { continue } - set testname "try `set target-charset $target_charset'" - send_gdb "set target-charset $target_charset\n" - gdb_expect { - -re "GDB doesn't know of any character set named.*\[\r\n]+${gdb_prompt} $" { - fail "$testname (didn't recognize name)" - } - -re "GDB can't convert from the .* character set to .*\\.\[\r\n\]+${gdb_prompt} $" { - # This is a serious problem. GDB should be able to convert - # between any arbitrary pair of character sets. - fail "$testname (can't convert)" - } - -re "${gdb_prompt} $" { - pass $testname - } - timeout { - fail "$testname (timeout)" - } - } - - # Check that the command actually had its intended effect: - # $target_charset should now be the target charset. - send_gdb "show charset\n" - set result [parse_show_charset_output "parse `show charset' after `set target-charset $target_charset'"] - if {! [string compare $result [list $host_charset $target_charset]]} { - pass "check effect of `set target-charset $target_charset'" - } else { - fail "check effect of `set target-charset $target_charset'" - } - - # Test handling of characters in the host charset which - # can't be translated into the target charset. \xA2 is - # `cent' in ISO-8859-1, which has no equivalent in ASCII. - # - # On some systems, the pseudo-tty through which we - # communicate with GDB insists on stripping the high bit - # from input characters, meaning that `cent' turns into - # `"'. Since ISO-8859-1 and ASCII are identical in the - # lower 128 characters, it's tough to see how we can test - # this behavior on such systems, so we just xfail it. + set testname "try `set target-charset $target_charset'" + send_gdb "set target-charset $target_charset\n" + gdb_expect { + -re "GDB doesn't know of any character set named.*\[\r\n]+${gdb_prompt} $" { + fail "$testname (didn't recognize name)" + } + -re "GDB can't convert from the .* character set to .*\\.\[\r\n\]+${gdb_prompt} $" { + # This is a serious problem. GDB should be able to convert + # between any arbitrary pair of character sets. + fail "$testname (can't convert)" + } + -re "${gdb_prompt} $" { + pass $testname + } + timeout { + fail "$testname (timeout)" + } + } + + # Check that the command actually had its intended effect: + # $target_charset should now be the target charset. + send_gdb "show charset\n" + set result [parse_show_charset_output "parse `show charset' after `set target-charset $target_charset'"] + if {! [string compare $result [list $host_charset $target_charset]]} { + pass "check effect of `set target-charset $target_charset'" + } else { + fail "check effect of `set target-charset $target_charset'" + } + + # Test handling of characters in the host charset which + # can't be translated into the target charset. \xA2 is + # `cent' in ISO-8859-1, which has no equivalent in ASCII. + # + # On some systems, the pseudo-tty through which we + # communicate with GDB insists on stripping the high bit + # from input characters, meaning that `cent' turns into + # `"'. Since ISO-8859-1 and ASCII are identical in the + # lower 128 characters, it's tough to see how we can test + # this behavior on such systems, so we just xfail it. # # Note: the \x16 (Control-V) is an escape to allow \xA2 to # get past readline. - if {! [string compare $host_charset iso-8859-1] && ! [string compare $target_charset ascii]} { - - set testname "untranslatable character in character literal" - send_gdb "print '\x16\xA2'\n" - gdb_expect { - -re "There is no character corresponding to .* in the target character set .*\\.\[\r\n\]+$gdb_prompt $" { - pass $testname - } - -re " = 34 '\"'\[\r\n\]+$gdb_prompt $" { - xfail "$testname (DejaGNU's pseudo-tty strips eighth bit)" - } - -re "$gdb_prompt $" { - fail $testname - } - timeout { - fail "$testname (timeout)" - } - } - - set testname "untranslatable character in string literal" - # If the PTTY zeros bit seven, then this turns into - # print """ - # which gets us a syntax error. We don't care. - send_gdb "print \"\x16\xA2\"\n" - gdb_expect { - -re "There is no character corresponding to .* in the target character set .*\\.\[\r\n\]+$gdb_prompt $" { - pass $testname - } - -re "Unterminated string in expression.\[\r\n\]+$gdb_prompt $" { - xfail "$testname (DejaGNU's pseudo-tty strips eighth bit)" - } - -re "$gdb_prompt $" { - fail $testname - } - timeout { - fail "$testname (timeout)" - } - } - - set testname "untranslatable characters in backslash escape" - send_gdb "print '\\\x16\xA2'\n" - gdb_expect { - -re "The escape sequence .* is equivalent to plain .*, which has no equivalent\[\r\n\]+in the .* character set\\.\[\r\n\]+$gdb_prompt $" { - pass $testname - } - -re " = 34 '\"'\[\r\n\]+$gdb_prompt $" { - xfail "$testname (DejaGNU's pseudo-tty strips eighth bit)" - } - -re "$gdb_prompt $" { - fail $testname - } - timeout { - fail "$testname (timeout)" - } - } - } - } + if {! [string compare $host_charset iso-8859-1] && ! [string compare $target_charset ascii]} { + + set testname "untranslatable character in character literal" + send_gdb "print '\x16\xA2'\n" + gdb_expect { + -re "There is no character corresponding to .* in the target character set .*\\.\[\r\n\]+$gdb_prompt $" { + pass $testname + } + -re " = 34 '\"'\[\r\n\]+$gdb_prompt $" { + xfail "$testname (DejaGNU's pseudo-tty strips eighth bit)" + } + -re "$gdb_prompt $" { + fail $testname + } + timeout { + fail "$testname (timeout)" + } + } + + set testname "untranslatable character in string literal" + # If the PTTY zeros bit seven, then this turns into + # print """ + # which gets us a syntax error. We don't care. + send_gdb "print \"\x16\xA2\"\n" + gdb_expect { + -re "There is no character corresponding to .* in the target character set .*\\.\[\r\n\]+$gdb_prompt $" { + pass $testname + } + -re "Unterminated string in expression.\[\r\n\]+$gdb_prompt $" { + xfail "$testname (DejaGNU's pseudo-tty strips eighth bit)" + } + -re "$gdb_prompt $" { + fail $testname + } + timeout { + fail "$testname (timeout)" + } + } + + set testname "untranslatable characters in backslash escape" + send_gdb "print '\\\x16\xA2'\n" + gdb_expect { + -re "The escape sequence .* is equivalent to plain .*, which has no equivalent\[\r\n\]+in the .* character set\\.\[\r\n\]+$gdb_prompt $" { + pass $testname + } + -re " = 34 '\"'\[\r\n\]+$gdb_prompt $" { + xfail "$testname (DejaGNU's pseudo-tty strips eighth bit)" + } + -re "$gdb_prompt $" { + fail $testname + } + timeout { + fail "$testname (timeout)" + } + } + } + } } } @@ -332,8 +332,8 @@ foreach_with_prefix host_charset $charset_subset { # test program to the point at which the strings have been # initialized. gdb_test "break ${srcfile}:[gdb_get_line_number "all strings initialized"]" \ - ".*Breakpoint.* at .*" \ - "set breakpoint after all strings have been initialized" + ".*Breakpoint.* at .*" \ + "set breakpoint after all strings have been initialized" gdb_run_cmd gdb_test "" "Breakpoint.*all strings initialized.*" "run until all strings have been initialized" @@ -368,15 +368,15 @@ foreach target_charset $charset_subset { # gdb_test that requires us to use gdb_expect here. send_gdb "print $L'\\0'\n" gdb_expect { - -re "\\\$${decimal} = 0 $L'\\\\000'\[\r\n\]+$gdb_prompt $" { - pass "print the null character in ${target_charset}" - } - -re "$gdb_prompt $" { - fail "print the null character in ${target_charset}" - } - timeout { - fail "print the null character in ${target_charset} (timeout)" - } + -re "\\\$${decimal} = 0 $L'\\\\000'\[\r\n\]+$gdb_prompt $" { + pass "print the null character in ${target_charset}" + } + -re "$gdb_prompt $" { + fail "print the null character in ${target_charset}" + } + timeout { + fail "print the null character in ${target_charset} (timeout)" + } } # Compute the name of the variable in the test program that holds @@ -391,7 +391,7 @@ foreach target_charset $charset_subset { set var_name [string tolower "${target_charset}_string"] regsub -all -- "\[^a-z0-9_\]" $var_name "_" var_name } - + # Compute a regexp matching the results we expect. This is static, # but it's easier than writing it out. regsub -all "." "abfnrtv" "(\\\\&|x)" escapes @@ -403,101 +403,101 @@ foreach target_charset $charset_subset { send_gdb "print $var_name\n" # ${escapes}${uppercase}${lowercase}${digits}${octal}${octal} gdb_expect { - -re ".* = $L\"(\\\\a|x)(\\\\b|x)(\\\\f|x)(\\\\n|x)(\\\\r|x)(\\\\t|x)(\\\\v|x)${uppercase}${lowercase}${digits}(${octal_escape}|x)+\"\[\r\n\]+$gdb_prompt $" { - pass "print string in $target_charset" - } - -re "$gdb_prompt $" { - fail "print string in $target_charset" - } - timeout { - fail "print string in $target_charset (timeout)" - } + -re ".* = $L\"(\\\\a|x)(\\\\b|x)(\\\\f|x)(\\\\n|x)(\\\\r|x)(\\\\t|x)(\\\\v|x)${uppercase}${lowercase}${digits}(${octal_escape}|x)+\"\[\r\n\]+$gdb_prompt $" { + pass "print string in $target_charset" + } + -re "$gdb_prompt $" { + fail "print string in $target_charset" + } + timeout { + fail "print string in $target_charset (timeout)" + } } # Try entering a character literal, and see if it comes back unchanged. gdb_test "print $L'A'" \ - " = \[0-9-\]+ $L'A'" \ - "parse character literal in ${target_charset}" + " = \[0-9-\]+ $L'A'" \ + "parse character literal in ${target_charset}" # Check that the character literal was encoded correctly. gdb_test "print /d $L'A' == $var_name\[7\]" \ - " = 1" \ - "check value of parsed character literal in ${target_charset}" + " = 1" \ + "check value of parsed character literal in ${target_charset}" # Try entering a string literal, and see if it comes back unchanged. gdb_test "print $L\"abcdefABCDEF012345\"" \ - " = $L\"abcdefABCDEF012345\"" \ - "parse string literal in ${target_charset}" + " = $L\"abcdefABCDEF012345\"" \ + "parse string literal in ${target_charset}" # Check that the string literal was encoded correctly. gdb_test "print /d $L\"q\"\[0\] == $var_name\[49\]" \ - " = 1" \ - "check value of parsed string literal in ${target_charset}" + " = 1" \ + "check value of parsed string literal in ${target_charset}" # Test handling of characters in the target charset which # can't be translated into the host charset. if {! [string compare $target_charset iso-8859-1]} { - gdb_test "print iso_8859_1_string\[69\]" \ - " = \[0-9-\]+ '\\\\242'" \ - "print character with no equivalent in host character set" - gdb_test "print iso_8859_1_string + 70" \ - " = ${hex} \"\\\\242.*\"" \ - "print string with no equivalent in host character set" + gdb_test "print iso_8859_1_string\[69\]" \ + " = \[0-9-\]+ '\\\\242'" \ + "print character with no equivalent in host character set" + gdb_test "print iso_8859_1_string + 70" \ + " = ${hex} \"\\\\242.*\"" \ + "print string with no equivalent in host character set" } # Make sure that we don't apply the ISO-8859-1 `print_literally' # function to ASCII. if {! [string compare $target_charset ascii]} { - gdb_test "print iso_8859_1_string\[69\]" \ - " = \[0-9-\]+ '\\\\242'" \ - "print ASCII unprintable character" - gdb_test "print iso_8859_1_string + 70" \ - " = ${hex} \"\\\\242.*\"" \ - "print ASCII unprintable string" + gdb_test "print iso_8859_1_string\[69\]" \ + " = \[0-9-\]+ '\\\\242'" \ + "print ASCII unprintable character" + gdb_test "print iso_8859_1_string + 70" \ + " = ${hex} \"\\\\242.*\"" \ + "print ASCII unprintable string" } # Try printing characters with backslash escape equivalents. set escapees {a b f n r t v} for {set i 0} {$i < [llength $escapees]} {incr i} { - set escape [lindex $escapees $i] - send_gdb "print $var_name\[$i\]\n" - set have_escape 1 - gdb_expect { - -re "= \[0-9-\]+ $L'\\\\${escape}'\[\r\n\]+$gdb_prompt $" { - pass "try printing '\\${escape}' in ${target_charset}" - } - -re "= \[0-9-\]+ 'x'\[\r\n\]+$gdb_prompt $" { - xfail "try printing '\\${escape}' in ${target_charset} (no such escape)" - set have_escape 0 - } - -re "$gdb_prompt $" { - fail "try printing '\\${escape}' in ${target_charset}" - } - timeout { - fail "try printing '\\${escape}' in ${target_charset} (timeout)" - } - } - - if {$have_escape} { - - # Try parsing a backslash escape in a character literal. - gdb_test "print /d $L'\\${escape}' == $var_name\[$i\]" \ - " = 1" \ - "check value of '\\${escape}' in ${target_charset}" - - # Try parsing a backslash escape in a string literal. - gdb_test "print /d $L\"\\${escape}\"\[0\] == $var_name\[$i\]" \ - " = 1" \ - "check value of \"\\${escape}\" in ${target_charset}" - } + set escape [lindex $escapees $i] + send_gdb "print $var_name\[$i\]\n" + set have_escape 1 + gdb_expect { + -re "= \[0-9-\]+ $L'\\\\${escape}'\[\r\n\]+$gdb_prompt $" { + pass "try printing '\\${escape}' in ${target_charset}" + } + -re "= \[0-9-\]+ 'x'\[\r\n\]+$gdb_prompt $" { + xfail "try printing '\\${escape}' in ${target_charset} (no such escape)" + set have_escape 0 + } + -re "$gdb_prompt $" { + fail "try printing '\\${escape}' in ${target_charset}" + } + timeout { + fail "try printing '\\${escape}' in ${target_charset} (timeout)" + } + } + + if {$have_escape} { + + # Try parsing a backslash escape in a character literal. + gdb_test "print /d $L'\\${escape}' == $var_name\[$i\]" \ + " = 1" \ + "check value of '\\${escape}' in ${target_charset}" + + # Try parsing a backslash escape in a string literal. + gdb_test "print /d $L\"\\${escape}\"\[0\] == $var_name\[$i\]" \ + " = 1" \ + "check value of \"\\${escape}\" in ${target_charset}" + } } - # Try printing a character escape that doesn't exist. We should + # Try printing a character escape that doesn't exist. We should # get the unescaped character, in the target character set. gdb_test "print $L'\\q'" " = \[0-9-\]+ $L'q'" \ - "print escape that doesn't exist in $target_charset" + "print escape that doesn't exist in $target_charset" gdb_test "print /d $L'\\q' == $var_name\[49\]" " = 1" \ - "check value of escape that doesn't exist in $target_charset" + "check value of escape that doesn't exist in $target_charset" } # Reset the target charset. @@ -549,7 +549,7 @@ if {$wchar_ok} { set ucs2_ok [expr {[get_sizeof char16_t 99] == 2}] -if ![valid_host_charset "UTF-16"] { +if {![valid_host_charset "UTF-16"]} { verbose -log "Disabling UTF-16 tests." set ucs2_ok 0 } @@ -640,4 +640,4 @@ foreach name {short int long} { } -gdb_exit +gdb_exit diff --git a/gdb/testsuite/gdb.base/check-psymtab.c b/gdb/testsuite/gdb.base/check-psymtab.c index 2e251e2..8772187 100644 --- a/gdb/testsuite/gdb.base/check-psymtab.c +++ b/gdb/testsuite/gdb.base/check-psymtab.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/check-psymtab.exp b/gdb/testsuite/gdb.base/check-psymtab.exp index 43e232c..1dfbd7d 100644 --- a/gdb/testsuite/gdb.base/check-psymtab.exp +++ b/gdb/testsuite/gdb.base/check-psymtab.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/checkpoint-ns.exp b/gdb/testsuite/gdb.base/checkpoint-ns.exp index 1cc130f..5d31799 100644 --- a/gdb/testsuite/gdb.base/checkpoint-ns.exp +++ b/gdb/testsuite/gdb.base/checkpoint-ns.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/checkpoint.c b/gdb/testsuite/gdb.base/checkpoint.c index 0e01e2b..ec1d05a 100644 --- a/gdb/testsuite/gdb.base/checkpoint.c +++ b/gdb/testsuite/gdb.base/checkpoint.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2005-2024 Free Software Foundation, Inc. + Copyright 2005-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 diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp index 68bddd8..779b88e 100644 --- a/gdb/testsuite/gdb.base/checkpoint.exp +++ b/gdb/testsuite/gdb.base/checkpoint.exp @@ -1,4 +1,4 @@ -# Copyright 2005-2024 Free Software Foundation, Inc. +# Copyright 2005-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 @@ -290,7 +290,7 @@ gdb_test "restart 10" "has no checkpoints" "no more checkpoint 10" # Now let's try setting a large number of checkpoints (>600) # -clean_restart $binfile +clean_restart $testfile runto_main gdb_breakpoint $break1_loc @@ -356,7 +356,7 @@ gdb_test "kill" "" "kill all one with many checkpoints" \ # with_test_prefix "delete checkpoint 0" { - clean_restart $binfile + clean_restart $testfile runto_main gdb_test "checkpoint" "Checkpoint 1: fork returned pid $decimal\\." diff --git a/gdb/testsuite/gdb.base/chng-syms.c b/gdb/testsuite/gdb.base/chng-syms.c index 3394f5c..f08294c 100644 --- a/gdb/testsuite/gdb.base/chng-syms.c +++ b/gdb/testsuite/gdb.base/chng-syms.c @@ -1,6 +1,6 @@ /* - * Test that GDB cleans up properly after errors that result when a - * breakpoint is reset. + * Test that GDB cleans up properly after errors that result when a + * breakpoint is reset. */ /* VARIABLE is a macro defined on the compiler command line. */ @@ -19,4 +19,3 @@ int main () stop_here (); exit (0); } - diff --git a/gdb/testsuite/gdb.base/chng-syms.exp b/gdb/testsuite/gdb.base/chng-syms.exp index 7f5490f..d8d52a5 100644 --- a/gdb/testsuite/gdb.base/chng-syms.exp +++ b/gdb/testsuite/gdb.base/chng-syms.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 @@ -15,14 +15,14 @@ # Author: Paul N. Hilfinger (Hilfinger@gnat.com) -# Test that GDB cleans up properly after errors that result when a -# breakpoint is reset. +# Test that GDB cleans up properly after errors that result when a +# breakpoint is reset. standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var1}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile \ + {debug additional_flags=-DVARIABLE=var1}] != 0 } { + return } set oldtimeout $timeout @@ -36,29 +36,27 @@ proc expect_to_stop_here { ident } { gdb_test "" "Breakpoint \[0-9\]*, stop_here .*" "running to stop_here $ident" } -clean_restart ${binfile} - gdb_test "break stop_here if (var1 == 42)" \ "Breakpoint.*at.* file .*$srcfile, line.*" \ "setting conditional breakpoint on function" gdb_run_cmd expect_to_stop_here "first time" - + gdb_continue_to_end "breakpoint first time through" # Now we recompile the executable, but without a variable named "var1", first # waiting to insure that even on fast machines, the file modification times -# are distinct. This will force GDB to reload the file on the -# next "run" command, causing an error when GDB tries to tries to reset +# are distinct. This will force GDB to reload the file on the +# next "run" command, causing an error when GDB tries to tries to reset # the breakpoint. sleep 2 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var2}] != "" } { -# Complication: Since GDB generally holds an open file descriptor on the -# executable at this point, there are some systems in which the -# re-compilation will fail. In such cases, we'll consider the test +# Complication: Since GDB generally holds an open file descriptor on the +# executable at this point, there are some systems in which the +# re-compilation will fail. In such cases, we'll consider the test # (vacuously) passed providing that re-running it succeeds as before. gdb_run_cmd diff --git a/gdb/testsuite/gdb.base/clear_non_user_bp.exp b/gdb/testsuite/gdb.base/clear_non_user_bp.exp index d1d9bd7..ce2098a 100644 --- a/gdb/testsuite/gdb.base/clear_non_user_bp.exp +++ b/gdb/testsuite/gdb.base/clear_non_user_bp.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -37,17 +37,13 @@ proc get_first_maint_bp_num { } { return "" } -standard_testfile .c - # This testcase just needs a "Hello world" source file, reuse # gdb.base/main.c instead of adding a new one. -if { [gdb_compile "${srcdir}/${subdir}/main.c" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 -} +standard_testfile main.c -# Start with a fresh gdb. -clean_restart ${binfile} +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return +} if {![runto_main]} { return 0 @@ -68,4 +64,3 @@ gdb_test "clear *$bp_addr" \ gdb_test "maint info break $bp_num" \ "$bp_num.*$bp_addr.*" \ "maint info breakpoint \$bp_num after clear" - diff --git a/gdb/testsuite/gdb.base/cli-suppress-notification.c b/gdb/testsuite/gdb.base/cli-suppress-notification.c index b364109..12fe04c 100644 --- a/gdb/testsuite/gdb.base/cli-suppress-notification.c +++ b/gdb/testsuite/gdb.base/cli-suppress-notification.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 @@ -15,12 +15,85 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -static int global = 0; +#include <stdlib.h> +#include <pthread.h> +#include <unistd.h> +#include <assert.h> + +/* Used for thread synchronisation. */ + +pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t g_cond = PTHREAD_COND_INITIALIZER; + +/* This is set by GDB. */ + +volatile int wait_for_gdb = 1; + +/* This is used to create some work for GDB to step through. */ + +volatile int global_var = 0; + +/* A simple thread worker function. */ + +void* +worker_thread_func (void *arg) +{ + int res; + + /* Grab the mutex. This completes once the main thread is waiting. */ + res = pthread_mutex_lock (&g_mutex); + assert (res == 0); + + /* Wake the main thread, letting it know that we are here. At this + point the main thread is still blocked as we hold G_MUTEX. */ + res = pthread_cond_signal (&g_cond); + + /* Now we wait. This releases G_MUTEX and allows the main thread to + continue. */ + res = pthread_cond_wait (&g_cond, &g_mutex); + assert (res == 0); + + /* Unlock the mutex. We're all done now. */ + res = pthread_mutex_unlock (&g_mutex); + assert (res == 0); + + return NULL; +} int -main () +main (void) { - global++; - global++; + pthread_t thr; + int res; + + /* Lock G_MUTEX before creating the worker thread. */ + pthread_mutex_lock (&g_mutex); + + res = pthread_create (&thr, NULL, worker_thread_func, NULL); + assert (res == 0); + + /* Release G_MUTEX and wait for the worker thread. */ + res = pthread_cond_wait (&g_cond, &g_mutex); + assert (res == 0); + + global_var++; /* Break here. */ + global_var++; /* Second. */ + global_var++; /* Third. */ + + while (wait_for_gdb) + sleep(1); + + /* Notify the worker thread, it will exit once G_MUTEX is released. */ + pthread_cond_signal (&g_cond); + pthread_mutex_unlock (&g_mutex); + + /* Wait for the worker to actually exit. */ + res = pthread_join (thr, NULL); + assert (res == 0); + + /* Clean up the mutex and condition variable. */ + pthread_mutex_destroy (&g_mutex); + pthread_cond_destroy (&g_cond); + return 0; } diff --git a/gdb/testsuite/gdb.base/cli-suppress-notification.exp b/gdb/testsuite/gdb.base/cli-suppress-notification.exp index 1b06ec4..003f7d2 100644 --- a/gdb/testsuite/gdb.base/cli-suppress-notification.exp +++ b/gdb/testsuite/gdb.base/cli-suppress-notification.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -17,7 +17,8 @@ standard_testfile -if {[prepare_for_testing "failed to prepare" ${binfile} ${srcfile}]} { +if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ + {debug pthreads}] } { return } @@ -25,15 +26,53 @@ if {![runto_main]} { return } -gdb_test "inferior 1" ".*Switching to inferior 1 .* to thread 1 .*" \ - "inferior switch is not suppressed" +delete_breakpoints + +gdb_breakpoint [gdb_get_line_number "Break here"] +gdb_continue_to_breakpoint "threads created" + +if {![use_gdb_stub]} { + gdb_test "add-inferior -exec $binfile" ".*" \ + "add a second inferior" + + gdb_test "inferior 2" ".*Switching to inferior 2 .*" \ + "inferior switch is not suppressed" + gdb_test "info breakpoints" + gdb_test "info inferiors" + gdb_test "info connections" + gdb_run_cmd + gdb_test_multiple "" "stop at breakpoint in inferior 2" { + -wrap -re "Breakpoint ${::decimal}(?:\\.${::decimal})?, main .*" { + pass $gdb_test_name + } + } +} gdb_test_no_output "set suppress-cli-notifications on" -gdb_test_no_output "inferior 1" "inferior switch is suppressed" +if {![use_gdb_stub]} { + gdb_test_no_output "inferior 1" \ + "inferior switch is suppressed when changing inferior" +} +gdb_test_no_output "inferior 1" \ + "inferior switch is suppressed when same inferior selected" gdb_test_no_output "next" "stepping is suppressed" +gdb_test_no_output "thread 2" "switch to a new thread" +gdb_test_no_output "thread 2" "switch to the same thread" # Now check that suppression can be turned back off. gdb_test_no_output "set suppress-cli-notifications off" -gdb_test "inferior 1" ".*Switching to inferior 1 .* to thread 1 .*" \ - "inferior switch is not suppressed again" -gdb_test "next" "return 0;" "stepping is not suppressed" +gdb_test "thread 1" \ + [multi_line \ + "\\\[Switching to thread 1\[^\r\n\]*\\\]" \ + "#0\\s+main\[^\r\n\]+" \ + "\[^\r\n\]+Second\\. \\*/"] +gdb_test_no_output "set wait_for_gdb = 0" \ + "set wait_for_gdb in first inferior" + +if {![use_gdb_stub]} { + gdb_test "inferior 2" ".*Switching to inferior 2 .* to thread 2\\.1 .*" \ + "inferior switch is not suppressed again" + gdb_test "next" ".*Second.*" "stepping is not suppressed" + gdb_test_no_output "set wait_for_gdb = 0" \ + "set wait_for_gdb in second inferior" +} diff --git a/gdb/testsuite/gdb.base/code-expr.exp b/gdb/testsuite/gdb.base/code-expr.exp index 33bac17..119f1d9 100644 --- a/gdb/testsuite/gdb.base/code-expr.exp +++ b/gdb/testsuite/gdb.base/code-expr.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024 Free Software Foundation, Inc. +# Copyright (C) 2001-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 @@ -24,13 +24,10 @@ standard_testfile cvexpr.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart ${binfile} - gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set print address off" gdb_test_no_output "set width 0" @@ -274,7 +271,7 @@ gdb_test "whatis (enum misordered @data) v_misordered" \ "type = @data enum misordered" \ "(enum misordered @data)" -# +# # Pointers # @@ -374,4 +371,3 @@ gdb_test "whatis (union t_union @code * @code) &v_union" \ # # Function pointers TODO # - diff --git a/gdb/testsuite/gdb.base/code_elim.exp b/gdb/testsuite/gdb.base/code_elim.exp index 8ead31d..0270bc9 100644 --- a/gdb/testsuite/gdb.base/code_elim.exp +++ b/gdb/testsuite/gdb.base/code_elim.exp @@ -1,4 +1,4 @@ -# Copyright 2002-2024 Free Software Foundation, Inc. +# Copyright 2002-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 diff --git a/gdb/testsuite/gdb.base/code_elim1.c b/gdb/testsuite/gdb.base/code_elim1.c index f51af97..5a3cce2 100644 --- a/gdb/testsuite/gdb.base/code_elim1.c +++ b/gdb/testsuite/gdb.base/code_elim1.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/code_elim2.c b/gdb/testsuite/gdb.base/code_elim2.c index 0b719b4..a01aac3 100644 --- a/gdb/testsuite/gdb.base/code_elim2.c +++ b/gdb/testsuite/gdb.base/code_elim2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/color-prompt.exp b/gdb/testsuite/gdb.base/color-prompt.exp new file mode 100644 index 0000000..c037185 --- /dev/null +++ b/gdb/testsuite/gdb.base/color-prompt.exp @@ -0,0 +1,29 @@ +# 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/>. + +# Check using a prompt with color in CLI. + +# Using tuiterm requires setting TERM on host. +require {!is_remote host} + +# We use a tuiterm, which allows us to determine cursor position. +tuiterm_env +Term::clean_restart 8 80 + +# We start with an empty screen, to generate a visible prompt. +Term::gen_prompt + +set tui 0 +source $srcdir/$subdir/../gdb.tui/color-prompt.exp.tcl diff --git a/gdb/testsuite/gdb.base/command-line-input.exp b/gdb/testsuite/gdb.base/command-line-input.exp index 86870bf..9760f1a 100644 --- a/gdb/testsuite/gdb.base/command-line-input.exp +++ b/gdb/testsuite/gdb.base/command-line-input.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2024 Free Software Foundation, Inc. +# Copyright (C) 2016-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 @@ -18,19 +18,59 @@ # Test issuing a command split in multiple lines with continuation # characters. -gdb_exit -gdb_start +clean_restart -set test "print 1\\\\n + 2" -gdb_test_multiple "print 1\\\n + 2" $test { - -re "^print 1\\\\\r\n \\+ 2\r\n\\\$$decimal = 3\r\n$gdb_prompt $" { - pass $test +set bs "\\" +set re_bs [string_to_regexp $bs] +set re_dollar [string_to_regexp $] + +set re \ + [multi_line \ + ^[string_to_regexp "print 1$bs"] \ + [string_to_regexp " + 2"] \ + "$re_dollar$decimal = 3" \ + "$gdb_prompt $"] +gdb_test_multiple "print 1$bs\n + 2" "print 1$bs${bs}n + 2" { + -re $re { + pass $gdb_test_name + } +} + +set re \ + [multi_line \ + ^[string_to_regexp "print 1$bs"] \ + "2" \ + "$re_dollar$decimal = 12" \ + "$gdb_prompt $"] +gdb_test_multiple "print 1$bs\n2" "print 1$bs${bs}n2" { + -re $re { + pass $gdb_test_name } } -set test "print 1\\\\n2" -gdb_test_multiple "print 1\\\n2" $test { - -re "^print 1\\\\\r\n2\r\n\\\$$decimal = 12\r\n$gdb_prompt $" { - pass $test +with_test_prefix "cancel multiline" { + send_gdb "print$bs\n 1" + gdb_test_multiple "" "setup" { + -re "print$re_bs\r\n 1" { + pass $gdb_test_name + } + } + + send_gdb "\003" + gdb_test_multiple "" "cancel" { + -re -wrap "" { + pass $gdb_test_name + } + } + + # Regression test for PR cli/33063. + gdb_test_multiple "print 2" "command after cancel" { + -re -wrap " = 2" { + pass $gdb_test_name + } + -re -wrap "" { + # Avoid undefined command error. + fail $gdb_test_name + } } } diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp index 6aee034..047dab3 100644 --- a/gdb/testsuite/gdb.base/commands.exp +++ b/gdb/testsuite/gdb.base/commands.exp @@ -1,4 +1,4 @@ -# Copyright 1988-2024 Free Software Foundation, Inc. +# Copyright 1988-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 @@ -255,7 +255,7 @@ proc_with_prefix infrun_breakpoint_command_test {} { delete_breakpoints gdb_test "break factorial if value == 5" "Breakpoint.*at.*" -# infrun_breakpoint_command_test - This test was broken into two parts +# infrun_breakpoint_command_test - This test was broken into two parts # to get around a synchronization problem in expect. # part1: issue the gdb command "commands" # part2: send the list of commands @@ -547,7 +547,7 @@ proc_with_prefix user_defined_command_manyargs_test {} { set expected "nargs=$nargs:" for {set i 1} {$i <= $nargs} {incr i} { - append expected " " [expr 2 * $i] + append expected " " [expr {2 * $i}] } gdb_test $cmd $expected "execute command" @@ -580,10 +580,10 @@ proc_with_prefix watchpoint_command_test {} { set wp_id -1 gdb_test_multiple "watch local_var" "watch local_var" { - -re "\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $" { - set wp_id $expect_out(1,string) - pass "watch local_var" - } + -re "\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $" { + set wp_id $expect_out(1,string) + pass "watch local_var" + } } if {$wp_id == -1} {return} @@ -658,7 +658,7 @@ proc_with_prefix test_command_prompt_position {} { gdb_test_multiple "printf \"Now the value is %d\\n\", value" $test { -re "^printf.*value\r\n>$" { gdb_test_multiple "end" $test { - -re "^end\r\n$gdb_prompt $" { + -re "^end\r\n$gdb_prompt $" { pass $test } } @@ -672,7 +672,7 @@ proc_with_prefix test_command_prompt_position {} { proc_with_prefix deprecated_command_test {} { gdb_test "maintenance deprecate blah" "Can't find command.*" \ - "tried to deprecate non-existing command" + "tried to deprecate non-existing command" gdb_test_no_output "maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /1/" gdb_test "p 5" \ @@ -681,7 +681,7 @@ proc_with_prefix deprecated_command_test {} { gdb_test "p 5" ".\[0-9\]* = 5.*" "deprecated warning goes away /1/" gdb_test_no_output "maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /2/" - gdb_test_no_output "maintenance deprecate print \"new_print\"" + gdb_test_no_output "maintenance deprecate print \"new_print\"" gdb_test "p 5" \ "Warning: command 'print' \\(p\\) is deprecated.*Use 'new_print'.*" \ "both alias and command are deprecated" @@ -750,31 +750,31 @@ proc_with_prefix bp_deleted_in_command_test {} { # Create a breakpoint, and associate a command-list to it, with # one command that deletes this breakpoint. gdb_test "break factorial" \ - "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\." - + "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\." + gdb_test_multiple "commands" "begin commands" { -re "Type commands for breakpoint.*>$" { - pass "begin commands" + pass "begin commands" } } gdb_test_multiple "silent" "add silent command" { - -re ">$" { + -re ">$" { pass "add silent command" } } gdb_test_multiple "clear factorial" "add clear command" { - -re ">$" { + -re ">$" { pass "add clear command" } } gdb_test_multiple "printf \"factorial command-list executed\\n\"" \ "add printf command" { - -re ">$" { + -re ">$" { pass "add printf command" } } gdb_test_multiple "cont" "add cont command" { - -re ">$" { + -re ">$" { pass "add cont command" } } diff --git a/gdb/testsuite/gdb.base/compare-sections.c b/gdb/testsuite/gdb.base/compare-sections.c index 40acd93..40222d3 100644 --- a/gdb/testsuite/gdb.base/compare-sections.c +++ b/gdb/testsuite/gdb.base/compare-sections.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/compare-sections.exp b/gdb/testsuite/gdb.base/compare-sections.exp index cf43602..b95149e 100644 --- a/gdb/testsuite/gdb.base/compare-sections.exp +++ b/gdb/testsuite/gdb.base/compare-sections.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -136,7 +136,7 @@ with_test_prefix "read-only" { } # Come up with different value. - set patch [expr 255 - $orig] + set patch [expr {255 - $orig}] # Write PATCH to memory. set written -1 diff --git a/gdb/testsuite/gdb.base/complete-empty.exp b/gdb/testsuite/gdb.base/complete-empty.exp index 2689068..5e87431 100644 --- a/gdb/testsuite/gdb.base/complete-empty.exp +++ b/gdb/testsuite/gdb.base/complete-empty.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp index 571d714..67906f1 100644 --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -20,7 +20,7 @@ # # tests for command completion # -# Here are some useful test cases for completion. +# Here are some useful test cases for completion. # They should be tested with both M-? and TAB. # # "show output-" "radix" @@ -210,7 +210,7 @@ gdb_test_multiple "" "$test" { -re "Default output radix for printing of values is 10\\..*$gdb_prompt $" { pass "$test" } - } + } } } @@ -223,7 +223,7 @@ gdb_test_multiple "" "$test" { -re "The history is empty\\..*$gdb_prompt $" { pass "$test" } - } + } } } @@ -514,12 +514,12 @@ set test "complete 'p no_var_named_this-arg'" send_gdb "p no_var_named_this-arg\t" gdb_test_multiple "" "$test" { -re "^p no_var_named_this-arg\\\x07$" { - send_gdb "\n" + send_gdb "\n" gdb_test_multiple "" "$test" { - -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { + -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { pass "$test" - } - } + } + } } } @@ -556,7 +556,7 @@ gdb_test_multiple "" "$test" { } } } - } + } } } @@ -676,12 +676,12 @@ with_cwd $srcdir { } # If the directory name contains a '+' we must escape it, adding a backslash. -# If not, the test below will fail because it will interpret the '+' as a +# If not, the test below will fail because it will interpret the '+' as a # regexp operator. We use string_to_regexp for this purpose. gdb_test "cd ${fullsrcdir}" \ - "Working directory [string_to_regexp ${fullsrcdir}].*" \ - "cd to \${srcdir}" + "Working directory [string_to_regexp ${fullsrcdir}].*" \ + "cd to \${srcdir}" # GDB used to fail adding / on directories, on the first try only. diff --git a/gdb/testsuite/gdb.base/complex-parts.c b/gdb/testsuite/gdb.base/complex-parts.c index 73c2bb3..8dde5aa 100644 --- a/gdb/testsuite/gdb.base/complex-parts.c +++ b/gdb/testsuite/gdb.base/complex-parts.c @@ -1,4 +1,4 @@ -/* Copyright 2019-2024 Free Software Foundation, Inc. +/* Copyright 2019-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/complex-parts.exp b/gdb/testsuite/gdb.base/complex-parts.exp index 40f14f4..5b81966 100644 --- a/gdb/testsuite/gdb.base/complex-parts.exp +++ b/gdb/testsuite/gdb.base/complex-parts.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/complex.c b/gdb/testsuite/gdb.base/complex.c index 4735ff4..2a82902 100644 --- a/gdb/testsuite/gdb.base/complex.c +++ b/gdb/testsuite/gdb.base/complex.c @@ -1,4 +1,4 @@ -/* Copyright 2002-2024 Free Software Foundation, Inc. +/* Copyright 2002-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/complex.exp b/gdb/testsuite/gdb.base/complex.exp index 99842eb..ef17c47 100644 --- a/gdb/testsuite/gdb.base/complex.exp +++ b/gdb/testsuite/gdb.base/complex.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 diff --git a/gdb/testsuite/gdb.base/comprdebug.exp b/gdb/testsuite/gdb.base/comprdebug.exp index c12224e..18f53cf 100644 --- a/gdb/testsuite/gdb.base/comprdebug.exp +++ b/gdb/testsuite/gdb.base/comprdebug.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -25,7 +25,7 @@ if {[gdb_compile $srcdir/$subdir/$srcfile $ofile \ set objcopy_program [gdb_find_objcopy] set cmd "$objcopy_program --compress-debug-sections $ofile" verbose "invoking $cmd" -set result [catch "exec $cmd" output] +set result [catch {exec {*}$cmd} output] verbose "result is $result" verbose "output is $output" @@ -41,4 +41,3 @@ if {[gdb_file_cmd $ofile] == 0} { } else { fail $testname } - diff --git a/gdb/testsuite/gdb.base/cond-eval-mode.c b/gdb/testsuite/gdb.base/cond-eval-mode.c index e958f5e..8fd797e 100644 --- a/gdb/testsuite/gdb.base/cond-eval-mode.c +++ b/gdb/testsuite/gdb.base/cond-eval-mode.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/cond-eval-mode.exp b/gdb/testsuite/gdb.base/cond-eval-mode.exp index 0e98b83..9f49801 100644 --- a/gdb/testsuite/gdb.base/cond-eval-mode.exp +++ b/gdb/testsuite/gdb.base/cond-eval-mode.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -58,7 +58,7 @@ gdb_test_multiple $test_target $test_target { # We now know that the target supports target-side conditional # evaluation. Now make sure we can force-disable the # ConditionalBreakpoints RSP feature. -if [gdb_protocol_is_remote] { +if {[gdb_protocol_is_remote]} { gdb_test \ "set remote conditional-breakpoints-packet off" \ "Support for the 'ConditionalBreakpoints' packet on the current remote target is set to \"off\"." diff --git a/gdb/testsuite/gdb.base/cond-expr.exp b/gdb/testsuite/gdb.base/cond-expr.exp index 67918cf..b605264 100644 --- a/gdb/testsuite/gdb.base/cond-expr.exp +++ b/gdb/testsuite/gdb.base/cond-expr.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -18,7 +18,7 @@ # This file is part of the gdb testsuite # -# test of evaluation of conditional expressions, with constants and +# test of evaluation of conditional expressions, with constants and # variables. Using the print and the whatis command # written with the only purpose in mind to cover the holes in the # eval.c file @@ -33,14 +33,9 @@ standard_testfile int-type.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { - untested "failed to compile" - return -1 - } - - -clean_restart ${binfile} - +if { [prepare_for_testing "prepare" $testfile $srcfile {debug nowarnings}] != 0 } { + return +} if {![runto_main]} { return @@ -66,14 +61,3 @@ gdb_test "print (x ? y : z)" "\[0-9\]* = 3" \ gdb_test "whatis (0 ? 3 : 4)" "type = int" \ "print whatis of cond expr" - - - - - - - - - - - diff --git a/gdb/testsuite/gdb.base/condbreak-bad.c b/gdb/testsuite/gdb.base/condbreak-bad.c index 2ceac89..d13f6f4 100644 --- a/gdb/testsuite/gdb.base/condbreak-bad.c +++ b/gdb/testsuite/gdb.base/condbreak-bad.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/condbreak-bad.exp b/gdb/testsuite/gdb.base/condbreak-bad.exp index 4644ae7..578478d 100644 --- a/gdb/testsuite/gdb.base/condbreak-bad.exp +++ b/gdb/testsuite/gdb.base/condbreak-bad.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -17,7 +17,7 @@ standard_testfile -if {[prepare_for_testing "failed to prepare" ${binfile} ${srcfile}]} { +if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { return } @@ -94,7 +94,7 @@ with_test_prefix "with continue 2" { set bpnum [get_integer_valueof "\$bpnum" 0 "get bpnum"] gdb_test_no_output "cond $bpnum a == 999" - + gdb_test "cond $bpnum gibberish" \ "No symbol \"gibberish\" in current context." \ "attempt a bad condition" diff --git a/gdb/testsuite/gdb.base/condbreak-call-false.c b/gdb/testsuite/gdb.base/condbreak-call-false.c index 431c3a1..0df9e84 100644 --- a/gdb/testsuite/gdb.base/condbreak-call-false.c +++ b/gdb/testsuite/gdb.base/condbreak-call-false.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2024 Free Software Foundation, Inc. +/* Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/condbreak-call-false.exp b/gdb/testsuite/gdb.base/condbreak-call-false.exp index 7b68a52..d46f47f 100644 --- a/gdb/testsuite/gdb.base/condbreak-call-false.exp +++ b/gdb/testsuite/gdb.base/condbreak-call-false.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/condbreak-multi-context.cc b/gdb/testsuite/gdb.base/condbreak-multi-context.cc index a674fd2..fa5966e 100644 --- a/gdb/testsuite/gdb.base/condbreak-multi-context.cc +++ b/gdb/testsuite/gdb.base/condbreak-multi-context.cc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/condbreak-multi-context.exp b/gdb/testsuite/gdb.base/condbreak-multi-context.exp index 024f768..7301c34 100644 --- a/gdb/testsuite/gdb.base/condbreak-multi-context.exp +++ b/gdb/testsuite/gdb.base/condbreak-multi-context.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -51,9 +51,9 @@ set loc_index(C) 0 proc find_location_contexts { } { global loc_name loc_index fill - global decimal hex gdb_prompt binfile + global decimal hex gdb_prompt - clean_restart ${binfile} + clean_restart $::testfile if {![runto_main]} { return @@ -128,9 +128,9 @@ proc check_bp_locations {bpnum states cond {msg ""}} { # starting GDB, but before running to main. proc_with_prefix scenario_1 { start_before } { - global warning decimal fill bkptno_num_re binfile + global warning decimal fill bkptno_num_re - clean_restart ${binfile} + clean_restart $::testfile if { $start_before } { if {![runto_main temporary]} { @@ -240,9 +240,9 @@ proc setup_bps { bpnum1_name bpnum2_name } { # starting GDB, but before running to main. proc_with_prefix scenario_2 { start_before } { - global binfile bkptno_num_re + global bkptno_num_re - clean_restart ${binfile} + clean_restart $::testfile if { $start_before } { if {![runto_main temporary]} { @@ -288,9 +288,9 @@ proc_with_prefix scenario_2 { start_before } { # starting GDB, but before running to main. proc_with_prefix scenario_3 { start_before } { - global binfile bkptno_num_re loc_index warning + global bkptno_num_re loc_index warning - clean_restart ${binfile} + clean_restart $::testfile if { $start_before } { if {![runto_main temporary]} { @@ -365,9 +365,9 @@ proc_with_prefix scenario_3 { start_before } { # bother with a run to main in this case. proc_with_prefix scenario_4 { start_before } { - global binfile bkptno_num_re loc_index warning + global bkptno_num_re loc_index warning - clean_restart ${binfile} + clean_restart $::testfile if { $start_before } { if {![runto_main temporary]} { diff --git a/gdb/testsuite/gdb.base/condbreak.exp b/gdb/testsuite/gdb.base/condbreak.exp index 1f07bb5..6392dbc 100644 --- a/gdb/testsuite/gdb.base/condbreak.exp +++ b/gdb/testsuite/gdb.base/condbreak.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -13,7 +13,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/>. -# This test was written by Rich Title. +# This test was written by Rich Title. # Purpose is to test conditional breakpoints. # Modeled after "break.exp". @@ -42,7 +42,7 @@ gdb_test "break -q main" \ "Breakpoint.*at.* file .*$srcfile, line.*" \ "breakpoint function" -# +# # test conditional break at function # gdb_test "break marker1 if 1==1" \ @@ -58,7 +58,7 @@ gdb_test "break $srcfile:$bp_location1 if 1==1" \ gdb_test_no_output "delete 3" -# +# # test conditional break at function # gdb_test "break marker1 if (1==1)" \ @@ -139,7 +139,7 @@ gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=. # user instruction, GDB's search finds the second line entry, decides # that the PC is indeed at the beginning of a source line, and doesn't # print an address in the breakpoint hit message. -# +# # GCC's Dwarf2 writer, on the other hand, squeezes out duplicate line # entries, so GDB considers the source line to begin at the start of # the function's prologue. Thus, if the program stops at the diff --git a/gdb/testsuite/gdb.base/consecutive-step-over.c b/gdb/testsuite/gdb.base/consecutive-step-over.c index e5dab4a..747b608 100644 --- a/gdb/testsuite/gdb.base/consecutive-step-over.c +++ b/gdb/testsuite/gdb.base/consecutive-step-over.c @@ -1,4 +1,4 @@ -/* Copyright 2014-2024 Free Software Foundation, Inc. +/* Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/consecutive-step-over.exp b/gdb/testsuite/gdb.base/consecutive-step-over.exp index 9da35df..65379cc 100644 --- a/gdb/testsuite/gdb.base/consecutive-step-over.exp +++ b/gdb/testsuite/gdb.base/consecutive-step-over.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -39,7 +39,7 @@ set n_insns 3 # Extract addresses of a few consecutive instructions. set test "get breakpoint addresses" -if { [gdb_test_multiple "x /[expr $n_insns + 1]i \$pc" $test { +if { [gdb_test_multiple "x /[expr {$n_insns + 1}]i \$pc" $test { -re "=> $hex${up_to_nl} ($hex)${up_to_nl} ($hex)${up_to_nl} ($hex)${up_to_nl}$gdb_prompt $" { for {set i 1} {$i <= $n_insns} {incr i} { set bp_addrs($i) $expect_out($i,string) diff --git a/gdb/testsuite/gdb.base/consecutive.c b/gdb/testsuite/gdb.base/consecutive.c index 869a88c..9bb215a 100644 --- a/gdb/testsuite/gdb.base/consecutive.c +++ b/gdb/testsuite/gdb.base/consecutive.c @@ -1,4 +1,4 @@ -/* +/* Purpose of this test: to test breakpoints on consecutive instructions. */ diff --git a/gdb/testsuite/gdb.base/consecutive.exp b/gdb/testsuite/gdb.base/consecutive.exp index 5ea146c..007c6a5 100644 --- a/gdb/testsuite/gdb.base/consecutive.exp +++ b/gdb/testsuite/gdb.base/consecutive.exp @@ -1,4 +1,4 @@ -# Copyright 2001-2024 Free Software Foundation, Inc. +# Copyright 2001-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 @@ -54,7 +54,7 @@ gdb_test "break \*$bp_addr" "Breakpoint $decimal at $bp_addr: file .*" \ gdb_test_multiple "step" "stopped at bp, 2nd instr" { -re -wrap "Breakpoint $decimal, ($hex) in foo.*" { set stop_addr $expect_out(1,string) - if {[eval expr "$bp_addr == $stop_addr"]} { + if {$bp_addr == $stop_addr} { pass "stopped at bp, 2nd instr" } else { fail "stopped at bp, 2nd instr (wrong address)" @@ -65,11 +65,10 @@ gdb_test_multiple "step" "stopped at bp, 2nd instr" { set stop_addr_is_stmt [hex_in_list $stop_addr $is_stmt] if {!$stop_addr_is_stmt} { fail "stopped at bp, 2nd instr (missing hex prefix)" - } elseif {[eval expr "$bp_addr == $stop_addr"]} { + } elseif {$bp_addr == $stop_addr} { pass "stopped at bp, 2nd instr" } else { fail "stopped at bp, 2nd instr (wrong address)" } } } - diff --git a/gdb/testsuite/gdb.base/constvars.c b/gdb/testsuite/gdb.base/constvars.c index 60cca2a..8534913 100644 --- a/gdb/testsuite/gdb.base/constvars.c +++ b/gdb/testsuite/gdb.base/constvars.c @@ -104,7 +104,7 @@ main (void) volatile unsigned long valve = 2000; volatile float vacuity = 3.0; volatile double vertigo = 10.3; - + /* pointers to volatile variables */ volatile char * vampire = &vox; @@ -176,17 +176,17 @@ main (void) const char * const volatile cove = &laconic; const unsigned char * const volatile cavity = &laggard; - + /* const volatile pointers to volatile vars */ volatile char * const volatile vagus = &vox; volatile unsigned char * const volatile vagrancy = &victuals; - + /* const volatile pointers to const volatile */ const volatile char * const volatile vagary = &victor; const volatile unsigned char * const volatile vendor = &vicar; - + /* const volatile arrays */ const volatile char vindictive[2] = {victor, victor}; const volatile unsigned char vegetation[2] = {vicar, vicar}; @@ -206,7 +206,7 @@ main (void) volatile signed char & remuneration = lemonade; */ marker1 (); - + return 0; } diff --git a/gdb/testsuite/gdb.base/constvars.exp b/gdb/testsuite/gdb.base/constvars.exp index 05085b7..3fdadbf 100644 --- a/gdb/testsuite/gdb.base/constvars.exp +++ b/gdb/testsuite/gdb.base/constvars.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -29,14 +29,10 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug ] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart ${binfile} - - # # set it up at a breakpoint so we can play with the variable values # @@ -53,7 +49,7 @@ proc local_compiler_xfail_check { } { if {[test_compiler_info gcc-2-*]} { if { ![test_debug_format "HP"] \ && ![test_debug_format "DWARF \[0-9\]"] } then { - setup_xfail "*-*-*" + setup_xfail "*-*-*" } } } @@ -68,7 +64,7 @@ proc local_compiler_xfail_check_2 { } { } } -gdb_test "break marker1" "Breakpoint $decimal at .*" +gdb_test "break marker1" "Breakpoint $decimal at .*" gdb_test_multiple "cont" "up from marker1" { -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" { diff --git a/gdb/testsuite/gdb.base/continue-after-aborted-step-over.c b/gdb/testsuite/gdb.base/continue-after-aborted-step-over.c index c5b670f..0701df3 100644 --- a/gdb/testsuite/gdb.base/continue-after-aborted-step-over.c +++ b/gdb/testsuite/gdb.base/continue-after-aborted-step-over.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp b/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp index d586135..f736845 100644 --- a/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp +++ b/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -43,14 +43,14 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} { # DISPLACED indicates whether to use displaced-stepping. proc do_test {displaced breakpoint_always_inserted} { global gdb_prompt decimal - global srcfile binfile + global srcfile - clean_restart $binfile + clean_restart $::testfile gdb_test_no_output "set displaced-stepping $displaced" gdb_test_no_output "set breakpoint always-inserted $breakpoint_always_inserted" - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -58,7 +58,7 @@ proc do_test {displaced breakpoint_always_inserted} { # any kind of breakpoint insertion failure. If we can examine # what's at memory address 0, it is possible that we could also # execute it. - if [is_address_zero_readable] { + if {[is_address_zero_readable]} { untested "memory at address 0 is possibly executable" return } diff --git a/gdb/testsuite/gdb.base/continue-all-already-running.c b/gdb/testsuite/gdb.base/continue-all-already-running.c index f6683c0..2f67835 100644 --- a/gdb/testsuite/gdb.base/continue-all-already-running.c +++ b/gdb/testsuite/gdb.base/continue-all-already-running.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/continue-all-already-running.exp b/gdb/testsuite/gdb.base/continue-all-already-running.exp index 993c15c..a3e8c27 100644 --- a/gdb/testsuite/gdb.base/continue-all-already-running.exp +++ b/gdb/testsuite/gdb.base/continue-all-already-running.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2024 Free Software Foundation, Inc. +# Copyright (C) 2014-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 @@ -25,7 +25,7 @@ save_vars { GDBFLAGS } { } } -if ![runto_main] { +if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/coredump-filter-build-id.exp b/gdb/testsuite/gdb.base/coredump-filter-build-id.exp index cddacce..75ba07d 100644 --- a/gdb/testsuite/gdb.base/coredump-filter-build-id.exp +++ b/gdb/testsuite/gdb.base/coredump-filter-build-id.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -28,7 +28,7 @@ if { ![istarget *-*-linux*] } { untested "$testfile.exp" return -1 } -require is_x86_64_m64_target +require is_x86_64_m64_target gcore_cmd_available if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug build-id}] } { return -1 @@ -48,7 +48,7 @@ if { ![gdb_gcore_cmd "$corefilename" "save corefile"] } { # Determine if GDB dumped the mapping containing the build-id. This # is done by invoking an external program (eu-unstrip). -if { [catch "exec [gdb_find_eu-unstrip] -n --core $corefilename" output] == 0 } { +if { [catch {exec [gdb_find_eu-unstrip] -n --core $corefilename} output] == 0 } { set line [lindex [split $output "\n"] 0] set test "gcore dumped mapping with build-id" diff --git a/gdb/testsuite/gdb.base/coredump-filter.c b/gdb/testsuite/gdb.base/coredump-filter.c index e11a706..63a5ca0 100644 --- a/gdb/testsuite/gdb.base/coredump-filter.c +++ b/gdb/testsuite/gdb.base/coredump-filter.c @@ -1,4 +1,4 @@ -/* Copyright 2015-2024 Free Software Foundation, Inc. +/* Copyright 2015-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/coredump-filter.exp b/gdb/testsuite/gdb.base/coredump-filter.exp index 18c3505..008c1f9 100644 --- a/gdb/testsuite/gdb.base/coredump-filter.exp +++ b/gdb/testsuite/gdb.base/coredump-filter.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -39,7 +39,7 @@ proc do_save_core { filter_flag core dump_excluded } { # Enable dumping of excluded mappings (i.e. VM_DONTDUMP). if { $dump_excluded == 1 } { - gdb_test_no_output "set dump-excluded-mappings on" + gdb_test_no_output "set dump-excluded-mappings on" } # Generate a corefile. @@ -47,7 +47,7 @@ proc do_save_core { filter_flag core dump_excluded } { # Restore original status. if { $dump_excluded == 1 } { - gdb_test_no_output "set dump-excluded-mappings off" + gdb_test_no_output "set dump-excluded-mappings off" } } @@ -62,13 +62,13 @@ proc do_load_and_test_core { core var working_var working_value dump_excluded } # Access the memory the addresses point to. if { $dump_excluded == 0 } { - gdb_test "print/x *(char *) $coredump_var_addr($var)" "\(\\\$$decimal = <error: \)?Cannot access memory at address $hex\(>\)?" \ + gdb_test "print/x *(char *) $coredump_var_addr($var)" "\(\\\$$decimal = <error: \)?Cannot access memory at address $hex\(>\)?" \ "printing $var when core is loaded (should not work)" - gdb_test "print/x *(char *) $coredump_var_addr($working_var)" " = $working_value.*" \ + gdb_test "print/x *(char *) $coredump_var_addr($working_var)" " = $working_value.*" \ "print/x *$working_var ( = $working_value)" } else { - # Check if VM_DONTDUMP mappings are present in the core file. - gdb_test "print/x *(char *) $coredump_var_addr($var)" " = $working_value.*" \ + # Check if VM_DONTDUMP mappings are present in the core file. + gdb_test "print/x *(char *) $coredump_var_addr($var)" " = $working_value.*" \ "print/x *$var ( = $working_value)" } } @@ -223,7 +223,7 @@ foreach item $all_anon_corefiles { # Generate corefiles for the "anon" case. foreach item $all_anon_corefiles { with_test_prefix "saving corefile for [lindex $item 0]" { - do_save_core [lindex $item 1] [subst [lindex $item 2]] [lindex $item 6] + do_save_core [lindex $item 1] [subst_vars [lindex $item 2]] [lindex $item 6] } } @@ -235,12 +235,12 @@ clean_restart $testfile foreach item $all_anon_corefiles { with_test_prefix "loading and testing corefile for [lindex $item 0]" { - do_load_and_test_core [subst [lindex $item 2]] [lindex $item 3] \ + do_load_and_test_core [subst_vars [lindex $item 2]] [lindex $item 3] \ [lindex $item 4] [lindex $item 5] [lindex $item 6] } with_test_prefix "disassembling function main for [lindex $item 0]" { - test_disasm [subst [lindex $item 2]] $main_addr 0 + test_disasm [subst_vars [lindex $item 2]] $main_addr 0 } } diff --git a/gdb/testsuite/gdb.base/corefile-buildid-shlib-shr.c b/gdb/testsuite/gdb.base/corefile-buildid-shlib-shr.c index 7c46479..7ab63bd 100644 --- a/gdb/testsuite/gdb.base/corefile-buildid-shlib-shr.c +++ b/gdb/testsuite/gdb.base/corefile-buildid-shlib-shr.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/corefile-buildid-shlib.c b/gdb/testsuite/gdb.base/corefile-buildid-shlib.c index c01f829..e2b3af9 100644 --- a/gdb/testsuite/gdb.base/corefile-buildid-shlib.c +++ b/gdb/testsuite/gdb.base/corefile-buildid-shlib.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2024 Free Software Foundation, Inc. +/* Copyright (C) 2007-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 diff --git a/gdb/testsuite/gdb.base/corefile-buildid.c b/gdb/testsuite/gdb.base/corefile-buildid.c index fe76957..69ccd97 100644 --- a/gdb/testsuite/gdb.base/corefile-buildid.c +++ b/gdb/testsuite/gdb.base/corefile-buildid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2019-2024 Free Software Foundation, Inc. +/* Copyright (C) 2019-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 diff --git a/gdb/testsuite/gdb.base/corefile-buildid.exp b/gdb/testsuite/gdb.base/corefile-buildid.exp index 377ae80..de0b295 100644 --- a/gdb/testsuite/gdb.base/corefile-buildid.exp +++ b/gdb/testsuite/gdb.base/corefile-buildid.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -36,7 +36,7 @@ proc create_core_file { progname } { verbose -log "corefile is $corefile" # Check the corefile has a build-id for the executable. - if { [catch "exec [gdb_find_eu-unstrip] -n --core $corefile" output] == 0 } { + if { [catch {exec [gdb_find_eu-unstrip] -n --core $corefile} output] == 0 } { set line [lindex [split $output "\n"] 0] set binfile_re (?:[string_to_regexp $progname]|\\\[(?:exe|pie)\\\]) if { ![regexp "^${::hex}\\+${::hex} \[a-f0-9\]+@${::hex}.*$binfile_re$" $line] } { diff --git a/gdb/testsuite/gdb.base/corefile-exec-context.c b/gdb/testsuite/gdb.base/corefile-exec-context.c index ed4df60..6f5f29c 100644 --- a/gdb/testsuite/gdb.base/corefile-exec-context.c +++ b/gdb/testsuite/gdb.base/corefile-exec-context.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/corefile-exec-context.exp b/gdb/testsuite/gdb.base/corefile-exec-context.exp index 6bd2b04..08110dd 100644 --- a/gdb/testsuite/gdb.base/corefile-exec-context.exp +++ b/gdb/testsuite/gdb.base/corefile-exec-context.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 @@ -32,7 +32,7 @@ if {[build_executable $testfile.exp $testfile $srcfile] == -1} { # length then lets try to make it longer. set binfile_len [string length $binfile] if { $binfile_len <= 80 } { - set extra_len [expr 80 - $binfile_len + 1] + set extra_len [expr {80 - $binfile_len + 1}] set extra_str [string repeat "x" $extra_len] set new_binfile $binfile$extra_str remote_exec build "mv $binfile $new_binfile" @@ -51,7 +51,7 @@ remote_exec build "mv $corefile $corefile_1" # Load the core file and confirm that the full executable name is # seen. -clean_restart $binfile +clean_restart $testfile set saw_generated_line false gdb_test_multiple "core-file $corefile_1" "load core file no args" { -re "^Core was generated by `[string_to_regexp $binfile]'\\.\r\n" { @@ -80,7 +80,7 @@ remote_exec build "mv $corefile $corefile_2" # Load the core file and confirm that the full executable name and # argument list are seen. -clean_restart $binfile +clean_restart $testfile set saw_generated_line false gdb_test_multiple "core-file $corefile_2" "load core file with args" { -re "^Core was generated by `[string_to_regexp $binfile] $args'\\.\r\n" { @@ -155,7 +155,7 @@ remote_exec build "mv $corefile $corefile_3" # Restart, load the core file, and check the environment variable # shows up. -clean_restart $binfile +clean_restart $testfile # Check for environment variable VAR_NAME in the environment, its # value should be VAR_VALUE. diff --git a/gdb/testsuite/gdb.base/corefile-exec-mismatch.c b/gdb/testsuite/gdb.base/corefile-exec-mismatch.c new file mode 100644 index 0000000..a52b2a3 --- /dev/null +++ b/gdb/testsuite/gdb.base/corefile-exec-mismatch.c @@ -0,0 +1,36 @@ +/* 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/>. */ + +#include <stdlib.h> + +#ifdef GEN_CORE +static int +crashfunc (void) +{ + abort (); + return 0; +} +#endif + +int +main (void) +{ +#ifdef GEN_CORE + int ret = crashfunc (); +#else + int ret = 0; +#endif + return ret; +} diff --git a/gdb/testsuite/gdb.base/corefile-exec-mismatch.exp b/gdb/testsuite/gdb.base/corefile-exec-mismatch.exp new file mode 100644 index 0000000..dbd652d --- /dev/null +++ b/gdb/testsuite/gdb.base/corefile-exec-mismatch.exp @@ -0,0 +1,188 @@ +# 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/>. + +# Test that when loading a core file, if the current executable +# doesn't match the expected executable for this core file, then GDB +# should give a warning. +# +# We only check the build-id based verification as the name only based +# verification relies on the name held in the PRPSINFO note, which is +# only 80 characters long, as a result, when running the testsuite, +# this string usually only holds the path to the testsuite build +# directory, which might be the same for every core file created. +# +# In addition, as the check is in a similar area of GDB, we check that +# if the executable is newer than the core file, GDB gives a warning. + +# The core file management in this script only works if the host +# machine is local. +require {!is_remote host} + +standard_testfile .c + +# Build an executable with a build id. +if { [build_executable "build" $testfile $srcfile \ + { debug build-id additional_flags=-DGEN_CORE } ] } { + return +} + +# Build an alternative executable. This is different than +# TESTFILE, and so has a different build-id. +set alt_testfile "alt-with-build-id" +set alt_binfile [standard_output_file $alt_testfile] +if { [build_executable "build" $alt_testfile $srcfile \ + { debug build-id } ] } { + return +} + +# Do we expect the build-id for BINFILE to appear in a core file +# generated from BINFILE? If not then this test isn't going to +# work. +if { ![expect_build_id_in_core_file $binfile] } { + unsupported "build-id will not appear in core file" + return +} + +# Create a core file by running BINFILE. +set corefile [core_find $binfile {}] +if {$corefile == ""} { + untested "unable to create corefile" + return +} + +# Start GDB using a completely different executable (than was used +# to generate the core file); this has a different filename and +# build-id. +clean_restart $alt_testfile + +# Load the core file. GDB should warn because the build-id of the +# executable doesn't match the expected build-id pulled from the +# core file. +set saw_mismatch_warning false +gdb_test_multiple "core $corefile" "load core file, different exec name" { + -re "^core \[^\r\n\]+\r\n" { + exp_continue + } + -re "^warning: core file may not match specified executable file\\.\r\n" { + set saw_mismatch_warning true + exp_continue + } + -re "^$gdb_prompt $" { + gdb_assert { $saw_mismatch_warning } $gdb_test_name + } + -re "^\[^\r\n\]*\r\n" { + exp_continue + } +} + +# Cleanup before the next test. +unset saw_mismatch_warning +gdb_exit + +# Touch TESTFILE (via its full filename) so that it is newer than +# the core file. +sleep 1 +remote_exec host "touch ${binfile}" + +# Start GDB using the correct executable, but this file is newer than +# the core file, we expect GDB to warn about this. +clean_restart $testfile + +# Load the core file. GDB should warn that the executable is +# newer than the core file. +# +# NOTE: In this case the build-ids match, so maybe GDB should +# ignore the fact that the core file is older than the executable? +# If we every make that change to GDB, and this test starts to +# fail, then the test should be updated to build executables +# without build-ids so that this warning is still tested. +# +# The reason I didn't do this initially is that, if there are any +# build-ids in the core file, from any shared library at all, then +# GDB will use this as "the" build-id for the core file, and +# compare this to the build-id of the executable. I say GDB here, +# but some of this logic is in BFD. Anyway, if GDB thinks that +# the core file has a build-id, but the executable doesn't, then +# GDB gives the generic "core file may not match specified +# executable file" warning instead of the "exec file is newer than +# core file" warning, which is what we want. +# +# For now then, I just check for the age based warning when we +# also have full build-ids. +set saw_age_warning false +gdb_test_multiple "core $corefile" "load core file, exec is newer" { + -re "^core \[^\r\n\]+\r\n" { + exp_continue + } + -re "^warning: exec file is newer than core file\\.\r\n" { + set saw_age_warning true + exp_continue + } + -re "^$gdb_prompt $" { + gdb_assert { $saw_age_warning } $gdb_test_name + } + -re "^\[^\r\n\]*\r\n" { + exp_continue + } +} + +# Cleanup before the next test. +unset saw_age_warning +gdb_exit + +# Replace BINFILE with ALT_BINFILE, a file with a different +# build-id. +remote_exec host "mv $binfile ${binfile}-hidden" +remote_exec host "cp $alt_binfile $binfile" + +# Ensure COREFILE is newer than BINFILE. +sleep 1 +remote_exec host "touch ${corefile}" + +# Start GDB using the filename that now points to the replacement +# file. +clean_restart $testfile + +# Load the core file. GDB should use the build-id to warn the +# user that the executable doesn't match the core file. We'll +# also get a warning that the build-id of the executable doesn't +# match while processing the mapped file information in the core +# file. +set saw_mismatch_warning false +set saw_build_id_warning false +gdb_test_multiple "core $corefile" "load core file, same exec name" { + -re "^core \[^\r\n\]+\r\n" { + exp_continue + } + -re "^warning: File [string_to_regexp $binfile] doesn't match build-id from core-file during file-backed mapping processing" { + set saw_build_id_warning true + exp_continue + } + -re "^warning: core file may not match specified executable file\\.\r\n" { + set saw_mismatch_warning true + exp_continue + } + -re "^$gdb_prompt $" { + gdb_assert { $saw_mismatch_warning \ + && $saw_build_id_warning } $gdb_test_name + } + -re "^\[^\r\n\]*\r\n" { + exp_continue + } +} + +unset saw_mismatch_warning +unset saw_build_id_warning +gdb_exit diff --git a/gdb/testsuite/gdb.base/corefile-find-exec.c b/gdb/testsuite/gdb.base/corefile-find-exec.c index ed4df60..6f5f29c 100644 --- a/gdb/testsuite/gdb.base/corefile-find-exec.c +++ b/gdb/testsuite/gdb.base/corefile-find-exec.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/corefile-find-exec.exp b/gdb/testsuite/gdb.base/corefile-find-exec.exp index 07e660d..0daabc8 100644 --- a/gdb/testsuite/gdb.base/corefile-find-exec.exp +++ b/gdb/testsuite/gdb.base/corefile-find-exec.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/corefile-shmem-zero-id-lib.c b/gdb/testsuite/gdb.base/corefile-shmem-zero-id-lib.c new file mode 100644 index 0000000..58fdec6 --- /dev/null +++ b/gdb/testsuite/gdb.base/corefile-shmem-zero-id-lib.c @@ -0,0 +1,522 @@ +/* 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/>. */ + +/* This file contains a library that can be preloaded into GDB on Linux + using the LD_PRELOAD technique. + + The library intercepts calls to OPEN, CLOSE, READ, and PREAD in order to + fake the inode number of a shared memory mapping. + + When GDB creates a core file (e.g. with the 'gcore' command), then + shared memory mappings should be included in the generated core file. + + The 'id' for the shared memory mapping shares the inode slot in the + /proc/PID/smaps file, which is what GDB consults to decide which + mappings should be included in the core file. + + It is possible for a shared memory mapping to have an 'id' of zero. + + At one point there was a bug in GDB where mappings with an inode of zero + would not be included in the generated core file. This meant that most + shared memory mappings would be included in the generated core file, + but, if a shared memory mapping happened to get an 'id' of zero, then, + because this would appear as a zero inode in the smaps file, this shared + memory mapping would be excluded from the generated core file. + + This preload library spots when GDB opens a /proc/PID/smaps file and + immediately copies the contents of this file into an internal buffer. + The buffer is then scanned looking for a shared memory mapping, and, if + a shared memory mapping is found, its 'id' (in the inode position) is + changed to zero. + + Calls to read/pread are intercepted, and attempts to read from the smaps + file are then served from the modified buffer contents. + + The close calls are monitored and, when the smaps file is closed, the + internal buffer is released. + + This works with GDB (currently) because the requirements for access to + the smaps file are pretty simple. GDB opens the file and grabs the + entire contents with a single pread call and a large buffer. There's no + seeking within the file or anything like that. + + The intention is that this library is preloaded into a GDB session which + is then used to start an inferior and generate a core file. GDB will + then see the zero inode for the shared memory mapping and should, if the + bug is correctly fixed, still add the shared memory mapping to the + generated core file. */ + +#define _GNU_SOURCE + +#include <stdio.h> +#include <stdlib.h> +#include <dlfcn.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdarg.h> +#include <errno.h> +#include <ctype.h> +#include <string.h> +#include <stdbool.h> +#include <assert.h> + +/* Logging. */ + +static void +log_msg (const char *fmt, ...) +{ +#ifdef LOGGING + va_list ap; + + va_start (ap, fmt); + vfprintf (stderr, fmt, ap); + va_end (ap); +#endif /* LOGGING */ +} + +/* Error handling, message and exit. */ + +static void +error (const char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + vfprintf (stderr, fmt, ap); + va_end (ap); + + exit (EXIT_FAILURE); +} + +/* The type of the open() function. */ +typedef int (*open_func_type)(const char *pathname, int flags, ...); + +/* The type of the close() function. */ +typedef int (*close_func_type)(int fd); + +/* The type of the read() function. */ +typedef ssize_t (*read_func_type)(int fd, void *buf, size_t count); + +/* The type of the pread() function. */ +typedef ssize_t (*pread_func_type) (int fd, void *buf, size_t count, off_t offset); + +/* Structure that holds information about a /proc/PID/smaps file that has + been opened. */ +struct interesting_file +{ + /* The file descriptor for the opened file. */ + int fd; + + /* The read offset within the file. Set to zero when the file is + opened. Any 'read' calls will update this offset. */ + size_t offset; + + /* The size of the contents within the buffer. This is not the total + buffer size (which might be larger). Attempts to read beyond SIZE + indicate an attempt to read beyond the end of the file. */ + size_t size; + + /* The (possibly modified) contents of the file. */ + char *content; +}; + +/* We only track a single interesting file. Currently, for the use case + we imagine, GDB will only ever open one /proc/PID/smaps file at once. */ +struct interesting_file the_file = { -1, 0, 0, NULL }; + +/* Update the contents of the global THE_FILE buffer. It is assumed that + the file contents have already been loaded into THE_FILE's content + buffer. + + Look for any lines that represent a shared memory mapping and modify + the inode field (which holds the shared memory id) to be zero. */ +static void +update_file_content_buffer (void) +{ + assert (the_file.content != NULL); + + char *start = the_file.content; + do + { + /* Every line, even the last one, ends with a newline. */ + char *end = strchrnul (start, '\n'); + assert (end != NULL); + assert (*end != '\0'); + + /* Attribute lines start with an uppercase letter. The lines we want + to modify should start with a lower case hex character, + i.e. [0-9a-f]. Also, every line that we want to consider should + be long enough, but just in case, check the longest possible + filename that we care about. */ + if (isxdigit (*start) && (isdigit (*start) || islower (*start)) + && (end - start) > 23) + { + /* There are two possible filenames that we look for: + /SYSV%08x + /SYSV%08x (deleted) + The END pointer is pointing to the first character after the + filename. + + Setup OFFSET to be the offset from END to the start of the + filename. As we check the filename we set OFFSET to 0 if the + filename doesn't match one of the expected patterns. */ + size_t offset; + if (strncmp ((end - 13), "/SYSV", 5) == 0) + offset = 13; + else if (strncmp ((end - 23), "/SYSV", 5) == 0) + { + if (strncmp ((end - 10), " (deleted)", 10) == 0) + offset = 23; + else + offset = 0; + } + else + offset = 0; + + for (int i = 0; i < 8 && offset != 0; ++i) + { + if (!isdigit (*(end - offset + 5 + i))) + offset = 0; + } + + /* If OFFSET is non-zero then the filename on this line looks + like a shared memory mapping, and OFFSET is the offset from + END to the first character of the filename. */ + if (offset != 0) + { + log_msg ("[LD_PRELOAD] shared memory entry: %.*s\n", + offset, (end - offset)); + + /* Set PTR to the first character before the filename. This + should be a white space character. */ + char *ptr = end - offset - 1; + assert (isspace (*ptr)); + + /* Walk backwards until we find the inode field. */ + while (isspace (*ptr)) + --ptr; + + /* Now replace every character in the inode field, except the + first one, with a space character. */ + while (!isspace (*(ptr - 1))) + { + assert (isdigit (*ptr)); + *ptr = ' '; + --ptr; + } + + /* Replace the first character with '0'. */ + assert (isdigit (*ptr)); + *ptr = '0'; + + /* This print is checked for from GDB. */ + printf ("[LD_PRELOAD] updated a shared memory mapping\n"); + } + } + + /* Update START to point to the next line. The last line of the + file will be empty. */ + assert (*end == '\n'); + start = end; + while (*start == '\n') + ++start; + } + while (*start != '\0'); +} + +/* Return true if PATHNAME has for form "/proc/PID/smaps" (without the + quotes). Otherwise, return false. */ + +static bool +is_smaps_file (const char *pathname) +{ + if (strncmp (pathname, "/proc/", 6) == 0) + { + int idx = 6; + while (isdigit (pathname[idx])) + idx++; + if (idx > 6 && strcmp (&pathname[idx], "/smaps") == 0) + return true; + } + + return false; +} + +/* Return true if PATHNAME should be considered interesting. PATHNAME is + interesting if it has the form /proc/PID/smaps, and there is no + interesting file already opened. */ + +static bool +is_interesting_pathname (const char *pathname) +{ + return the_file.fd == -1 && is_smaps_file (pathname); +} + +/* Read the contents of an interesting file from FD (and open file + descriptor) into the global THE_FILE variable, making the file FD the + current interesting file. There should be no already open interesting + file when this function is called. + + The contents of the file FD are read into a memory buffer and updated so + that any shared memory mappings listed within FD (which will be an smaps + file) will have the id zero. */ + +static void +read_interesting_file_contents (int fd) +{ +#define BLOCK_SIZE 1024 + /* Slurp contents into a local buffer. */ + size_t buffer_size = 1024; + size_t offset = 0; + + assert (the_file.size == 0); + assert (the_file.content == NULL); + assert (the_file.fd == -1); + assert (the_file.offset == 0); + + do + { + the_file.content = (char *) realloc (the_file.content, buffer_size); + if (the_file.content == NULL) + error ("[LD_PRELOAD] Failed allocating memory: %s\n", strerror (errno)); + + ssize_t bytes_read = read (fd, the_file.content + offset, BLOCK_SIZE); + if (bytes_read == -1) + error ("[LD_PRELOAD] Failed reading file: %s\n", strerror (errno)); + + the_file.size += bytes_read; + + if (bytes_read < BLOCK_SIZE) + break; + + offset += BLOCK_SIZE; + buffer_size += BLOCK_SIZE; + } + while (true); + + /* Add a null terminator. This makes the update easier. We know + there will be space because we only break out of the loop above + when the last read returns less than BLOCK_SIZE bytes. This means + we allocated an extra BLOCK_SIZE bytes, but didn't fill them all. + This means there must be at least 1 byte available for the null. */ + the_file.content[the_file.size] = '\0'; + + /* Reset the seek pointer. */ + if (lseek (fd, 0, SEEK_SET) == (off_t) -1) + error ("[LD_PRELOAD] Failed to lseek in file: %s\n", strerror (errno)); + + /* Record the file descriptor, this is used in read, pread, and close + in order to spot when we need to intercept the call. */ + the_file.fd = fd; + + update_file_content_buffer (); +#undef BLOCK_SIZE +} + +/* Intercept calls to 'open'. If this is an attempt to open a + /proc/PID/smaps file then intercept it, load the file contents into a + buffer and update the file contents. For all other open requests, just + forward to the real open function. */ +int +open (const char *pathname, int flags, ...) +{ + /* Pointer to the real open function. */ + static open_func_type real_open = NULL; + + /* Mode is only used if the O_CREAT flag is set in FLAGS. */ + mode_t mode = 0; + + /* Set true if this is a /proc/PID/smaps file. */ + bool is_interesting = is_interesting_pathname (pathname); + + /* Check if O_CREAT is in flags. If it is, get the mode. */ + if (flags & O_CREAT) + { + va_list args; + va_start (args, flags); + mode = va_arg (args, mode_t); + va_end (args); + } + + /* Debug. */ + if (is_interesting) + log_msg ("[LD_PRELOAD] Opening file: %s\n", pathname); + + /* Make sure we have a pointer to the real open() function. */ + if (real_open == NULL) + { + /* Get the address of the real open() function. */ + real_open = (open_func_type) dlsym (RTLD_NEXT, "open"); + if (real_open == NULL) + error ("[LD_PRELOAD] dlsym() error for 'open': %s\n", dlerror ()); + } + + /* Call the original open() function with the provided arguments. */ + int res = -1; + if (flags & O_CREAT) + res = real_open (pathname, flags, mode); + else + res = real_open (pathname, flags); + + if (res != -1 && is_interesting) + read_interesting_file_contents (res); + + return res; +} + +/* Like above, but for open64. */ + +int +open64 (const char *pathname, int flags, ...) +{ + /* Pointer to the real open64 function. */ + static open_func_type real_open64 = NULL; + + /* Mode is only used if the O_CREAT flag is set in FLAGS. */ + mode_t mode = 0; + + /* Set true if this is a /proc/PID/smaps file. */ + bool is_interesting = is_interesting_pathname (pathname); + + /* Check if O_CREAT is in flags. If it is, get the mode. */ + if (flags & O_CREAT) + { + va_list args; + va_start (args, flags); + mode = va_arg (args, mode_t); + va_end (args); + } + + /* Debug. */ + if (is_interesting) + log_msg ("[LD_PRELOAD] Opening file: %s\n", pathname); + + /* Make sure we have a pointer to the real open64() function. */ + if (real_open64 == NULL) + { + /* Get the address of the real open64() function. */ + real_open64 = (open_func_type) dlsym (RTLD_NEXT, "open64"); + if (real_open64 == NULL) + error ("[LD_PRELOAD] dlsym() error for 'open64': %s\n", dlerror ()); + } + + /* Call the original open64() function with the provided arguments. */ + int res = -1; + if (flags & O_CREAT) + res = real_open64 (pathname, flags, mode); + else + res = real_open64 (pathname, flags); + + if (res != -1 && is_interesting) + read_interesting_file_contents (res); + + return res; +} + +/* Intercept the 'close' function. If this is a previously opened + interesting file then clean up. Otherwise, forward to the normal close + function. */ +int +close (int fd) +{ + static close_func_type real_close = NULL; + + if (fd == the_file.fd) + { + the_file.fd = -1; + free (the_file.content); + the_file.content = NULL; + the_file.offset = 0; + the_file.size = 0; + log_msg ("[LD_PRELOAD] Closing file.\n"); + } + + /* Make sure we have a pointer to the real open() function. */ + if (real_close == NULL) + { + /* Get the address of the real open() function. */ + real_close = (close_func_type) dlsym (RTLD_NEXT, "close"); + if (real_close == NULL) + error ("[LD_PRELOAD] dlsym() error for 'close': %s\n", dlerror ()); + } + + return real_close (fd); +} + +/* Intercept 'pread' calls. If this is a pread from a previously opened + interesting file, then read from the in memory buffer. Otherwise, + forward to the real pread function. */ +ssize_t +pread (int fd, void *buf, size_t count, off_t offset) +{ + static pread_func_type real_pread = NULL; + + if (fd == the_file.fd) + { + size_t max; + + if (offset > the_file.size) + max = 0; + else + max = the_file.size - offset; + if (count > max) + count = max; + + memcpy (buf, the_file.content + offset, count); + log_msg ("[LD_PRELOAD] Read from file.\n"); + return count; + } + + if (real_pread == NULL) + { + /* Get the address of the real read() function. */ + real_pread = (pread_func_type) dlsym (RTLD_NEXT, "pread"); + if (real_pread == NULL) + error ("[LD_PRELOAD] dlsym() error for 'pread': %s\n", dlerror ()); + } + + return real_pread (fd, buf, count, offset); +} + +/* Intercept 'read' calls. If this is a read from a previously opened + interesting file, then read from the in memory buffer. Otherwise, + forward to the real read function. */ +ssize_t +read (int fd, void *buf, size_t count) +{ + static read_func_type real_read = NULL; + + if (fd == the_file.fd) + { + ssize_t bytes_read = pread (fd, buf, count, the_file.offset); + if (bytes_read > 0) + the_file.offset += bytes_read; + return bytes_read; + } + + if (real_read == NULL) + { + /* Get the address of the real read() function. */ + real_read = (read_func_type) dlsym (RTLD_NEXT, "read"); + if (real_read == NULL) + error ("[LD_PRELOAD] dlsym() error for 'read': %s\n", dlerror ()); + } + + return real_read (fd, buf, count); +} diff --git a/gdb/testsuite/gdb.base/corefile-shmem-zero-id.c b/gdb/testsuite/gdb.base/corefile-shmem-zero-id.c new file mode 100644 index 0000000..92d2edf --- /dev/null +++ b/gdb/testsuite/gdb.base/corefile-shmem-zero-id.c @@ -0,0 +1,63 @@ +/* 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/>. */ + +#include <sys/ipc.h> +#include <sys/shm.h> +#include <stdio.h> +#include <errno.h> +#include <stdlib.h> +#include <unistd.h> +#include <assert.h> +#include <time.h> + +void +breakpt (void) +{ + /* Nothing. */ +} + +int +main (void) +{ + /* Create a shared memory mapping. */ + int sid = shmget (IPC_PRIVATE, 0x1000, IPC_CREAT | IPC_EXCL | 0777); + if (sid == -1) + { + perror ("shmget"); + exit (1); + } + + /* Attach the shared memory mapping. */ + void *addr = shmat (sid, NULL, SHM_RND); + if (addr == (void *) -1L) + { + perror ("shmat"); + exit (1); + } + + breakpt (); + + /* Mark the shared memory mapping as deleted -- once the last user + has finished with it. */ + if (shmctl (sid, IPC_RMID, NULL) != 0) + { + perror ("shmctl"); + exit (1); + } + + return 0; +} diff --git a/gdb/testsuite/gdb.base/corefile-shmem-zero-id.exp b/gdb/testsuite/gdb.base/corefile-shmem-zero-id.exp new file mode 100644 index 0000000..0ee3715 --- /dev/null +++ b/gdb/testsuite/gdb.base/corefile-shmem-zero-id.exp @@ -0,0 +1,228 @@ +# 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/>. + +# This test script tries to check GDB's ability to create a core file +# (e.g. with 'gcore' command) when there's a shared memory mapping +# with the id zero. +# +# Testing this case is hard. Older kernels don't even seem to give +# out the shared memory id zero. And on new kernels you still cannot +# guarantee to grab the zero id for testing; the id might be in use by +# some other process, or the kernel might just not give out that id +# for some other reason. +# +# To figure out which mappings to include in the core file, GDB reads +# the /proc/PID/smaps file. There is a field in this file which for +# file backed mappings, holds the inode of the file. But for shared +# memory mappings this field holds the shared memory id. The problem +# was that GDB would ignore any entry in /proc/PID/smaps with an inode +# entry of zero, which would catch the shared memory mapping with a +# zero id. +# +# There was an attempt to write a test which spammed out requests for +# shared memory mappings and tried to find the one with id zero, but +# this was still really unreliable. +# +# This test takes a different approach. We compile a library which we +# preload into the GDB process. This library intercepts calls to +# open, close, read, and pread, and watches for an attempt to open the +# /proc/PID/smaps file. +# +# When we see that file being opened, we copy the file contents into a +# memory buffer and modify the buffer so that the inode field for any +# shared memory mappings is set to zero. We then intercept calls to +# read and pread and return results from that in memory buffer. +# +# The test executable itself create a shared memory mapping (which +# might have any id). +# +# GDB, with the pre-load library in place, start the inferior and then +# uses the 'gcore' command to dump a core file. When GDB opens the +# smaps file and reads from it, the preload library ensures that GDB +# sees an inode of zero. +# + +# This test only works on Linux +require isnative +require {!is_remote host} +require {!is_remote target} +require {istarget *-linux*} +require gcore_cmd_available + +standard_testfile .c -lib.c + +set libfile ${testfile}-lib +set libobj [standard_output_file ${libfile}.so] + +# Compile the preload library. We only get away with this as we +# limit this test to running when ISNATIVE is true. +if { [build_executable "build preload lib" $libobj $srcfile2 \ + {debug shlib libs=-ldl}] == -1 } { + return +} + +# Now compile the inferior executable. +if {[build_executable "build executable" $testfile $srcfile] == -1} { + return +} + +# Spawn GDB with LIBOBJ preloaded using LD_PRELOAD. +save_vars { env(LD_PRELOAD) env(ASAN_OPTIONS) } { + if { ![info exists env(LD_PRELOAD) ] + || $env(LD_PRELOAD) == "" } { + set env(LD_PRELOAD) "$libobj" + } else { + append env(LD_PRELOAD) ":$libobj" + } + + # Prevent address sanitizer error: + # ASan runtime does not come first in initial library list; you should + # either link runtime to your application or manually preload it with + # LD_PRELOAD. + append_environment_default ASAN_OPTIONS verify_asan_link_order 0 + + clean_restart $testfile + + # Start GDB with the modified environment, this means that, when + # using remote targets, gdbserver will also use the preload + # library. + if {![runto_main]} { + return + } +} + +gdb_breakpoint breakpt +gdb_continue_to_breakpoint "run to breakpt" + +# Check the /proc/PID/smaps file itself. The call to 'cat' should +# inherit the preload library, so should see the modified file +# contents. Check that the shared memory mapping line has an id of +# zero. This confirms that the preload library is working. If the +# preload library breaks then we'll start seeing non-zero shared +# memory ids, which always worked, so we'd never know that this test +# is broken! +# +# This check ensures the test is working as expected. +set shmem_line_count 0 +set fixup_line_count 0 +set inf_pid [get_inferior_pid] +gdb_test_multiple "shell cat /proc/${inf_pid}/smaps" "check smaps" { + -re "^\\\[LD_PRELOAD\\\] updated a shared memory mapping\r\n" { + incr fixup_line_count + exp_continue + } + -re "^\[^\r\n\]+($decimal)\\s+/SYSV\[0-9\]{8}(?: \\(deleted\\))?\r\n" { + set id $expect_out(1,string) + if { $id == 0 } { + incr shmem_line_count + } + exp_continue + } + -re "^$gdb_prompt $" { + with_test_prefix $gdb_test_name { + gdb_assert { $shmem_line_count == 1 } \ + "single shared memory mapping found" + gdb_assert { $fixup_line_count == 1 } \ + "single fixup line found" + } + } + -re "^\[^\r\n\]+\r\n" { + exp_continue + } +} + +# Now generate a core file. This will use the preload library to read +# the smaps file. The code below is copied from 'proc gdb_gcore_cmd', +# but we don't use that as we also look for a message that is printed +# by the LD_PRELOAD library. This is an extra level of check that the +# preload library is triggering when needed. +set corefile [standard_output_file ${testfile}.core] +set saw_ld_preload_msg false +set saw_saved_msg false +with_timeout_factor 3 { + gdb_test_multiple "gcore $corefile" "save core file" { + -re "^\\\[LD_PRELOAD\\\] updated a shared memory mapping\r\n" { + # GDB actually reads the smaps file multiple times when + # creating a core file, so we'll see multiple of these + # fixup lines. + set saw_ld_preload_msg true + exp_continue + } + -re "^Saved corefile \[^\r\n\]+\r\n" { + set saw_saved_msg true + exp_continue + } + -re "^$gdb_prompt $" { + with_test_prefix $gdb_test_name { + gdb_assert { $saw_saved_msg } \ + "saw 'Saved corefile' message" + + # If we're using a remote target then the message from + # the preload library will go to gdbservers stdout, + # not GDB's, so don't check for it. + if { [gdb_protocol_is_native] } { + gdb_assert { $saw_ld_preload_msg } \ + "saw LD_PRELOAD message from library" + } + } + } + -re "^\[^\r\n\]*\r\n" { + exp_continue + } + } +} + +# Restart GDB. This time we are _not_ using the preload library. We +# no longer need it as we are only analysing the core file now. +clean_restart $testfile + +# Load the core file. +gdb_test "core-file $corefile" \ + "Program terminated with signal SIGTRAP, Trace/breakpoint trap\\..*" \ + "load core file" + +# Look through the mappings. We _should_ see the shared memory +# mapping. We _should_not_ see any of the special '[blah]' style +# mappings, e.g. [vdso], [vstack], [vsyscalls], etc. +set saw_special_mapping false +set saw_shmem_mapping false +gdb_test_multiple "info proc mappings" "" { + -re "\r\nStart Addr\[^\r\n\]+File\\s*\r\n" { + exp_continue + } + + -re "^$hex\\s+$hex\\s+$hex\\s+$hex\\s+\\\[\\S+\\\]\\s*\r\n" { + set saw_special_mapping true + exp_continue + } + + -re "^$hex\\s+$hex\\s+$hex\\s+$hex\\s+/SYSV\[0-9\]+ \\(deleted\\)\\s*\r\n" { + set saw_shmem_mapping true + exp_continue + } + + -re "^$hex\\s+$hex\\s+$hex\\s+$hex\[^\r\n\]*\r\n" { + exp_continue + } + + -re "^$gdb_prompt $" { + with_test_prefix $gdb_test_name { + gdb_assert { $saw_shmem_mapping } \ + "check shared memory mapping exists" + gdb_assert { !$saw_special_mapping } \ + "check no special mappings added" + } + } +} diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp index 83b42ab..48d3225 100644 --- a/gdb/testsuite/gdb.base/corefile.exp +++ b/gdb/testsuite/gdb.base/corefile.exp @@ -1,4 +1,4 @@ -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -31,6 +31,7 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} { # mmapped data in core file" test. set corefile [core_find $binfile {}] if {$corefile == ""} { + untested "unable to create or find corefile" return 0 } @@ -59,7 +60,7 @@ proc start_gdb_with_corefile { testname coreopt corefile {binfile ""} } { -re -wrap "Couldn't find .* registers in core file.*" { fail "$gdb_test_name (couldn't find regs)" } - -re -wrap "Core was generated by `[string_to_regexp $corefile]'\\.\r\n.*\#0 \[^\r\n\]+\(\).*" { + -re -wrap "Core was generated by `[string_to_regexp $binfile]'\\.\r\n.*\#0 \[^\r\n\]+\(\).*" { pass $gdb_test_name } -re -wrap "Core was generated by .*\r\n\#0 .*\(\).*" { @@ -74,6 +75,16 @@ proc start_gdb_with_corefile { testname coreopt corefile {binfile ""} } { fail "$gdb_test_name (core not loaded)" } } + + # COREFILE will have whitespace quoted ready for use on the command + # line. But for the 'info inferiors' output whitespace is not quoted, + # so remote the quoting now. + regsub -all "\\\\ " $corefile " " corefile + gdb_test "info inferiors" \ + [multi_line \ + "\\* 1\[^\r\n\]+\\(core\\)\\s+.*[string_to_regexp $binfile]\\s*" \ + "\\s+core file [string_to_regexp $corefile]"] \ + "$testname, info inferiors" } } @@ -96,7 +107,7 @@ foreach_with_prefix coreopt {--core= -core= "-c "} { # Now restart normally. -clean_restart $binfile +clean_restart $testfile # Test basic corefile recognition via core-file command. @@ -200,7 +211,7 @@ set coremmap_data_backup_filename \ remote_exec host "mv ${coremmap_data_filename} \ ${coremmap_data_backup_filename}" -clean_restart $binfile +clean_restart $testfile # Load the core file and check we get a warning about the # coremmap.data file being missing. @@ -229,7 +240,7 @@ remote_exec host "mv ${coremmap_data_backup_filename} \ # Test that we can unload the core with the "detach" command. proc_with_prefix corefile_detach {} { - clean_restart $::binfile + clean_restart $::testfile gdb_test "core-file $::corefile" "Core was generated by .*" "load core" gdb_test "detach" "No core file now\\." "detach core" @@ -251,7 +262,7 @@ proc corefile_test_run {} { return } - clean_restart $::binfile + clean_restart $::testfile gdb_test "core-file $corefile" "Core was generated by .*" "run: load core again" set re "Local core dump file:" @@ -260,7 +271,7 @@ proc corefile_test_run {} { "run: sanity check we see the core file" set test "run: with core" - if [runto_main] { + if {[runto_main]} { pass $test } else { fail $test @@ -322,7 +333,7 @@ proc corefile_test_attach {} { return } - if [can_spawn_for_attach] { + if {[can_spawn_for_attach]} { set test "attach: spawn sleep" set res [remote_spawn host "$binfile sleep"] if { $res < 0 || $res == "" } { diff --git a/gdb/testsuite/gdb.base/corefile2.exp b/gdb/testsuite/gdb.base/corefile2.exp index c0624f6..4152013 100644 --- a/gdb/testsuite/gdb.base/corefile2.exp +++ b/gdb/testsuite/gdb.base/corefile2.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -40,6 +40,7 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} { set corefile [core_find $binfile {}] if {$corefile == ""} { + untested "unable to create or find corefile" return 0 } @@ -170,7 +171,7 @@ with_test_prefix "renamed binfile" { # Restart and run to the abort call. -clean_restart $binfile +clean_restart $testfile if {![runto_main]} { return @@ -194,7 +195,7 @@ if {!$core_supported} { gdb_test_no_output "maint print core-file-backed-mappings" \ "maint print core-file-backed-mapping with no core file" -clean_restart $binfile +clean_restart $testfile set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"] if { $core_loaded == -1 } { diff --git a/gdb/testsuite/gdb.base/corefile3.c b/gdb/testsuite/gdb.base/corefile3.c new file mode 100644 index 0000000..16030dd --- /dev/null +++ b/gdb/testsuite/gdb.base/corefile3.c @@ -0,0 +1,118 @@ +/* Copyright 1992-2025 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/>. */ + +/* This file is based on coremaker.c. */ + +#include <stdio.h> +#include <sys/types.h> +#include <fcntl.h> +#include <sys/mman.h> +#include <signal.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <assert.h> +#include <sys/ipc.h> +#include <sys/shm.h> + +#define MAPSIZE (8 * 1024) + +/* Global pointers so it's easier to access them from GDB. */ + +char *rw_mapping = NULL; +char *malloc_buffer = NULL; +char *anon_mapping = NULL; +char *shm_mapping = NULL; + +/* Create mappings within this process. */ + +void +mmapdata () +{ + /* Allocate and initialize a buffer that will be used to write the file + that is later mapped in. */ + + malloc_buffer = (char *) malloc (MAPSIZE); + for (int j = 0; j < MAPSIZE; ++j) + malloc_buffer[j] = j; + + /* Write the file to map in. */ + + int fd = open ("coremmap.data", O_CREAT | O_RDWR, 0666); + assert (fd != -1); + write (fd, malloc_buffer, MAPSIZE); + + /* Now map the file into our address space as RW_MAPPING. */ + + rw_mapping + = (char *) mmap (0, MAPSIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); + assert (rw_mapping != (char *) MAP_FAILED); + + /* Verify that the original data and the mapped data are identical. If + not, we'd rather fail now than when trying to access the mapped data + from the core file. */ + + for (int j = 0; j < MAPSIZE; ++j) + assert (malloc_buffer[j] == rw_mapping[j]); + + /* Touch RW_MAPPING so the kernel writes it out into 'core'. */ + rw_mapping[0] = malloc_buffer[0]; + + /* Create yet another region which is allocated, but not written to. */ + anon_mapping = mmap (NULL, MAPSIZE, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + assert (anon_mapping != MAP_FAILED); + + /* Create a shared memory mapping. */ + int sid = shmget (IPC_PRIVATE, MAPSIZE, IPC_CREAT | IPC_EXCL | 0777); + assert (sid != -1); + shm_mapping = (char *) shmat (sid, NULL, 0); + int res = shmctl (sid, IPC_RMID, NULL); + assert (res == 0); + assert (shm_mapping != MAP_FAILED); +} + +void +func2 () +{ +#ifdef SA_FULLDUMP + /* Force a corefile that includes the data section for AIX. */ + { + struct sigaction sa; + + sigaction (SIGABRT, (struct sigaction *)0, &sa); + sa.sa_flags |= SA_FULLDUMP; + sigaction (SIGABRT, &sa, (struct sigaction *)0); + } +#endif + + abort (); +} + +void +func1 () +{ + func2 (); +} + +int +main (void) +{ + mmapdata (); + func1 (); + return 0; +} diff --git a/gdb/testsuite/gdb.base/corefile3.exp b/gdb/testsuite/gdb.base/corefile3.exp new file mode 100644 index 0000000..bee393c --- /dev/null +++ b/gdb/testsuite/gdb.base/corefile3.exp @@ -0,0 +1,72 @@ +# 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/>. + +# Create a core file with some mapped file regions, but ensure that +# the the kernel should write the regions into the core file (e.g. r/w +# file backed mapping). +# +# We then delete the file that backed the mapping and load the core +# file into GDB. +# +# GDB shouldn't warn about the file being missing. It doesn't matter; +# the file contents can all be found in the core file itself. + +require isnative +require {!is_remote host} + +standard_testfile + +if {[build_executable $testfile.exp $testfile $srcfile] == -1} { + return +} + +set corefile [core_find $binfile {}] +if {$corefile == ""} { + untested "unable to create or find corefile" + return +} + +# Move the coremap.data file out of the way, so it cannot be found +# when we later load the core file into GDB. This file was generated +# by the inferior as it was running. +set data_filename \ + [standard_output_file coredir.[getpid]/coremmap.data] +set backup_filename \ + [standard_output_file coredir.[getpid]/coremmap.data.backup] +remote_exec host "mv ${data_filename} ${backup_filename}" + +clean_restart $testfile + +# Load the core file. The 'coremap.data' file cannot be found by GDB, +# but all the mappings for that file are r/w and should be present in +# the core file, so we shouldn't get any warnings from GDB about it. +set warnings_seen 0 +gdb_test_multiple "core-file $corefile" "core-file command" { + -re "^warning: Can't open file \[^\r\n\]+ during file-backed mapping note processing\r\n" { + incr warnings_seen + exp_continue + } + -re "^$gdb_prompt $" { + gdb_assert { $warnings_seen == 0 } $gdb_test_name + } + -re "^\[^\r\n\]*\r\n" { + exp_continue + } +} + +# Check the mappings are all readable. +foreach label { rw_mapping malloc_buffer anon_mapping shm_mapping } { + gdb_test "x/1wd $label" "^$hex:\\s+$decimal" +} diff --git a/gdb/testsuite/gdb.base/coremaker.c b/gdb/testsuite/gdb.base/coremaker.c index 5e19766..220d2ab 100644 --- a/gdb/testsuite/gdb.base/coremaker.c +++ b/gdb/testsuite/gdb.base/coremaker.c @@ -1,4 +1,4 @@ -/* Copyright 1992-2024 Free Software Foundation, Inc. +/* Copyright 1992-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -118,7 +118,7 @@ mmapdata () /* Create yet another region which is allocated, but not written to. */ buf3 = mmap (NULL, MAPSIZE, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (buf3 == (char *) -1) { perror ("mmap failed"); diff --git a/gdb/testsuite/gdb.base/coremaker2.c b/gdb/testsuite/gdb.base/coremaker2.c index f9a1759..8a15e6a 100644 --- a/gdb/testsuite/gdb.base/coremaker2.c +++ b/gdb/testsuite/gdb.base/coremaker2.c @@ -1,4 +1,4 @@ -/* Copyright 1992-2024 Free Software Foundation, Inc. +/* Copyright 1992-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -15,7 +15,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/>. */ -/* This test has two large memory areas buf_rw and buf_ro. +/* This test has two large memory areas buf_rw and buf_ro. buf_rw is written to by the program while buf_ro is initialized at compile / load time. Thus, when a core file is created, buf_rw's @@ -117,7 +117,7 @@ main (int argc, char **argv) } mbuf_ro = mmap ((void *) addr, pagesize, PROT_READ, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); if (mbuf_ro == MAP_FAILED) { @@ -141,7 +141,7 @@ main (int argc, char **argv) } mbuf_rw = mmap ((void *) addr, pagesize, PROT_READ, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); if (mbuf_rw == MAP_FAILED) { diff --git a/gdb/testsuite/gdb.base/ctf-constvars.c b/gdb/testsuite/gdb.base/ctf-constvars.c index 43d68a6..01a8976 100644 --- a/gdb/testsuite/gdb.base/ctf-constvars.c +++ b/gdb/testsuite/gdb.base/ctf-constvars.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 @@ -93,12 +93,12 @@ unsigned char * const volatile veldt; const char * const volatile cove; const unsigned char * const volatile cavity; - + /* const volatile pointers to volatile vars */ volatile char * const volatile vagus; volatile unsigned char * const volatile vagrancy; - + /* const volatile pointers to const volatile */ const volatile char * const volatile vagary; diff --git a/gdb/testsuite/gdb.base/ctf-constvars.exp b/gdb/testsuite/gdb.base/ctf-constvars.exp index ea3cc93..f38ee53 100644 --- a/gdb/testsuite/gdb.base/ctf-constvars.exp +++ b/gdb/testsuite/gdb.base/ctf-constvars.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/ctf-ptype.c b/gdb/testsuite/gdb.base/ctf-ptype.c index ca34789..3984cf3 100644 --- a/gdb/testsuite/gdb.base/ctf-ptype.c +++ b/gdb/testsuite/gdb.base/ctf-ptype.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/ctf-ptype.exp b/gdb/testsuite/gdb.base/ctf-ptype.exp index 25e31fc..daa9283 100644 --- a/gdb/testsuite/gdb.base/ctf-ptype.exp +++ b/gdb/testsuite/gdb.base/ctf-ptype.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -204,17 +204,17 @@ gdb_test "ptype nested_su.inner_union_instance" "type = union inner_union \{.*\[ # correctly printed (at nesting level 1 and 2). gdb_test "ptype the_highest" \ - "type = struct highest \{.*\[\r\n\] *int a;.*\[\r\n\] *struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{\.\.\.\} anonymous_level_2;.*\[\r\n\] *\} anonymous_level_1;.*\[\r\n\]}.*" \ - "ptype the_highest" + "type = struct highest \{.*\[\r\n\] *int a;.*\[\r\n\] *struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{\.\.\.\} anonymous_level_2;.*\[\r\n\] *\} anonymous_level_1;.*\[\r\n\]}.*" \ + "ptype the_highest" -# Print the type descrption for one of the fields of variable the_highest. +# Print the type description for one of the fields of variable the_highest. # The purpose is to verify that the type of a field that was printed above # as "struct {...}" is now printed in a more descriptive way (because the # nesting level is now one level less). gdb_test "ptype the_highest.anonymous_level_1" \ - "type = struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{.*\[\r\n\] *int c;.*\[\r\n\] *\} anonymous_level_2;.*\[\r\n\]}.*" \ - "ptype the_highest.anonymous_level_1" + "type = struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{.*\[\r\n\] *int c;.*\[\r\n\] *\} anonymous_level_2;.*\[\r\n\]}.*" \ + "ptype the_highest.anonymous_level_1" # Print the type of the identifier ID, and check the response: # - Expect to see PROTOTYPED as the type. PROTOTYPED is not a regular @@ -234,45 +234,44 @@ proc ptype_maybe_prototyped { id prototyped plain { overprototyped "NO-MATCH" } # Turn the arguments, which are literal strings, into # regular expressions by quoting any special characters they contain. foreach var { prototyped plain overprototyped } { - eval "set val \$$var" - regsub -all "\[\]\[*()\]" $val "\\\\&" val + set val [string_to_regexp [set $var]] regsub -all "short int" $val "short( int)?" val regsub -all "long int" $val "long( int)?" val - eval "set $var \$val" + set $var $val } gdb_test_multiple "ptype $id" "ptype $id" { - -re "type = $prototyped\[\r\n\]+$gdb_prompt $" { - pass "ptype $id" - } - -re "type = $plain\[\r\n\]+$gdb_prompt $" { - if {$gcc_compiled} { setup_xfail_format "stabs" } - fail "ptype $id (compiler doesn't emit prototyped types)" - } - -re "type = $overprototyped\[\r\n\]+$gdb_prompt $" { - if { [test_compiler_info "armcc-*"] } { + -re "type = $prototyped\[\r\n\]+$gdb_prompt $" { + pass "ptype $id" + } + -re "type = $plain\[\r\n\]+$gdb_prompt $" { + if {$gcc_compiled} { setup_xfail_format "stabs" } + fail "ptype $id (compiler doesn't emit prototyped types)" + } + -re "type = $overprototyped\[\r\n\]+$gdb_prompt $" { + if { [test_compiler_info "armcc-*"] } { setup_xfail "*-*-*" } - fail "ptype $id (compiler doesn't emit unprototyped types)" - } + fail "ptype $id (compiler doesn't emit unprototyped types)" + } } } ptype_maybe_prototyped "func_type" "int (*)(int (*)(int, float), float)" \ - "int (*)()" + "int (*)()" ptype_maybe_prototyped "old_fptr" "double (*)()" "double (*)()" \ - "double (*)(void)" + "double (*)(void)" ptype_maybe_prototyped "new_fptr" "double (*)()" "double (*)()" ptype_maybe_prototyped "fptr" "int (*)(int, float)" "int (*)()" ptype_maybe_prototyped "fptr2" "int *(*)(int (*)(int, float), float)" \ - "int *(*)()" + "int *(*)()" ptype_maybe_prototyped "xptr" "int (*)(int (*)(), int (*)(), int)" \ - "int (*)()" \ - "int (*)(int (*)(void), int (*)(void), int)" + "int (*)()" \ + "int (*)(int (*)(void), int (*)(void), int)" ptype_maybe_prototyped "ffptr" "int (*(*)(char))(short int)" \ - "int (*(*)())()" + "int (*(*)())()" ptype_maybe_prototyped "fffptr" "int (*(*(*)(char))(short int))(long int)" \ - "int (*(*(*)())())()" + "int (*(*(*)())())()" # Test printing type of string constants and array constants, but # requires a running process. These call malloc, and can take a long @@ -280,7 +279,7 @@ ptype_maybe_prototyped "fffptr" "int (*(*(*)(char))(short int))(long int)" \ if {[runto_main]} { - if [target_info exists gdb,cannot_call_functions] { + if {[target_info exists gdb,cannot_call_functions]} { unsupported "this target can not call functions" return } diff --git a/gdb/testsuite/gdb.base/ctxobj-f.c b/gdb/testsuite/gdb.base/ctxobj-f.c index d258e9f..e9884c4 100644 --- a/gdb/testsuite/gdb.base/ctxobj-f.c +++ b/gdb/testsuite/gdb.base/ctxobj-f.c @@ -1,5 +1,5 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/ctxobj-m.c b/gdb/testsuite/gdb.base/ctxobj-m.c index f9fbfda..a883875 100644 --- a/gdb/testsuite/gdb.base/ctxobj-m.c +++ b/gdb/testsuite/gdb.base/ctxobj-m.c @@ -1,5 +1,5 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 @@ -34,4 +34,3 @@ main (void) return 0; } - diff --git a/gdb/testsuite/gdb.base/ctxobj-v.c b/gdb/testsuite/gdb.base/ctxobj-v.c index 6e39d8d..f9f108c 100644 --- a/gdb/testsuite/gdb.base/ctxobj-v.c +++ b/gdb/testsuite/gdb.base/ctxobj-v.c @@ -1,5 +1,5 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/ctxobj.exp b/gdb/testsuite/gdb.base/ctxobj.exp index d113718..545465d 100644 --- a/gdb/testsuite/gdb.base/ctxobj.exp +++ b/gdb/testsuite/gdb.base/ctxobj.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -26,17 +26,17 @@ set executable ctxobj-m # in that SO while the variable's associated symtab has not been created # yet. set libsrc [list "${srcdir}/${subdir}/ctxobj-v.c" \ - "${srcdir}/${subdir}/ctxobj-f.c"] + "${srcdir}/${subdir}/ctxobj-f.c"] set libobj1 [standard_output_file libctxobj1.so] set libobj2 [standard_output_file libctxobj2.so] set libobj1_opts { debug - additional_flags=-DVERSION=104 - additional_flags=-DGET_VERSION=get_version_1 } + additional_flags=-DVERSION=104 + additional_flags=-DGET_VERSION=get_version_1 } set libobj2_opts { debug - additional_flags=-DVERSION=203 - additional_flags=-DGET_VERSION=get_version_2 } + additional_flags=-DVERSION=203 + additional_flags=-DGET_VERSION=get_version_2 } if { [gdb_compile_shlib $libsrc $libobj1 $libobj1_opts ] != "" } { return -1 @@ -45,9 +45,9 @@ if { [gdb_compile_shlib $libsrc $libobj2 $libobj2_opts ] != "" } { return -1 } if { [gdb_compile "${srcdir}/${subdir}/${executable}.c" \ - [standard_output_file ${executable}] \ - executable \ - [list debug shlib=${libobj1} shlib=${libobj2}]] + [standard_output_file ${executable}] \ + executable \ + [list debug shlib=${libobj1} shlib=${libobj2}]] != ""} { return -1 } @@ -56,14 +56,14 @@ clean_restart $executable gdb_load_shlib $libobj1 gdb_load_shlib $libobj2 -if ![runto_main] { +if {![runto_main]} { return -1 } set bp_location [gdb_get_line_number "STOP" "ctxobj-f.c"] gdb_test "break ctxobj-f.c:$bp_location" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \ - "break in get_version functions" + "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \ + "break in get_version functions" global expect_out set test "continue to get_version_1" @@ -98,12 +98,12 @@ gdb_test "printf \"%d.%d\\n\", \$_hit_bpnum, \$_hit_locno" "$bpno" \ # seen by the program itself. gdb_test "print this_version_num == v" \ - " = 1" \ - "print libctxobj1's this_version_num from partial symtab" + " = 1" \ + "print libctxobj1's this_version_num from partial symtab" gdb_test "print this_version_num == v" \ - " = 1" \ - "print libctxobj1's this_version_num from symtab" + " = 1" \ + "print libctxobj1's this_version_num from symtab" # Do the same, but from get_version_2. set test "continue to get_version_2" @@ -118,9 +118,9 @@ gdb_test "printf \"%d.%d\\n\", \$_hit_bpnum, \$_hit_locno" "$bpno" \ "$test \$_hit_bpnum.\$_hit_locno is $bpno" gdb_test "print this_version_num == v" \ - " = 1" \ - "print libctxobj2's this_version_num from partial symtab" + " = 1" \ + "print libctxobj2's this_version_num from partial symtab" gdb_test "print this_version_num == v" \ - " = 1" \ - "print libctxobj2's this_version_num from symtab" + " = 1" \ + "print libctxobj2's this_version_num from symtab" diff --git a/gdb/testsuite/gdb.base/cursal.c b/gdb/testsuite/gdb.base/cursal.c index bc1e46f..a400503 100644 --- a/gdb/testsuite/gdb.base/cursal.c +++ b/gdb/testsuite/gdb.base/cursal.c @@ -1,4 +1,4 @@ -/* Copyright 2004-2024 Free Software Foundation, Inc. +/* Copyright 2004-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/cursal.exp b/gdb/testsuite/gdb.base/cursal.exp index 6c1fe38..04a41bc 100644 --- a/gdb/testsuite/gdb.base/cursal.exp +++ b/gdb/testsuite/gdb.base/cursal.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/cvexpr.c b/gdb/testsuite/gdb.base/cvexpr.c index 35f259a..2bd5924 100644 --- a/gdb/testsuite/gdb.base/cvexpr.c +++ b/gdb/testsuite/gdb.base/cvexpr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2024 Free Software Foundation, Inc. +/* Copyright (C) 2001-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 @@ -217,7 +217,7 @@ t_union3 v_union3; /**** Enumerations *******/ -enum +enum /* Work around the bug for compilers which don't put out the right stabs. */ #if __GNUC__ < 2 && !defined (_AIX) primary1_tag diff --git a/gdb/testsuite/gdb.base/cvexpr.exp b/gdb/testsuite/gdb.base/cvexpr.exp index 439bf71..e2f8c35 100644 --- a/gdb/testsuite/gdb.base/cvexpr.exp +++ b/gdb/testsuite/gdb.base/cvexpr.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024 Free Software Foundation, Inc. +# Copyright (C) 2001-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 @@ -517,7 +517,7 @@ foreach testspec $specs { # These tests don't rely on the debug format. with_test_prefix nodebug { - if { [prepare_for_testing "failed to prepare" $binfile $srcfile {nodebug}] } { + if { [prepare_for_testing "failed to prepare" $testfile $srcfile {nodebug}] } { return 0 } diff --git a/gdb/testsuite/gdb.base/dcache-flush.c b/gdb/testsuite/gdb.base/dcache-flush.c index 5161709..cd18a88 100644 --- a/gdb/testsuite/gdb.base/dcache-flush.c +++ b/gdb/testsuite/gdb.base/dcache-flush.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/dcache-flush.exp b/gdb/testsuite/gdb.base/dcache-flush.exp index 2d4def2..0bd034b 100644 --- a/gdb/testsuite/gdb.base/dcache-flush.exp +++ b/gdb/testsuite/gdb.base/dcache-flush.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile}] } { return -1 } -if ![runto func] { +if {![runto func]} { return -1 } diff --git a/gdb/testsuite/gdb.base/dcache-line-read-error.c b/gdb/testsuite/gdb.base/dcache-line-read-error.c index 6feb201..25f9026 100644 --- a/gdb/testsuite/gdb.base/dcache-line-read-error.c +++ b/gdb/testsuite/gdb.base/dcache-line-read-error.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 @@ -55,18 +55,18 @@ main (void) '---'---'---'---'---'---. | | | | <- line alignment ^^^^^^^ ^^^^^^^ - | | - + line1 + line2 + | | + + line1 + line2 Or: .---.---.---.---.---.---. | U | M | U | U | M | U | '---'---'---'---'---'---. - | | | <- line alignment - ^^^^^^^ ^^^^^^^ - | | - line1 + + line2 + | | | <- line alignment + ^^^^^^^ ^^^^^^^ + | | + line1 + + line2 Note we really want to test that dcache behaves correctly when reading a cache line fails. We're just using unmapped memory as diff --git a/gdb/testsuite/gdb.base/dcache-line-read-error.exp b/gdb/testsuite/gdb.base/dcache-line-read-error.exp index d10c3a4..62d561c 100644 --- a/gdb/testsuite/gdb.base/dcache-line-read-error.exp +++ b/gdb/testsuite/gdb.base/dcache-line-read-error.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile}] } { return -1 } -if ![runto breakpt] { +if {![runto breakpt]} { return -1 } @@ -45,7 +45,7 @@ proc delete_mem {} { # Make the dcache line size bigger than the pagesize. set pagesize [get_integer_valueof "pg_size" -1] -set linesize [expr $pagesize * 2] +set linesize [expr {$pagesize * 2}] gdb_test_no_output "set dcache line-size $linesize" \ "set dcache line size to twice the pagesize" diff --git a/gdb/testsuite/gdb.base/debug-expr.exp b/gdb/testsuite/gdb.base/debug-expr.exp index 838a2a5..0775d23 100644 --- a/gdb/testsuite/gdb.base/debug-expr.exp +++ b/gdb/testsuite/gdb.base/debug-expr.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -25,7 +25,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug}]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/debug-frame-2.c b/gdb/testsuite/gdb.base/debug-frame-2.c index 571b140..9a284ec 100644 --- a/gdb/testsuite/gdb.base/debug-frame-2.c +++ b/gdb/testsuite/gdb.base/debug-frame-2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/debug-frame.c b/gdb/testsuite/gdb.base/debug-frame.c index 629c309..9d419f7 100644 --- a/gdb/testsuite/gdb.base/debug-frame.c +++ b/gdb/testsuite/gdb.base/debug-frame.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/debug-frame.exp b/gdb/testsuite/gdb.base/debug-frame.exp index f928f19..eee65ae 100644 --- a/gdb/testsuite/gdb.base/debug-frame.exp +++ b/gdb/testsuite/gdb.base/debug-frame.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 @@ -23,7 +23,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfiles]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/decl-before-def-decl.c b/gdb/testsuite/gdb.base/decl-before-def-decl.c index 3b46366..507e595 100644 --- a/gdb/testsuite/gdb.base/decl-before-def-decl.c +++ b/gdb/testsuite/gdb.base/decl-before-def-decl.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/decl-before-def-def.c b/gdb/testsuite/gdb.base/decl-before-def-def.c index 1dda03b..29959b4 100644 --- a/gdb/testsuite/gdb.base/decl-before-def-def.c +++ b/gdb/testsuite/gdb.base/decl-before-def-def.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/decl-before-def.exp b/gdb/testsuite/gdb.base/decl-before-def.exp index 62e152e..4456929 100644 --- a/gdb/testsuite/gdb.base/decl-before-def.exp +++ b/gdb/testsuite/gdb.base/decl-before-def.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/default-args.c b/gdb/testsuite/gdb.base/default-args.c index eccdcfd..f78eb2a 100644 --- a/gdb/testsuite/gdb.base/default-args.c +++ b/gdb/testsuite/gdb.base/default-args.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/default-args.exp b/gdb/testsuite/gdb.base/default-args.exp index 1ddf682..e3402fd 100644 --- a/gdb/testsuite/gdb.base/default-args.exp +++ b/gdb/testsuite/gdb.base/default-args.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -25,7 +25,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} { return -1 } -clean_restart $binfile +clean_restart $testfile # Basic/core tests using user-visible commands. with_test_prefix "basics" { diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp index 93a6733..aab074c 100644 --- a/gdb/testsuite/gdb.base/default.exp +++ b/gdb/testsuite/gdb.base/default.exp @@ -1,4 +1,4 @@ -# Copyright 1988-2024 Free Software Foundation, Inc. +# Copyright 1988-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 @@ -31,14 +31,14 @@ set timeout 60 gdb_test "add-symbol-file" "add-symbol-file takes a file name and an address" # test append -gdb_test "append" "List of \"append\" subcommands:.*" -gdb_test "append binary" "List of \"append binary\" subcommands:.*" -gdb_test "append memory" "Missing filename\." -gdb_test "append value" "Missing filename\." -gdb_test "append binary memory" "Missing filename\." -gdb_test "append binary value" "Missing filename\." - -if !$use_gdb_stub { +gdb_test "append" "List of \"append\" subcommands:.*" +gdb_test "append binary" "List of \"append binary\" subcommands:.*" +gdb_test "append memory" "Missing filename\." +gdb_test "append value" "Missing filename\." +gdb_test "append binary memory" "Missing filename\." +gdb_test "append binary value" "Missing filename\." + +if {!$use_gdb_stub} { gdb_test_multiple "attach" "attach" { -re "Argument required .(process-id|program) to attach.*$gdb_prompt $"\ { pass "attach" } @@ -59,7 +59,7 @@ if !$use_gdb_stub { gdb_test $i "No default breakpoint address now." "break \"$i\" abbreviation" } - + gdb_test "backtrace" "No stack." # ba and bac are no longer unique command prefixes. So these tests @@ -148,21 +148,21 @@ gdb_test "down" "No stack.*" #test down-silently gdb_test "down-silently" "No stack." # test dump -gdb_test "dump" "List of \"dump\" subcommands:.*" -gdb_test "dump binary" "List of \"dump binary\" subcommands:.*" -gdb_test "dump ihex" "List of \"dump ihex\" subcommands:.*" -gdb_test "dump memory" "Missing filename\." -gdb_test "dump srec" "List of \"dump srec\" subcommands:.*" -gdb_test "dump tekhex" "List of \"dump tekhex\" subcommands:.*" -gdb_test "dump value" "Missing filename\." -gdb_test "dump binary memory" "Missing filename\." -gdb_test "dump binary value" "Missing filename\." -gdb_test "dump ihex memory" "Missing filename\." -gdb_test "dump ihex value" "Missing filename\." -gdb_test "dump srec memory" "Missing filename\." -gdb_test "dump srec value" "Missing filename\." -gdb_test "dump tekhex memory" "Missing filename\." -gdb_test "dump tekhex value" "Missing filename\." +gdb_test "dump" "List of \"dump\" subcommands:.*" +gdb_test "dump binary" "List of \"dump binary\" subcommands:.*" +gdb_test "dump ihex" "List of \"dump ihex\" subcommands:.*" +gdb_test "dump memory" "Missing filename\." +gdb_test "dump srec" "List of \"dump srec\" subcommands:.*" +gdb_test "dump tekhex" "List of \"dump tekhex\" subcommands:.*" +gdb_test "dump value" "Missing filename\." +gdb_test "dump binary memory" "Missing filename\." +gdb_test "dump binary value" "Missing filename\." +gdb_test "dump ihex memory" "Missing filename\." +gdb_test "dump ihex value" "Missing filename\." +gdb_test "dump srec memory" "Missing filename\." +gdb_test "dump srec value" "Missing filename\." +gdb_test "dump tekhex memory" "Missing filename\." +gdb_test "dump tekhex value" "Missing filename\." #test echo gdb_test_no_output "echo" "echo" #test enable breakpoints delete @@ -253,10 +253,39 @@ gdb_test "h" "List of classes of commands:(\[^\r\n\]*\[\r\n\])+aliases -- User-d gdb_test "help" "List of classes of commands:(\[^\r\n\]*\[\r\n\])+aliases -- User-defined aliases of other commands(\[^\r\n\]*\[\r\n\])+breakpoints -- Making program stop at certain points(\[^\r\n\]*\[\r\n\])+data -- Examining data(\[^\r\n\]*\[\r\n\])+files -- Specifying and examining files(\[^\r\n\]*\[\r\n\])+obscure -- Obscure features(\[^\r\n\]*\[\r\n\])+running -- Running the program(\[^\r\n\]*\[\r\n\])+stack -- Examining the stack(\[^\r\n\]*\[\r\n\])+status -- Status inquiries(\[^\r\n\]*\[\r\n\])+support -- Support facilities(\[^\r\n\]*\[\r\n\])+user-defined -- User-defined commands(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by a class name for a list of commands in that class.(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by command name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." #test handle gdb_test "handle" "Argument required .signal to handle.*" -#test info "i" abbreviation -gdb_test "i" "List of \"info\" subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help info\" followed by subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "info \"i\" abbreviation" + +proc test_info_command { command message } { + set saw_info_header 0 + set saw_help_info 0 + set saw_command_abbrev 0 + gdb_test_multiple $command $message -lbl { + -re "\r\nList of \"info\" subcommands:" { + verbose "Info header displayed" + set saw_info_header 1 + exp_continue + } + -re "Type \"help info\" followed by subcommand name for full documentation\\." { + verbose "Help info displayed" + set saw_help_info 1 + exp_continue + } + -re "\r\nCommand name abbreviations are allowed if unambiguous\\." { + verbose "Command name abbreviations displayed" + set saw_command_abbrev 1 + exp_continue + } + -re -wrap "" { + gdb_assert { $saw_info_header && $saw_help_info + && $saw_command_abbrev } $gdb_test_name + } + } +} + +#test info "i" abbreviation +test_info_command "i" "info \"i\" abbreviation" #test info -gdb_test "info" "List of \"info\" subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help info\" followed by subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." +test_info_command "info" "info" + #test ignore gdb_test "ignore" "Argument required .a breakpoint number.*" #test info address @@ -379,38 +408,52 @@ gdb_test "info registers" "The program has no registers now." gdb_test "info s" "No stack." "info stack \"s\" abbreviation" #test info stack gdb_test "info stack" "No stack." -#test info set -# Test improved to check three parts: -# 1) confirm -# 2) prompt -# 3) write -# And only succeed if all three are matched. -# This should fix an old problem on native solaris 2.8, -# where this test fails due to this line: + +#test "info set" and "show" commands +# The test needs to match the "prompt: ..." part to fix an old problem on native +# Solaris 2.8, where this test fails due to this line: # prompt: Gdb's prompt is "(gdb) ".^M -set set_confirm_seen 0 -set set_prompt_seen 0 -gdb_test_multiple "info set" "info set" { - -re "confirm: Whether to confirm potentially dangerous operations is o\[a-z\]*.(\[^\r\n\]*\[\r\n\])+history filename: The filename in which to record the command history is (\[^\r\n\]*\[\r\n\])+listsize: Number of source lines gdb will list by default is 10" { - verbose "Confirm dislayed" - set set_confirm_seen 1 - exp_continue - } - -re "Gdb's prompt is \"$gdb_prompt \"" { - verbose "GDB prompt displayed" - set set_prompt_seen 1 - exp_continue - } - -re "Writing into executable.*$gdb_prompt $" { - verbose "write displayed" - if { $set_prompt_seen && $set_confirm_seen } { - pass "info set" - } else { - verbose "prompt $set_prompt_seen confirm $set_confirm_seen" - fail "info set (incomplete output)" +proc test_info_set_show { command } { + set set_confirm_seen 0 + set set_history_filename_seen 0 + set set_listsize_seen 0 + set set_prompt_seen 0 + set set_write_seen 0 + gdb_test_multiple $command $command -lbl { + -re "\r\nconfirm: Whether to confirm potentially dangerous operations is o\[a-z\]+\\." { + verbose "Confirm displayed" + set set_confirm_seen 1 + exp_continue + } + -re "\r\nhistory filename: The filename in which to record the command history is \[^\r\n\]+\\." { + verbose "History filename displayed" + set set_history_filename_seen 1 + exp_continue + } + -re "\r\nlistsize: Number of source lines gdb will list by default is 10\\." { + verbose "Listsize displayed" + set set_listsize_seen 1 + exp_continue + } + -re "\r\nprompt: Gdb's prompt is \"$::gdb_prompt \"" { + verbose "GDB prompt displayed" + set set_prompt_seen 1 + exp_continue + } + -re "write: Writing into executable and core files is o\[a-z\]+\\." { + verbose "Write displayed" + set set_write_seen 1 + exp_continue + } + -re -wrap "" { + gdb_assert { $set_confirm_seen && $set_history_filename_seen + && $set_listsize_seen && $set_prompt_seen + && $set_write_seen } $gdb_test_name } } } +test_info_set_show "info set" + gdb_test "info symbol" "Argument required .address.." #test info source gdb_test "info source" "No current source file..*" @@ -484,7 +527,7 @@ gdb_test "ptype" "The history is empty." gdb_test "pwd" "Working directory .*" #test run "r" abbreviation -if $use_gdb_stub { +if {$use_gdb_stub} { # Only extended-remote supports "run". } else { gdb_test_multiple "r" "run \"r\" abbreviation" { @@ -506,7 +549,7 @@ if $use_gdb_stub { } #test run -if $use_gdb_stub { +if {$use_gdb_stub} { # Only extended-remote supports "run". } else { gdb_test_multiple "run" "run" { @@ -591,12 +634,41 @@ gdb_test "set history" "List of \"set history\" subcommands:(\[^\r\n\]*\[\r\n\]) gdb_test "set language" "Requires an argument. Valid arguments are auto, local, unknown, ada, asm, c, c.., d, fortran, go, minimal, modula-2, objective-c, opencl, pascal, rust." #test set listsize gdb_test "set listsize" "Argument required .integer to set it to.*" + +proc test_set_print { command message } { + set saw_info_header 0 + set saw_help_info 0 + set saw_command_abbrev 0 + gdb_test_multiple $command $message -lbl { + -re "\r\nList of \"set print\" subcommands:" { + verbose "Info header displayed" + set saw_info_header 1 + exp_continue + } + -re "Type \"help set print\" followed by subcommand name for full documentation\\." { + verbose "Help info displayed" + set saw_help_info 1 + exp_continue + } + -re "\r\nCommand name abbreviations are allowed if unambiguous\\." { + verbose "Command name abbreviations displayed" + set saw_command_abbrev 1 + exp_continue + } + -re -wrap "" { + gdb_assert { $saw_info_header && $saw_help_info + && $saw_command_abbrev } $gdb_test_name + } + } +} + #test set print "p" abbreviation -gdb_test "set p" "List of \"set print\" subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help set print\" followed by subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "set print \"p\" abbreviation" +test_set_print "set p" "set print \"p\" abbreviation" #test set print "pr" abbreviation -gdb_test "set pr" "List of \"set print\" subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help set print\" followed by subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "set print \"pr\" abbreviation" +test_set_print "set pr" "set print \"pr\" abbreviation" #test set print -gdb_test "set print" "List of \"set print\" subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help set print\" followed by subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." +test_set_print "set print" "set print" + #test set print address gdb_test_no_output "set print address" "set print address" #test set print array @@ -687,7 +759,6 @@ set show_conv_list \ {$_probe_arg10 = <error: No frame selected>} \ {$_probe_arg11 = <error: No frame selected>} \ {$_cimag = <internal function _cimag>} \ - {$_colorsupport = "monochrome"} \ {$_creal = <internal function _creal>} \ {$_isvoid = <internal function _isvoid>} \ {$_shell = <internal function _shell>} \ @@ -695,12 +766,12 @@ set show_conv_list \ {$_gdb_maint_setting = <internal function _gdb_maint_setting>} \ {$_gdb_setting_str = <internal function _gdb_setting_str>} \ {$_gdb_setting = <internal function _gdb_setting>} \ - {$_gdb_major = 17} \ - {$_gdb_minor = 1} \ {$_shell_exitsignal = void} \ {$_shell_exitcode = 0} \ + {$_linker_namespace_count = 0} \ + {$_linker_namespace = <error: No registers.>}\ } -if [allow_python_tests] { +if {[allow_python_tests]} { append show_conv_list \ { {$_memeq = <internal function _memeq>} \ @@ -714,10 +785,52 @@ if [allow_python_tests] { {$_any_caller_matches = <internal function _any_caller_matches>} \ } } -gdb_test_list_exact "show convenience" "show convenience" \ - "\[^\r\n\]+\[\r\n\]+" \ - "\[^\r\n\]+" \ - $show_conv_list + +set lines [gdb_get_lines_no_pass "show convenience"] +set matches 0 +set all_found 1 +foreach s $show_conv_list { + if {  $lines] } { + verbose -log "didn't match: '$s'" + set all_found 0 + break + } + incr matches +} + +set re_var [string_to_regexp {$_colorsupport}] +if { [is_remote host] } { + set re_val {[^\r\n]+} +} else { + set re_val [string_to_regexp {"monochrome"}] +} +if { [regexp "$re_var = $re_val" $lines] } { + incr matches +} else { + set all_found 0 +} + +set re_vars \ + [list \ + [string_to_regexp {$_gdb_major}] \ + [string_to_regexp {$_gdb_minor}]] +foreach re_var $re_vars { + if { [regexp "$re_var = $decimal" $lines] } { + incr matches + } else { + set all_found 0 + } +} + +if { [regexp [string_to_regexp {$_tlb = void}] $lines] } { + incr matches +} else { + # Convenience variable _tlb is added only if support for windows targets + # is enabled. Don't complain if it's missing. +} + +gdb_assert { $all_found && $matches == [count_newlines $lines] } \ + "show convenience" #test show directories gdb_test "show directories" "Source directories searched: .cdir\[:;\].cwd" @@ -739,12 +852,47 @@ gdb_test "show history" "history expansion: *History expansion on command input gdb_test "show language" "The current source language is \"auto; currently c\"." #test show listsize gdb_test "show listsize" "Number of source lines gdb will list by default is 10." + +proc test_show_print { command } { + set saw_print_address 0 + set saw_print_frame_args 0 + set saw_print_symbol 0 + set saw_print_vtbl 0 + gdb_test_multiple $command $command -lbl { + -re "\r\nprint address: Printing of addresses is o\[a-z\]+\\." { + verbose "Print address displayed" + set saw_print_address 1 + exp_continue + } + -re "\r\nprint frame-arguments: Printing of non-scalar frame arguments is \[^\r\n\]+\\." { + verbose "Print frame-arguments displayed" + set saw_print_frame_args 1 + exp_continue + } + -re "\r\nprint symbol: Printing of symbols when printing pointers is o\[a-z\]+\\." { + verbose "Print symbol displayed" + set saw_print_symbol 1 + exp_continue + } + -re "\r\nprint vtbl: Printing of C\\+\\+ virtual function tables is o\[a-z\]+\\." { + verbose "Print vtbl displayed" + set saw_print_vtbl 1 + exp_continue + } + -re -wrap "" { + gdb_assert { $saw_print_address && $saw_print_frame_args + && $saw_print_symbol && $saw_print_vtbl } $gdb_test_name + } + } +} + #test show print "p" abbreviation -gdb_test "show p" ".*" +test_show_print "show p" #test show print "pr" abbreviation -gdb_test "show pr" ".*" +test_show_print "show pr" #test show print -gdb_test "show print" ".*" +test_show_print "show print" + #test show paths gdb_test "show paths" "Executable and object file path:.*" #test show print address @@ -790,30 +938,10 @@ gdb_test "show width" "Number of characters gdb thinks are in a line is.*" #test show write # This is only supported on targets which use exec.o. gdb_test "show write" "Writing into executable and core files is o.*" + #test show -set show_confirm_seen 0 -set show_prompt_seen 0 -gdb_test_multiple "show" "show" { - -re "confirm: *Whether to confirm potentially dangerous operations is on.(\[^\r\n\]*\[\r\n\])+history filename: *The filename in which to record the command history is (\[^\r\n\]*\[\r\n\])+history save: *Saving of the history record on exit is on.(\[^\r\n\]*\[\r\n\])+history size: *The size of the command history is(\[^\r\n\]*\[\r\n\])+listsize: *Number of source lines gdb will list by default is 10(\[^\r\n]*\[\r\n\])+print elements: *Limit on string chars or array elements to print is 200." { - verbose "Confirm displayed" - set show_confirm_seen 1 - exp_continue - } - -re "Gdb's prompt is \"$gdb_prompt \"" { - verbose "GDB prompt displayed" - set show_prompt_seen 1 - exp_continue - } - -re "Writing into executable.*$gdb_prompt $" { - verbose "write displayed" - if { $show_prompt_seen && $show_confirm_seen } { - pass "show" - } else { - verbose "prompt $show_prompt_seen confirm $show_confirm_seen" - fail "show (incomplete output)" - } - } -} +test_info_set_show "show" + #history saving should stay disabled gdb_test_no_output "set history save off" "set history save off" #test stepi "si" abbreviation diff --git a/gdb/testsuite/gdb.base/define-prefix.exp b/gdb/testsuite/gdb.base/define-prefix.exp index 81d3a56..818d7fa 100644 --- a/gdb/testsuite/gdb.base/define-prefix.exp +++ b/gdb/testsuite/gdb.base/define-prefix.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -161,4 +161,3 @@ gdb_test "define-prefix something-not-existing something-else" \ gdb_test "define-prefix abc-prefix something-not-existing something-else" \ "Undefined abc-prefix command: \"something-not-existing\".*" - diff --git a/gdb/testsuite/gdb.base/define.exp b/gdb/testsuite/gdb.base/define.exp index 193eb7a..10a0644 100644 --- a/gdb/testsuite/gdb.base/define.exp +++ b/gdb/testsuite/gdb.base/define.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -71,21 +71,21 @@ gdb_test "define nextwhere" \ send_gdb "define nextwhere\n" gdb_expect { -re "Redefine command \"nextwhere\".*y or n. $"\ - {send_gdb "y\n" - gdb_expect { - -re "Type commands for definition of \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\ - {send_gdb "bt\nnext\nend\n" - gdb_expect { - -re "$gdb_prompt $"\ - {pass "redefine user command: nextwhere"} - timeout {fail "(timeout) redefine user command: nextwhere"} - } - } - timeout {fail "(timeout) redefine user command: nextwhere"} - } - } + {send_gdb "y\n" + gdb_expect { + -re "Type commands for definition of \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\ + {send_gdb "bt\nnext\nend\n" + gdb_expect { + -re "$gdb_prompt $"\ + {pass "redefine user command: nextwhere"} + timeout {fail "(timeout) redefine user command: nextwhere"} + } + } + timeout {fail "(timeout) redefine user command: nextwhere"} + } + } -re "$gdb_prompt $"\ - {fail "redefine user command: nextwhere"} + {fail "redefine user command: nextwhere"} timeout {fail "(timeout) redefine user command: nextwhere"} } @@ -165,10 +165,10 @@ gdb_test_multiple "define ifnospace" "define user command: ifnospace" \ -re "Type commands for definition of \"ifnospace\".\r\nEnd with a line saying just \"end\".\r\n>$" \ { gdb_test_multiple "if(3<4)\nprint \"hi there\\n\"\nend\nend" "send body of ifnospace" \ - { - -re "$gdb_prompt $"\ - {pass "define user command: ifnospace"} - } + { + -re "$gdb_prompt $"\ + {pass "define user command: ifnospace"} + } } } @@ -214,10 +214,10 @@ gdb_test_multiple "define whilenospace" "define user command: whilenospace" \ -re "Type commands for definition of \"whilenospace\".\r\nEnd with a line saying just \"end\".\r\n>$" \ { gdb_test_multiple "set \$i=1\nwhile(\$i<2)\nset \$i=2\nprint \"hi there\\n\"\nend\nend" "send body of whilenospace" \ - { - -re "$gdb_prompt $" \ - {pass "define user command: whilenospace"} - } + { + -re "$gdb_prompt $" \ + {pass "define user command: whilenospace"} + } } } @@ -259,23 +259,23 @@ gdb_test "define hook-bar" \ send_gdb "define hook-bar\n" gdb_expect { -re "warning: Your new `hook-bar' command does not hook any existing command.\r\nProceed.*y or n. $"\ - {send_gdb "y\n" - gdb_expect { - -re "Type commands for definition of \"hook-bar\".\r\nEnd with a line saying just \"end\".\r\n>$"\ - {send_gdb "nextwhere\nend\n" - gdb_expect { - -re "$gdb_prompt $"\ - {pass "define hook undefined command: bar"} - timeout {fail "(timeout) define hook undefined command: bar"} - } - } - -re "$gdb_prompt $"\ - {fail "define hook undefined command: bar"} - timeout {fail "(timeout) define hook undefined command: bar"} - } - } + {send_gdb "y\n" + gdb_expect { + -re "Type commands for definition of \"hook-bar\".\r\nEnd with a line saying just \"end\".\r\n>$"\ + {send_gdb "nextwhere\nend\n" + gdb_expect { + -re "$gdb_prompt $"\ + {pass "define hook undefined command: bar"} + timeout {fail "(timeout) define hook undefined command: bar"} + } + } + -re "$gdb_prompt $"\ + {fail "define hook undefined command: bar"} + timeout {fail "(timeout) define hook undefined command: bar"} + } + } -re "$gdb_prompt $"\ - {fail "define hook undefined command: bar"} + {fail "define hook undefined command: bar"} timeout {fail "(timeout) define hook undefined command: bar"} } diff --git a/gdb/testsuite/gdb.base/del.c b/gdb/testsuite/gdb.base/del.c index a567d94..c0ba6ac 100644 --- a/gdb/testsuite/gdb.base/del.c +++ b/gdb/testsuite/gdb.base/del.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2006-2024 Free Software Foundation, Inc. + Copyright 2006-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 diff --git a/gdb/testsuite/gdb.base/del.exp b/gdb/testsuite/gdb.base/del.exp index 58937de..90a1656 100644 --- a/gdb/testsuite/gdb.base/del.exp +++ b/gdb/testsuite/gdb.base/del.exp @@ -1,4 +1,4 @@ -# Copyright 2006-2024 Free Software Foundation, Inc. +# Copyright 2006-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 @@ -32,26 +32,26 @@ proc test_delete_alias { alias } { # First of all, remove all previous breakpoints if there were any, # and then verify that we do not have any breakpoint lying around. gdb_test_no_output "delete" \ - "remove all breakpoints" + "remove all breakpoints" gdb_test "info break" \ "No breakpoints, watchpoints, tracepoints, or catchpoints." \ - "info break after clearing breakpoints" + "info break after clearing breakpoints" # Now, insert a breakpoint at an easy location, and then remove it # using $alias. We verified that the removal worked by checking # the list of breakpoints. gdb_test "break -q main" \ - "Breakpoint.*at.* file .*$srcfile, line.*" \ - "breakpoint insertion" + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint insertion" gdb_test_no_output "$alias \$bpnum" \ - "Remove last breakpoint" + "Remove last breakpoint" gdb_test "info break" \ "No breakpoints, watchpoints, tracepoints, or catchpoints." \ - "info break after removing break on main" + "info break after removing break on main" } # Test various shortcut forms of the "delete" command. diff --git a/gdb/testsuite/gdb.base/detach-sysroot-target.c b/gdb/testsuite/gdb.base/detach-sysroot-target.c index b1ce99c..a21818d 100644 --- a/gdb/testsuite/gdb.base/detach-sysroot-target.c +++ b/gdb/testsuite/gdb.base/detach-sysroot-target.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/detach-sysroot-target.exp b/gdb/testsuite/gdb.base/detach-sysroot-target.exp index d4374fa..b6a9da1 100644 --- a/gdb/testsuite/gdb.base/detach-sysroot-target.exp +++ b/gdb/testsuite/gdb.base/detach-sysroot-target.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 @@ -22,7 +22,7 @@ standard_testfile -if {[prepare_for_testing "failed to prepare" ${binfile} ${srcfile}]} { +if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { return } @@ -48,7 +48,7 @@ gdb_test_multiple "show sysroot" "" { } } -if ![runto_main] { +if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/detach-while-running.c b/gdb/testsuite/gdb.base/detach-while-running.c index 9c038f4..5be97f4 100644 --- a/gdb/testsuite/gdb.base/detach-while-running.c +++ b/gdb/testsuite/gdb.base/detach-while-running.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/detach-while-running.exp b/gdb/testsuite/gdb.base/detach-while-running.exp index 4ce6c70..0082051 100644 --- a/gdb/testsuite/gdb.base/detach-while-running.exp +++ b/gdb/testsuite/gdb.base/detach-while-running.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 @@ -45,7 +45,7 @@ proc test {} { if {$is_remote} { append ::GDBFLAGS " -ex \"maint set target-non-stop on\"" } - clean_restart ${binfile} + clean_restart $::testfile } set test_spawn_id [spawn_wait_for_attach $binfile] diff --git a/gdb/testsuite/gdb.base/detach.exp b/gdb/testsuite/gdb.base/detach.exp index 99c5bf1..5338855 100644 --- a/gdb/testsuite/gdb.base/detach.exp +++ b/gdb/testsuite/gdb.base/detach.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 @@ -25,9 +25,8 @@ if { ! [istarget "*-*-linux*"] } { standard_testfile attach.c set escapedbinfile [string_to_regexp ${binfile}] -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } proc do_detach_tests {} { @@ -42,8 +41,6 @@ proc do_detach_tests {} { gdb_test "detach" "Detaching from program: .*$escapedbinfile, .*" "detach, $pass" } -clean_restart $binfile - global pass set pass "one" do_detach_tests diff --git a/gdb/testsuite/gdb.base/dfp-exprs.exp b/gdb/testsuite/gdb.base/dfp-exprs.exp index 411e4ed..adeddfb 100644 --- a/gdb/testsuite/gdb.base/dfp-exprs.exp +++ b/gdb/testsuite/gdb.base/dfp-exprs.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2007-2024 Free Software Foundation, Inc. +# Copyright (C) 2007-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 @@ -126,7 +126,7 @@ proc test_dfp_arithmetic_expressions {} { set dsuffix {"dd" "df" "dl"} foreach l $dsuffix { - foreach r $dsuffix { + foreach r $dsuffix { gdb_test "p 1.2${l} == 1.2${r}" " = 1" gdb_test "p 1.2${l} == 1.3${r}" " = 0" diff --git a/gdb/testsuite/gdb.base/dfp-test.c b/gdb/testsuite/gdb.base/dfp-test.c index 85a2ef9..7084ddd 100644 --- a/gdb/testsuite/gdb.base/dfp-test.c +++ b/gdb/testsuite/gdb.base/dfp-test.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2007-2024 Free Software Foundation, Inc. + Copyright 2007-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 @@ -121,21 +121,21 @@ struct decstruct static _Decimal32 arg0_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, - _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) { return arg0; } static _Decimal64 arg0_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, - _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) { return arg0; } static _Decimal128 arg0_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, - _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) { return arg0; } diff --git a/gdb/testsuite/gdb.base/dfp-test.exp b/gdb/testsuite/gdb.base/dfp-test.exp index c758e00..622dd29 100644 --- a/gdb/testsuite/gdb.base/dfp-test.exp +++ b/gdb/testsuite/gdb.base/dfp-test.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2007-2024 Free Software Foundation, Inc. +# Copyright (C) 2007-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 @@ -22,14 +22,10 @@ standard_testfile .c # Try to compile the test case. If we can't, assume the # toolchain does not yet provide DFP support and bail out. -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quiet debug}] != "" } { - unsupported "decimal floating point not supported for this target." - verbose "Skipping DFP tests." - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile {quiet debug}] != 0 } { + return } -clean_restart ${binfile} - if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/disabled-location.c b/gdb/testsuite/gdb.base/disabled-location.c index 0f07fe0..b89014d 100644 --- a/gdb/testsuite/gdb.base/disabled-location.c +++ b/gdb/testsuite/gdb.base/disabled-location.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2012-2024 Free Software Foundation, Inc. + Copyright (C) 2012-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 diff --git a/gdb/testsuite/gdb.base/disabled-location.exp b/gdb/testsuite/gdb.base/disabled-location.exp index c8979df..d2b16f6 100644 --- a/gdb/testsuite/gdb.base/disabled-location.exp +++ b/gdb/testsuite/gdb.base/disabled-location.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2024 Free Software Foundation, Inc. +# Copyright (C) 2012-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 diff --git a/gdb/testsuite/gdb.base/disasm-end-cu-1.c b/gdb/testsuite/gdb.base/disasm-end-cu-1.c index 7b8de8b..20c5017 100644 --- a/gdb/testsuite/gdb.base/disasm-end-cu-1.c +++ b/gdb/testsuite/gdb.base/disasm-end-cu-1.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2010-2024 Free Software Foundation, Inc. + Copyright (C) 2010-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 diff --git a/gdb/testsuite/gdb.base/disasm-end-cu-2.c b/gdb/testsuite/gdb.base/disasm-end-cu-2.c index e637d84..5857a52 100644 --- a/gdb/testsuite/gdb.base/disasm-end-cu-2.c +++ b/gdb/testsuite/gdb.base/disasm-end-cu-2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2010-2024 Free Software Foundation, Inc. + Copyright (C) 2010-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 diff --git a/gdb/testsuite/gdb.base/disasm-end-cu.exp b/gdb/testsuite/gdb.base/disasm-end-cu.exp index 6570b4c..d23876a 100644 --- a/gdb/testsuite/gdb.base/disasm-end-cu.exp +++ b/gdb/testsuite/gdb.base/disasm-end-cu.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2010-2024 Free Software Foundation, Inc. +# Copyright (C) 2010-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 @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" "disasm-end-cu" {disasm-end-cu-1.c return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } @@ -35,15 +35,15 @@ if {$main_addr == 0 || $dummy_3_addr == 0 || $dummy_3_addr <= $main_addr} { gdb_test_multiple "disassemble /m ${main_addr},${dummy_3_addr}" "disassemble address range with source" { -re "Dump of assembler code from ${main_addr} to ${dummy_3_addr}:\r\nEnd of assembler dump\." { - fail "no output from the disassemble command" + fail "no output from the disassemble command" } -re "Line number 0 out of range;.* has $decimal lines\." { - fail "the disassemble command failed" + fail "the disassemble command failed" } -re "Dump of assembler code from ${main_addr} to ${dummy_3_addr}:\r\n.*main.*End of assembler dump\." { - pass "disassemble command returned some output" + pass "disassemble command returned some output" } -re ".*$gdb_prompt $" { - fail "unexpected output from disassemble command" + fail "unexpected output from disassemble command" } } diff --git a/gdb/testsuite/gdb.base/disasm-optim.S b/gdb/testsuite/gdb.base/disasm-optim.S index caa39fe..b5202b0 100644 --- a/gdb/testsuite/gdb.base/disasm-optim.S +++ b/gdb/testsuite/gdb.base/disasm-optim.S @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2015-2024 Free Software Foundation, Inc. + Copyright (C) 2015-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 diff --git a/gdb/testsuite/gdb.base/disasm-optim.c b/gdb/testsuite/gdb.base/disasm-optim.c index 68a626f..f672d97 100644 --- a/gdb/testsuite/gdb.base/disasm-optim.c +++ b/gdb/testsuite/gdb.base/disasm-optim.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2015-2024 Free Software Foundation, Inc. + Copyright (C) 2015-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 diff --git a/gdb/testsuite/gdb.base/disasm-optim.exp b/gdb/testsuite/gdb.base/disasm-optim.exp index cded114..9b81a4c 100644 --- a/gdb/testsuite/gdb.base/disasm-optim.exp +++ b/gdb/testsuite/gdb.base/disasm-optim.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2024 Free Software Foundation, Inc. +# Copyright (C) 2015-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 @@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" $testfile ${testfile}.S {nodebug}] return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/disasm-optim.h b/gdb/testsuite/gdb.base/disasm-optim.h index 321aa38..6009e5e 100644 --- a/gdb/testsuite/gdb.base/disasm-optim.h +++ b/gdb/testsuite/gdb.base/disasm-optim.h @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2015-2024 Free Software Foundation, Inc. + Copyright (C) 2015-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 diff --git a/gdb/testsuite/gdb.base/displaced-step-closure.c b/gdb/testsuite/gdb.base/displaced-step-closure.c index 075b9ee..d45c14b 100644 --- a/gdb/testsuite/gdb.base/displaced-step-closure.c +++ b/gdb/testsuite/gdb.base/displaced-step-closure.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2023-2024 Free Software Foundation, Inc. + Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/displaced-step-closure.exp b/gdb/testsuite/gdb.base/displaced-step-closure.exp index 0929f29..bbdd207 100644 --- a/gdb/testsuite/gdb.base/displaced-step-closure.exp +++ b/gdb/testsuite/gdb.base/displaced-step-closure.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 @@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/display.c b/gdb/testsuite/gdb.base/display.c index 67f205a..c62d250 100644 --- a/gdb/testsuite/gdb.base/display.c +++ b/gdb/testsuite/gdb.base/display.c @@ -17,12 +17,12 @@ int do_loops() int *p_i = &i; for( i = 0; i < LOOP; i++ ) { /* set breakpoint 1 here */ - for( j = 0; j < LOOP; j++ ) { - for( k = 0; k < LOOP; k++ ) { - sum++; f++; force_mem (&k); - } - } - } + for( j = 0; j < LOOP; j++ ) { + for( k = 0; k < LOOP; k++ ) { + sum++; f++; force_mem (&k); + } + } + } return i; /* set breakpoint 2 here */ } @@ -39,12 +39,12 @@ int do_vars() /* Need some code here to set breaks on. */ for( j = 0; j < LOOP; j++ ) { - if( p_c[j] == c ) { /* set breakpoint 3 here */ - j++; - } - else { - i++; - } + if( p_c[j] == c ) { /* set breakpoint 3 here */ + j++; + } + else { + i++; + } } return *p_i; @@ -54,6 +54,6 @@ int main() { do_loops(); - do_vars(); + do_vars(); return 0; } diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp index 9964c23..4138367 100644 --- a/gdb/testsuite/gdb.base/display.exp +++ b/gdb/testsuite/gdb.base/display.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -35,7 +35,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile \ # Preserve the old timeout, and set a new one that should be # sufficient to avoid timing out during this test. set oldtimeout $timeout -set timeout [expr "$timeout + 60"] +set timeout [expr {$timeout + 60}] verbose "Timeout is now $timeout seconds" 2 # use this to debug: @@ -43,7 +43,7 @@ verbose "Timeout is now $timeout seconds" 2 # Some coverage stuff # -if !$use_gdb_stub { +if {!$use_gdb_stub} { gdb_test "kill" ".*The program is not being run.*" gdb_test "detach" ".*" gdb_test "run" ".*" @@ -52,7 +52,7 @@ if !$use_gdb_stub { gdb_test "kill" ".*" "kill again" gdb_test "detach" ".*" "detach again" - clean_restart $binfile + clean_restart $testfile } # Ok, on to real life diff --git a/gdb/testsuite/gdb.base/dlmopen-lib-dep.c b/gdb/testsuite/gdb.base/dlmopen-lib-dep.c index 1645f55..f981bea 100644 --- a/gdb/testsuite/gdb.base/dlmopen-lib-dep.c +++ b/gdb/testsuite/gdb.base/dlmopen-lib-dep.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/dlmopen-lib.c b/gdb/testsuite/gdb.base/dlmopen-lib.c index 4ce9280..36ccbf02 100644 --- a/gdb/testsuite/gdb.base/dlmopen-lib.c +++ b/gdb/testsuite/gdb.base/dlmopen-lib.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/dlmopen-main.c b/gdb/testsuite/gdb.base/dlmopen-main.c index 196d13a..cf82a69 100644 --- a/gdb/testsuite/gdb.base/dlmopen-main.c +++ b/gdb/testsuite/gdb.base/dlmopen-main.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/gdbindex-stabs-dwarf.c b/gdb/testsuite/gdb.base/dlmopen-ns-ids-lib.c index 0e17dc1..86cbb0f 100644 --- a/gdb/testsuite/gdb.base/gdbindex-stabs-dwarf.c +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids-lib.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + 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 @@ -13,13 +13,16 @@ 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/>. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. -extern void stabs_function (void); +*/ +int gdb_dlmopen_glob = 0; + +__attribute__((visibility ("default"))) int -main (void) +inc (int n) { - stabs_function (); - return 0; + int amount = gdb_dlmopen_glob; + return n + amount; /* bp.inc. */ } diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids-main.c b/gdb/testsuite/gdb.base/dlmopen-ns-ids-main.c new file mode 100644 index 0000000..c7c038a --- /dev/null +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids-main.c @@ -0,0 +1,60 @@ +/* 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/>. + +*/ + +#define _GNU_SOURCE +#include <dlfcn.h> +#include <stddef.h> +#include <assert.h> +#include <unistd.h> +#include <stdio.h> + +int +main (void) +{ + void *handle[4]; + int (*fun) (int); + Lmid_t lmid; + int dl; + + handle[0] = dlmopen (LM_ID_NEWLM, DSO_NAME, RTLD_LAZY | RTLD_LOCAL); + assert (handle[0] != NULL); + + handle[1] = dlmopen (LM_ID_NEWLM, DSO_NAME, RTLD_LAZY | RTLD_LOCAL); + assert (handle[1] != NULL); + + handle[2] = dlmopen (LM_ID_NEWLM, DSO_NAME, RTLD_LAZY | RTLD_LOCAL); + assert (handle[2] != NULL); + + for (dl = 2; dl >= 0; dl--) + { + fun = dlsym (handle[dl], "inc"); + fun (dl); + } + + dlclose (handle[0]); /* TAG: first dlclose */ + dlclose (handle[1]); /* TAG: second dlclose */ + dlclose (handle[2]); /* TAG: third dlclose */ + + handle[3] = dlmopen (LM_ID_NEWLM, DSO_NAME, RTLD_LAZY | RTLD_LOCAL); + dlinfo (handle[3], RTLD_DI_LMID, &lmid); + + dlclose (handle[3]); /* TAG: fourth dlclose */ + + return 0; +} diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp new file mode 100644 index 0000000..008f060 --- /dev/null +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp @@ -0,0 +1,316 @@ +# 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/>. +# +# +# Test several things related to handling linker namespaces: +# * That the user-facing namespace ID is consistent; + +require allow_dlmopen_tests + +standard_testfile -main.c -lib.c + +set srcfile_lib $srcfile2 +set so_name dlmopen-lib.so +set binfile_lib [standard_output_file $so_name] + +if { [build_executable "build shlib" $binfile_lib $srcfile_lib \ + [list debug shlib]] == -1 } { + return +} + +if { [build_executable "failed to build" $testfile $srcfile \ + [list additional_flags=-DDSO_NAME=\"$binfile_lib\" \ + shlib_load debug]] } { + return +} + +# Return a list of shared libraries extract from the "info sharedlibrary" +# command. Each item in the list is itself a list with the following items: +# +# - "from" address +# - "to" address +# - namespace ID +# - name (file path) + +proc get_info_shared {} { + set from_re "($::hex)\\s+" + set to_re "($::hex)\\s+" + set ns_re "(?:($::decimal)\\s+)?" + set syms_read_re "(Yes( \\(\\*\\))?|No)\\s+" + set name_re "(\[^\r\n\]+)" + set libs {} + + gdb_test_multiple "info sharedlibrary" "" { + -re {From\s+To\s+(Linker NS\s+)?Syms Read\s+Shared Object Library\r\n} { + exp_continue + } + + -re "^${from_re}${to_re}${ns_re}${syms_read_re}${name_re}\r\n" { + set from $expect_out(1,string) + set to $expect_out(2,string) + set ns $expect_out(3,string) + set name $expect_out(4,string) + + lappend libs [list $from $to $ns $name] + exp_continue + } + + -re {^\(\*\): Shared library is missing debugging information\.\r\n} { + exp_continue + } + + -re "^$::gdb_prompt " { + pass $gdb_test_name + } + } + + return $libs +} + +# Verify that "info sharedlibrary" does not contain duplicate entries. + +proc check_no_duplicates {} { + with_test_prefix "check no duplicates" { + set libs [get_info_shared] + array set seen {} + set seen_duplicate 0 + + foreach lib $libs { + if {[info exists seen($lib)]} { + verbose -log "already seen: $lib" + set seen_duplicate 1 + } + + set seen($lib) 1 + } + + gdb_assert {!$seen_duplicate} "no duplicates" + } +} + +# Run the command "info sharedlibrary" and get the first namespace +# for the so +proc get_first_so_ns {} { + set ns -1 + set lib_regexp [string_to_regexp ${::binfile_lib}] + gdb_test_multiple "info sharedlibrary $::so_name" "get SO namespace" -lbl { + -re "\r\nFrom\\s+To\\s+\(Linker NS\\s+\)?Syms\\s+Read\\s+Shared Object Library(?=\r\n)" { + exp_continue + } + -re "\r\n$::hex\\s+$::hex\\s+($::decimal)\\s+\[^\r\n]+${lib_regexp}(?=\r\n)" { + if {$ns == -1} { + set ns $expect_out(1,string) + } + exp_continue + } + -re -wrap "" { + } + } + return $ns +} + +# Run the tests relating to the command "info sharedlibrary", to +# verify that the namespace ID is consistent. +proc test_info_shared {} { + clean_restart $::testfile + + if { ![runto_main] } { + return + } + + # First test that we don't print a namespace column at the start. + gdb_test "info sharedlibrary" \ + "From\\s+To\\s+Syms\\s+Read\\s+Shared Object Library.*" \ + "before loading anything" + + gdb_breakpoint [gdb_get_line_number "TAG: first dlclose"] + gdb_continue_to_breakpoint "TAG: first dlclose" + + # Next, test that we *do* print a namespace column after loading SOs. + gdb_test "info sharedlibrary" \ + "From\\s+To\\s+Linker NS\\s+Syms\\s+Read\\s+Shared Object Library.*" \ + "after loading everything" + + check_no_duplicates + + gdb_assert {[get_first_so_ns] == 1} "before closing any library" + + gdb_test "next" ".*second dlclose.*" "close first library" + gdb_assert {[get_first_so_ns] == 2} "after closing one library" + + gdb_test "next" ".*third dlclose.*" "close second library" + gdb_assert {[get_first_so_ns] == 3} "before closing two libraries" + + gdb_breakpoint [gdb_get_line_number "TAG: fourth dlclose"] + gdb_continue_to_breakpoint "TAG: fourth dlclose" + # As of writing this test, glibc's LMID is just an index on an array of + # namespaces. After closing a namespace, requesting a new one will + # return the index of the lowest-closed namespace, so this will likely + # be namespace 1, and because of glibc's reuse of the r_debug object, + # GDB should be able to assign the same number. + gdb_assert {[get_first_so_ns] == [get_integer_valueof "lmid" "-1"]} \ + "reopen a namespace" + + gdb_test "next" ".*return 0.*" "final namespace inactive" + gdb_test "info sharedlibrary" \ + "From\\s+To\\s+Syms\\s+Read\\s+Shared Object Library.*" \ + "after unloading everything" +} + +# Run all tests related to the linkage namespaces convenience +# variables, _active_namespaces and _current_namespaces. +# Also tests that the namespace ID is only printed at the correct +# times. +proc_with_prefix test_conv_vars {} { + clean_restart $::testfile + + gdb_test "print \$_linker_namespace_count" "0" \ + "0 namespace before starting inferior" + gdb_test "print \$_linker_namespace" "No registers." \ + "No current namespace before starting inferior" + + if { ![runto_main] } { + return + } + + gdb_test "print \$_linker_namespace_count" "1" \ + "Before activating namespaces" + gdb_test "print \$_linker_namespace" ".* = 0" \ + "Still in the default namespace" + + gdb_breakpoint "inc" allow-pending + gdb_breakpoint [gdb_get_line_number "TAG: first dlclose"] + + foreach_with_prefix dl {3 2 1} { + gdb_continue_to_breakpoint "inc" + + gdb_test "print \$_linker_namespace" ".* = $dl" \ + "Verify we're in namespace $dl" + } + + # Check that we display the namespace of the selected + # frame, not the lowermost one. + gdb_test "up" "\#1.*in main.*" + gdb_test "print \$_linker_namespace" ".* = 0" \ + "print namespace of selected frame" + + gdb_continue_to_breakpoint "first dlclose" + gdb_test "print \$_linker_namespace_count" "4" "all SOs loaded" + + gdb_test "next" ".*second dlclose.*" "close one SO" + gdb_test "print \$_linker_namespace_count" "3" "one SOs unloaded" + gdb_test "next" ".*third dlclose.*" "close another SO" + gdb_test "print \$_linker_namespace_count" "2" "two SOs unloaded" + + # Restarting GDB so that we can test setting a breakpoint + # using the convenience variable, while a proper bp syntax + # isn't implemented for namespaces + clean_restart $::testfile + if {![runto_main]} { + return + } + + # We need to load one SO because you can't have confitional + # breakpoints and pending breakpoints at the same time with + # gdb_breakpoint. + gdb_test "next" ".*assert.*" "load the first SO" + gdb_breakpoint "inc if \$_linker_namespace == 2" + gdb_continue_to_breakpoint "inc" + gdb_continue_to_end "" continue 1 +} + +# Run several tests relating to the command "info namespaces". +proc test_info_linker_namespaces {} { + clean_restart $::testfile + + # Check that "info linker-namespaces" while the inferior is not running + # doesn't crash. + gdb_test "info linker-namespaces" \ + "Current inferior does not support linker namespaces\\. Use \"info sharedlibrary\" instead\\." \ + "info linker-namespaces before running" + + if { ![runto_main] } { + return + } + + with_test_prefix "info linker-namespaces" { + gdb_breakpoint [gdb_get_line_number "TAG: first dlclose"] + gdb_continue_to_breakpoint "TAG: first dlclose" + } + + # First, test printing a single namespace, and ensure all of + # them are correct, using both syntaxes. + set n_libraries 999 + + gdb_test_multiple "info linker-namespaces \[\[0\]\]" "print namespace 0" { + -re -wrap "($::decimal) librar(?:y|ies) loaded in linker namespace 0:.*" { + set n_libraries $expect_out(1,string) + } + } + + # Some systems may add libc and libm to every loaded namespace, + # others may load only one or neither, because the SO doesn't + # actually use either library. The best we can do is check if + # we found the dynamic linker, and up to 2 more libraries. + gdb_assert {$n_libraries <= 3} "the correct number of libraries was reported" + + set binfile_lib_re [string_to_regexp $::binfile_lib] + + foreach_with_prefix ns {1 2 3} { + set found_test_so false + set n_libraries 999 + + gdb_test_multiple "info linker-namespaces $ns" "print namespace $ns" { + -re ".*($::decimal) librar(?:y|ies) loaded in linker namespace $ns:\r\n" { + set n_libraries $expect_out(1,string) + exp_continue + } + + -re -wrap "${binfile_lib_re}.*" { + set found_test_so true + } + } + + # Some systems may add libc and libm to every loaded namespace, + # others may load only one or neither, because the SO doesn't + # actually use either library. The best we can do is check if + # we found the dynamic linker, the test SO, and maybe up to 2 + # more libraries. + gdb_assert {$n_libraries <= 4} "the correct number of libraries was reported" + gdb_assert {$found_test_so} "this testfile's SO was reported" + } + + # These patterns are simpler, and purposefully glob multiple lines. + # The point is to ensure that we find and display all the namespaces, + # without worrying about the libraries printed, since that was tested + # above. + gdb_test "info linker-namespaces" \ + [multi_line "There are 4 linker namespaces loaded\\." \ + "" \ + "$::decimal librar(y|ies) loaded in linker namespace 0:" \ + ".*" \ + "$::decimal librar(y|ies) loaded in linker namespace 1:" \ + ".*" \ + "$::decimal librar(y|ies) loaded in linker namespace 2:" \ + ".*" \ + "$::decimal librar(y|ies) loaded in linker namespace 3:" \ + ".*" ] "print namespaces with no argument" +} + +test_info_shared +test_conv_vars +test_info_linker_namespaces diff --git a/gdb/testsuite/gdb.base/dlmopen.exp b/gdb/testsuite/gdb.base/dlmopen.exp index a8e3b08..3cc4282 100644 --- a/gdb/testsuite/gdb.base/dlmopen.exp +++ b/gdb/testsuite/gdb.base/dlmopen.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. # -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 @@ -95,9 +95,19 @@ if { $dyln_name eq "" } { return } +# If the dynamic linker path contains a symlink, some instances show the real +# path instead of the original path. Accept both. +lassign [remote_exec target realpath "$dyln_name"] realpath_ret dyln_realpath_name + +if { $realpath_ret == 0 } { + set dyln_realpath_name [string trim $dyln_realpath_name] +} else { + set dyln_realpath_name "not-a-valid-path" +} + # Return true if FILENAME is the dynamic linker. Otherwise return false. proc is_dyln { filename } { - return [expr {$filename eq $::dyln_name}] + return [expr {$filename eq $::dyln_name || $filename eq $::dyln_realpath_name}] } # Check that 'info shared' show NUM occurrences of DSO. @@ -106,9 +116,9 @@ proc check_dso_count { dso num } { set count 0 gdb_test_multiple "info shared" "info shared" { - -re "$hex $hex Yes \[^\r\n\]*$dso\r\n" { + -re "$hex $hex \($::decimal\\s+\)\?Yes \[^\r\n\]*$dso\r\n" { # use longer form so debug remote does not interfere - set count [expr $count + 1] + set count [expr {$count + 1}] exp_continue } -re "$gdb_prompt " { @@ -173,7 +183,7 @@ proc test_dlmopen {} { # Setup for calling 'test_dlmopen', this is the version of the test # that doesn't use 'attach'. proc test_dlmopen_no_attach {} { - clean_restart $::binfile + clean_restart $::testfile if { ![runto_main] } { return @@ -198,7 +208,7 @@ proc test_dlmopen_with_attach {} { return } - clean_restart $::binfile + clean_restart $::testfile # Start the test program. set test_spawn_id [spawn_wait_for_attach $::binfile] @@ -233,12 +243,12 @@ proc get_dyld_info {} { set dyld_count 0 set dyld_start_addr "" gdb_test_multiple "info sharedlibrary" "" { - -re "From\\s+To\\s+Syms\\s+Read\\s+Shared Object Library\r\n" { + -re "From\\s+To\\s+\(Linker NS\\s+\)?Syms\\s+Read\\s+Shared Object Library\r\n" { exp_continue } - -re "^($::hex)\\s+$::hex\\s+\[^/\]+(/\[^\r\n\]+)\r\n" { + -re "^($::hex)\\s+$::hex\\s+\(\#$::decimal\\s+\)?\[^/\]+(/\[^\r\n\]+)\r\n" { set addr $expect_out(1,string) - set lib $expect_out(2,string) + set lib $expect_out(3,string) if { [is_dyln $lib] } { # This looks like it might be the dynamic linker. @@ -288,7 +298,7 @@ proc_with_prefix test_solib_unmap_events { } { return } - clean_restart $::binfile + clean_restart $::testfile if { ![runto_main] } { return @@ -358,15 +368,19 @@ proc_with_prefix test_solib_unmap_events { } { # dynamic linker as pending when some instances of the library were # unloaded, despite there really only being one copy of the dynamic # linker actually loaded into the inferior's address space. - gdb_test_multiple "info breakpoints $bpnum" "check b/p status" { - -re -wrap "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+<PENDING>\\s+\\*$::hex\\s*\r\n\\s+stop only if \\(0\\)" { - fail $gdb_test_name - } - - -re -wrap "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+$::hex\\s*\[^\r\n\]+\r\n\\s+stop only if \\(0\\)" { - pass $gdb_test_name - } - } + set hs {[^\r\n]} + set re_pass \ + [multi_line \ + "" \ + [join \ + [list \ + "$bpnum" "breakpoint" "keep" "y" "$::hex$hs+"] \ + {\s+}] \ + [string cat \ + {\s+} \ + [string_to_regexp "stop only if (0)"] \ + ([string_to_regexp " (target evals)"])?]] + gdb_test "info breakpoints $bpnum" $re_pass "check b/p status" # With all the dlclose calls now complete, we should be back to a # single copy of the dynamic linker. @@ -379,7 +393,7 @@ proc_with_prefix test_solib_unmap_events { } { # Check that we can 'next' over the dlclose calls without GDB giving any # warnings or errors. proc_with_prefix test_next_over_dlclose {} { - clean_restart $::binfile + clean_restart $::testfile if { ![runto_main] } { return diff --git a/gdb/testsuite/gdb.base/dmsym.c b/gdb/testsuite/gdb.base/dmsym.c index ad92ed2..6b13ed2 100644 --- a/gdb/testsuite/gdb.base/dmsym.c +++ b/gdb/testsuite/gdb.base/dmsym.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/dmsym.exp b/gdb/testsuite/gdb.base/dmsym.exp index a806845..ceef724 100644 --- a/gdb/testsuite/gdb.base/dmsym.exp +++ b/gdb/testsuite/gdb.base/dmsym.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2024 Free Software Foundation, Inc. +# Copyright (C) 2011-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 @@ -24,8 +24,8 @@ set testfile dmsym_main set dmsym_o [standard_output_file dmsym.o] if {[gdb_compile "${srcdir}/${subdir}/dmsym.c" \ - $dmsym_o \ - object {}] != ""} { + $dmsym_o \ + object {}] != ""} { untested "failed to compile object file" return -1 } @@ -51,13 +51,13 @@ set addr "0x\[0-9a-zA-Z\]+" # should not be used for breakpoint purposes. gdb_test "break test_minsym" \ - "Breakpoint $num at $addr.: file .*dmsym_main\\.c, line $num\\." + "Breakpoint $num at $addr.: file .*dmsym_main\\.c, line $num\\." # However, verify that the `info line' command, on the other hand, # finds both locations. gdb_test "info line test_minsym" \ - "Line $num of \".*dmsym_main\\.c\" .*\r\nNo line number information available for address $addr <test_minsym>" + "Line $num of \".*dmsym_main\\.c\" .*\r\nNo line number information available for address $addr <test_minsym>" # Now, run the program until we get past the call to test_minsym. # Except when using hardware breakpoints, inferior behavior is going @@ -68,11 +68,11 @@ gdb_breakpoint dmsym_main.c:[gdb_get_line_number "BREAK" dmsym_main.c] gdb_run_cmd gdb_test "" \ - "Breakpoint $num, test_minsym \\(\\) at.*" \ - "run until breakpoint at BREAK" + "Breakpoint $num, test_minsym \\(\\) at.*" \ + "run until breakpoint at BREAK" gdb_test "continue" \ - "Breakpoint $num, main \\(\\) at.*" + "Breakpoint $num, main \\(\\) at.*" gdb_test "print val" \ - " = 124" + " = 124" diff --git a/gdb/testsuite/gdb.base/dmsym_main.c b/gdb/testsuite/gdb.base/dmsym_main.c index 97ee31b..f2f67c0 100644 --- a/gdb/testsuite/gdb.base/dmsym_main.c +++ b/gdb/testsuite/gdb.base/dmsym_main.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 @@ -32,5 +32,3 @@ main (void) return 1; return 0; } - - diff --git a/gdb/testsuite/gdb.base/document.exp b/gdb/testsuite/gdb.base/document.exp index 8a5e7d0..1d7b9b2 100644 --- a/gdb/testsuite/gdb.base/document.exp +++ b/gdb/testsuite/gdb.base/document.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 diff --git a/gdb/testsuite/gdb.base/dprintf-bp-same-addr.c b/gdb/testsuite/gdb.base/dprintf-bp-same-addr.c index bbd8a57..be48418 100644 --- a/gdb/testsuite/gdb.base/dprintf-bp-same-addr.c +++ b/gdb/testsuite/gdb.base/dprintf-bp-same-addr.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2014-2024 Free Software Foundation, Inc. + Copyright (C) 2014-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 diff --git a/gdb/testsuite/gdb.base/dprintf-bp-same-addr.exp b/gdb/testsuite/gdb.base/dprintf-bp-same-addr.exp index b2c9557..9b23338 100644 --- a/gdb/testsuite/gdb.base/dprintf-bp-same-addr.exp +++ b/gdb/testsuite/gdb.base/dprintf-bp-same-addr.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -17,20 +17,20 @@ standard_testfile -if [build_executable "failed to prepare" \ - ${testfile} ${srcfile} {debug}] { +if {[build_executable "failed to prepare" \ + ${testfile} ${srcfile} {debug}]} { return -1 } set dp_location [gdb_get_line_number "set dprintf here"] proc test { style } { - global gdb_prompt binfile dp_location + global gdb_prompt dp_location with_test_prefix "$style" { - clean_restart $binfile + clean_restart $::testfile - if ![runto_main] { + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/dprintf-detach.c b/gdb/testsuite/gdb.base/dprintf-detach.c index 97ea4ed..15481c2 100644 --- a/gdb/testsuite/gdb.base/dprintf-detach.c +++ b/gdb/testsuite/gdb.base/dprintf-detach.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/dprintf-detach.exp b/gdb/testsuite/gdb.base/dprintf-detach.exp index b4184d6..be8a410 100644 --- a/gdb/testsuite/gdb.base/dprintf-detach.exp +++ b/gdb/testsuite/gdb.base/dprintf-detach.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -26,24 +26,24 @@ require can_spawn_for_attach standard_testfile set escapedbinfile [string_to_regexp ${binfile}] -if [build_executable "failed to prepare for dprintf-detach" \ - ${testfile} ${srcfile} {debug}] { +if {[build_executable "failed to prepare for dprintf-detach" \ + ${testfile} ${srcfile} {debug}]} { return -1 } proc dprintf_detach_test { breakpoint_always_inserted dprintf_style disconnected_dprintf } { set test_prefix "bai=${breakpoint_always_inserted} ds=${dprintf_style} dd=${disconnected_dprintf}" - global binfile decimal gdb_prompt escapedbinfile + global decimal gdb_prompt escapedbinfile with_test_prefix "$test_prefix" { # Start with a clean gdb - clean_restart ${binfile} + clean_restart $::testfile gdb_test_no_output "set breakpoint always-inserted ${breakpoint_always_inserted}" gdb_test_no_output "set dprintf-style ${dprintf_style}" gdb_test_no_output "set disconnected-dprintf ${disconnected_dprintf}" - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -68,7 +68,7 @@ proc dprintf_detach_test { breakpoint_always_inserted dprintf_style disconnected gdb_exit # Check that the process still exists by attaching a new gdb to it. - clean_restart ${binfile} + clean_restart $::testfile set test "re-attach to inferior" set is_gdbserver [target_is_gdbserver] diff --git a/gdb/testsuite/gdb.base/dprintf-execution-x-script.c b/gdb/testsuite/gdb.base/dprintf-execution-x-script.c index f8ad58f..610e354 100644 --- a/gdb/testsuite/gdb.base/dprintf-execution-x-script.c +++ b/gdb/testsuite/gdb.base/dprintf-execution-x-script.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp b/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp index 12de3ae..a544b42 100644 --- a/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp +++ b/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 @@ -93,7 +93,7 @@ do_test "" $test # Restart GDB and 'source' the script; this will (still) run the program # due to the 'run' command in the script. -clean_restart $binfile +clean_restart $testfile do_test "source $x_file" "load and run script using source command" # This should leave us at the gdb prompt; Run program again using diff --git a/gdb/testsuite/gdb.base/dprintf-execution-x-script.gdb b/gdb/testsuite/gdb.base/dprintf-execution-x-script.gdb index 433c0ca..cf6ed0e 100644 --- a/gdb/testsuite/gdb.base/dprintf-execution-x-script.gdb +++ b/gdb/testsuite/gdb.base/dprintf-execution-x-script.gdb @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/dprintf-next.c b/gdb/testsuite/gdb.base/dprintf-next.c index ffcdd73..74f6c42 100644 --- a/gdb/testsuite/gdb.base/dprintf-next.c +++ b/gdb/testsuite/gdb.base/dprintf-next.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2013-2024 Free Software Foundation, Inc. + Copyright (C) 2013-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 diff --git a/gdb/testsuite/gdb.base/dprintf-next.exp b/gdb/testsuite/gdb.base/dprintf-next.exp index b276394..d8ba03d 100644 --- a/gdb/testsuite/gdb.base/dprintf-next.exp +++ b/gdb/testsuite/gdb.base/dprintf-next.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 @@ -19,12 +19,12 @@ set expfile $testfile.exp set dp_location [gdb_get_line_number "Set dprintf here"] -if [prepare_for_testing "failed to prepare for dprintf with next" \ - ${testfile} ${srcfile} {debug}] { +if {[prepare_for_testing "failed to prepare for dprintf with next" \ + ${testfile} ${srcfile} {debug}]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/dprintf-non-stop.c b/gdb/testsuite/gdb.base/dprintf-non-stop.c index e804977..58c785c 100644 --- a/gdb/testsuite/gdb.base/dprintf-non-stop.c +++ b/gdb/testsuite/gdb.base/dprintf-non-stop.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2013-2024 Free Software Foundation, Inc. + Copyright (C) 2013-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 diff --git a/gdb/testsuite/gdb.base/dprintf-non-stop.exp b/gdb/testsuite/gdb.base/dprintf-non-stop.exp index 7c6365a..538f703 100644 --- a/gdb/testsuite/gdb.base/dprintf-non-stop.exp +++ b/gdb/testsuite/gdb.base/dprintf-non-stop.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2024 Free Software Foundation, Inc. +# Copyright (C) 2013-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 @@ -16,8 +16,8 @@ standard_testfile set executable ${testfile} -if [build_executable "failed to prepare for dprintf with non-stop" \ - ${testfile} ${srcfile} {debug}] { +if {[build_executable "failed to prepare for dprintf with non-stop" \ + ${testfile} ${srcfile} {debug}]} { return -1 } @@ -26,7 +26,7 @@ save_vars { GDBFLAGS } { clean_restart ${executable} } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/dprintf-pending.c b/gdb/testsuite/gdb.base/dprintf-pending.c index e246e88..2180dd2 100644 --- a/gdb/testsuite/gdb.base/dprintf-pending.c +++ b/gdb/testsuite/gdb.base/dprintf-pending.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/dprintf-pending.exp b/gdb/testsuite/gdb.base/dprintf-pending.exp index 528dd10..a0630b5 100644 --- a/gdb/testsuite/gdb.base/dprintf-pending.exp +++ b/gdb/testsuite/gdb.base/dprintf-pending.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 @@ -48,7 +48,7 @@ with_test_prefix "without symbols" { "y" gdb_test "info break" \ - "Num Type\[ \]+Disp Enb Address\[ \]+What.* + "Num Type\[ \]+Disp Enb Address\[ \]+What.* \[0-9\]+\[\t \]+dprintf.*keep y.*PENDING.*pendfunc1.*" \ "single pending dprintf info" @@ -60,7 +60,7 @@ with_test_prefix "without symbols" { gdb_test "" ".*x=3.*x=4.*x=3.*" "run to resolved dprintf" } -clean_restart ${binfile} +clean_restart $testfile gdb_load_shlib $lib_sl # diff --git a/gdb/testsuite/gdb.base/dprintf-pendshr.c b/gdb/testsuite/gdb.base/dprintf-pendshr.c index 6fcbc03..89797c2 100644 --- a/gdb/testsuite/gdb.base/dprintf-pendshr.c +++ b/gdb/testsuite/gdb.base/dprintf-pendshr.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/dprintf.c b/gdb/testsuite/gdb.base/dprintf.c index eebbfb3..f6d1e3d 100644 --- a/gdb/testsuite/gdb.base/dprintf.c +++ b/gdb/testsuite/gdb.base/dprintf.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2012-2024 Free Software Foundation, Inc. + Copyright (C) 2012-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 diff --git a/gdb/testsuite/gdb.base/dprintf.exp b/gdb/testsuite/gdb.base/dprintf.exp index 649126f..d6f7781 100644 --- a/gdb/testsuite/gdb.base/dprintf.exp +++ b/gdb/testsuite/gdb.base/dprintf.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2024 Free Software Foundation, Inc. +# Copyright (C) 2012-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 @@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile $flags] } { set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] set dp_location1 [gdb_get_line_number "set dprintf 1 here"] -if ![runto_main] { +if {![runto_main]} { return -1 } @@ -71,12 +71,11 @@ gdb_test "continue" "At foo entry.*arg=1235, g=2222.*" "2nd dprintf, gdb" # Restart GDB and set set up for testing. proc restart {} { - global binfile global bp_location1 dp_location1 - clean_restart $binfile + clean_restart $::testfile - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -99,7 +98,6 @@ proc test_dprintf {pattern msg} { # Test the "call" style. proc test_call {} { - global binfile global bp_location1 # Now switch styles and rerun; in the absence of redirection the @@ -141,7 +139,7 @@ proc test_call {} { # The "call" style depends on having I/O functions available. -if ![target_info exists gdb,noinferiorio] { +if {![target_info exists gdb,noinferiorio]} { with_test_prefix "call" { test_call } @@ -150,7 +148,6 @@ if ![target_info exists gdb,noinferiorio] { # Test the "agent" style. proc test_agent {} { - global binfile global gdb_prompt restart @@ -170,7 +167,7 @@ proc test_agent {} { } } - if !$target_can_dprintf { + if {!$target_can_dprintf} { return } @@ -190,7 +187,7 @@ proc test_agent {} { } } - if $target_can_dprintf { + if {$target_can_dprintf} { gdb_test "continue" "Breakpoint \[0-9\]+, foo .*" "2nd dprintf" gdb_test_sequence "info breakpoints" "dprintf info" { @@ -217,7 +214,7 @@ gdb_test "set dprintf-style foobar" "Undefined item: \"foobar\"." \ # Test that force-disabling the BreakpointCommands RSP feature works # as expected. dprintf relies on support for target-side breakpoint # commands --- use it as proxy. -if [gdb_protocol_is_remote] { +if {[gdb_protocol_is_remote]} { gdb_test \ "set remote breakpoint-commands-packet off" \ "Support for the 'BreakpointCommands' packet on the current remote target is set to \"off\"." diff --git a/gdb/testsuite/gdb.base/dso2dso-dso1.c b/gdb/testsuite/gdb.base/dso2dso-dso1.c index 8b1619d..c51d196 100644 --- a/gdb/testsuite/gdb.base/dso2dso-dso1.c +++ b/gdb/testsuite/gdb.base/dso2dso-dso1.c @@ -1,4 +1,4 @@ -/* Copyright 2015-2024 Free Software Foundation, Inc. +/* Copyright 2015-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/dso2dso-dso1.h b/gdb/testsuite/gdb.base/dso2dso-dso1.h index 74920834..4a4144c 100644 --- a/gdb/testsuite/gdb.base/dso2dso-dso1.h +++ b/gdb/testsuite/gdb.base/dso2dso-dso1.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2024 Free Software Foundation, Inc. +/* Copyright 2015-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/dso2dso-dso2.c b/gdb/testsuite/gdb.base/dso2dso-dso2.c index 5dc6591..1b30c5c 100644 --- a/gdb/testsuite/gdb.base/dso2dso-dso2.c +++ b/gdb/testsuite/gdb.base/dso2dso-dso2.c @@ -1,4 +1,4 @@ -/* Copyright 2015-2024 Free Software Foundation, Inc. +/* Copyright 2015-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/dso2dso-dso2.h b/gdb/testsuite/gdb.base/dso2dso-dso2.h index 394681e..d4b5744 100644 --- a/gdb/testsuite/gdb.base/dso2dso-dso2.h +++ b/gdb/testsuite/gdb.base/dso2dso-dso2.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2024 Free Software Foundation, Inc. +/* Copyright 2015-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/dso2dso.c b/gdb/testsuite/gdb.base/dso2dso.c index d4557c43..9b39bb7 100644 --- a/gdb/testsuite/gdb.base/dso2dso.c +++ b/gdb/testsuite/gdb.base/dso2dso.c @@ -1,4 +1,4 @@ -/* Copyright 2015-2024 Free Software Foundation, Inc. +/* Copyright 2015-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/dso2dso.exp b/gdb/testsuite/gdb.base/dso2dso.exp index 9ca1bd0..ad03e53 100644 --- a/gdb/testsuite/gdb.base/dso2dso.exp +++ b/gdb/testsuite/gdb.base/dso2dso.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -37,24 +37,21 @@ set libdso1 $testfile-dso1 set srcfile_libdso1 $srcdir/$subdir/$libdso1.c set binfile_libdso1 [standard_output_file $libdso1.so] -if { [gdb_compile_shlib $srcfile_libdso2 $binfile_libdso2 \ - [list debug]] != "" } { - untested "failed to compile shared library 2" - return -1 +if { [build_executable "build shlib 1" $binfile_libdso1 \ + $srcfile_libdso1 {debug shlib}] != 0 } { + return } -if { [gdb_compile_shlib $srcfile_libdso1 $binfile_libdso1 \ - [list debug]] != "" } { - untested "failed to compile shared library 1" - return -1 +if { [build_executable "build shlib 2" $binfile_libdso2 \ + $srcfile_libdso2 {debug shlib}] != 0 } { + return } -if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable \ - [list debug shlib=$binfile_libdso2 shlib=$binfile_libdso1]] != "" } { - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile \ + [list debug shlib=$binfile_libdso2 shlib=$binfile_libdso1]] != 0 } { + return } -clean_restart $binfile gdb_load_shlib $binfile_libdso2 gdb_load_shlib $binfile_libdso1 diff --git a/gdb/testsuite/gdb.base/dtrace-probe.c b/gdb/testsuite/gdb.base/dtrace-probe.c index 6920389..b6be97f 100644 --- a/gdb/testsuite/gdb.base/dtrace-probe.c +++ b/gdb/testsuite/gdb.base/dtrace-probe.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 @@ -23,7 +23,7 @@ main () char *name = "application"; TEST_TWO_LOCATIONS (); - + int i = 0; while (i < 10) { @@ -33,6 +33,6 @@ main () else TEST_TWO_LOCATIONS (); } - + return 0; /* last break here */ } diff --git a/gdb/testsuite/gdb.base/dtrace-probe.d b/gdb/testsuite/gdb.base/dtrace-probe.d index 3cda1a2..a8784de 100644 --- a/gdb/testsuite/gdb.base/dtrace-probe.d +++ b/gdb/testsuite/gdb.base/dtrace-probe.d @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/dtrace-probe.exp b/gdb/testsuite/gdb.base/dtrace-probe.exp index a8c38f9..879f338 100644 --- a/gdb/testsuite/gdb.base/dtrace-probe.exp +++ b/gdb/testsuite/gdb.base/dtrace-probe.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2024 Free Software Foundation, Inc. +# Copyright (C) 2014-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 @@ -18,28 +18,28 @@ load_lib "dtrace.exp" # Run the tests. # This returns -1 on failure to compile or start, 0 otherwise. proc dtrace_test {} { - global testfile hex srcfile binfile + global testfile hex srcfile standard_testfile - + if {[dtrace_build_usdt_test_program] == -1} { - untested "failed to compile" - return -1 + untested "failed to compile" + return -1 } - clean_restart ${binfile} - - if ![runto_main] { - return -1 + clean_restart $testfile + + if {![runto_main]} { + return -1 } gdb_test "print \$_probe_argc" "No probe at PC $hex" \ - "check argument not at probe point" + "check argument not at probe point" # Test the 'info probes' command. gdb_test "info probes dtrace" \ - "test *progress-counter *$hex +no.*test *two-locations *$hex +always.*test *two-locations *$hex +always.*" \ - "info probes dtrace" + "test *progress-counter *$hex +no.*test *two-locations *$hex +always.*test *two-locations *$hex +always.*" \ + "info probes dtrace" # Disabling the probe test:two-locations shall have no effect, # since no is-enabled probes are defined for it in the object @@ -63,14 +63,14 @@ proc dtrace_test {} { # Since test:progress-counter is disabled we can run to the second # instance of the test:two-locations probe. - runto "-probe-dtrace test:two-locations"] - runto "-probe-dtrace test:two-locations"] + runto "-probe-dtrace test:two-locations" + runto "-probe-dtrace test:two-locations" # Go back to the breakpoint on main() and enable the # test:progress-counter probe. Set a breakpoint on it and see # that it gets reached. - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -84,17 +84,17 @@ proc dtrace_test {} { # Test probe arguments. gdb_test "print \$_probe_argc" " = 2" \ - "print \$_probe_argc for probe progress-counter" + "print \$_probe_argc for probe progress-counter" gdb_test "print \$_probe_arg0" \ - " = $hex \"application\"" \ - "print \$_probe_arg0 for probe progress-counter" + " = $hex \"application\"" \ + "print \$_probe_arg0 for probe progress-counter" gdb_test "print \$_probe_arg1" " = 1" \ - "print \$_probe_arg1 for probe progress-counter" + "print \$_probe_arg1 for probe progress-counter" # Set a breakpoint with multiple probe locations. gdb_test "break -pdtrace test:two-locations" \ - "Breakpoint \[0-9\]+ at $hex.*2 locations.*" \ - "set multi-location probe breakpoint (probe two-locations)" + "Breakpoint \[0-9\]+ at $hex.*2 locations.*" \ + "set multi-location probe breakpoint (probe two-locations)" return 0 } diff --git a/gdb/testsuite/gdb.base/dump.c b/gdb/testsuite/gdb.base/dump.c index bdcafbf..14b66b1 100644 --- a/gdb/testsuite/gdb.base/dump.c +++ b/gdb/testsuite/gdb.base/dump.c @@ -35,7 +35,7 @@ main() for (i = 0; i < ARRSIZE; i++) intarray[i] = i+1; - intstruct.a = 12 * 1; + intstruct.a = (12 * 1) << 16; intstruct.b = 12 * 2; intstruct.c = 12 * 3; intstruct.d = 12 * 4; diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp index 54efe51..1cc9eee 100644 --- a/gdb/testsuite/gdb.base/dump.exp +++ b/gdb/testsuite/gdb.base/dump.exp @@ -1,4 +1,4 @@ -# Copyright 2002-2024 Free Software Foundation, Inc. +# Copyright 2002-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 @@ -41,13 +41,10 @@ proc print_zero_all { } { # this causes addresses to be out of range for IHEX. lappend options {nopie} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${options}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile $options] != 0 } { + return } -clean_restart $binfile - gdb_test "dump mem /dev/null 0x10 0x20" "Cannot access memory at address 0x10" \ "inaccessible memory is reported" @@ -107,14 +104,7 @@ set endian [get_endianness] # Now generate some dump files. proc make_dump_file { command msg } { - global gdb_prompt - - gdb_test_multiple "${command}" "$msg" { - -re ".*\[Ee\]rror.*$gdb_prompt $" { fail $msg } - -re ".*\[Ww\]arning.*$gdb_prompt $" { fail $msg } - -re ".*\[Uu\]ndefined .*$gdb_prompt $" { fail $msg } - -re ".*$gdb_prompt $" { pass $msg } - } + gdb_test_no_output "${command}" "$msg" } make_dump_file "dump val [set intarr1.bin] intarray" \ @@ -198,7 +188,7 @@ proc capture_pointer_with_type { pointer } { # Expected output of "p ${pointer}" is like "$7 = (int (*)[32]) 0x804a0e0", # and we want to extract "(int (*)[32]) 0x804a0e0" from it via # following regexp. - if [regexp " \\(.*\\).* 0x\[0-9a-fA-F\]+" $expect_out(0,string) output_string] { + if {[regexp " \\(.*\\).* 0x\[0-9a-fA-F\]+" $expect_out(0,string) output_string]} { # OUTPUT_STRING is expected to be like "(int (*)[32]) 0x804a0e0". pass "$test" } else { @@ -267,12 +257,12 @@ make_dump_file \ proc test_restore_saved_value { restore_args msg oldval newval } { global gdb_prompt - + gdb_test "restore $restore_args" \ "Restoring .*" \ "$msg; file restored ok" if { ![string compare $oldval \ - [capture_value $newval "$msg"]] } then { + [capture_value $newval "$msg"]] } then { pass "$msg; value restored ok" } else { fail "$msg; value restored ok" @@ -404,7 +394,7 @@ test_restore_saved_value "[set intstr1.bin] binary $struct2_start" \ # # test restore with start/stop addresses. # -# For this purpose, we will restore just the third element of the array, +# For this purpose, we will restore just the third element of the array, # and check to see that adjacent elements are not modified. # # We will need the address and offset of the third and fourth elements. @@ -455,7 +445,7 @@ gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 4" if {![string compare $is64bitonly "no"]} { print_zero_all - # restore with expressions + # restore with expressions test_restore_saved_value \ "[set intarr3.srec] (char*)${array2_start}-(char*)${array_start} &intarray\[3\] &intarray\[4\]" \ "array partial with expressions" 4 "intarray2\[3\]" @@ -481,7 +471,7 @@ gdb_file_cmd ${binfile} # Now fix the endianness at the correct state. gdb_test_multiple "set endian $endian" "set endianness" { - -re ".* (big|little) endian.*$gdb_prompt $" { + -re ".* (big|little) endian.*$gdb_prompt $" { pass "setting $endian endianness" } } @@ -504,10 +494,10 @@ if { ![string compare $struct_val \ proc test_reload_saved_value { filename msg oldval newval } { global gdb_prompt - + gdb_file_cmd $filename if { ![string compare $oldval \ - [capture_value $newval "$msg"]] } then { + [capture_value $newval "$msg"]] } then { pass "$msg; value restored ok" } else { fail "$msg; value restored ok" diff --git a/gdb/testsuite/gdb.base/dup-sect.S b/gdb/testsuite/gdb.base/dup-sect.S index 64e9161..d640a66 100644 --- a/gdb/testsuite/gdb.base/dup-sect.S +++ b/gdb/testsuite/gdb.base/dup-sect.S @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/dup-sect.exp b/gdb/testsuite/gdb.base/dup-sect.exp index e5d185f..5a5ad91 100644 --- a/gdb/testsuite/gdb.base/dup-sect.exp +++ b/gdb/testsuite/gdb.base/dup-sect.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -42,7 +42,7 @@ if {[build_executable ${testfile}.exp $executable [list ${srcfile} ${srcmainfile set test "rename section" set objcopy_program [gdb_find_objcopy] -set result [catch "exec $objcopy_program --rename-section sect2=sect1 $binfile" output] +set result [catch {exec $objcopy_program --rename-section sect2=sect1 $binfile} output] verbose "result is $result" verbose "output is $output" if {$result != 0} { @@ -62,7 +62,7 @@ if {[gdb_gnu_strip_debug $binfile] != 0} { # in $binfile. set test "strip" set strip_program [transform strip] -set result [catch "exec $strip_program $binfile" output] +set result [catch {exec $strip_program $binfile} output] verbose "result is $result" verbose "output is $output" if {$result != 0} { diff --git a/gdb/testsuite/gdb.base/duplicate-bp.c b/gdb/testsuite/gdb.base/duplicate-bp.c index 8212b24..bb6c155 100644 --- a/gdb/testsuite/gdb.base/duplicate-bp.c +++ b/gdb/testsuite/gdb.base/duplicate-bp.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/duplicate-bp.exp b/gdb/testsuite/gdb.base/duplicate-bp.exp index 5ab001d..9295642 100644 --- a/gdb/testsuite/gdb.base/duplicate-bp.exp +++ b/gdb/testsuite/gdb.base/duplicate-bp.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -22,9 +22,8 @@ if { [build_executable "failed to prepare" ${testfile}] } { # Setup for the test, create COUNT breakpoints at the function BREAKPT. proc test_setup { count } { global srcfile - global binfile - clean_restart ${binfile} + clean_restart $::testfile if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/early-init-file.c b/gdb/testsuite/gdb.base/early-init-file.c index b1ce99c..a21818d 100644 --- a/gdb/testsuite/gdb.base/early-init-file.c +++ b/gdb/testsuite/gdb.base/early-init-file.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/early-init-file.exp b/gdb/testsuite/gdb.base/early-init-file.exp index 7c6e9e2..6d70c4c 100644 --- a/gdb/testsuite/gdb.base/early-init-file.exp +++ b/gdb/testsuite/gdb.base/early-init-file.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/echo.exp b/gdb/testsuite/gdb.base/echo.exp index 30c0ab9..bb6a343 100644 --- a/gdb/testsuite/gdb.base/echo.exp +++ b/gdb/testsuite/gdb.base/echo.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1988-2024 Free Software Foundation, Inc. +# Copyright (C) 1988-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 diff --git a/gdb/testsuite/gdb.base/eh_return.c b/gdb/testsuite/gdb.base/eh_return.c index 7329de6..6817d2a 100644 --- a/gdb/testsuite/gdb.base/eh_return.c +++ b/gdb/testsuite/gdb.base/eh_return.c @@ -2,7 +2,7 @@ It was copied from gcc repo, gcc/testsuite/gcc.target/aarch64/eh_return.c. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/eh_return.exp b/gdb/testsuite/gdb.base/eh_return.exp index 9fefc89..b08e495 100644 --- a/gdb/testsuite/gdb.base/eh_return.exp +++ b/gdb/testsuite/gdb.base/eh_return.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -71,7 +71,7 @@ if { $address == -1 } { return 0 } -clean_restart ${binfile} +clean_restart $testfile gdb_assert [gdb_breakpoint "*$address" no-message] "set breakpoint on address" diff --git a/gdb/testsuite/gdb.base/empty-host-env-vars.exp b/gdb/testsuite/gdb.base/empty-host-env-vars.exp index 5fab65a..1a1b158 100644 --- a/gdb/testsuite/gdb.base/empty-host-env-vars.exp +++ b/gdb/testsuite/gdb.base/empty-host-env-vars.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/empty_exe.exp b/gdb/testsuite/gdb.base/empty_exe.exp index 20feb74..dedf902 100644 --- a/gdb/testsuite/gdb.base/empty_exe.exp +++ b/gdb/testsuite/gdb.base/empty_exe.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -19,7 +19,7 @@ gdb_start # Make sure that the "file" command rejects an empty filename, # rather than crash. gdb_test "file ''" \ - ": No such file or directory\\." + ": No such file or directory\\." # And to make extra sure that GDB is still alive, do a quick # sanity check. diff --git a/gdb/testsuite/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp index 924133e..ca762fc 100644 --- a/gdb/testsuite/gdb.base/ena-dis-br.exp +++ b/gdb/testsuite/gdb.base/ena-dis-br.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -240,7 +240,7 @@ with_test_prefix "run $count" { incr count } -# See the comments in condbreak.exp for "run until breakpoint at marker1" +# See the comments in condbreak.exp for "run until breakpoint at marker1" # for an explanation of the xfail below. set test "continue to break marker1, 2nd time" gdb_test_multiple "continue" "$test" { @@ -410,10 +410,10 @@ proc test_ena_dis_br { what } { # Now $b1.1 and $b2.1 should be enabled(disabled). gdb_test_multiple "info break" "$test1" { -re "(${b1})(\[^\n\r\]*)( n.*)(${b2})(\[^\n\r\]*)( n.*)$gdb_prompt $" { - $p1 "$test1" + $p1 "$test1" } -re ".*$gdb_prompt $" { - $p2 "$test1" + $p2 "$test1" } } @@ -448,11 +448,11 @@ proc test_ena_dis_br { what } { # $b4.1 should be enabled(disabled). gdb_test_multiple "info break" "$test1" { - -re "(${b4})(\[^\n\r\]*)( n.*)$gdb_prompt $" { - $p1 "$test1" + -re "(${b4})(\[^\n\r\]*)( n.*)$gdb_prompt $" { + $p1 "$test1" } -re ".*$gdb_prompt $" { - $p2 "$test1" + $p2 "$test1" } } } diff --git a/gdb/testsuite/gdb.base/endian.c b/gdb/testsuite/gdb.base/endian.c index 8567fdd..c135956 100644 --- a/gdb/testsuite/gdb.base/endian.c +++ b/gdb/testsuite/gdb.base/endian.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-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 diff --git a/gdb/testsuite/gdb.base/endian.exp b/gdb/testsuite/gdb.base/endian.exp index 7ef288b..993617b 100644 --- a/gdb/testsuite/gdb.base/endian.exp +++ b/gdb/testsuite/gdb.base/endian.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2018-2024 Free Software Foundation, Inc. +# Copyright (C) 2018-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 diff --git a/gdb/testsuite/gdb.base/endianity.c b/gdb/testsuite/gdb.base/endianity.c index f415c4a..a8cdca8 100644 --- a/gdb/testsuite/gdb.base/endianity.c +++ b/gdb/testsuite/gdb.base/endianity.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/endianity.exp b/gdb/testsuite/gdb.base/endianity.exp index 789266d..013866d 100644 --- a/gdb/testsuite/gdb.base/endianity.exp +++ b/gdb/testsuite/gdb.base/endianity.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -16,8 +16,8 @@ standard_testfile .c set test_sso [expr \ - [supports_scalar_storage_order_attribute] \ - && [supports_gnuc]] + {[supports_scalar_storage_order_attribute] \ + && [supports_gnuc]}] if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ [list debug additional_flags=-DTEST_SSO=$test_sso]] } { diff --git a/gdb/testsuite/gdb.base/ending-run.c b/gdb/testsuite/gdb.base/ending-run.c index a499f37..fd149cc 100644 --- a/gdb/testsuite/gdb.base/ending-run.c +++ b/gdb/testsuite/gdb.base/ending-run.c @@ -23,10 +23,10 @@ int main() p = (int *) malloc( 4 ); for (i = 1; i < 10; i++) - { - printf( "%d ", callee( i )); - fflush (stdout); - } + { + printf( "%d ", callee( i )); + fflush (stdout); + } printf( " Goodbye!\n" ); fflush (stdout); /* -break2- */ return 0; } diff --git a/gdb/testsuite/gdb.base/ending-run.exp b/gdb/testsuite/gdb.base/ending-run.exp index 90359fd..b0313d5 100644 --- a/gdb/testsuite/gdb.base/ending-run.exp +++ b/gdb/testsuite/gdb.base/ending-run.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -66,25 +66,25 @@ gdb_test "cle ending-run.c:$break1_line" \ gdb_test_multiple "info line ending-run.c:$break1_line" "" { -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" { - set line_nine $expect_out(1,string) + set line_nine $expect_out(1,string) gdb_test "b ending-run.c:$break1_line" ".*Breakpoint 4.*ending-run.c, line $break1_line.*" gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 5.*" "breakpoint 7 at *ending-run.c:$break1_line" gdb_test "cle" "Deleted breakpoints 4 5 " "clear 2 by default" } -re ".*$gdb_prompt $" { - fail "need to fix test for new compile outcome" + fail "need to fix test for new compile outcome" } } gdb_test_multiple "i b" "all set to continue" { -re ".* breakpoint .* breakpoint .*$gdb_prompt $" { - fail "all set to continue (didn't clear bps)" + fail "all set to continue (didn't clear bps)" } -re ".*2.*main.*$break2_line.*$gdb_prompt $" { - pass "all set to continue" + pass "all set to continue" } -re ".*$gdb_prompt $" { - fail "all set to continue (missing bp at end)" + fail "all set to continue (missing bp at end)" } } @@ -92,7 +92,7 @@ gdb_test_multiple "i b" "all set to continue" { # See if we can step out with control. The "1 2 3" stuff # is output from the program. # -if ![gdb_skip_stdio_test "cont"] { +if {![gdb_skip_stdio_test "cont"]} { gdb_test_stdio "cont" \ "1 2 7 14 23 34 47 62 79" \ "Breakpoint.*$break2_line.*" @@ -100,7 +100,7 @@ if ![gdb_skip_stdio_test "cont"] { gdb_test "cont" ".*Breakpoint.*$break2_line.*" } -if ![gdb_skip_stdio_test "Step to return"] { +if {![gdb_skip_stdio_test "Step to return"]} { gdb_test_stdio "next" \ "Goodbye!" \ "[expr {$break2_line + 1}].*" \ @@ -129,13 +129,13 @@ gdb_test_multiple "next" "step out of main" { fail "step out of main" gdb_test "n" ".*" "" } - -re ".*in.*start.*$gdb_prompt $" { + -re ".*in.*start.*$gdb_prompt $" { pass "step out of main" } - -re ".*in.*bsp_trap.*$gdb_prompt $" { + -re ".*in.*bsp_trap.*$gdb_prompt $" { pass "step out of main" } - -re ".*in.*init.*$gdb_prompt $" { + -re ".*in.*init.*$gdb_prompt $" { # This is what happens on sparc64-elf ultra. pass "step out of main" } @@ -172,7 +172,7 @@ gdb_test_multiple "next" "step out of main" { # This is what happens on the ARM RVDS runtime pass "step out of main" } - -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" { + -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" { pass "step out of main" } -re ".*in __wrap__?main ().*$gdb_prompt $" { @@ -183,14 +183,14 @@ gdb_test_multiple "next" "step out of main" { # another `next' is necessary. gdb_test "next" ".*in start_l ().*" "step out of main" } - -re ".*in.*currently asm.*$gdb_prompt $" { - pass "step out of main" + -re ".*in.*currently asm.*$gdb_prompt $" { + pass "step out of main" } -re "_*start\[0-9\]* \\(\[^)\]*\\).*$gdb_prompt $" { - pass "step out of main" + pass "step out of main" } -re ".*Program received signal SIGTRAP.*$gdb_prompt $" { - pass "step out of main" + pass "step out of main" } -re ".*in.*__uClibc_main.*$gdb_prompt $" { # This is what happens on system using uClibc. @@ -224,7 +224,7 @@ set program_in_exit 0 if {!$use_gdb_stub && (! [target_info exists use_cygmon] || ! [target_info use_cygmon])} { global program_exited - if {[eval expr $program_exited == 0]} { + if {$program_exited == 0} { gdb_test_multiple "n" "step to end of run" { -re "$inferior_exited_re normally.*$gdb_prompt $" { # If we actually have debug info for the start function, @@ -245,16 +245,16 @@ if {!$use_gdb_stub set program_exited_normally 1 } -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" { - pass "step to end of run" + pass "step to end of run" set program_in_exit 1 } -re ".*Single.*_int_reset.*$gdb_prompt $" { - pass "step to end of run" + pass "step to end of run" if {![istarget "xstormy16-*-*"]} { set program_exited_normally 1 } } - } + } } if {$program_in_exit} { @@ -266,7 +266,7 @@ if {!$use_gdb_stub } if {$program_exited_normally} { - gdb_test "n" ".*The program is not being run.*" "don't step after run" + gdb_test "n" ".*The program is not being run.*" "don't step after run" } elseif {$program_not_exited} { unresolved "don't step after run" } else { @@ -275,10 +275,10 @@ if {!$use_gdb_stub set exec_output [remote_exec host "ls core"] - if [ regexp "core not found" $exec_output] { + if {[ regexp "core not found" $exec_output]} { pass "no core dumped on quit" } else { - if [ regexp "No such file or directory" $exec_output] { + if {[ regexp "No such file or directory" $exec_output]} { pass "ls: core (No core dumped on quit)" } else { remote_exec build "rm -f core" @@ -290,8 +290,3 @@ if {!$use_gdb_stub set timeout $old_timeout #remote_exec build "rm -f ${binfile}" - - - - - diff --git a/gdb/testsuite/gdb.base/enum_cond.c b/gdb/testsuite/gdb.base/enum_cond.c index df8830f..d264200 100644 --- a/gdb/testsuite/gdb.base/enum_cond.c +++ b/gdb/testsuite/gdb.base/enum_cond.c @@ -1,5 +1,5 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/enum_cond.exp b/gdb/testsuite/gdb.base/enum_cond.exp index d58da47..9317fd0 100644 --- a/gdb/testsuite/gdb.base/enum_cond.exp +++ b/gdb/testsuite/gdb.base/enum_cond.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -45,10 +45,9 @@ if {![runto_main]} { } gdb_test "break call_me if param.e == 1" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal\\." + "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal\\." # Continue. We should hit our breakpoint... gdb_test "continue" \ - "Breakpoint $decimal, call_me \\(param=\\.\\.\\.\\) at .*" \ - "continue to conditional breakpoint in call_me" - + "Breakpoint $decimal, call_me \\(param=\\.\\.\\.\\) at .*" \ + "continue to conditional breakpoint in call_me" diff --git a/gdb/testsuite/gdb.base/enumval.c b/gdb/testsuite/gdb.base/enumval.c index c487e78..ab7496a 100644 --- a/gdb/testsuite/gdb.base/enumval.c +++ b/gdb/testsuite/gdb.base/enumval.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/enumval.exp b/gdb/testsuite/gdb.base/enumval.exp index 79adb46..de95745 100644 --- a/gdb/testsuite/gdb.base/enumval.exp +++ b/gdb/testsuite/gdb.base/enumval.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/environ.exp b/gdb/testsuite/gdb.base/environ.exp index 1bc5c71..091010a 100644 --- a/gdb/testsuite/gdb.base/environ.exp +++ b/gdb/testsuite/gdb.base/environ.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -13,7 +13,11 @@ # 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_start +# Make sure there is at least one environment variable. +save_vars { env(GDB_TEST_ENV_VAR) } { + setenv GDB_TEST_ENV_VAR abc + gdb_start +} proc test_set_show_env_var { name value test_name } { gdb_test_no_output "set environment $name $value" "$test_name" @@ -29,11 +33,20 @@ proc test_set_show_env_var_equal { name value test_name } { # Verify that we can show all currently-set environment variables. # It's hard to do this verification since we can't really compare each -# entry with the current environment. So we just check to see if -# there is anything that looks like an environment variable being -# printed. -gdb_test "show environment" "(\[A-Za-z_\]+=.*)+" \ - "show environment works" +# entry with the current environment. So we just check to see if the +# environment variable we set at startup is printed. +set saw_env 0 +gdb_test_multiple "show environment" "show environment works" -lbl { + -re "\r\nGDB_TEST_ENV_VAR=abc" { + incr saw_env 1 + exp_continue + } + + -re "\r\n$gdb_prompt $" { + } +} + +gdb_assert {$saw_env == 1} "show environment displayed variable" # Verify that we can unset a specific environment variable. gdb_test_no_output "unset environment EDITOR" "unset environment variable" diff --git a/gdb/testsuite/gdb.base/eof-exit.exp b/gdb/testsuite/gdb.base/eof-exit.exp index 5b9ec7b..9b6be28 100644 --- a/gdb/testsuite/gdb.base/eof-exit.exp +++ b/gdb/testsuite/gdb.base/eof-exit.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2022-2024 Free Software Foundation, Inc. +# Copyright (C) 2022-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 diff --git a/gdb/testsuite/gdb.base/errno.c b/gdb/testsuite/gdb.base/errno.c index c6835a8..a896d36 100644 --- a/gdb/testsuite/gdb.base/errno.c +++ b/gdb/testsuite/gdb.base/errno.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/errno.exp b/gdb/testsuite/gdb.base/errno.exp index 262176e..ac682dd 100644 --- a/gdb/testsuite/gdb.base/errno.exp +++ b/gdb/testsuite/gdb.base/errno.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 @@ -45,8 +45,10 @@ standard_testfile proc do_tests {{do_xfail_cast 0} {do_xfail 0} {do_xfail_core_test 0}} { - clean_restart $::binfile - if ![runto_main] { + set filename [file tail $::binfile] + + clean_restart $filename + if {![runto_main]} { return } @@ -144,12 +146,12 @@ proc do_tests {{do_xfail_cast 0} {do_xfail 0} {do_xfail_core_test 0}} { } } - if $do_xfail { + if {$do_xfail} { setup_xfail *-*-* } gdb_test "print errno" ".* = 42" - if $do_xfail_cast { + if {$do_xfail_cast} { setup_xfail *-*-* } gdb_test "print (int) errno" ".* = 42" @@ -172,17 +174,17 @@ proc do_tests {{do_xfail_cast 0} {do_xfail 0} {do_xfail_core_test 0}} { gdb_test "print errno" ".* = 36" "print masking errno" # Finish test early if no core file was made. - if !$core_supported { + if {!$core_supported} { return } - clean_restart $::binfile + clean_restart $filename set core_loaded [gdb_core_cmd $corefile "load corefile"] if { $core_loaded == -1 } { return } - if $do_xfail_core_test { + if {$do_xfail_core_test} { setup_xfail *-*-* } gdb_test "print errno" ".* = 42" "check errno value from corefile" diff --git a/gdb/testsuite/gdb.base/eu-strip-infcall.c b/gdb/testsuite/gdb.base/eu-strip-infcall.c index b4b59f5..896d51c 100644 --- a/gdb/testsuite/gdb.base/eu-strip-infcall.c +++ b/gdb/testsuite/gdb.base/eu-strip-infcall.c @@ -1,4 +1,4 @@ -/* Copyright 2011-2024 Free Software Foundation, Inc. +/* Copyright 2011-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/eu-strip-infcall.exp b/gdb/testsuite/gdb.base/eu-strip-infcall.exp index 531906f..43f2bc0 100644 --- a/gdb/testsuite/gdb.base/eu-strip-infcall.exp +++ b/gdb/testsuite/gdb.base/eu-strip-infcall.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2024 Free Software Foundation, Inc. +# Copyright (C) 2011-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 @@ -28,7 +28,7 @@ if {[lindex $status 0] != 0} { clean_restart $testfile -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/eval-avoid-side-effects.exp b/gdb/testsuite/gdb.base/eval-avoid-side-effects.exp index 914f01e..fdd6bed 100644 --- a/gdb/testsuite/gdb.base/eval-avoid-side-effects.exp +++ b/gdb/testsuite/gdb.base/eval-avoid-side-effects.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 @@ -22,7 +22,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/eval-skip.exp b/gdb/testsuite/gdb.base/eval-skip.exp index e8f766e..1bcea05 100644 --- a/gdb/testsuite/gdb.base/eval-skip.exp +++ b/gdb/testsuite/gdb.base/eval-skip.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -23,7 +23,7 @@ # operators, or in the non returned part of a (x ? y: z) expression. # the part that is not evaluated is parsed and evaluated anyway, but with # the EVAL_SKIP flag set -# +# # source file "int-type.c" # @@ -34,12 +34,9 @@ standard_testfile int-type.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { - untested "failed to compile" - return -1 - } - -clean_restart ${binfile} +if { [prepare_for_testing "prepare" $testfile $srcfile { debug nowarnings }] != 0 } { + return +} if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/eval.exp b/gdb/testsuite/gdb.base/eval.exp index bcc9fb9..e471b20 100644 --- a/gdb/testsuite/gdb.base/eval.exp +++ b/gdb/testsuite/gdb.base/eval.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/examine-backward.c b/gdb/testsuite/gdb.base/examine-backward.c index d54e100..dbeda41 100644 --- a/gdb/testsuite/gdb.base/examine-backward.c +++ b/gdb/testsuite/gdb.base/examine-backward.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 @@ -117,14 +117,14 @@ main (void) for (i = 0; i < len - 1; ++i) { for (j = i; j < len; ++j) - { - if (n[j] < n[i]) - { - int tmp = n[i]; - n[i] = n[j]; - n[j] = tmp; - } - } + { + if (n[j] < n[i]) + { + int tmp = n[i]; + n[i] = n[j]; + n[j] = tmp; + } + } } return 42; } diff --git a/gdb/testsuite/gdb.base/examine-backward.exp b/gdb/testsuite/gdb.base/examine-backward.exp index fe3d13e..d2cf3ff 100644 --- a/gdb/testsuite/gdb.base/examine-backward.exp +++ b/gdb/testsuite/gdb.base/examine-backward.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -18,11 +18,11 @@ standard_testfile if { [prepare_for_testing "failed to prepare for examine-backward" \ - ${testfile} ${srcfile}] } { + ${testfile} ${srcfile}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } @@ -31,23 +31,23 @@ proc get_first_mapped_address {} { set addr "0" gdb_test_multiple "info proc mappings" "info proc mappings" { - -re "objfile\[\r\n\t \]+(0x\[0-9a-fA-F\]+).*\[\r\n\]*$gdb_prompt $" { - set addr $expect_out(1,string) - } - -re "$gdb_prompt $" { - unsupported "current target does not support 'info proc mappings'" - } + -re "objfile\[\r\n\t \]+(0x\[0-9a-fA-F\]+).*\[\r\n\]*$gdb_prompt $" { + set addr $expect_out(1,string) + } + -re "$gdb_prompt $" { + unsupported "current target does not support 'info proc mappings'" + } } return ${addr} } with_test_prefix "invalid format" { gdb_test "x/- 10xb main" "Invalid number \"10xb\"\." \ - "a whitespace after a leading hyphen" + "a whitespace after a leading hyphen" gdb_test "x/--10xb main" "Invalid number \"10xb\"\." \ - "double hyphen" + "double hyphen" gdb_test "x/-a10xb main" "Invalid number \"10xb\"\." \ - "an alphabet after a leading hyphen" + "an alphabet after a leading hyphen" gdb_test_no_output "x/-0i main" "zero with backward disassemble" gdb_test_no_output "x/-0sh main" "zero with backward examine string" } @@ -55,29 +55,29 @@ with_test_prefix "invalid format" { with_test_prefix "memory page boundary" { set boundary [get_first_mapped_address] if {![is_address_zero_readable] && $boundary != 0} { - gdb_test_no_output "set print elements 0" - gdb_test_sequence "x/3s ${boundary}" "take 3 strings forward" { - "0x" - "0x" - "0x" - } - gdb_test_sequence "x/-4s" "take 4 strings backward" { - "Cannot access memory at address 0x" - "0x" - "0x" - "0x" - } - gdb_test_sequence "x/3s ${boundary}" "take 3 strings forward again" { - "0x" - "0x" - "0x" - } - gdb_test_sequence "x/-3s" "take 3 strings backward" { - "Cannot access memory at address 0x" - "0x" - "0x" - "0x" - } + gdb_test_no_output "set print elements 0" + gdb_test_sequence "x/3s ${boundary}" "take 3 strings forward" { + "0x" + "0x" + "0x" + } + gdb_test_sequence "x/-4s" "take 4 strings backward" { + "Cannot access memory at address 0x" + "0x" + "0x" + "0x" + } + gdb_test_sequence "x/3s ${boundary}" "take 3 strings forward again" { + "0x" + "0x" + "0x" + } + gdb_test_sequence "x/-3s" "take 3 strings backward" { + "Cannot access memory at address 0x" + "0x" + "0x" + "0x" + } } } @@ -146,29 +146,29 @@ gdb_test_no_output "set charset ASCII" with_test_prefix "char-width=1, print-max=20" { gdb_test_no_output "set print elements 20" gdb_test_sequence "x/6s TestStrings" "take 6 strings forward" { - "\"ABCDEFGHIJKLMNOPQRST\"\.\.\." - "\"UVWXYZ\"" - "\"\"" - "\"\"" - "\"[^\"]+\"" - "\"01234567890123456789\"\.\.\." + "\"ABCDEFGHIJKLMNOPQRST\"\.\.\." + "\"UVWXYZ\"" + "\"\"" + "\"\"" + "\"[^\"]+\"" + "\"01234567890123456789\"\.\.\." } gdb_test "x/-1xb" "0x39" "take 1 char backward" gdb_test_sequence "x/-6s" "take 6 strings backward" { - "\"ABCDEFGHIJKLMNOPQRST\"\.\.\." - "\"UVWXYZ\"" - "\"\"" - "\"\"" - "\"[^\"]+\"" - "\"01234567890123456789\"\.\.\." + "\"ABCDEFGHIJKLMNOPQRST\"\.\.\." + "\"UVWXYZ\"" + "\"\"" + "\"\"" + "\"[^\"]+\"" + "\"01234567890123456789\"\.\.\." } gdb_test_sequence "x/6s TestStrings" "take 6 strings forward again" { - "\"ABCDEFGHIJKLMNOPQRST\"\.\.\." - "\"UVWXYZ\"" - "\"\"" - "\"\"" - "\"[^\"]+\"" - "\"01234567890123456789\"\.\.\." + "\"ABCDEFGHIJKLMNOPQRST\"\.\.\." + "\"UVWXYZ\"" + "\"\"" + "\"\"" + "\"[^\"]+\"" + "\"01234567890123456789\"\.\.\." } gdb_test "x/-xb" "0x39" "take 1 char backward again" gdb_test "x/-s" "\"01234567890123456789\"\.\.\." \ @@ -188,29 +188,29 @@ with_test_prefix "char-width=1, print-max=20" { with_test_prefix "char-width=2, print-max=20" { gdb_test_no_output "set print elements 20" gdb_test_sequence "x/6sh TestStringsH" "take 6 strings forward" { - "u\"ABCDEFGHIJKLMNOPQRST\"\.\.\." - "u\"UVWXYZ\"" - "u\"\"" - "u\"\"" - "u\"[^\"]+\"" - "u\"01234567890123456789\"\.\.\." + "u\"ABCDEFGHIJKLMNOPQRST\"\.\.\." + "u\"UVWXYZ\"" + "u\"\"" + "u\"\"" + "u\"[^\"]+\"" + "u\"01234567890123456789\"\.\.\." } gdb_test "x/-1xh" "0x0039" "take 1 char backward" gdb_test_sequence "x/-6sh" "take 6 strings backward" { - "u\"ABCDEFGHIJKLMNOPQRST\"\.\.\." - "u\"UVWXYZ\"" - "u\"\"" - "u\"\"" - "u\"[^\"]+\"" - "u\"01234567890123456789\"\.\.\." + "u\"ABCDEFGHIJKLMNOPQRST\"\.\.\." + "u\"UVWXYZ\"" + "u\"\"" + "u\"\"" + "u\"[^\"]+\"" + "u\"01234567890123456789\"\.\.\." } gdb_test_sequence "x/6sh TestStringsH" "take 6 strings forward again" { - "u\"ABCDEFGHIJKLMNOPQRST\"\.\.\." - "u\"UVWXYZ\"" - "u\"\"" - "u\"\"" - "u\"[^\"]+\"" - "u\"01234567890123456789\"\.\.\." + "u\"ABCDEFGHIJKLMNOPQRST\"\.\.\." + "u\"UVWXYZ\"" + "u\"\"" + "u\"\"" + "u\"[^\"]+\"" + "u\"01234567890123456789\"\.\.\." } gdb_test "x/-xh" "0x0039" "take 1 char backward again" gdb_test "x/-sh" "u\"01234567890123456789\"\.\.\." \ @@ -230,29 +230,29 @@ with_test_prefix "char-width=2, print-max=20" { with_test_prefix "char-width=4, print-max=20" { gdb_test_no_output "set print elements 20" gdb_test_sequence "x/6sw TestStringsW" "take 6 strings forward" { - "U\"ABCDEFGHIJKLMNOPQRST\"\.\.\." - "U\"UVWXYZ\"" - "U\"\"" - "U\"\"" - "U\"[^\"]+\"" - "U\"01234567890123456789\"\.\.\." + "U\"ABCDEFGHIJKLMNOPQRST\"\.\.\." + "U\"UVWXYZ\"" + "U\"\"" + "U\"\"" + "U\"[^\"]+\"" + "U\"01234567890123456789\"\.\.\." } gdb_test "x/-1xw" "0x00000039" "take 1 char backward" gdb_test_sequence "x/-6sw" "take 6 strings backward" { - "U\"ABCDEFGHIJKLMNOPQRST\"\.\.\." - "U\"UVWXYZ\"" - "U\"\"" - "U\"\"" - "U\"[^\"]+\"" - "U\"01234567890123456789\"\.\.\." + "U\"ABCDEFGHIJKLMNOPQRST\"\.\.\." + "U\"UVWXYZ\"" + "U\"\"" + "U\"\"" + "U\"[^\"]+\"" + "U\"01234567890123456789\"\.\.\." } gdb_test_sequence "x/6sw TestStringsW" "take 6 strings forward again" { - "U\"ABCDEFGHIJKLMNOPQRST\"\.\.\." - "U\"UVWXYZ\"" - "U\"\"" - "U\"\"" - "U\"[^\"]+\"" - "U\"01234567890123456789\"\.\.\." + "U\"ABCDEFGHIJKLMNOPQRST\"\.\.\." + "U\"UVWXYZ\"" + "U\"\"" + "U\"\"" + "U\"[^\"]+\"" + "U\"01234567890123456789\"\.\.\." } gdb_test "x/-xw" "0x00000039" "take 1 char backward again" gdb_test "x/-sw" "U\"01234567890123456789\"\.\.\." \ @@ -272,30 +272,30 @@ with_test_prefix "char-width=4, print-max=20" { with_test_prefix "char-width=2, print-max=0" { gdb_test_no_output "set print elements 0" gdb_test_sequence "x/6sh TestStringsH" "take 6 strings forward" { - "u\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"" - "u\"\"" - "u\"\"" - "u\"\\\\x307b\\\\x3052\\\\x307b\\\\x3052\"" - "u\"012345678901234567890123456789\"" - "u\"!!!!!!\"" + "u\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"" + "u\"\"" + "u\"\"" + "u\"\\\\x307b\\\\x3052\\\\x307b\\\\x3052\"" + "u\"012345678901234567890123456789\"" + "u\"!!!!!!\"" } gdb_test "x/-4xh" "0x0021\[\t \]+0x0021\[\t \]+0x0021\[\t \]+0x0000" \ - "take 4 characters backward" + "take 4 characters backward" gdb_test_sequence "x/-6sh" "take 6 strings backward" { - "u\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"" - "u\"\"" - "u\"\"" - "u\"[^\"]+\"" - "u\"012345678901234567890123456789\"" - "u\"!!!!!!\"" + "u\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"" + "u\"\"" + "u\"\"" + "u\"[^\"]+\"" + "u\"012345678901234567890123456789\"" + "u\"!!!!!!\"" } gdb_test_sequence "x/6sh TestStringsH" "take 6 strings forward again" { - "u\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"" - "u\"\"" - "u\"\"" - "u\"\\\\x307b\\\\x3052\\\\x307b\\\\x3052\"" - "u\"012345678901234567890123456789\"" - "u\"!!!!!!\"" + "u\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"" + "u\"\"" + "u\"\"" + "u\"\\\\x307b\\\\x3052\\\\x307b\\\\x3052\"" + "u\"012345678901234567890123456789\"" + "u\"!!!!!!\"" } gdb_test "x/-xh" "0x0000" "take 1 char backward" gdb_test "x/-sh" "u\"!!!!!!\"" \ @@ -315,28 +315,28 @@ with_test_prefix "char-width=2, print-max=0" { with_test_prefix "char-width=1, print-max=4" { gdb_test_no_output "set print elements 4" gdb_test_sequence "x/9s TestStrings" "take 9 strings forward" { - "\"ABCD\"\.\.\." - "\"EFGH\"\.\.\." - "\"IJKL\"\.\.\." - "\"MNOP\"\.\.\." - "\"QRST\"\.\.\." - "\"UVWX\"\.\.\." - "\"YZ\"" - "\"\"" - "\"\"" + "\"ABCD\"\.\.\." + "\"EFGH\"\.\.\." + "\"IJKL\"\.\.\." + "\"MNOP\"\.\.\." + "\"QRST\"\.\.\." + "\"UVWX\"\.\.\." + "\"YZ\"" + "\"\"" + "\"\"" } gdb_test "x/-xb" "0x00" "take 1 byte backward" gdb_test_sequence "x/-4s" "take 4 strings backward, 1/2" { - "\"TUVW\"\.\.\." - "\"XYZ\"" - "\"\"" - "\"\"" + "\"TUVW\"\.\.\." + "\"XYZ\"" + "\"\"" + "\"\"" } gdb_test_sequence "x/-4s" "take 4 strings backward, 2/2" { - "\"CDEF\"\.\.\." - "\"GHIJ\"\.\.\." - "\"KLMN\"\.\.\." - "\"OPQR\"\.\.\." + "\"CDEF\"\.\.\." + "\"GHIJ\"\.\.\." + "\"KLMN\"\.\.\." + "\"OPQR\"\.\.\." } } @@ -352,19 +352,19 @@ with_test_prefix "backward disassemble general" { gdb_test "x/-i" "0x\[0-9a-fA-F\]+ <$main_re>:\t.*" \ "move the current position to main, x/-i" for {set i 0} {$i < [llength $length_to_examine]} {incr i} { - set len [lindex $length_to_examine $i] - set instructions [capture_command_output "x/${len}i" ""] - lappend disassmbly $instructions + set len [lindex $length_to_examine $i] + set instructions [capture_command_output "x/${len}i" ""] + lappend disassmbly $instructions } for {set i 0} {$i < [llength $length_to_examine]} {incr i} { - set idx [expr [llength $length_to_examine] - $i - 1] - set len [lindex $length_to_examine $idx] - set actual [capture_command_output "x/-${len}i" ""] - set expected [lindex $disassmbly $idx] - if {$actual == $expected} { - pass "inst:$idx" - } else { - fail "inst:$idx" - } + set idx [expr {[llength $length_to_examine] - $i - 1}] + set len [lindex $length_to_examine $idx] + set actual [capture_command_output "x/-${len}i" ""] + set expected [lindex $disassmbly $idx] + if {$actual == $expected} { + pass "inst:$idx" + } else { + fail "inst:$idx" + } } } diff --git a/gdb/testsuite/gdb.base/exe-lock.exp b/gdb/testsuite/gdb.base/exe-lock.exp index 532c7bb..d516141 100644 --- a/gdb/testsuite/gdb.base/exe-lock.exp +++ b/gdb/testsuite/gdb.base/exe-lock.exp @@ -1,4 +1,4 @@ -# Copyright 2009-2024 Free Software Foundation, Inc. +# Copyright 2009-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 @@ -22,13 +22,10 @@ standard_testfile arrayidx.c # don't find the $binfile for 'file delete $binfile'. append binfile $EXEEXT -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart ${binfile} - # Sanity-check: Verify that the executable exists. This is just to # make sure that, when we verify later that the file does not exist, # it really has been deleted. @@ -51,5 +48,3 @@ file delete $binfile if { [file exists $binfile] } { fail "executable still exists (${binfile})" } - - diff --git a/gdb/testsuite/gdb.base/exec-invalid-sysroot.exp b/gdb/testsuite/gdb.base/exec-invalid-sysroot.exp index 30c72dc..085cb4b 100644 --- a/gdb/testsuite/gdb.base/exec-invalid-sysroot.exp +++ b/gdb/testsuite/gdb.base/exec-invalid-sysroot.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -19,31 +19,29 @@ standard_testfile foll-exec.c -global binfile -set binfile [standard_output_file "foll-exec"] +set testfile "foll-exec" +set binfile [standard_output_file $testfile] set testfile2 "execd-prog" set srcfile2 ${testfile2}.c set binfile2 [standard_output_file ${testfile2}] set compile_options debug -# build the first test case -if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable $compile_options] != "" } { - untested "failed to compile secondary testcase" - return -1 +# Build the executable which will be exec'd. +if { [build_executable "build exec'd file" $testfile2 $srcfile2 $compile_options] != 0 } { + return } if { [is_remote target] } { gdb_remote_download target $binfile2 } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_options] != "" } { - untested "failed to compile main testcase" - return -1 +# Build the test executable, which performs the exec. +if { [prepare_for_testing "prepare" $testfile $srcfile $compile_options] != 0 } { + return } proc do_exec_sysroot_test {} { - global binfile srcfile srcfile2 testfile testfile2 global gdb_prompt gdb_test_no_output "set sysroot /a/path/that/does/not/exist" @@ -68,6 +66,4 @@ proc do_exec_sysroot_test {} { } } -# Start with a fresh gdb -clean_restart $binfile do_exec_sysroot_test diff --git a/gdb/testsuite/gdb.base/execl-update-breakpoints.c b/gdb/testsuite/gdb.base/execl-update-breakpoints.c index f0dea4d..e71efd0 100644 --- a/gdb/testsuite/gdb.base/execl-update-breakpoints.c +++ b/gdb/testsuite/gdb.base/execl-update-breakpoints.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/execl-update-breakpoints.exp b/gdb/testsuite/gdb.base/execl-update-breakpoints.exp index 86f038a..95198a4 100644 --- a/gdb/testsuite/gdb.base/execl-update-breakpoints.exp +++ b/gdb/testsuite/gdb.base/execl-update-breakpoints.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -23,8 +23,10 @@ standard_testfile # unmapped address in the second binary. set objfile ${binfile}.o -set exec1 ${binfile}1 -set exec2 ${binfile}2 +set testfile1 ${testfile}1 +set testfile2 ${testfile}2 +set exec1 [standard_output_file $testfile1] +set exec2 [standard_output_file $testfile2] if { [gdb_compile [file join $srcdir $subdir $srcfile] $objfile \ object [list debug]] != "" } { @@ -41,7 +43,7 @@ if { [gdb_compile $objfile $exec1 executable {debug text_segment=0x1000000}] != # First check whether the address of "main" in exec1 is readable in # exec2. If it is, then skip the test as unsupported. -clean_restart ${exec1} +clean_restart $testfile1 if {![runto_main]} { return -1 } @@ -55,7 +57,7 @@ gdb_test_multiple "p/x &main" $test { } } -clean_restart ${exec2} +clean_restart $testfile2 if {![runto_main]} { return -1 } @@ -81,10 +83,9 @@ if {!$cannot_access} { # "breakpoint always-inserted" mode. proc test { always_inserted } { - global exec1 global gdb_prompt - clean_restart ${exec1} + clean_restart $::testfile1 gdb_test_no_output "set breakpoint always-inserted $always_inserted" diff --git a/gdb/testsuite/gdb.base/execution-termios.c b/gdb/testsuite/gdb.base/execution-termios.c index b4c13b2..f3e4f16 100644 --- a/gdb/testsuite/gdb.base/execution-termios.c +++ b/gdb/testsuite/gdb.base/execution-termios.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/execution-termios.exp b/gdb/testsuite/gdb.base/execution-termios.exp index c530d73..c817db2 100644 --- a/gdb/testsuite/gdb.base/execution-termios.exp +++ b/gdb/testsuite/gdb.base/execution-termios.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -24,7 +24,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { proc test { prefix body } { with_test_prefix $prefix { - if ![runto_main] { + if {![runto_main]} { return 0 } uplevel 1 $body @@ -39,7 +39,7 @@ test "next" { } test "infcall" { - if ![target_info exists gdb,cannot_call_functions] { + if {![target_info exists gdb,cannot_call_functions]} { gdb_test "print func ()" " = 1" "termios ok" } else { unsupported "cannot call functions" diff --git a/gdb/testsuite/gdb.base/exitsignal.exp b/gdb/testsuite/gdb.base/exitsignal.exp index 2d6fc03..6606cc1 100644 --- a/gdb/testsuite/gdb.base/exitsignal.exp +++ b/gdb/testsuite/gdb.base/exitsignal.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/expand-psymtabs.c b/gdb/testsuite/gdb.base/expand-psymtabs.c index 8af65ba..ba0c64c 100644 --- a/gdb/testsuite/gdb.base/expand-psymtabs.c +++ b/gdb/testsuite/gdb.base/expand-psymtabs.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2007-2024 Free Software Foundation, Inc. + Copyright 2007-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 diff --git a/gdb/testsuite/gdb.base/expand-psymtabs.exp b/gdb/testsuite/gdb.base/expand-psymtabs.exp index 875b100..bdbc678 100644 --- a/gdb/testsuite/gdb.base/expand-psymtabs.exp +++ b/gdb/testsuite/gdb.base/expand-psymtabs.exp @@ -1,4 +1,4 @@ -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 @@ -26,7 +26,7 @@ # # This test is meant to verify that, even with lazy partial symtab # reading in effect, GDB can set breakpoints by line number -# successfully in either compilation unit. +# successfully in either compilation unit. standard_testfile @@ -39,4 +39,3 @@ if {[prepare_for_testing_full "failed to prepare" \ set foo_bp [gdb_get_line_number "Break here"] gdb_test "break $foo_bp" "Breakpoint.*" "expand psymtabs" - diff --git a/gdb/testsuite/gdb.base/exprs.c b/gdb/testsuite/gdb.base/exprs.c index 195b88e..e1cd4f2 100644 --- a/gdb/testsuite/gdb.base/exprs.c +++ b/gdb/testsuite/gdb.base/exprs.c @@ -3,7 +3,7 @@ int main (int argc, char **argv, char **envp) extern void dummy(); dummy(); return 0; - + } /* We put main() right up front so its line number doesn't keep changing. */ @@ -190,16 +190,16 @@ void dummy() v_short = 3; v_signed_short = 4; - v_unsigned_short = 5; + v_unsigned_short = 5; v_int = 6; v_signed_int = 7; - v_unsigned_int = 8; + v_unsigned_int = 8; v_long = 9; v_signed_long = 10; - v_unsigned_long = 11; - + v_unsigned_long = 11; + v_float = 100.0; v_double = 200.0; v_char_array[0] = v_char; diff --git a/gdb/testsuite/gdb.base/exprs.exp b/gdb/testsuite/gdb.base/exprs.exp index 375af6b..d5a0227 100644 --- a/gdb/testsuite/gdb.base/exprs.exp +++ b/gdb/testsuite/gdb.base/exprs.exp @@ -1,4 +1,4 @@ -# Copyright 1988-2024 Free Software Foundation, Inc. +# Copyright 1988-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 @@ -21,13 +21,10 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart ${binfile} - # # set it up at a breakpoint so we can play with the variable values # @@ -44,11 +41,11 @@ proc test_expr { args } { if { [llength $args] % 2 } { warning "an even # of arguments should be passed to test_expr" } - set last_ent [expr [llength $args] - 1] + set last_ent [expr {[llength $args] - 1}] set testname [lindex $args $last_ent] gdb_test [lindex $args 0] ".*" "$testname, setup" - for {set x 1} {$x < $last_ent} {set x [expr $x + 2]} { - gdb_test [lindex $args $x] [lindex $args [expr $x + 1]] "$testname, [lindex $args $x]" + for {set x 1} {$x < $last_ent} {set x [expr {$x + 2}]} { + gdb_test [lindex $args $x] [lindex $args [expr {$x + 1}]] "$testname, [lindex $args $x]" } } # @@ -223,10 +220,10 @@ gdb_test_multiple "print sizeof (long long) > sizeof (long)" \ pass "sizeof (long long) > sizeof (long) (false)" } } -if [expr ! $ok] { setup_xfail "*-*-*" } +if {!$ok} { setup_xfail "*-*-*" } gdb_test "print (void*) ((long long) (unsigned long) -1 + 1)" \ "warning: value truncated.*" "truncate (void*) 0x00000000ffffffff + 1" -if [expr ! $ok] { setup_xfail "*-*-*" } +if {!$ok} { setup_xfail "*-*-*" } gdb_test "print (void*) (~((long long)(unsigned long) -1) - 1)" \ "warning: value truncated.*" "truncate (void*) 0xffffffff00000000 - 1" @@ -284,3 +281,24 @@ gdb_test "print v_short + " \ # Test for a syntax error in the middle of an expression. gdb_test "print v_short =}{= 3" \ "A syntax error in expression, near `\\}\\{= 3'\\." + +set hs {[^\r\n]} +set re_debug [string cat $hs* {[Ss]hift} $hs*] + +gdb_test_no_output "set debug parse 1" +set saw_start 0 +set saw_val 0 +gdb_test_multiple "print 23" "print with debugging" -lbl { + -re "\r\n${re_debug}(?=\r\n)" { + set saw_start 1 + exp_continue + } + -re "\r\n.$decimal = 23(?=\r\n)" { + set saw_val 1 + exp_continue + } + + -re -wrap "" { + gdb_assert {$saw_start && $saw_val} $gdb_test_name + } +} diff --git a/gdb/testsuite/gdb.base/fileio.c b/gdb/testsuite/gdb.base/fileio.c index 0f20151..0ef85a2 100644 --- a/gdb/testsuite/gdb.base/fileio.c +++ b/gdb/testsuite/gdb.base/fileio.c @@ -14,7 +14,7 @@ 1) Attempt to create file that already exists - EEXIST 2) Attempt to open a directory for writing - EISDIR 3) Pathname does not exist - ENOENT -4) Open for write but no write permission - EACCES +4) Open for write but no write permission - EACCES read(int fd, void *buf, size_t count); 1) Read using invalid file descriptor - EBADF @@ -65,7 +65,7 @@ static const char *strerrno (int err); /* Note that OUTDIR is defined by the test suite. */ #define FILENAME "foo.fileio.test" #define RENAMED "bar.fileio.test" -#define NONEXISTANT "nofoo.fileio.test" +#define NONEXISTENT "nofoo.fileio.test" #define NOWRITE "nowrt.fileio.test" #define TESTDIR1 "dir1.fileio.test" #define TESTDIR2 "dir2.fileio.test" @@ -73,6 +73,10 @@ static const char *strerrno (int err); #define STRING "Hello World" +#define STRINGIFY(s) STRINGIFY_(s) +#define STRINGIFY_(s) #s +#define OUTDIR STRINGIFY (OUTDIR_) + static void stop (void) {} /* A NULL string. We pass this to stat below instead of a NULL @@ -89,7 +93,7 @@ test_open (void) ret = open (OUTDIR FILENAME, O_CREAT | O_TRUNC | O_RDWR, S_IWUSR | S_IRUSR); printf ("open 1: ret = %d, errno = %d %s\n", ret, errno, ret >= 0 ? "OK" : ""); - + if (ret >= 0) close (ret); stop (); @@ -111,7 +115,7 @@ test_open (void) stop (); /* Opening nonexistant file */ errno = 0; - ret = open (NONEXISTANT, O_RDONLY); + ret = open (NONEXISTENT, O_RDONLY); printf ("open 4: ret = %d, errno = %d %s\n", ret, errno, strerrno (errno)); if (ret >= 0) @@ -152,7 +156,7 @@ test_write (void) errno = 0; ret = write (fd, STRING, strlen (STRING)); printf ("write 1: ret = %d, errno = %d %s\n", ret, errno, - ret == strlen (STRING) ? "OK" : ""); + ret == strlen (STRING) ? "OK" : ""); close (fd); } else @@ -196,7 +200,7 @@ test_read (void) ret = read (fd, buf, 16); buf[15] = '\0'; /* Don't trust anybody... */ if (ret == strlen (STRING)) - printf ("read 1: %s %s\n", buf, !strcmp (buf, STRING) ? "OK" : ""); + printf ("read 1: %s %s\n", buf, !strcmp (buf, STRING) ? "OK" : ""); else printf ("read 1: ret = %d, errno = %d\n", ret, errno); close (fd); @@ -226,17 +230,17 @@ test_lseek (void) errno = 0; ret = lseek (fd, 0, SEEK_CUR); printf ("lseek 1: ret = %ld, errno = %d, %s\n", (long) ret, errno, - ret == 0 ? "OK" : ""); + ret == 0 ? "OK" : ""); stop (); errno = 0; ret = lseek (fd, 0, SEEK_END); printf ("lseek 2: ret = %ld, errno = %d, %s\n", (long) ret, errno, - ret == 11 ? "OK" : ""); + ret == 11 ? "OK" : ""); stop (); errno = 0; ret = lseek (fd, 3, SEEK_SET); printf ("lseek 3: ret = %ld, errno = %d, %s\n", (long) ret, errno, - ret == 3 ? "OK" : ""); + ret == 3 ? "OK" : ""); close (fd); } else @@ -267,7 +271,7 @@ test_close (void) errno = 0; ret = close (fd); printf ("close 1: ret = %d, errno = %d, %s\n", ret, errno, - ret == 0 ? "OK" : ""); + ret == 0 ? "OK" : ""); } else printf ("close 1: errno = %d\n", errno); @@ -276,7 +280,7 @@ test_close (void) errno = 0; ret = close (999); printf ("close 2: ret = %d, errno = %d, %s\n", ret, errno, - strerrno (errno)); + strerrno (errno)); stop (); } @@ -299,19 +303,19 @@ test_stat (void) errno = 0; ret = stat (null_str, &st); printf ("stat 2: ret = %d, errno = %d %s\n", ret, errno, - strerrno (errno)); + strerrno (errno)); stop (); /* Empty pathname */ errno = 0; ret = stat ("", &st); printf ("stat 3: ret = %d, errno = %d %s\n", ret, errno, - strerrno (errno)); + strerrno (errno)); stop (); - /* Nonexistant file */ + /* Nonexistent file */ errno = 0; - ret = stat (NONEXISTANT, &st); + ret = stat (NONEXISTENT, &st); printf ("stat 4: ret = %d, errno = %d %s\n", ret, errno, - strerrno (errno)); + strerrno (errno)); stop (); } @@ -342,7 +346,7 @@ test_fstat (void) errno = 0; ret = fstat (999, &st); printf ("fstat 2: ret = %d, errno = %d %s\n", ret, errno, - strerrno (errno)); + strerrno (errno)); stop (); } @@ -422,7 +426,7 @@ test_rename (void) errno = 0; ret = stat (FILENAME, &st); if (ret && errno == ENOENT) - { + { errno = 0; ret = stat (OUTDIR RENAMED, &st); printf ("rename 1: ret = %d, errno = %d %s\n", ret, errno, @@ -445,7 +449,7 @@ test_rename (void) errno = 0; ret = rename (OUTDIR TESTDIR2, OUTDIR TESTDIR1); printf ("rename 3: ret = %d, errno = %d %s\n", ret, errno, - strerrno (errno)); + strerrno (errno)); stop (); /* newpath is a subdirectory of old path */ errno = 0; @@ -455,7 +459,7 @@ test_rename (void) stop (); /* oldpath does not exist */ errno = 0; - ret = rename (OUTDIR NONEXISTANT, OUTDIR FILENAME); + ret = rename (OUTDIR NONEXISTENT, OUTDIR FILENAME); printf ("rename 5: ret = %d, errno = %d %s\n", ret, errno, strerrno (errno)); stop (); @@ -483,12 +487,12 @@ test_unlink (void) sprintf (sys, "chmod -w %s/%s", OUTDIR, TESTDIR2); ret = system (sys); if (!ret) - { + { errno = 0; ret = unlink (name); printf ("unlink 2: ret = %d, errno = %d %s\n", ret, errno, strerrno (errno)); - } + } else printf ("unlink 2: ret = %d chmod failed, errno= %d\n", ret, errno); } @@ -497,9 +501,9 @@ test_unlink (void) stop (); /* pathname doesn't exist */ errno = 0; - ret = unlink (OUTDIR NONEXISTANT); + ret = unlink (OUTDIR NONEXISTENT); printf ("unlink 3: ret = %d, errno = %d %s\n", ret, errno, - strerrno (errno)); + strerrno (errno)); stop (); } diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp index f31a775..b9f7b47 100644 --- a/gdb/testsuite/gdb.base/fileio.exp +++ b/gdb/testsuite/gdb.base/fileio.exp @@ -1,4 +1,4 @@ -# Copyright 2002-2024 Free Software Foundation, Inc. +# Copyright 2002-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 @@ -27,7 +27,7 @@ if {[is_remote host]} { if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ executable \ - [list debug "additional_flags=-DOUTDIR=\"$outdir/\""]] != "" } { + [list debug additional_flags=[quote_for_host -DOUTDIR_=$outdir/]]] != "" } { untested "failed to compile" return -1 } @@ -39,9 +39,9 @@ if {[file exists $dir2] && ![file writable $dir2]} { system "rm -rf [standard_output_file *.fileio.test]" set oldtimeout $timeout -set timeout [expr "$timeout + 60"] +set timeout [expr {$timeout + 60}] -clean_restart $binfile +clean_restart $testfile gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set print address off" gdb_test_no_output "set width 0" @@ -50,7 +50,7 @@ if {![runto_main]} { return } -gdb_test "break stop" "Breakpoint .*$srcfile.*" +gdb_test "break stop" "Breakpoint .*$srcfile.*" set stop_msg ".*Breakpoint .* stop \\(\\) at.*$srcfile:.*static void stop \\(void\\) {}.*" @@ -72,7 +72,7 @@ gdb_test continue \ gdb_test "continue" ".*" "" -catch "system \"chmod -f -w [standard_output_file nowrt.fileio.test]\"" +catch {system "chmod -f -w [standard_output_file nowrt.fileio.test]"} # If the user is root, we will always have write permission. if { [root_user] } { @@ -240,7 +240,7 @@ gdb_test continue \ # This test fails on Cygwin because unlink() succeeds on Win32 systems # in that situation. -if [ishost *cygwin*] { +if {[ishost *cygwin*]} { setup_xfail "*-*-*" } # If the user is root, we will always have write permission. diff --git a/gdb/testsuite/gdb.base/filename-completion.exp b/gdb/testsuite/gdb.base/filename-completion.exp index 03ead59..c80e634 100644 --- a/gdb/testsuite/gdb.base/filename-completion.exp +++ b/gdb/testsuite/gdb.base/filename-completion.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 @@ -148,7 +148,7 @@ proc test_tab_complete_within_line_multiple { input_line back_count \ [join [list \ [string range $input_line 0 end-$back_count] \ ${add_completed_line} \ - [string range $input_line end-[expr $back_count - 1] end]] \ + [string range $input_line end-[expr {$back_count - 1}] end]] \ ""] set expanded_line_re [string_to_regexp $expanded_line] @@ -166,7 +166,7 @@ proc test_tab_complete_within_line_multiple { input_line back_count \ set after_tab_re "^$input_line_re" set after_tab_re "$after_tab_re\\\x08{$back_count}" set after_tab_re "$after_tab_re${completion::bell_re}" - set tail [string range $input_line end-[expr $back_count - 1] end] + set tail [string range $input_line end-[expr {$back_count - 1}] end] set after_tab_re "$after_tab_re$add_completed_line_re" set after_tab_re "$after_tab_re[string_to_regexp $tail]" set after_tab_re "$after_tab_re\\\x08{$back_count}" @@ -218,7 +218,7 @@ proc test_tab_complete_within_line_unique { input_line back_count insert_str } { set re [string_to_regexp $input_line] set re $re\\\x08{$back_count} set re $re[string_to_regexp $insert_str] - set tail [string range $input_line end-[expr $back_count - 1] end] + set tail [string range $input_line end-[expr {$back_count - 1}] end] set re $re[string_to_regexp $tail] set re $re\\\x08{$back_count} @@ -381,11 +381,15 @@ proc run_mid_line_completion_tests { root cmd } { proc run_quoting_and_escaping_tests { root } { # Test all the commands which allow quoting of filenames, and # which require whitespace to be escaped in unquoted filenames. - foreach_with_prefix cmd { file exec-file symbol-file add-symbol-file \ - remove-symbol-file \ - "target core" "target exec" "target tfile" \ - "maint print c-tdesc" "compile file" \ - "save gdb-index" "save gdb-index -dwarf-5" } { + set all_cmds { file exec-file symbol-file add-symbol-file \ + remove-symbol-file \ + "target core" "target exec" "target tfile" \ + "maint print c-tdesc" "save gdb-index" + "save gdb-index -dwarf-5" "shell ls"} + if { [allow_compile_tests] } { + lappend all_cmds "compile file" + } + foreach_with_prefix cmd $all_cmds { # Try each test placing the filename as the first argument # then again with a quoted string immediately after the # command. This works because the filename completer will @@ -404,6 +408,31 @@ proc run_quoting_and_escaping_tests { root } { run_quoting_and_escaping_tests_1 $root $cmd } } + + # Some additional testing of shell command. Test 'shell' and '!' + # when there are multiple filenames on the command line. This + # focuses on completion of the final filename. There is also some + # testing of the shell command above, this tests completion within + # the line. + foreach_with_prefix shell_cmd { "shell " "!" "pipe print 1 | " } { + foreach suffix { "aaa/aa bb" "bb2/dir 1/unique file" } { + set dir $root/$suffix + + regsub -all " " "$dir" "\\ " dir_with_backslash + + with_test_prefix "suffix='$suffix'" { + with_test_prefix "with_backslash" { + run_quoting_and_escaping_tests_1 $root "${shell_cmd}ls $dir_with_backslash" + } + with_test_prefix "with double quotes" { + run_quoting_and_escaping_tests_1 $root "${shell_cmd}ls \"$dir\"" + } + with_test_prefix "with single quotes" { + run_quoting_and_escaping_tests_1 $root "${shell_cmd}ls '$dir'" + } + } + } + } } # Helper for run_unquoted_tests. ROOT is the root directory as setup diff --git a/gdb/testsuite/gdb.base/filesym.c b/gdb/testsuite/gdb.base/filesym.c index 4145e37..66cb1bb 100644 --- a/gdb/testsuite/gdb.base/filesym.c +++ b/gdb/testsuite/gdb.base/filesym.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/filesym.exp b/gdb/testsuite/gdb.base/filesym.exp index 28f0776..4cfba92 100644 --- a/gdb/testsuite/gdb.base/filesym.exp +++ b/gdb/testsuite/gdb.base/filesym.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/find-unmapped.c b/gdb/testsuite/gdb.base/find-unmapped.c index c4517db..c02cea6 100644 --- a/gdb/testsuite/gdb.base/find-unmapped.c +++ b/gdb/testsuite/gdb.base/find-unmapped.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/find-unmapped.exp b/gdb/testsuite/gdb.base/find-unmapped.exp index cab1fe9..8f18650 100644 --- a/gdb/testsuite/gdb.base/find-unmapped.exp +++ b/gdb/testsuite/gdb.base/find-unmapped.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -19,7 +19,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile}] } { return -1 } -if ![runto breakpt] { +if {![runto breakpt]} { return -1 } diff --git a/gdb/testsuite/gdb.base/find.c b/gdb/testsuite/gdb.base/find.c index ffac2c9..786b960 100644 --- a/gdb/testsuite/gdb.base/find.c +++ b/gdb/testsuite/gdb.base/find.c @@ -1,7 +1,7 @@ /* Testcase for the find command. This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/find.exp b/gdb/testsuite/gdb.base/find.exp index a46d6af..23207be 100644 --- a/gdb/testsuite/gdb.base/find.exp +++ b/gdb/testsuite/gdb.base/find.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -17,13 +17,11 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile \ + {debug nowarnings}] != 0 } { + return } -clean_restart ${binfile} - gdb_test "break $srcfile:stop_here" \ "Breakpoint.*at.* file .*$srcfile, line.*" \ "breakpoint function in file" @@ -164,7 +162,7 @@ gdb_test "find /w search_buf, +search_buf_size, 0x12345678" \ # For native targets, test a pattern straddling a chunk boundary. -if [isnative] { +if {[isnative]} { gdb_test_no_output "set *(int32_t*) &search_buf\[${CHUNK_SIZE}-1\] = 0xfdb97531" "" gdb_test "find /w search_buf, +search_buf_size, 0xfdb97531" \ "${hex_number}${one_pattern_found}" \ diff --git a/gdb/testsuite/gdb.base/finish-pretty.c b/gdb/testsuite/gdb.base/finish-pretty.c index 41f1118..48dbc67 100644 --- a/gdb/testsuite/gdb.base/finish-pretty.c +++ b/gdb/testsuite/gdb.base/finish-pretty.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/finish-pretty.exp b/gdb/testsuite/gdb.base/finish-pretty.exp index 0b6bea6..8f0c7c1 100644 --- a/gdb/testsuite/gdb.base/finish-pretty.exp +++ b/gdb/testsuite/gdb.base/finish-pretty.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -29,7 +29,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] } { } proc finish_pretty { } { - if ![runto foo] { + if {![runto foo]} { return } gdb_test_no_output "set print pretty" \ diff --git a/gdb/testsuite/gdb.base/finish.exp b/gdb/testsuite/gdb.base/finish.exp index f40577c..af1d79b 100644 --- a/gdb/testsuite/gdb.base/finish.exp +++ b/gdb/testsuite/gdb.base/finish.exp @@ -1,4 +1,4 @@ -# Copyright 2000-2024 Free Software Foundation, Inc. +# Copyright 2000-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 @@ -77,12 +77,12 @@ proc finish_void { } { proc finish_abbreviation { abbrev } { if {![runto "int_func"]} { - return -1 + return -1 } gdb_test "$abbrev" \ - "Value returned is .* = 1" \ - "Testing the \"$abbrev\" abbreviation for \"finish\"" + "Value returned is .* = 1" \ + "Testing the \"$abbrev\" abbreviation for \"finish\"" } # Test "set print finish off". diff --git a/gdb/testsuite/gdb.base/fission-macro-2.c b/gdb/testsuite/gdb.base/fission-macro-2.c index fb088c8..ecd3ab3 100644 --- a/gdb/testsuite/gdb.base/fission-macro-2.c +++ b/gdb/testsuite/gdb.base/fission-macro-2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/fission-macro.c b/gdb/testsuite/gdb.base/fission-macro.c index 9c8cbec..03606bb 100644 --- a/gdb/testsuite/gdb.base/fission-macro.c +++ b/gdb/testsuite/gdb.base/fission-macro.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/fission-macro.exp b/gdb/testsuite/gdb.base/fission-macro.exp index 9e5d5c0..29ef6920 100644 --- a/gdb/testsuite/gdb.base/fission-macro.exp +++ b/gdb/testsuite/gdb.base/fission-macro.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 @@ -14,15 +14,18 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. */ # Gcc 14 is the first release containing the fix for PR debug/111409. -require {expr [gcc_major_version] >= 14} +require {expr {[gcc_major_version] >= 14}} standard_testfile .c -2.c -proc do_tests { dwarf_version dwarf_bits strict_dwarf } { +proc do_tests { lang dwarf_version dwarf_bits strict_dwarf } { set opts {} lappend opts debug lappend opts quiet lappend opts additional_flags=-gsplit-dwarf + if {$lang == "c++"} { + lappend opts "additional_flags=-x c++" + } lappend opts macros if { $dwarf_bits == 64 } { @@ -66,14 +69,16 @@ proc do_tests { dwarf_version dwarf_bits strict_dwarf } { gdb_test "info macro FOURTH" "#define FOURTH 4" } -foreach_with_prefix dwarf_version {4 5} { - if { $dwarf_version == 4 && [gcc_major_version] < 15 } { - # Gcc does not contain fix for PR debug/115066. - continue - } - foreach_with_prefix dwarf_bits {32 64} { - foreach_with_prefix strict_dwarf {0 1} { - do_tests $dwarf_version $dwarf_bits $strict_dwarf +foreach_with_prefix lang {c c++} { + foreach_with_prefix dwarf_version {4 5} { + if { $dwarf_version == 4 && [gcc_major_version] < 15 } { + # Gcc does not contain fix for PR debug/115066. + continue + } + foreach_with_prefix dwarf_bits {32 64} { + foreach_with_prefix strict_dwarf {0 1} { + do_tests $lang $dwarf_version $dwarf_bits $strict_dwarf + } } } } diff --git a/gdb/testsuite/gdb.base/fixsection.c b/gdb/testsuite/gdb.base/fixsection.c index d3874b3..0de02388 100644 --- a/gdb/testsuite/gdb.base/fixsection.c +++ b/gdb/testsuite/gdb.base/fixsection.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2024 Free Software Foundation, Inc. +/* Copyright (C) 2008-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 diff --git a/gdb/testsuite/gdb.base/fixsection.exp b/gdb/testsuite/gdb.base/fixsection.exp index 23c7475..1915797 100644 --- a/gdb/testsuite/gdb.base/fixsection.exp +++ b/gdb/testsuite/gdb.base/fixsection.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2008-2024 Free Software Foundation, Inc. +# Copyright (C) 2008-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 @@ -22,17 +22,17 @@ set libfile "fixsectshr" set libsrc ${srcdir}/${subdir}/${libfile}.c set lib_sl [standard_output_file ${libfile}.sl] -set lib_opts [list debug nowarnings] +set lib_opts [list debug nowarnings shlib] set exec_opts [list debug nowarnings shlib=$lib_sl] -if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != "" - || [gdb_compile $srcdir/$subdir/$srcfile $binfile \ - executable $exec_opts] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build shlib" $lib_sl $libsrc $lib_opts] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } { + return } -clean_restart $binfile gdb_load_shlib ${lib_sl} if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/flexible-array-member.c b/gdb/testsuite/gdb.base/flexible-array-member.c index d53bcd0..00e1313 100644 --- a/gdb/testsuite/gdb.base/flexible-array-member.c +++ b/gdb/testsuite/gdb.base/flexible-array-member.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/flexible-array-member.exp b/gdb/testsuite/gdb.base/flexible-array-member.exp index 7bc40de..5e8cc9a 100644 --- a/gdb/testsuite/gdb.base/flexible-array-member.exp +++ b/gdb/testsuite/gdb.base/flexible-array-member.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/float.c b/gdb/testsuite/gdb.base/float.c index ec0beee..52e4719 100644 --- a/gdb/testsuite/gdb.base/float.c +++ b/gdb/testsuite/gdb.base/float.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/float.exp b/gdb/testsuite/gdb.base/float.exp index 49dc0a3..bb350ed 100644 --- a/gdb/testsuite/gdb.base/float.exp +++ b/gdb/testsuite/gdb.base/float.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 @@ -49,8 +49,8 @@ if {[is_aarch64_target]} { # if we have NEON. pass "info float (VFP)" } - -re "No floating.point info available for this processor.*$gdb_prompt $" { - pass "info float (without FPU)" + -re "No floating.point info available for this processor.*$gdb_prompt $" { + pass "info float (without FPU)" } } } elseif {[istarget "i?86-*-*"] || [istarget "x86_64-*-*"]} { @@ -59,11 +59,11 @@ if {[is_aarch64_target]} { gdb_test "info float" "f0.*f1.*f127.*" } elseif {[istarget "m68k-*-*"]} { gdb_test_multiple "info float" "info_float" { - -re "fp0.*fp1.*fp7.*$gdb_prompt $" { - pass "info float (with FPU)" + -re "fp0.*fp1.*fp7.*$gdb_prompt $" { + pass "info float (with FPU)" } - -re "No floating.point info available for this processor.*$gdb_prompt $" { - pass "info float (without FPU)" + -re "No floating.point info available for this processor.*$gdb_prompt $" { + pass "info float (without FPU)" } } } elseif {[istarget "mips*-*-*"]} { @@ -77,20 +77,20 @@ if {[is_aarch64_target]} { } } elseif {[istarget "nds32*-*-*"]} { gdb_test_multiple "info float" "info_float" { - -re "fd0.*fd3.*$gdb_prompt $" { - pass "info float (with FPU)" + -re "fd0.*fd3.*$gdb_prompt $" { + pass "info float (with FPU)" } - -re "No floating.point info available for this processor.*$gdb_prompt $" { - pass "info float (without FPU)" + -re "No floating.point info available for this processor.*$gdb_prompt $" { + pass "info float (without FPU)" } } } elseif {[istarget "powerpc*-*-*"]} { gdb_test_multiple "info float" "info_float" { - -re "f0.*f1.*f31.*fpscr.*$gdb_prompt $" { - pass "info float (with FPU)" + -re "f0.*f1.*f31.*fpscr.*$gdb_prompt $" { + pass "info float (with FPU)" } - -re "No floating.point info available for this processor.*$gdb_prompt $" { - pass "info float (without FPU)" + -re "No floating.point info available for this processor.*$gdb_prompt $" { + pass "info float (without FPU)" } } } elseif {[istarget "s390*-*-*"]} { diff --git a/gdb/testsuite/gdb.base/float128.c b/gdb/testsuite/gdb.base/float128.c index ee6dde4..475d7f4 100644 --- a/gdb/testsuite/gdb.base/float128.c +++ b/gdb/testsuite/gdb.base/float128.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/float128.exp b/gdb/testsuite/gdb.base/float128.exp index a779318..c6ed0ce 100644 --- a/gdb/testsuite/gdb.base/float128.exp +++ b/gdb/testsuite/gdb.base/float128.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 @@ -30,7 +30,7 @@ if { [do_compile] != "" && [do_compile {-mfloat128}] != "" } { return -1 } -clean_restart ${binfile} +clean_restart $testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/floatn.c b/gdb/testsuite/gdb.base/floatn.c index 5b1a741..d7c33e7 100644 --- a/gdb/testsuite/gdb.base/floatn.c +++ b/gdb/testsuite/gdb.base/floatn.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/floatn.exp b/gdb/testsuite/gdb.base/floatn.exp index 6cfd0fd..f08ed90 100644 --- a/gdb/testsuite/gdb.base/floatn.exp +++ b/gdb/testsuite/gdb.base/floatn.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 @@ -30,7 +30,7 @@ if { [do_compile] != "" && [do_compile {-mfloat128}] != "" } { return -1 } -clean_restart ${binfile} +clean_restart $testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/foll-exec-c++.exp b/gdb/testsuite/gdb.base/foll-exec-c++.exp new file mode 100644 index 0000000..d96310b --- /dev/null +++ b/gdb/testsuite/gdb.base/foll-exec-c++.exp @@ -0,0 +1,24 @@ +# 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/>. + +# This file is part of the gdb testsuite + +# See foll-exec.exp.tcl for test details. This file runs the test +# using the C++ compiler. + +require allow_cplus_tests +set lang c++ + +source $srcdir/$subdir/foll-exec.exp.tcl diff --git a/gdb/testsuite/gdb.base/foll-exec-c.exp b/gdb/testsuite/gdb.base/foll-exec-c.exp new file mode 100644 index 0000000..67f62cc --- /dev/null +++ b/gdb/testsuite/gdb.base/foll-exec-c.exp @@ -0,0 +1,23 @@ +# 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/>. + +# This file is part of the gdb testsuite + +# See foll-exec.exp.tcl for test details. This file runs the test +# using the C compiler. + +set lang c + +source $srcdir/$subdir/foll-exec.exp.tcl diff --git a/gdb/testsuite/gdb.base/foll-exec-mode.c b/gdb/testsuite/gdb.base/foll-exec-mode.c index 9bd2554..be0fa80 100644 --- a/gdb/testsuite/gdb.base/foll-exec-mode.c +++ b/gdb/testsuite/gdb.base/foll-exec-mode.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/foll-exec-mode.exp b/gdb/testsuite/gdb.base/foll-exec-mode.exp index 56a2ffc..ec2d905 100644 --- a/gdb/testsuite/gdb.base/foll-exec-mode.exp +++ b/gdb/testsuite/gdb.base/foll-exec-mode.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 diff --git a/gdb/testsuite/gdb.base/foll-exec.c b/gdb/testsuite/gdb.base/foll-exec.c index e3a47f0..291f803 100644 --- a/gdb/testsuite/gdb.base/foll-exec.c +++ b/gdb/testsuite/gdb.base/foll-exec.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 1997-2024 Free Software Foundation, Inc. + Copyright 1997-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 @@ -19,25 +19,38 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> - +#include <libgen.h> +#include <assert.h> #include <limits.h> int global_i = 100; +#ifndef EXECD_PROG +#define EXECD_PROG "execd-prog" +#endif + int main (int argc, char ** argv) { int local_j = global_i + 1; int local_k = local_j + 1; char prog[PATH_MAX]; - int len; + size_t len = PATH_MAX - 1; + + printf ("foll-exec is about to execlp(%s)...\n", EXECD_PROG); + + prog [len] = '\0'; + + strncpy (prog, dirname (argv[0]), len); + len -= strlen (prog); + assert (len > 0); - printf ("foll-exec is about to execlp(execd-prog)...\n"); + strncat (prog, "/", len); + len -= 1; + assert (len > 0); - strcpy (prog, argv[0]); - len = strlen (prog); - /* Replace "foll-exec" with "execd-prog". */ - memcpy (prog + len - 9, "execd-prog", 10); - prog[len + 1] = 0; + strncat (prog, EXECD_PROG, len); + len -= strlen (EXECD_PROG); + assert (len > 0); /* In the following function call, maximum line length exceed the limit 80. This is intentional and required for clang compiler such that complete @@ -45,7 +58,7 @@ int main (int argc, char ** argv) multi-line. */ execlp (prog, /* tbreak-execlp */ prog, "execlp arg1 from foll-exec", (char *) 0); - printf ("foll-exec is about to execl(execd-prog)...\n"); + printf ("foll-exec is about to execl(%s)...\n", EXECD_PROG); /* In the following function call, maximum line length exceed the limit 80. This is intentional and required for clang compiler such that complete @@ -61,7 +74,7 @@ int main (int argc, char ** argv) argv[0] = prog; - printf ("foll-exec is about to execv(execd-prog)...\n"); + printf ("foll-exec is about to execv(%s)...\n", EXECD_PROG); execv (prog, argv); /* tbreak-execv */ } diff --git a/gdb/testsuite/gdb.base/foll-exec.exp b/gdb/testsuite/gdb.base/foll-exec.exp.tcl index 206e713..dc65d95 100644 --- a/gdb/testsuite/gdb.base/foll-exec.exp +++ b/gdb/testsuite/gdb.base/foll-exec.exp.tcl @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -22,33 +22,56 @@ require {istarget "*-linux*"} standard_testfile foll-exec.c -set testfile2 "execd-prog" -set srcfile2 ${testfile2}.c -set binfile2 [standard_output_file ${testfile2}] +# Compile a program that performs an exec as EXECER_LANG, and a +# program that will be exec'd as EXECEE_LANG. Either language can be +# 'c' or 'c++'. Then run various test associated with 'catch exec' +# using the compiled programs. +proc do_exec_tests { execer_lang execee_lang } { + global srcfile testfile + global gdb_prompt -set compile_options debug + # First compile the program to be exec'd, the execee. + set execee_base_filename "execd-prog" + set srcfile2 ${execee_base_filename}.c + set execee_testfile "execd-prog-${execee_lang}" + set execee_testfile_re [string_to_regexp $execee_testfile] + set execee_binfile [standard_output_file $execee_testfile] -# build the first test case -if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable $compile_options] != "" } { - untested "failed to compile" - return -1 -} + set execee_flags debug + if { $execee_lang == "c++" } { + lappend execee_flags "c++" + } -if { [is_remote target] } { - gdb_remote_download target $binfile2 -} + if { [build_executable "failed to build $execee_testfile" $execee_testfile \ + $srcfile2 $execee_flags] == -1 } { + return + } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_options] != "" } { - untested "failed to compile" - return -1 -} + if { [is_remote target] } { + gdb_remote_download target $execee_binfile + } -proc do_exec_tests {} { - global binfile srcfile srcfile2 testfile testfile2 - global gdb_prompt + + # Now compile the program to do the exec, the execer. + set execer_testfile "$testfile-${execee_lang}" + set execer_binfile [standard_output_file $execer_testfile] + + set execer_flags debug + if { $execer_lang == "c++" } { + lappend execer_flags "c++" + } + lappend execer_flags "additional_flags=-DEXECD_PROG=\"${execee_testfile}\"" + + if { [build_executable "failed to build $execer_testfile" $execer_testfile \ + $srcfile $execer_flags] == -1 } { + return + } + + # Now we can start running the tests. + clean_restart + gdb_load $execer_binfile # Start the program running, and stop at main. - # if {![runto_main]} { return } @@ -71,7 +94,8 @@ proc do_exec_tests {} { return } - clean_restart $binfile + clean_restart + gdb_load $execer_binfile # Start the program running, and stop at main. # @@ -95,21 +119,21 @@ proc do_exec_tests {} { send_gdb "print global_i\n" gdb_expect { -re ".* = 100.*$gdb_prompt $"\ - {pass "print follow-exec/global_i"} + {pass "print follow-exec/global_i"} -re "$gdb_prompt $" {fail "print follow-exec/global_i"} timeout {fail "(timeout) print follow-exec/global_i"} } send_gdb "print local_j\n" gdb_expect { -re ".* = 101.*$gdb_prompt $"\ - {pass "print follow-exec/local_j"} + {pass "print follow-exec/local_j"} -re "$gdb_prompt $" {fail "print follow-exec/local_j"} timeout {fail "(timeout) print follow-exec/local_j"} } send_gdb "print local_k\n" gdb_expect { -re ".* = 102.*$gdb_prompt $"\ - {pass "print follow-exec/local_k"} + {pass "print follow-exec/local_k"} -re "$gdb_prompt $" {fail "print follow-exec/local_k"} timeout {fail "(timeout) print follow-exec/local_k"} } @@ -120,8 +144,8 @@ proc do_exec_tests {} { set execd_line [gdb_get_line_number "after-exec" $srcfile2] send_gdb "next\n" gdb_expect { - -re ".*xecuting new program: .*${testfile2}.*${srcfile2}:${execd_line}.*int local_j = argc;.*$gdb_prompt $"\ - {pass "step through execlp call"} + -re ".*xecuting new program: .*${execee_testfile_re}.*${srcfile2}:${execd_line}.*int local_j = argc;.*$gdb_prompt $"\ + {pass "step through execlp call"} -re "$gdb_prompt $" {fail "step through execlp call"} timeout {fail "(timeout) step through execlp call"} } @@ -132,7 +156,7 @@ proc do_exec_tests {} { send_gdb "next\n" gdb_expect { -re "printf \\(.Hello .*$gdb_prompt $"\ - {pass "step after execlp call"} + {pass "step after execlp call"} -re "$gdb_prompt $" {fail "step after execlp call"} timeout {fail "(timeout) step after execlp call"} } @@ -160,7 +184,8 @@ proc do_exec_tests {} { # Explicitly kill this program, or a subsequent rerun actually runs # the exec'd program, not the original program... - clean_restart $binfile + clean_restart + gdb_load $execer_binfile # Start the program running, and stop at main. # @@ -176,7 +201,7 @@ proc do_exec_tests {} { send_gdb "catch exec\n" gdb_expect { -re "Catchpoint .*(exec).*$gdb_prompt $"\ - {pass "set catch exec"} + {pass "set catch exec"} -re "$gdb_prompt $" {fail "set catch exec"} timeout {fail "(timeout) set catch exec"} } @@ -187,14 +212,14 @@ proc do_exec_tests {} { set msg "info shows catchpoint without exec pathname" gdb_test_multiple "info breakpoints" $msg { -re ".*catchpoint.*keep y.*exec\[\n\r\]+$gdb_prompt $" { - pass $msg + pass $msg } } send_gdb "continue\n" gdb_expect { - -re ".*xecuting new program:.*${testfile2}.*Catchpoint .*(exec\'d .*${testfile2}).*$gdb_prompt $"\ - {pass "hit catch exec"} + -re ".*xecuting new program:.*${execee_testfile_re}.*Catchpoint .*(exec\'d .*${execee_testfile_re}).*$gdb_prompt $"\ + {pass "hit catch exec"} -re "$gdb_prompt $" {fail "hit catch exec"} timeout {fail "(timeout) hit catch exec"} } @@ -210,8 +235,8 @@ proc do_exec_tests {} { # set msg "info shows catchpoint exec pathname" gdb_test_multiple "info breakpoints" $msg { - -re ".*catchpoint.*keep y.*exec, program \".*${testfile2}\".*$gdb_prompt $" { - pass $msg + -re ".*catchpoint.*keep y.*exec, program \".*${execee_testfile_re}\".*$gdb_prompt $" { + pass $msg } } @@ -221,14 +246,15 @@ proc do_exec_tests {} { send_gdb "continue\n" gdb_expect { -re ".*${srcfile2}:${execd_line}.*$gdb_prompt $"\ - {pass "continue after hit catch exec"} + {pass "continue after hit catch exec"} -re "$gdb_prompt $" {fail "continue after hit catch exec"} timeout {fail "(timeout) continue after hit catch exec"} } # Explicitly kill this program, or a subsequent rerun actually runs # the exec'd program, not the original program... - clean_restart $binfile + clean_restart + gdb_load $execer_binfile # Start the program running, and stop at main. # @@ -250,14 +276,14 @@ proc do_exec_tests {} { send_gdb "tbreak ${tbreak_line}\n" gdb_expect { -re "Temporary breakpoint .*file .*${srcfile}, line ${tbreak_line}.*$gdb_prompt $"\ - {pass "prepare to jump to execl call"} + {pass "prepare to jump to execl call"} -re "$gdb_prompt $" {fail "prepare to jump to execl call"} timeout {fail "(timeout) prepare to jump to execl call"} } send_gdb "jump ${tbreak_line}\n" gdb_expect { -re "main.* at .*${srcfile}:${tbreak_line}.*$gdb_prompt $"\ - {pass "jump to execl call"} + {pass "jump to execl call"} -re "$gdb_prompt $" {fail "jump to execl call"} timeout {fail "(timeout) jump to execl call"} } @@ -269,15 +295,15 @@ proc do_exec_tests {} { # send_gdb "next 2\n" gdb_expect { - -re ".*xecuting new program: .*${testfile2}.*${srcfile2}:${execd_line}.*int local_j = argc;.*$gdb_prompt $"\ - {pass "step through execl call"} + -re ".*xecuting new program: .*${execee_testfile_re}.*${srcfile2}:${execd_line}.*int local_j = argc;.*$gdb_prompt $"\ + {pass "step through execl call"} -re "$gdb_prompt $" {fail "step through execl call"} timeout {fail "(timeout) step through execl call"} } send_gdb "next\n" gdb_expect { -re "printf \\(.Hello .*$gdb_prompt $"\ - {pass "step after execl call"} + {pass "step after execl call"} -re "$gdb_prompt $" {fail "step after execl call"} timeout {fail "(timeout) step after execl call"} } @@ -295,7 +321,8 @@ proc do_exec_tests {} { # Explicitly kill this program, or a subsequent rerun actually runs # the exec'd program, not the original program... - clean_restart $binfile + clean_restart + gdb_load $execer_binfile # Start the program running, and stop at main. # @@ -317,28 +344,28 @@ proc do_exec_tests {} { send_gdb "tbreak ${tbreak_line}\n" gdb_expect { -re "Temporary breakpoint .*file .*${srcfile}, line ${tbreak_line}.*$gdb_prompt $"\ - {pass "prepare to jump to execv call"} + {pass "prepare to jump to execv call"} -re "$gdb_prompt $" {fail "prepare to jump to execv call"} timeout {fail "(timeout) prepare to jump to execv call"} } send_gdb "jump ${tbreak_line}\n" gdb_expect { -re "main.* at .*${srcfile}:${tbreak_line}.*$gdb_prompt $"\ - {pass "jump to execv call"} + {pass "jump to execv call"} -re "$gdb_prompt $" {fail "jump to execv call"} timeout {fail "(timeout) jump to execv call"} } send_gdb "next\n" gdb_expect { - -re ".*xecuting new program: .*${testfile2}.*${srcfile2}:${execd_line}.*int local_j = argc;.*$gdb_prompt $"\ - {pass "step through execv call"} + -re ".*xecuting new program: .*${execee_testfile_re}.*${srcfile2}:${execd_line}.*int local_j = argc;.*$gdb_prompt $"\ + {pass "step through execv call"} -re "$gdb_prompt $" {fail "step through execv call"} timeout {fail "(timeout) step through execv call"} } send_gdb "next\n" gdb_expect { -re "printf \\(.Hello .*$gdb_prompt $"\ - {pass "step after execv call"} + {pass "step after execv call"} -re "$gdb_prompt $" {fail "step after execv call"} timeout {fail "(timeout) step after execv call"} } @@ -356,7 +383,8 @@ proc do_exec_tests {} { # Explicitly kill this program, or a subsequent rerun actually runs # the exec'd program, not the original program... - clean_restart $binfile + clean_restart + gdb_load $execer_binfile # Start the program running, and stop at main. # @@ -370,13 +398,13 @@ proc do_exec_tests {} { # send_gdb "continue\n" gdb_expect { - -re ".*xecuting new program: .*${testfile2}.*${srcfile2}:${execd_line}.*int local_j = argc;.*$gdb_prompt $"\ - {pass "continue through exec"} + -re ".*xecuting new program: .*${execee_testfile_re}.*${srcfile2}:${execd_line}.*int local_j = argc;.*$gdb_prompt $"\ + {pass "continue through exec"} -re "$gdb_prompt $" {fail "continue through exec"} timeout {fail "(timeout) continue through exec"} } } -clean_restart $binfile - -do_exec_tests +foreach_with_prefix execee_lang { c c++ } { + do_exec_tests $lang $execee_lang +} diff --git a/gdb/testsuite/gdb.base/foll-fork-syscall.c b/gdb/testsuite/gdb.base/foll-fork-syscall.c new file mode 100644 index 0000000..ef695f5 --- /dev/null +++ b/gdb/testsuite/gdb.base/foll-fork-syscall.c @@ -0,0 +1,35 @@ +/* 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/>. */ + +#include <unistd.h> +#include <stdio.h> + +int +main (int argc, char **argv) +{ + int pid, x = 0; + + pid = fork (); + if (pid == 0) /* set breakpoint here */ + printf ("I am the child\n"); + else + printf ("I am the parent\n"); + + chdir ("."); + ++x; /* set exit breakpoint here */ + return 0; +} diff --git a/gdb/testsuite/gdb.base/foll-fork-syscall.exp b/gdb/testsuite/gdb.base/foll-fork-syscall.exp new file mode 100644 index 0000000..21ef334 --- /dev/null +++ b/gdb/testsuite/gdb.base/foll-fork-syscall.exp @@ -0,0 +1,143 @@ +# 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/>. + +# Test catching syscalls with all permutations of follow-fork parent/child +# and detach-on-fork on/off. + +# Test relies on checking follow-fork output. Do not run if gdb debug is +# enabled because it will be redirected to the log. +require !gdb_debug_enabled +require {is_any_target "i?86-*-*" "x86_64-*-*"} +require allow_fork_tests + +standard_testfile + +if {[build_executable "failed to prepare" $testfile $srcfile debug]} { + return -1 +} + +proc setup_gdb {} { + global testfile + + clean_restart $testfile + + if {![runto_main]} { + return false + } + + # Set a breakpoint after the fork is "complete." + if {![gdb_breakpoint [gdb_get_line_number "set breakpoint here"]]} { + return false + } + + # Set exit breakpoint (to prevent inferior from exiting). + if {![gdb_breakpoint [gdb_get_line_number "set exit breakpoint here"]]} { + return false + } + return true +} + +# Check that fork catchpoints are supported, as an indicator for whether +# fork-following is supported. Return 1 if they are, else 0. + +proc_with_prefix check_fork_catchpoints {} { + global gdb_prompt + + if { ![setup_gdb] } { + return false + } + + # Verify that the system supports "catch fork". + gdb_test "catch fork" "Catchpoint \[0-9\]* \\(fork\\)" "insert first fork catchpoint" + set has_fork_catchpoints false + gdb_test_multiple "continue" "continue to first fork catchpoint" { + -re ".*Your system does not support this type\r\nof catchpoint.*$gdb_prompt $" { + unsupported "continue to first fork catchpoint" + } + -re ".*Catchpoint.*$gdb_prompt $" { + set has_fork_catchpoints true + pass "continue to first fork catchpoint" + } + } + + return $has_fork_catchpoints +} + +proc_with_prefix test_catch_syscall {follow-fork-mode detach-on-fork} { + # Start with shiny new gdb instance. + if {![setup_gdb]} { + return + } + + # The "Detaching..." and "Attaching..." messages may be hidden by + # default. + gdb_test_no_output "set verbose" + + # Setup modes to test. + gdb_test_no_output "set follow-fork-mode ${follow-fork-mode}" + gdb_test_no_output "set detach-on-fork ${detach-on-fork}" + + gdb_test "catch fork" "Catchpoint . \\(fork\\)" + gdb_test "catch syscall chdir" "Catchpoint . \\(syscall 'chdir'.*\\)" + + # Which inferior we're expecting to follow. Assuming the parent + # will be inferior #1, and the child will be inferior #2. + if {${follow-fork-mode} == "parent"} { + set following_inf 1 + } else { + set followin_inf 2 + } + # Next stop should be the fork catchpoint. + set expected_re "" + append expected_re "Catchpoint . \\(forked process.*" + gdb_test "continue" $expected_re "continue to fork catchpoint" + + # Next stop should be the breakpoint after the fork. + set expected_re ".*" + if {${follow-fork-mode} == "child" || ${detach-on-fork} == "off"} { + append expected_re "\\\[New inferior.*" + } + if {${detach-on-fork} == "on"} { + append expected_re "\\\[Detaching after fork from " + if {${follow-fork-mode} == "parent"} { + append expected_re "child" + } else { + append expected_re "parent" + } + append expected_re " process.*" + } + append expected_re "Breakpoint .*set breakpoint here.*" + gdb_test "continue" $expected_re "continue to breakpoint after fork" + + # Next stop should be the syscall catchpoint. + set expected_re ".*Catchpoint . \\(call to syscall chdir\\).*" + gdb_test continue $expected_re "continue to chdir syscall" +} + +# Check for follow-fork support. +if {![check_fork_catchpoints]} { + untested "follow-fork not supported" + return +} + +# Test all permutations. +foreach_with_prefix follow-fork-mode {"parent" "child"} { + + # Do not run tests when not detaching from the parent. + # See breakpoints/13457 for discussion. + foreach_with_prefix detach-on-fork {"on"} { + test_catch_syscall ${follow-fork-mode} ${detach-on-fork} + } +} diff --git a/gdb/testsuite/gdb.base/foll-fork.exp b/gdb/testsuite/gdb.base/foll-fork.exp index 0d801f0..470f651 100644 --- a/gdb/testsuite/gdb.base/foll-fork.exp +++ b/gdb/testsuite/gdb.base/foll-fork.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -17,6 +17,8 @@ # enabled as it will be redirected to the log. require !gdb_debug_enabled +require allow_fork_tests + standard_testfile if {[build_executable "failed to prepare" $testfile $srcfile debug]} { @@ -65,8 +67,8 @@ proc_with_prefix check_fork_catchpoints {} { # the followed process stops where it is expected to stop, that processes # are detached (or not) as expected, and that the inferior list has the # expected contents after following the fork. WHO is the argument to -# the 'set follow-fork-mode' command, DETACH is the argument to the -# 'set detach-on-fork' command, and CMD is the GDB command used to +# the 'set follow-fork-mode' command, DETACH is the argument to the +# 'set detach-on-fork' command, and CMD is the GDB command used to # execute the program past the fork. If the value of WHO or DETACH is # 'default', the corresponding GDB command is skipped for that test. # The value of CMD must be either 'next 2' or 'continue'. diff --git a/gdb/testsuite/gdb.base/foll-vfork-exit.c b/gdb/testsuite/gdb.base/foll-vfork-exit.c index 5f8871d..5085a18 100644 --- a/gdb/testsuite/gdb.base/foll-vfork-exit.c +++ b/gdb/testsuite/gdb.base/foll-vfork-exit.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1997-2024 Free Software Foundation, Inc. + Copyright 1997-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 diff --git a/gdb/testsuite/gdb.base/foll-vfork.c b/gdb/testsuite/gdb.base/foll-vfork.c index 6a4d105..32a4c79 100644 --- a/gdb/testsuite/gdb.base/foll-vfork.c +++ b/gdb/testsuite/gdb.base/foll-vfork.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1997-2024 Free Software Foundation, Inc. + Copyright 1997-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 diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp index 6736303..a480b93 100644 --- a/gdb/testsuite/gdb.base/foll-vfork.exp +++ b/gdb/testsuite/gdb.base/foll-vfork.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -18,12 +18,7 @@ # either execs or exits --- since those events take somewhat different # code paths in GDB, both variants are exercised. -# Until "set follow-fork-mode" and "catch vfork" are implemented on -# other targets... -# -if {![istarget "*-linux*"]} { - continue -} +require allow_fork_tests standard_testfile .c -exit.c vforked-prog.c @@ -58,7 +53,7 @@ if { [is_remote target] } { proc setup_gdb { binfile srcfile } { clean_restart $binfile - if ![runto_main] { + if {![runto_main]} { return -code return } diff --git a/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen-shlib.c b/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen-shlib.c index 67c8e99..26ecf57 100644 --- a/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen-shlib.c +++ b/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen-shlib.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.c b/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.c index e6530af..f3921d0 100644 --- a/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.c +++ b/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp b/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp index de339c5..6547242 100644 --- a/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp +++ b/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -23,6 +23,7 @@ # in the source of the shlib, and "list" should display the source where # the program stopped. +require allow_fork_tests require allow_shlib_tests standard_testfile .c -shlib.c @@ -40,7 +41,7 @@ if { [build_executable "failed to prepare" ${testfile} ${srcfile} $opts] } { } proc do_test {} { - clean_restart $::binfile + clean_restart $::testfile gdb_locate_shlib $::shlib_path gdb_test_no_output "set follow-fork-mode child" gdb_test_no_output "set detach-on-fork off" diff --git a/gdb/testsuite/gdb.base/fork-print-inferior-events.c b/gdb/testsuite/gdb.base/fork-print-inferior-events.c index 94fb903..831f039 100644 --- a/gdb/testsuite/gdb.base/fork-print-inferior-events.c +++ b/gdb/testsuite/gdb.base/fork-print-inferior-events.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2007-2024 Free Software Foundation, Inc. + Copyright 2007-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 diff --git a/gdb/testsuite/gdb.base/fork-print-inferior-events.exp b/gdb/testsuite/gdb.base/fork-print-inferior-events.exp index 9e8c98d..4bafa68 100644 --- a/gdb/testsuite/gdb.base/fork-print-inferior-events.exp +++ b/gdb/testsuite/gdb.base/fork-print-inferior-events.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 @@ -19,6 +19,8 @@ # inferior-events [on,off]', 'set follow-fork-mode [child,parent]' and # 'set detach-on-fork [on,off]' are the correct ones. +require allow_fork_tests + # This test relies on "run", so it cannot run on target remote stubs. require !use_gdb_stub @@ -71,7 +73,7 @@ set i 0 foreach_with_prefix print_inferior_events { "on" "off" } { foreach_with_prefix follow_fork_mode { "child" "parent" } { foreach_with_prefix detach_on_fork { "on" "off" } { - clean_restart $binfile + clean_restart $testfile gdb_test_no_output "set print inferior-events $print_inferior_events" gdb_test_no_output "set follow-fork-mode $follow_fork_mode" gdb_test_no_output "set detach-on-fork $detach_on_fork" @@ -80,7 +82,7 @@ foreach_with_prefix print_inferior_events { "on" "off" } { # Always add the "Starting program..." string so that we # match exactly the lines we want. set output "Starting program: $binfile\\s*\r\n${thread_db_re}${output}${thread_db_re}${exited_normally_re}" - set i [expr $i + 1] + set i [expr {$i + 1}] gdb_test "run" $output } } diff --git a/gdb/testsuite/gdb.base/fork-running-state.c b/gdb/testsuite/gdb.base/fork-running-state.c index e1446a3..d5d34fe 100644 --- a/gdb/testsuite/gdb.base/fork-running-state.c +++ b/gdb/testsuite/gdb.base/fork-running-state.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/fork-running-state.exp b/gdb/testsuite/gdb.base/fork-running-state.exp index de4322e..c446800 100644 --- a/gdb/testsuite/gdb.base/fork-running-state.exp +++ b/gdb/testsuite/gdb.base/fork-running-state.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2024 Free Software Foundation, Inc. +# Copyright (C) 2016-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 @@ -17,6 +17,8 @@ # in non-stop). GDB used to miss updating the parent/child running # states after a fork. +require allow_fork_tests + standard_testfile # The test proper. diff --git a/gdb/testsuite/gdb.base/fortran-sym-case.c b/gdb/testsuite/gdb.base/fortran-sym-case.c index fdc2ea6..3760b91 100644 --- a/gdb/testsuite/gdb.base/fortran-sym-case.c +++ b/gdb/testsuite/gdb.base/fortran-sym-case.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/fortran-sym-case.exp b/gdb/testsuite/gdb.base/fortran-sym-case.exp index f4b8985..f0c4518 100644 --- a/gdb/testsuite/gdb.base/fortran-sym-case.exp +++ b/gdb/testsuite/gdb.base/fortran-sym-case.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2024 Free Software Foundation, Inc. +# Copyright (C) 2011-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 @@ -19,7 +19,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/frame-args.c b/gdb/testsuite/gdb.base/frame-args.c index 9123d1b..879ec60 100644 --- a/gdb/testsuite/gdb.base/frame-args.c +++ b/gdb/testsuite/gdb.base/frame-args.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2007-2024 Free Software Foundation, Inc. + Copyright 2007-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 diff --git a/gdb/testsuite/gdb.base/frame-args.exp b/gdb/testsuite/gdb.base/frame-args.exp index ddf8400..49cec5e 100644 --- a/gdb/testsuite/gdb.base/frame-args.exp +++ b/gdb/testsuite/gdb.base/frame-args.exp @@ -1,4 +1,4 @@ -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 @@ -14,12 +14,10 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 -} -clean_restart ${binfile} +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return +} if {![runto break_me]} { return @@ -28,37 +26,37 @@ if {![runto break_me]} { # Test with "print frame-arguments" set to "all" gdb_test_no_output "set print frame-arguments all" \ - "set print frame-arguments all" + "set print frame-arguments all" gdb_test "frame 1" \ - ".*in call_me \\(i=3, f=5, s=({a = 3, b = 5}|<optimized out>), ss=0x\[0-9a-f\]\+, u=({.*}|<optimized out>), e=green\\) at .*frame-args\\.c:.*" \ - "frame 1 with print frame-arguments set to all" + ".*in call_me \\(i=3, f=5, s=({a = 3, b = 5}|<optimized out>), ss=0x\[0-9a-f\]\+, u=({.*}|<optimized out>), e=green\\) at .*frame-args\\.c:.*" \ + "frame 1 with print frame-arguments set to all" # Test with "print frame-arguments" set to "scalars" gdb_test_no_output "set print frame-arguments scalars" \ - "set print frame-arguments scalars" + "set print frame-arguments scalars" gdb_test "frame 1" \ - ".*in call_me \\(i=3, f=5, s=\\.\\.\\., ss=0x\[0-9a-f\]\+, u=\\.\\.\\., e=green\\) at .*frame-args\\.c:.*" \ - "frame 1 with print frame-arguments set to scalars" + ".*in call_me \\(i=3, f=5, s=\\.\\.\\., ss=0x\[0-9a-f\]\+, u=\\.\\.\\., e=green\\) at .*frame-args\\.c:.*" \ + "frame 1 with print frame-arguments set to scalars" # Test with "print frame-arguments" set to "none" gdb_test_no_output "set print frame-arguments none" \ - "set print frame-arguments none" + "set print frame-arguments none" gdb_test "frame 1" \ - ".*in call_me \\(i=\\.\\.\\., f=\\.\\.\\., s=\\.\\.\\., ss=\\.\\.\\., u=\\.\\.\\., e=\\.\\.\\.\\) at .*frame-args\\.c:.*" \ - "frame 1 with print frame-arguments set to none" + ".*in call_me \\(i=\\.\\.\\., f=\\.\\.\\., s=\\.\\.\\., ss=\\.\\.\\., u=\\.\\.\\., e=\\.\\.\\.\\) at .*frame-args\\.c:.*" \ + "frame 1 with print frame-arguments set to none" # Test with "print frame-arguments" set to "presence" gdb_test_no_output "set print frame-arguments presence" \ - "set print frame-arguments presence" + "set print frame-arguments presence" gdb_test "frame 1" \ - ".*in call_me \\(\\.\\.\\.\\) at .*frame-args\\.c:.*" \ - "frame 1 with print frame-arguments set to presence" + ".*in call_me \\(\\.\\.\\.\\) at .*frame-args\\.c:.*" \ + "frame 1 with print frame-arguments set to presence" gdb_test "frame 2" \ - ".*in main \\(\\) at .*frame-args\\.c:.*" \ - "frame 2 (no args) with print frame-arguments set to presence" + ".*in main \\(\\) at .*frame-args\\.c:.*" \ + "frame 2 (no args) with print frame-arguments set to presence" # Test with "print frame-info" set to "location-and-address" diff --git a/gdb/testsuite/gdb.base/frame-info-consistent.exp b/gdb/testsuite/gdb.base/frame-info-consistent.exp index 4f48311..b83782f 100644 --- a/gdb/testsuite/gdb.base/frame-info-consistent.exp +++ b/gdb/testsuite/gdb.base/frame-info-consistent.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 @@ -97,7 +97,7 @@ proc compare_frames {frames} { proc test {enable} { - clean_restart $::binfile + clean_restart $::testfile gdb_test_no_output "maint frame-unwinder $enable DEBUGINFO" diff --git a/gdb/testsuite/gdb.base/frame-selection.c b/gdb/testsuite/gdb.base/frame-selection.c index 18a58e4..7d36c75 100644 --- a/gdb/testsuite/gdb.base/frame-selection.c +++ b/gdb/testsuite/gdb.base/frame-selection.c @@ -1,4 +1,4 @@ -/* Copyright 2018-2024 Free Software Foundation, Inc. +/* Copyright 2018-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/frame-selection.exp b/gdb/testsuite/gdb.base/frame-selection.exp index 32ed92d..f3fbd36 100644 --- a/gdb/testsuite/gdb.base/frame-selection.exp +++ b/gdb/testsuite/gdb.base/frame-selection.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -52,7 +52,7 @@ proc get_new_address { {addresses {}} } { set elem [lindex [lsort -integer -decreasing $addresses] 0] # Return a new address as a hex formatted string. - return [format "%#x" [expr $elem + 0x10]] + return [format "%#x" [expr {$elem + 0x10}]] } @@ -173,7 +173,7 @@ with_test_prefix "second frame_2 breakpoint" { gdb_continue_to_breakpoint frame_2 gdb_test "bt" \ "#0 frame_2.*#1 $hex in recursive.*#2 $hex in recursive.*#3 $hex in recursive.*#4 $hex in main.*" \ - "backtrace at breakpoint with recursive frames" + "backtrace at breakpoint with recursive frames" # Check "frame function" when a function name occurs multiple times in # the stack. The inner most (lowest level) should always be selected. diff --git a/gdb/testsuite/gdb.base/frame-view.c b/gdb/testsuite/gdb.base/frame-view.c index 619335e..ae00a2f 100644 --- a/gdb/testsuite/gdb.base/frame-view.c +++ b/gdb/testsuite/gdb.base/frame-view.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/frame-view.exp b/gdb/testsuite/gdb.base/frame-view.exp index 705a024..9c87f00 100644 --- a/gdb/testsuite/gdb.base/frame-view.exp +++ b/gdb/testsuite/gdb.base/frame-view.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -28,7 +28,7 @@ if { [build_executable "failed to prepare" \ # "select-frame view". proc test_select_frame_view { with_pretty_printer } { - clean_restart $::binfile + clean_restart $::testfile if { $with_pretty_printer } { require allow_python_tests diff --git a/gdb/testsuite/gdb.base/frame-view.py b/gdb/testsuite/gdb.base/frame-view.py index 7b341b4..322c264 100644 --- a/gdb/testsuite/gdb.base/frame-view.py +++ b/gdb/testsuite/gdb.base/frame-view.py @@ -1,4 +1,4 @@ -# Copyright (C) 2022-2024 Free Software Foundation, Inc. +# Copyright (C) 2022-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 @@ -12,6 +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/>. +import gdb class Printer1: diff --git a/gdb/testsuite/gdb.base/frameapply.c b/gdb/testsuite/gdb.base/frameapply.c index 388113c..0f1a32a 100644 --- a/gdb/testsuite/gdb.base/frameapply.c +++ b/gdb/testsuite/gdb.base/frameapply.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/frameapply.exp b/gdb/testsuite/gdb.base/frameapply.exp index 1d3eac9..589a922 100644 --- a/gdb/testsuite/gdb.base/frameapply.exp +++ b/gdb/testsuite/gdb.base/frameapply.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/freebpcmd.c b/gdb/testsuite/gdb.base/freebpcmd.c index 4d69c5b..cf749ee 100644 --- a/gdb/testsuite/gdb.base/freebpcmd.c +++ b/gdb/testsuite/gdb.base/freebpcmd.c @@ -1,5 +1,5 @@ /* Test program for GDB crashes while doing bp commands that continue inferior. - Copyright 2003-2024 Free Software Foundation, Inc. + Copyright 2003-2025 Free Software Foundation, Inc. This file is part of the gdb testsuite. diff --git a/gdb/testsuite/gdb.base/freebpcmd.exp b/gdb/testsuite/gdb.base/freebpcmd.exp index 3c6958b..4d14fad 100644 --- a/gdb/testsuite/gdb.base/freebpcmd.exp +++ b/gdb/testsuite/gdb.base/freebpcmd.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 @@ -59,39 +59,39 @@ set lines {{if i<0 || i > 100} {echo Invalid i value\n} {else} {if (i%2) == 0} - {echo "even "} - {print i} - {else} - {echo "odd "} - {print i} - {end} - {set variable $foo = 0} - {set variable $j = 0} - {while $j < i} - {set variable $foo += $j} - {set variable $j++} - {end} - {print $foo} - {if i != 40} - {c} - {end} + {echo "even "} + {print i} + {else} + {echo "odd "} + {print i} + {end} + {set variable $foo = 0} + {set variable $j = 0} + {while $j < i} + {set variable $foo += $j} + {set variable $j++} + {end} + {print $foo} + {if i != 40} + {c} + {end} {end} - {end}} + {end}} send_gdb "commands\n" for {set i 0} {$i < [llength $lines]} {incr i} { gdb_expect { - -re ".*>" { - send_gdb "[lindex $lines $i]\n" - } - -re "$gdb_prompt $" { - set reason "got top-level prompt early" - break - } - timeout { - set reason "timeout" - break - } + -re ".*>" { + send_gdb "[lindex $lines $i]\n" + } + -re "$gdb_prompt $" { + set reason "got top-level prompt early" + break + } + timeout { + set reason "timeout" + break + } } } if {$i >= [llength $lines]} { diff --git a/gdb/testsuite/gdb.base/fullname.c b/gdb/testsuite/gdb.base/fullname.c index 8a08de0..0ea4053 100644 --- a/gdb/testsuite/gdb.base/fullname.c +++ b/gdb/testsuite/gdb.base/fullname.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/fullname.exp b/gdb/testsuite/gdb.base/fullname.exp index be7250e..e0292c5 100644 --- a/gdb/testsuite/gdb.base/fullname.exp +++ b/gdb/testsuite/gdb.base/fullname.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -35,7 +35,7 @@ if { [gdb_compile [standard_output_file tmp-${srcfile}] "${binfile}" executable return -1 } -# Unlike most GDB tests, we do not use gdb_reinitialize_dir in this script. +# Unlike most GDB tests, we do not use gdb_reinitialize_dir in this script. # We're testing GDB's ability to find files in other ways. # Get the line number. @@ -45,7 +45,7 @@ set line [gdb_get_line_number "set breakpoint 1 here"] # Initialize GDB after getting the line number, to make sure # symbols aren't loaded. -clean_restart $binfile +clean_restart $testfile set msg "set breakpoint by full path before loading symbols - built absolute" if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } { @@ -65,12 +65,12 @@ if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] } # Build the test executable using a relative path. -if { [gdb_compile [relative_filename [pwd] [standard_output_file tmp-${srcfile}]] \ +if { [gdb_compile [relative_filename [pwd] [build_standard_output_file tmp-${srcfile}]] \ "${binfile}" executable {debug}] != "" } { return -1 } -clean_restart $binfile +clean_restart $testfile set msg "set breakpoint by full path before loading symbols - built relative" if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } { @@ -99,7 +99,7 @@ with_cwd [standard_output_file {}] { } } -clean_restart $binfile +clean_restart $testfile set msg "set breakpoint by full path before loading symbols - built other" if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } { diff --git a/gdb/testsuite/gdb.base/fullpath-expand-func.c b/gdb/testsuite/gdb.base/fullpath-expand-func.c index 9024f60..c07b72c 100644 --- a/gdb/testsuite/gdb.base/fullpath-expand-func.c +++ b/gdb/testsuite/gdb.base/fullpath-expand-func.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/fullpath-expand.c b/gdb/testsuite/gdb.base/fullpath-expand.c index 781951f..614f06a 100644 --- a/gdb/testsuite/gdb.base/fullpath-expand.c +++ b/gdb/testsuite/gdb.base/fullpath-expand.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/fullpath-expand.exp b/gdb/testsuite/gdb.base/fullpath-expand.exp index c2ae85a..a94488f 100644 --- a/gdb/testsuite/gdb.base/fullpath-expand.exp +++ b/gdb/testsuite/gdb.base/fullpath-expand.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2024 Free Software Foundation, Inc. +# Copyright (C) 2013-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 @@ -33,7 +33,7 @@ with_cwd $srcdir { } } -set result [catch "exec realpath ${srcdir}/${subdir}/${srcfile2}" realsrcfile2] +set result [catch {exec realpath ${srcdir}/${subdir}/${srcfile2}} realsrcfile2] if { $result != 0 || $realsrcfile2 == "" } { untested "invalid realpath of ${srcfile2}: result $result output $realsrcfile2" return -1 diff --git a/gdb/testsuite/gdb.base/func-ptr.c b/gdb/testsuite/gdb.base/func-ptr.c index cfb766b..d541905 100644 --- a/gdb/testsuite/gdb.base/func-ptr.c +++ b/gdb/testsuite/gdb.base/func-ptr.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/func-ptr.exp b/gdb/testsuite/gdb.base/func-ptr.exp index c1d79b2..d2eb0bc 100644 --- a/gdb/testsuite/gdb.base/func-ptr.exp +++ b/gdb/testsuite/gdb.base/func-ptr.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" "func-ptr" {func-ptr.c} {debug}] } return -1 } -if ![runto_main] { +if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.base/func-ptrs.c b/gdb/testsuite/gdb.base/func-ptrs.c index 7c05895..7eddfba 100644 --- a/gdb/testsuite/gdb.base/func-ptrs.c +++ b/gdb/testsuite/gdb.base/func-ptrs.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/func-ptrs.exp b/gdb/testsuite/gdb.base/func-ptrs.exp index cf6da04..5532c6c 100644 --- a/gdb/testsuite/gdb.base/func-ptrs.exp +++ b/gdb/testsuite/gdb.base/func-ptrs.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/funcargs.c b/gdb/testsuite/gdb.base/funcargs.c index d5ff192..add98b9 100644 --- a/gdb/testsuite/gdb.base/funcargs.c +++ b/gdb/testsuite/gdb.base/funcargs.c @@ -15,9 +15,9 @@ # include <alloca.h> # define HAVE_STACK_ALLOCA 1 # ifdef __STDC__ - void *alloca (); + void *alloca (); # else - char *alloca (); + char *alloca (); # endif /* __STDC__ */ # endif /* sparc */ # endif /* Not AIX */ @@ -418,7 +418,7 @@ typedef struct s short s; int i; long l; -} SVAL; +} SVAL; void hitbottom () { @@ -576,7 +576,7 @@ int main () call6a (c, s, i, l, f, d, uc, us, ui, ul); call7a (c, i, s, l, f, uc, d, us, ul, ui); - + /* Test passing structures recursively. */ test_struct_args (); diff --git a/gdb/testsuite/gdb.base/funcargs.exp b/gdb/testsuite/gdb.base/funcargs.exp index ac6741d..e4c3c5b 100644 --- a/gdb/testsuite/gdb.base/funcargs.exp +++ b/gdb/testsuite/gdb.base/funcargs.exp @@ -1,4 +1,4 @@ -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -21,7 +21,7 @@ standard_testfile set gcc_compiled [is_c_compiler_gcc] set compile_flags {debug nowarnings quiet} -if [support_complex_tests] { +if {[support_complex_tests]} { lappend compile_flags "additional_flags=-DTEST_COMPLEX" } @@ -55,7 +55,7 @@ proc_with_prefix integral_args {} { # Print each arg as a double check to see if we can print # them here as well as with backtrace. - gdb_test "print c" ".* = 97 'a'" "print c after run to call0a" + gdb_test "print c" ".* = 97 'a'" "print c after run to call0a" gdb_test "print s" ".* = 1" "print s after run to call0a" gdb_test "print i" ".* = 2" "print i after run to call0a" gdb_test "print l " ".* = 3" "print l after run to call0a" @@ -921,7 +921,7 @@ proc_with_prefix localvars_in_indirect_call { } { gdb_breakpoint call0a gdb_continue call0a delete_breakpoints - + # Print each arg as a double check to see if we can print # them here as well as with backtrace. @@ -937,9 +937,9 @@ proc_with_prefix localvars_in_indirect_call { } { "#0.*call0a \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" \ "backtrace in indirectly called function" - # + # # "finish" brings us back to main. We then will try to step through - # the second indirect call. + # the second indirect call. # On some targets (e.g. m68k) gdb will stop from the finish in midline # of the first indirect call. This is due to stack adjustment instructions # after the indirect call. In these cases we will step till we hit the @@ -1032,7 +1032,7 @@ proc_with_prefix stepping_over_trampolines { } { } set prev_timeout $timeout -if [istarget "mips*tx39-*"] { +if {[istarget "mips*tx39-*"]} { set timeout 300 } else { set timeout 60 @@ -1083,7 +1083,7 @@ if {$allow_float_test} { } # Test _Complex type here if supported. -if [support_complex_tests] { +if {[support_complex_tests]} { complex_args complex_integral_args diff --git a/gdb/testsuite/gdb.base/gcore-buffer-overflow.c b/gdb/testsuite/gdb.base/gcore-buffer-overflow.c index a035686..f5aa937 100644 --- a/gdb/testsuite/gdb.base/gcore-buffer-overflow.c +++ b/gdb/testsuite/gdb.base/gcore-buffer-overflow.c @@ -1,4 +1,4 @@ -/* Copyright 2007-2024 Free Software Foundation, Inc. +/* Copyright 2007-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp b/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp index f084eb4..edf7105 100644 --- a/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp +++ b/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp @@ -1,4 +1,4 @@ -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 @@ -17,19 +17,16 @@ standard_testfile .c -# The ${binfile} basename needs to exceed 80 characters (`sizeof (psargs)') + +# The executable basename needs to exceed 80 characters (`sizeof (psargs)') # plus some additional data to overwrite the stack frame. set pattern 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 -append binfile -${pattern} - -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 -} -# Start with a fresh gdb. +set filename ${testfile}-${pattern} -clean_restart ${binfile} +if { [prepare_for_testing "prepare" $filename $srcfile] != 0 } { + return +} gdb_test_no_output "set args ${pattern}" \ "set buffer exceeding arguments" diff --git a/gdb/testsuite/gdb.base/gcore-memory-usage.exp b/gdb/testsuite/gdb.base/gcore-memory-usage.exp index bd041f2..ca47ad6 100644 --- a/gdb/testsuite/gdb.base/gcore-memory-usage.exp +++ b/gdb/testsuite/gdb.base/gcore-memory-usage.exp @@ -47,8 +47,10 @@ proc get_mem_usage {pid prefix} { # This proc restarts GDB, runs the inferior with the desired # amount of memory, then checks how much memory is necessary # to run the gcore command. It will return -1 if the gcore -# command fails, 0 otherwise. -proc run_test {megs} { +# command fails, otherwise the amount of memory used by GDB +# to generate that gcore. MAX_MEM is the maximum amount of +# memory GDB is allowed to use, in megabytes. +proc run_test {megs max_mem} { with_test_prefix "$megs Mb" { clean_restart $::testfile @@ -71,26 +73,27 @@ proc run_test {megs} { # Do the main part of the test: How much is the memory # usage of GDB going to grow after using the gcore command. - set diff_k [expr $mem_after - $mem_before] - set diff [expr $diff_k/1024] + set diff_k [expr {$mem_after - $mem_before}] + set diff [expr {$diff_k/1024}] verbose -log "The gcore command used $diff Mb ($diff_k Kb)" - # The original plan was to compare to a multiple of MEGS - # but since the requirements don't seem to go up as the - # inferior allocated more memory, we instead just hardcode - # 2 megs, since sometimes 1 is used. - gdb_assert {$diff < 2} "gdb did not use too much memory" + gdb_assert {$diff <= $max_mem} "gdb did not use too much memory" gdb_test_no_output "set spin=0" "Allow program to exit" } - return 0 + return $diff } # If we couldn't create the first corefile, there's no point -# in running the second part of the test. -if {[run_test 4] != 0} { +# in running the second part of the test. The maximum amount +# of memory allowed is the same as the memory used by the +# inferior. +set mem_limit [run_test 4 4] +if {$mem_limit < 0} { return } # Surprisingly enough, the larger inferior doesn't seem to use # any extra memory, it usually uses less memory. Which is good, # it means our memory requirements aren't growing with the inferior. -run_test 64 +# This test ensures that it remains true that a larger inferior will +# not grow the memory requirements. +run_test 64 $mem_limit diff --git a/gdb/testsuite/gdb.base/gcore-relro-lib.c b/gdb/testsuite/gdb.base/gcore-relro-lib.c index 92d6f60..31ac8dc 100644 --- a/gdb/testsuite/gdb.base/gcore-relro-lib.c +++ b/gdb/testsuite/gdb.base/gcore-relro-lib.c @@ -1,4 +1,4 @@ -/* Copyright 2010-2024 Free Software Foundation, Inc. +/* Copyright 2010-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/gcore-relro-main.c b/gdb/testsuite/gdb.base/gcore-relro-main.c index 99bbfd6..359f304 100644 --- a/gdb/testsuite/gdb.base/gcore-relro-main.c +++ b/gdb/testsuite/gdb.base/gcore-relro-main.c @@ -1,4 +1,4 @@ -/* Copyright 2010-2024 Free Software Foundation, Inc. +/* Copyright 2010-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/gcore-relro-pie.c b/gdb/testsuite/gdb.base/gcore-relro-pie.c index b4865ff..0c7f1d4 100644 --- a/gdb/testsuite/gdb.base/gcore-relro-pie.c +++ b/gdb/testsuite/gdb.base/gcore-relro-pie.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2024 Free Software Foundation, Inc. +/* Copyright 2013-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/gcore-relro-pie.exp b/gdb/testsuite/gdb.base/gcore-relro-pie.exp index 1bec244..40170db 100644 --- a/gdb/testsuite/gdb.base/gcore-relro-pie.exp +++ b/gdb/testsuite/gdb.base/gcore-relro-pie.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 @@ -29,7 +29,7 @@ set gcorefile ${binfile}.gcore set strip_program [transform strip] remote_file host delete ${stripped_binfile} -if [run_on_host "strip" "$strip_program" "-g -o ${stripped_binfile} $binfile"] { +if {[run_on_host "strip" "$strip_program" "-g -o ${stripped_binfile} $binfile"]} { return -1 } @@ -38,10 +38,11 @@ if [run_on_host "strip" "$strip_program" "-g -o ${stripped_binfile} $binfile"] { set perm [file attributes ${binfile} -permissions] file attributes ${stripped_binfile} -permissions $perm -clean_restart ${stripped_binfile} +clean_restart +gdb_load $stripped_binfile # The binary is stripped of debug info, but not minsyms. -if ![runto break_here] { +if {![runto break_here]} { return -1 } @@ -51,7 +52,7 @@ if {![gdb_gcore_cmd $gcorefile "save a corefile"]} { # Now restart gdb with the unstripped binary and load the corefile. -clean_restart ${binfile} +clean_restart $testfile gdb_test "core ${gcorefile}" \ "Core was generated by .*" "re-load generated corefile" diff --git a/gdb/testsuite/gdb.base/gcore-relro.exp b/gdb/testsuite/gdb.base/gcore-relro.exp index 5f99cfb..229e8de 100644 --- a/gdb/testsuite/gdb.base/gcore-relro.exp +++ b/gdb/testsuite/gdb.base/gcore-relro.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -34,10 +34,10 @@ set objfile [standard_output_file ${testfile}.o] } with_test_prefix "first session" { - clean_restart ${binfile} + clean_restart $testfile gdb_load_shlib ${binfile_lib} - if ![runto lib] { + if {![runto lib]} { return -1 } @@ -49,7 +49,7 @@ with_test_prefix "first session" { # Now restart gdb and load the corefile. with_test_prefix "second session" { - clean_restart ${binfile} + clean_restart $testfile gdb_load_shlib ${binfile_lib} gdb_test "core ${gcorefile}" "Core was generated by .*" \ diff --git a/gdb/testsuite/gdb.base/gcore-tls-pie.c b/gdb/testsuite/gdb.base/gcore-tls-pie.c index 4a57a07..858921a 100644 --- a/gdb/testsuite/gdb.base/gcore-tls-pie.c +++ b/gdb/testsuite/gdb.base/gcore-tls-pie.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2024 Free Software Foundation, Inc. +/* Copyright 2013-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/gcore-tls-pie.exp b/gdb/testsuite/gdb.base/gcore-tls-pie.exp index a9c1fbd..34c5a60 100644 --- a/gdb/testsuite/gdb.base/gcore-tls-pie.exp +++ b/gdb/testsuite/gdb.base/gcore-tls-pie.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 @@ -33,7 +33,7 @@ set gcorefile ${binfile}.gcore set strip_program [transform strip] remote_file host delete ${stripped_binfile} -if [run_on_host "strip" "$strip_program" "-g -o ${stripped_binfile} $binfile"] { +if {[run_on_host "strip" "$strip_program" "-g -o ${stripped_binfile} $binfile"]} { return -1 } @@ -42,10 +42,11 @@ if [run_on_host "strip" "$strip_program" "-g -o ${stripped_binfile} $binfile"] { set perm [file attributes ${binfile} -permissions] file attributes ${stripped_binfile} -permissions $perm -clean_restart ${stripped_binfile} +clean_restart +gdb_load $stripped_binfile # The binary is stripped of debug info, but not minsyms. -if ![runto break_here] { +if {![runto break_here]} { return -1 } @@ -55,7 +56,7 @@ if {![gdb_gcore_cmd $gcorefile "save a corefile"]} { # Now restart gdb with the unstripped binary and load the corefile. -clean_restart ${binfile} +clean_restart $testfile gdb_test "core ${gcorefile}" \ "Core was generated by .*" "re-load generated corefile" diff --git a/gdb/testsuite/gdb.base/gcore.c b/gdb/testsuite/gdb.base/gcore.c index 9a3ac08d..1c924a1 100644 --- a/gdb/testsuite/gdb.base/gcore.c +++ b/gdb/testsuite/gdb.base/gcore.c @@ -1,4 +1,4 @@ -/* Copyright 2002-2024 Free Software Foundation, Inc. +/* Copyright 2002-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -27,7 +27,7 @@ static int static_array[4] = {5, 6, 7, 8}; static int un_initialized_array[4]; static char *heap_string; -void +void terminal_func () { return; diff --git a/gdb/testsuite/gdb.base/gcore.exp b/gdb/testsuite/gdb.base/gcore.exp index ff4e94c..eab0694 100644 --- a/gdb/testsuite/gdb.base/gcore.exp +++ b/gdb/testsuite/gdb.base/gcore.exp @@ -1,4 +1,4 @@ -# Copyright 2002-2024 Free Software Foundation, Inc. +# Copyright 2002-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 @@ -16,6 +16,7 @@ # This file was written by Michael Snyder (msnyder@redhat.com) # This is a test for the gdb command "generate-core-file". +require gcore_cmd_available standard_testfile @@ -57,7 +58,7 @@ if {!$core_supported} { } # Now restart gdb and load the corefile. -clean_restart $binfile +clean_restart $testfile set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"] if { $core_loaded == -1 } { @@ -100,7 +101,7 @@ if {![string compare $pre_corefile_sysregs $post_corefile_sysregs]} { set post_corefile_extern_array \ [capture_command_output "print extern_array" "$print_prefix"] -if ![string compare $pre_corefile_extern_array $post_corefile_extern_array] { +if {![string compare $pre_corefile_extern_array $post_corefile_extern_array]} { pass "corefile restored extern array" } else { fail "corefile restored extern array" @@ -108,7 +109,7 @@ if ![string compare $pre_corefile_extern_array $post_corefile_extern_array] { set post_corefile_static_array \ [capture_command_output "print static_array" "$print_prefix"] -if ![string compare $pre_corefile_static_array $post_corefile_static_array] { +if {![string compare $pre_corefile_static_array $post_corefile_static_array]} { pass "corefile restored static array" } else { fail "corefile restored static array" @@ -116,7 +117,7 @@ if ![string compare $pre_corefile_static_array $post_corefile_static_array] { set post_corefile_uninit_array \ [capture_command_output "print un_initialized_array" "$print_prefix"] -if ![string compare $pre_corefile_uninit_array $post_corefile_uninit_array] { +if {![string compare $pre_corefile_uninit_array $post_corefile_uninit_array]} { pass "corefile restored un-initialized array" } else { fail "corefile restored un-initialized array" @@ -124,7 +125,7 @@ if ![string compare $pre_corefile_uninit_array $post_corefile_uninit_array] { set post_corefile_heap_string \ [capture_command_output "print heap_string" "$print_prefix"] -if ![string compare $pre_corefile_heap_string $post_corefile_heap_string] { +if {![string compare $pre_corefile_heap_string $post_corefile_heap_string]} { pass "corefile restored heap array" } else { fail "corefile restored heap array" @@ -132,14 +133,14 @@ if ![string compare $pre_corefile_heap_string $post_corefile_heap_string] { set post_corefile_local_array \ [capture_command_output "print array_func::local_array" "$print_prefix"] -if ![string compare $pre_corefile_local_array $post_corefile_local_array] { +if {![string compare $pre_corefile_local_array $post_corefile_local_array]} { pass "corefile restored stack array" } else { fail "corefile restored stack array" } set post_corefile_backtrace [capture_command_output "backtrace" ""] -if ![string compare $pre_corefile_backtrace $post_corefile_backtrace] { +if {![string compare $pre_corefile_backtrace $post_corefile_backtrace]} { pass "corefile restored backtrace" } else { fail "corefile restored backtrace" diff --git a/gdb/testsuite/gdb.base/gcorebg.c b/gdb/testsuite/gdb.base/gcorebg.c index f055454..43d97e3 100644 --- a/gdb/testsuite/gdb.base/gcorebg.c +++ b/gdb/testsuite/gdb.base/gcorebg.c @@ -1,4 +1,4 @@ -/* Copyright 2007-2024 Free Software Foundation, Inc. +/* Copyright 2007-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 diff --git a/gdb/testsuite/gdb.base/gcorebg.exp b/gdb/testsuite/gdb.base/gcorebg.exp index 3761f22..5d8b85f 100644 --- a/gdb/testsuite/gdb.base/gcorebg.exp +++ b/gdb/testsuite/gdb.base/gcorebg.exp @@ -1,4 +1,4 @@ -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 @@ -46,17 +46,17 @@ proc test_body { detached } { global binfile global GCORE global corefile - global GDB_DATA_DIRECTORY + global GDB GDB_DATA_DIRECTORY # We can't use gdb_test_multiple here because GDB is not started. - set gcore_cmd $GCORE + set gcore_cmd "$GCORE -g $GDB" if {$GDB_DATA_DIRECTORY ne ""} { set gcore_cmd "$gcore_cmd -d '$GDB_DATA_DIRECTORY'" } set res [remote_spawn target "$binfile $detached \"$gcore_cmd\" $corefile"] if { ![gdb_assert { ![expr {$res < 0 || $res == ""}] } \ "spawned gcore"] } { - return + return } set saw_corefile_created false diff --git a/gdb/testsuite/gdb.base/gdb-index-err.c b/gdb/testsuite/gdb.base/gdb-index-err.c index cb8b860..4caa75a 100644 --- a/gdb/testsuite/gdb.base/gdb-index-err.c +++ b/gdb/testsuite/gdb.base/gdb-index-err.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2023-2024 Free Software Foundation, Inc. + Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/gdb-index-err.exp b/gdb/testsuite/gdb.base/gdb-index-err.exp index 0f46b3e..e7a647c 100644 --- a/gdb/testsuite/gdb.base/gdb-index-err.exp +++ b/gdb/testsuite/gdb.base/gdb-index-err.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 @@ -90,13 +90,13 @@ foreach_with_prefix flag { "" "-dwarf-5" } { } # Add the index section to the executable. - clean_restart ${binfile}.${extension} + clean_restart $testfile.$extension gdb_assert {[ensure_gdb_index ${binfile}.${extension} ${flag}] == 1} \ "add index to executable" # Reload the executable (which now has an index), and try to # generate and index from it. This will fail. - clean_restart ${binfile}.${extension} + clean_restart $testfile.$extension gdb_test "save gdb-index ${flag} $already_indexed_dir" \ "Error while writing index for `[string_to_regexp $binfile.$extension]': Cannot use an index to create the index" \ "try to generate an index from a binary with an index" diff --git a/gdb/testsuite/gdb.base/gdb-index-many-types-1.c b/gdb/testsuite/gdb.base/gdb-index-many-types-1.c new file mode 100644 index 0000000..00b793c --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb-index-many-types-1.c @@ -0,0 +1,48 @@ +/* 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/>. */ + +#include "gdb-index-many-types.h" + +int +main () +{ + foo_func_a (0); + foo_func_b (0); + bar_func_a (0); + bar_func_b (0); + baz_func_a (0); + baz_func_b (0); + return 0; +} + +void +foo_func_c (foo_t *obj) +{ + (void) obj; +} + +void +bar_func_c (bar_t *obj) +{ + (void) obj; +} + +void +baz_func_c (baz_t *obj) +{ + (void) obj; +} diff --git a/gdb/testsuite/gdb.base/gdb-index-many-types-2.c b/gdb/testsuite/gdb.base/gdb-index-many-types-2.c new file mode 100644 index 0000000..2c0a27f --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb-index-many-types-2.c @@ -0,0 +1,56 @@ +/* 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/>. */ + +#include "gdb-index-many-types.h" + +typedef struct foo_t +{ + int foo_t_1; + int foo_t_2; +} foo_t; + +typedef struct woof_t +{ + int woof_t_1; + int woof_t_2; +} woof_t; + +static void +woof_func (woof_t *obj) +{ + (void) obj; +} + +void +foo_func_a (foo_t *obj) +{ + woof_func (0); + (void) obj; +} + +void +baz_func_a (baz_t *obj) +{ + (void) obj; +} + +void +bar_func_a (bar_t *obj) +{ + woof_func (0); + (void) obj; +} diff --git a/gdb/testsuite/gdb.base/gdb-index-many-types-3.c b/gdb/testsuite/gdb.base/gdb-index-many-types-3.c new file mode 100644 index 0000000..54425ed --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb-index-many-types-3.c @@ -0,0 +1,56 @@ +/* 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/>. */ + +#include "gdb-index-many-types.h" + +typedef struct woof_t +{ + double woof_t_3; + double woof_t_4; +} woof_t; + +static void +woof_func (woof_t *obj) +{ + (void) obj; +} + +typedef struct bar_t +{ + int bar_t_1; + int bar_t_2; +} bar_t; + +void +bar_func_b (bar_t *obj) +{ + woof_func (0); + (void) obj; +} + +void +baz_func_b (baz_t *obj) +{ + (void) obj; +} + +void +foo_func_b (foo_t *obj) +{ + woof_func (0); + (void) obj; +} diff --git a/gdb/testsuite/gdb.base/gdb-index-many-types.exp b/gdb/testsuite/gdb.base/gdb-index-many-types.exp new file mode 100644 index 0000000..d7a1a7b --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb-index-many-types.exp @@ -0,0 +1,157 @@ +# 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/>. + +# Check that adding an index to an executable (both a gdb index and a +# dwarf-5 index are tested), doesn't prevent GDB from seeing the +# expected types. + +standard_testfile -1.c -2.c -3.c .h + +# One of the tests uses this Python file. The test_* proc checks that +# GDB supports Python tests. Some of the other procs don't use this +# Python file. +set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py] + +if {[build_executable "building" $testfile \ + [list $srcfile $srcfile2 $srcfile3]] == -1} { + return +} + +# Run 'info types TYPENAME', expect to see an entry from FILENAME for +# the line matching PATTERN. +proc check_info_types { testfile typename filename pattern } { + with_test_prefix "$filename '$pattern'" { + clean_restart $testfile + + set line_num [gdb_get_line_number $pattern $filename] + gdb_test "info types $typename" \ + "File \[^\r\n\]+/${filename}:(?:\r\n${::decimal}:\[^\r\n\]+)*\r\n${line_num}:\[^\r\n\]+.*" + } +} + +# Start GDB with FILENAME, and examine some of the types. This proc +# might seem to be using clean_restart a little too much, but we need +# to be really careful here. As we examine one type, e.g. foo_t, this +# might cause GDB to fully parse a CU, which then means examining +# bar_t gives the expected result. When, if we'd first looked for +# bar_t, then (due to an index bug) we might not have found the +# correct type definition. +# +# The only way we can be sure that an earlier test isn't going to +# trigger CU expansion is to restart GDB before every query. +proc run_test { filename } { + # Print all the types for which there is only one representation. + foreach type { foo_t bar_t baz_t } { + clean_restart $filename + gdb_test "ptype $type" \ + [multi_line \ + "type = struct $type {" \ + "\\s+int ${type}_1;" \ + "\\s+int ${type}_2;" \ + "}"] + } + + # There are two different versions of woof_t. For now, when using + # `ptype` GDB will just display the first one it finds, which could + # legitimately be either. + set woof_int_re [multi_line \ + "type = struct woof_t {" \ + "\\s+int woof_t_1;" \ + "\\s+int woof_t_2;" \ + "}"] + set woof_double_re [multi_line \ + "type = struct woof_t {" \ + "\\s+double woof_t_3;" \ + "\\s+double woof_t_4;" \ + "}"] + clean_restart $filename + gdb_test_multiple "ptype woof_t" "" { + -re -wrap $woof_int_re { + pass $gdb_test_name + } + -re -wrap $woof_double_re { + pass $gdb_test_name + } + } + + # Check for declarations and definitions of some types. + check_info_types $filename foo_t $::srcfile2 "typedef struct foo_t" + check_info_types $filename foo_t $::srcfile4 "typedef struct foo_t foo_t;" + check_info_types $filename bar_t $::srcfile3 "typedef struct bar_t" + check_info_types $filename bar_t $::srcfile4 "typedef struct bar_t bar_t;" + check_info_types $filename baz_t $::srcfile4 "typedef struct baz_t" + check_info_types $filename baz_t $::srcfile4 "\} baz_t;" + check_info_types $filename woof_t $::srcfile2 "typedef struct woof_t" + check_info_types $filename woof_t $::srcfile3 "typedef struct woof_t" + + # Use Python to look for type symbols. + if { [allow_python_tests] } { + foreach_with_prefix type { foo_t bar_t baz_t } { + clean_restart $filename + gdb_test_no_output "source $::pyfile" "import python scripts" + gdb_test "py-show-type $type" \ + [multi_line \ + "Looking for type '$type':" \ + " Found 3 type symbols" \ + " 1: struct $type \\{ int ${type}_1; int ${type}_2; \\}" \ + " 2: struct $type \\{ int ${type}_1; int ${type}_2; \\}" \ + " 3: struct $type \\{ int ${type}_1; int ${type}_2; \\}"] + } + + clean_restart $filename + gdb_test_no_output "source $::pyfile" "import python scripts" + gdb_test "py-show-type woof_t" \ + [multi_line \ + "Looking for type 'woof_t':" \ + " Found 2 type symbols" \ + " 1: struct woof_t \\{ (?:int|double) woof_t_(?:1|3); (?:int|double) woof_t_(?:2|4); \\}" \ + " 2: struct woof_t \\{ (?:int|double) woof_t_(?:1|3); (?:int|double) woof_t_(?:2|4); \\}"] + + } +} + +with_test_prefix "no index" { + run_test $testfile +} + +# The previous call to 'run_test' will have left GDB active. Check if +# BINFILE already has an index. If it does then we must be running +# with one of the boardfiles that adds an index. We could possibly +# try to remove the index, but for now, just don't run the following +# parts which rely on adding an index. +set index_type [get_index_type $binfile "check debug style"] +if { $index_type ne "cooked" } { + unsupported "cannot test without a cooked index" + return +} + +foreach_with_prefix index_type { gdb dwarf5 } { + set binfile_with_index ${binfile}-idx-${index_type} + + remote_exec build "cp $binfile $binfile_with_index" + + if { $index_type eq "gdb" } { + set style "" + } else { + set style "-dwarf-5" + } + + if {[ensure_gdb_index $binfile_with_index $style] != 1} { + unsupported "couldn't add $index_type index" + return + } + + run_test [file tail $binfile_with_index] +} diff --git a/gdb/testsuite/gdb.base/gdb-index-many-types.h b/gdb/testsuite/gdb.base/gdb-index-many-types.h new file mode 100644 index 0000000..eb5447a --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb-index-many-types.h @@ -0,0 +1,42 @@ +/* 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/>. */ + +#ifndef GDB_INDEX_MANY_TYPES_H +#define GDB_INDEX_MANY_TYPES_H + +typedef struct foo_t foo_t; +typedef struct bar_t bar_t; + +extern void foo_func_a (foo_t *obj); +extern void foo_func_b (foo_t *obj); +extern void foo_func_c (foo_t *obj); + +extern void bar_func_a (bar_t *obj); +extern void bar_func_b (bar_t *obj); +extern void bar_func_c (bar_t *obj); + +typedef struct baz_t +{ + int baz_t_1; + int baz_t_2; +} baz_t; + +extern void baz_func_a (baz_t *obj); +extern void baz_func_b (baz_t *obj); +extern void baz_func_c (baz_t *obj); + +#endif /* GDB_INDEX_MANY_TYPES_H */ diff --git a/gdb/testsuite/gdb.base/gdb-index-many-types.py b/gdb/testsuite/gdb.base/gdb-index-many-types.py new file mode 100644 index 0000000..7d2b3a7 --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb-index-many-types.py @@ -0,0 +1,56 @@ +# 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/>. + +import gdb + + +class TypeViewer(gdb.Command): + """A command which takes a string and looks up types with that name. + + The types are expected to all be structs. This command prints a + basic representation of the struct. This is only going to work when + used with the types defined in the gdb-index-many-types test source + files.""" + + def __init__(self): + super().__init__("py-show-type", gdb.COMMAND_USER) + + def invoke(self, args, from_tty): + argv = gdb.string_to_argv(args) + if argv[0] == "": + raise gdb.GdbError("missing argument") + print("Looking for type '" + argv[0] + "':") + syms = gdb.lookup_static_symbols(argv[0], gdb.SYMBOL_TYPE_DOMAIN) + count = len(syms) + print(" Found %d type symbol%s" % (count, "" if count == 1 else "s")) + for i, s in enumerate(syms, start=1): + t = s.type + if t is None: + print(" %d: No type." % i) + else: + fields = "struct " + argv[0] + " {" + try: + for f in t.fields(): + if len(fields) > 0: + fields = fields + " " + fields = fields + "%s %s;" % (str(f.type), f.name) + except Exception: + pass + fields = fields + " }" + + print(" %d: %s" % (i, fields)) + + +TypeViewer() diff --git a/gdb/testsuite/gdb.base/gdb-sigterm-2.exp b/gdb/testsuite/gdb.base/gdb-sigterm-2.exp index 3899e9b..f55c1ee 100644 --- a/gdb/testsuite/gdb.base/gdb-sigterm-2.exp +++ b/gdb/testsuite/gdb.base/gdb-sigterm-2.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. # -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/gdb-sigterm.c b/gdb/testsuite/gdb.base/gdb-sigterm.c index 7c64555..f7e3455 100644 --- a/gdb/testsuite/gdb.base/gdb-sigterm.c +++ b/gdb/testsuite/gdb.base/gdb-sigterm.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/gdb-sigterm.exp b/gdb/testsuite/gdb.base/gdb-sigterm.exp index 0f23d03..02410fd 100644 --- a/gdb/testsuite/gdb.base/gdb-sigterm.exp +++ b/gdb/testsuite/gdb.base/gdb-sigterm.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. # -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 @@ -34,7 +34,7 @@ if { [build_executable ${testfile}.exp ${testfile} $srcfile $options] == -1 } { proc do_test { pass } { global testfile gdb_prompt binfile pf_prefix - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -53,7 +53,7 @@ proc do_test { pass } { set abort 0 } } - if $abort { + if {$abort} { verbose -log "$pf_prefix $test: did not run" return $abort } diff --git a/gdb/testsuite/gdb.base/gdb1056.exp b/gdb/testsuite/gdb.base/gdb1056.exp index 78a2f1d..411e613 100644 --- a/gdb/testsuite/gdb.base/gdb1056.exp +++ b/gdb/testsuite/gdb.base/gdb1056.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 @@ -40,4 +40,3 @@ gdb_test_multiple "print 1/0" "" { } } gdb_test "print 1U/0" ".*Division by zero.*" "test unsigned division by zero" - diff --git a/gdb/testsuite/gdb.base/gdb1090.c b/gdb/testsuite/gdb.base/gdb1090.c index 602a29f..9daeffe 100644 --- a/gdb/testsuite/gdb.base/gdb1090.c +++ b/gdb/testsuite/gdb.base/gdb1090.c @@ -1,5 +1,5 @@ /* Test program for multi-register variable. - Copyright 2003-2024 Free Software Foundation, Inc. + Copyright 2003-2025 Free Software Foundation, Inc. This file is part of the gdb testsuite. @@ -15,7 +15,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/>. - + This file was written by Michael Elizabeth Chastain (mec@shout.net). */ struct s_2_by_4 diff --git a/gdb/testsuite/gdb.base/gdb1090.exp b/gdb/testsuite/gdb.base/gdb1090.exp index 447cb6f..7db8c4b 100644 --- a/gdb/testsuite/gdb.base/gdb1090.exp +++ b/gdb/testsuite/gdb.base/gdb1090.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 diff --git a/gdb/testsuite/gdb.base/gdb11530.c b/gdb/testsuite/gdb.base/gdb11530.c index 54b5b94..24b4dd0 100644 --- a/gdb/testsuite/gdb.base/gdb11530.c +++ b/gdb/testsuite/gdb.base/gdb11530.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-2025 Free Software Foundation, Inc. Contributed by Pierre Muller. @@ -23,7 +23,7 @@ struct a { union { - int i; + int i; }; } a; @@ -32,4 +32,3 @@ main (void) { return sizeof (a.i); } - diff --git a/gdb/testsuite/gdb.base/gdb11530.exp b/gdb/testsuite/gdb.base/gdb11530.exp index 7602251..be7d476 100644 --- a/gdb/testsuite/gdb.base/gdb11530.exp +++ b/gdb/testsuite/gdb.base/gdb11530.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -38,4 +38,3 @@ if {![runto_main]} { gdb_test "print a.i" " = 0" gdb_test "print sizeof (a.i)" " = \[0-9\]+" gdb_test "print sizeof (a.i) == sizeof (int)" " = 1" - diff --git a/gdb/testsuite/gdb.base/gdb11531.c b/gdb/testsuite/gdb.base/gdb11531.c index 900f513..97f5928 100644 --- a/gdb/testsuite/gdb.base/gdb11531.c +++ b/gdb/testsuite/gdb.base/gdb11531.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-2025 Free Software Foundation, Inc. Contributed by Pierre Muller. @@ -37,4 +37,3 @@ main () myrec.x = 78; return myrec.x; } - diff --git a/gdb/testsuite/gdb.base/gdb11531.exp b/gdb/testsuite/gdb.base/gdb11531.exp index 59fc6f5..82d399f 100644 --- a/gdb/testsuite/gdb.base/gdb11531.exp +++ b/gdb/testsuite/gdb.base/gdb11531.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -65,4 +65,3 @@ gdb_test "next" \ gdb_test "continue" \ ".*${nl}.*atchpoint \[0-9\]+: myrec\.x${nl}Old value = 5${nl}New value = 78${nl}.*" \ "watchpoint variable triggers at continue" - diff --git a/gdb/testsuite/gdb.base/gdb1250.c b/gdb/testsuite/gdb.base/gdb1250.c index c909496..06959a0 100644 --- a/gdb/testsuite/gdb.base/gdb1250.c +++ b/gdb/testsuite/gdb.base/gdb1250.c @@ -1,6 +1,6 @@ /* Test program for stack trace through noreturn function. - Copyright 2003-2024 Free Software Foundation, Inc. + Copyright 2003-2025 Free Software Foundation, Inc. This file is part of the gdb testsuite. @@ -16,7 +16,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/>. - + This file was written by Michael Elizabeth Chastain (mec@shout.net). */ #include <stdlib.h> diff --git a/gdb/testsuite/gdb.base/gdb1250.exp b/gdb/testsuite/gdb.base/gdb1250.exp index 832403a..16e4323 100644 --- a/gdb/testsuite/gdb.base/gdb1250.exp +++ b/gdb/testsuite/gdb.base/gdb1250.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 @@ -24,13 +24,10 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart ${binfile} - if {![runto abort {allow-pending}]} { return } diff --git a/gdb/testsuite/gdb.base/gdb1555-main.c b/gdb/testsuite/gdb.base/gdb1555-main.c index 63a73bd..c1cf1ae 100644 --- a/gdb/testsuite/gdb.base/gdb1555-main.c +++ b/gdb/testsuite/gdb.base/gdb1555-main.c @@ -1,6 +1,6 @@ /* Test step/next in a shared library - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/gdb1555.c b/gdb/testsuite/gdb.base/gdb1555.c index a799ab9..9f6f08c 100644 --- a/gdb/testsuite/gdb.base/gdb1555.c +++ b/gdb/testsuite/gdb.base/gdb1555.c @@ -1,6 +1,6 @@ /* Test step/next in a shared library - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -23,4 +23,3 @@ int hithere2() a = 21; return a; } - diff --git a/gdb/testsuite/gdb.base/gdb1555.exp b/gdb/testsuite/gdb.base/gdb1555.exp index a5b2760..f7f65fe 100644 --- a/gdb/testsuite/gdb.base/gdb1555.exp +++ b/gdb/testsuite/gdb.base/gdb1555.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 @@ -28,13 +28,15 @@ set execsrc "${srcdir}/${subdir}/${srcfile}" remote_exec build "rm -f ${binfile}" -if { [gdb_compile_shlib $libsrc $libobj {debug}] != "" - || [gdb_compile $execsrc ${binfile} executable \ - [list debug shlib=${libobj}]] != "" } { - return -1 +if { [build_executable "build shlib" $libobj $libsrc {debug shlib}] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $execsrc\ + [list debug shlib=${libobj}]] != 0 } { + return } -clean_restart ${binfile} gdb_load_shlib $libobj if {![runto_main]} { @@ -48,8 +50,8 @@ gdb_test_multiple "s" $name \ -re "hithere2 \\(\\) at.*${libfile}.c:\[0-9\]+\r\n\[0-9\]+.*a = 21;.*$gdb_prompt $" { pass $name } - -re "0x\[0-9a-f\]+ in .* \\(\\) from /lib/ld.so.1.*$gdb_prompt $" { - kfail "gdb/1555" $name + -re "0x\[0-9a-f\]+ in .* \\(\\) from /lib/ld.so.1.*$gdb_prompt $" { + kfail "gdb/1555" $name } } @@ -60,8 +62,7 @@ gdb_test_multiple "n" $name \ -re "\[0-9\]+.*return a;.*$gdb_prompt $" { pass $name } - -re "Single stepping until exit from function .*, \r\nwhich has no line number information.\r\n\r\n$inferior_exited_re normally.*$gdb_prompt $" { - kfail "gdb/1555" $name + -re "Single stepping until exit from function .*, \r\nwhich has no line number information.\r\n\r\n$inferior_exited_re normally.*$gdb_prompt $" { + kfail "gdb/1555" $name } } - diff --git a/gdb/testsuite/gdb.base/gdb1821.c b/gdb/testsuite/gdb.base/gdb1821.c index 6ee03f0..6f48eb3 100644 --- a/gdb/testsuite/gdb.base/gdb1821.c +++ b/gdb/testsuite/gdb.base/gdb1821.c @@ -1,6 +1,6 @@ /* Test printing of structure member names in gdb. PR exp/1821 - Copyright 2005-2024 Free Software Foundation, Inc. + Copyright 2005-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/gdb1821.exp b/gdb/testsuite/gdb.base/gdb1821.exp index e51444c..f84fc9c 100644 --- a/gdb/testsuite/gdb.base/gdb1821.exp +++ b/gdb/testsuite/gdb.base/gdb1821.exp @@ -1,4 +1,4 @@ -# Copyright 2005-2024 Free Software Foundation, Inc. +# Copyright 2005-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 @@ -30,6 +30,5 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { if {![runto_main]} { return -} -gdb_test "print /x bar" "{x__0 = 0x0, y__0 = 0x0, z__1 = 0x0}" - +} +gdb_test "print /x bar" "{x__0 = 0x0, y__0 = 0x0, z__1 = 0x0}" diff --git a/gdb/testsuite/gdb.base/gdbhistsize-history.exp b/gdb/testsuite/gdb.base/gdbhistsize-history.exp index 8a99ba9..5173b72 100644 --- a/gdb/testsuite/gdb.base/gdbhistsize-history.exp +++ b/gdb/testsuite/gdb.base/gdbhistsize-history.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -51,9 +51,9 @@ proc test_histsize_history_setting { histsize size { env_var "GDBHISTSIZE" } } { gdb_test_no_output "show commands" } elseif { $size != "1" } { gdb_test "show commands" \ - " . show history size\r\n . show commands" + " . show history size\r\n . show commands" } - } + } } } diff --git a/gdb/testsuite/gdb.base/gdbindex-stabs.exp b/gdb/testsuite/gdb.base/gdbindex-stabs.exp deleted file mode 100644 index c3fe7e5..0000000 --- a/gdb/testsuite/gdb.base/gdbindex-stabs.exp +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (C) 2011-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/>. - -# This problem is reproducible only when using `gdb/cc-with-index.sh'. - -standard_testfile gdbindex-stabs.c -set srcfile_stabs ${testfile}.c -set srcfile_dwarf ${testfile}-dwarf.c -set objfile_stabs [standard_output_file ${testfile}.o] -set objfile_dwarf [standard_output_file ${testfile}-dwarf.o] - -if {[gdb_compile "${srcdir}/${subdir}/${srcfile_stabs}" ${objfile_stabs} object {additional_flags=-gstabs quiet}] != "" - || [gdb_compile "${srcdir}/${subdir}/${srcfile_dwarf}" ${objfile_dwarf} object {additional_flags=-gdwarf-2}] != "" - || [gdb_compile "${objfile_stabs} ${objfile_dwarf}" ${binfile} executable {nodebug}] != ""} { - untested "failed to compile" - return -1 -} - -clean_restart ${binfile} - -# FAIL was: No line number known for stabs_function. -gdb_test "list stabs_function" " marker-here .*" diff --git a/gdb/testsuite/gdb.base/gdbinit-history.exp b/gdb/testsuite/gdb.base/gdbinit-history.exp index ac9630d..2830999 100644 --- a/gdb/testsuite/gdb.base/gdbinit-history.exp +++ b/gdb/testsuite/gdb.base/gdbinit-history.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -118,7 +118,7 @@ proc test_no_truncation_of_unlimited_history_file { } { gdb_start gdb_test "server show commands" " . print 1.*" } - } + } } } @@ -141,7 +141,7 @@ proc check_history { hist } { if { [llength $hist_lines] == 1 } { set pattern [lindex $hist_lines 0] } else { - set pattern [eval multi_line $hist_lines] + set pattern [multi_line {*}$hist_lines] } # Check the history. diff --git a/gdb/testsuite/gdb.base/gdbvars.exp b/gdb/testsuite/gdb.base/gdbvars.exp index 7ec7df3..e1eef85 100644 --- a/gdb/testsuite/gdb.base/gdbvars.exp +++ b/gdb/testsuite/gdb.base/gdbvars.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1992-2024 Free Software Foundation, Inc. +# Copyright (C) 1992-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 @@ -26,46 +26,46 @@ proc test_convenience_variables {} { global gdb_prompt gdb_test_no_output "set \$foo = 101" \ - "Set a new convenience variable" + "set a new convenience variable" gdb_test "print \$foo" " = 101" \ - "Print contents of new convenience variable" + "print contents of new convenience variable" gdb_test_no_output "set \$foo = 301" \ - "Set convenience variable to a new value" + "set convenience variable to a new value" gdb_test "print \$foo" " = 301" \ - "Print new contents of convenience variable" + "print new contents of convenience variable" gdb_test_no_output "set \$_ = 11" \ - "Set convenience variable \$_" + "set convenience variable \$_" gdb_test "print \$_" " = 11" \ - "Print contents of convenience variable \$_" + "print contents of convenience variable \$_" gdb_test "print \$foo + 10" " = 311" \ - "Use convenience variable in arithmetic expression" + "use convenience variable in arithmetic expression" gdb_test "print (\$foo = 32) + 4" " = 36" \ - "Use convenience variable assignment in arithmetic expression" + "use convenience variable assignment in arithmetic expression" gdb_test "print \$bar" " = void" \ - "Print contents of uninitialized convenience variable" + "print contents of uninitialized convenience variable" gdb_test "print \$str = \"some string\"" \ " = \"some string\"" \ - "Set convenience variable to string value" + "set convenience variable to string value" gdb_test "print \$str = \"some other string\"" \ " = \"some other string\"" \ - "Change convenience variable to different string value" + "change convenience variable to different string value" gdb_test "print \$arr = {1, 2, 3}" \ " = \\{1, 2, 3\\}" \ - "Set convenience variable to array value" + "set convenience variable to array value" gdb_test "print \$arr = {0, 1, 2, 3}" \ " = \\{0, 1, 2, 3\\}" \ - "Set convenience variable to different array value" + "set convenience variable to different array value" gdb_test "print \$ptr = (void *) 7" \ " = \\(void \\*\\) 0x7" \ @@ -78,19 +78,19 @@ proc test_convenience_variables {} { proc test_convenience_functions {} { gdb_test "print \$_isvoid" " = <internal function _isvoid>" \ - "Print internal function \$_isvoid" + "print internal function \$_isvoid" gdb_test "print \$isvoid_foo" " = void" \ - "Print void convenience variable" + "print void convenience variable" gdb_test "print \$_isvoid (\$isvoid_foo)" " = 1" \ - "Check whether void convenience variable is void" + "check whether void convenience variable is void" gdb_test_no_output "set \$isvoid_foo = 1" \ - "Set void convenience variable to 1" + "set void convenience variable to 1" gdb_test "print \$_isvoid (\$isvoid_foo)" " = 0" \ - "Check whether non-void convenience variable is void" + "check whether non-void convenience variable is void" # For the next test, we need the inferior to be running. if { ![runto_main] } { @@ -98,66 +98,66 @@ proc test_convenience_functions {} { } gdb_test "print \$_isvoid (foo_void ())" " = 1" \ - "Check whether void function is void" + "check whether void function is void" gdb_test "print \$_isvoid (foo_int ())" " = 0" \ - "Check whether non-void function is void" + "check whether non-void function is void" } proc test_value_history {} { global gdb_prompt gdb_test "print 101" "\\\$1 = 101" \ - "Set value-history\[1\] using \$1" + "set value-history\[1\] using \$1" gdb_test "print 102" "\\\$2 = 102" \ - "Set value-history\[2\] using \$2" + "set value-history\[2\] using \$2" gdb_test "print 103" "\\\$3 = 103" \ - "Set value-history\[3\] using \$3" + "set value-history\[3\] using \$3" gdb_test "print \$\$" "\\\$4 = 102" \ - "Print value-history\[MAX-1\] using inplicit index \$\$" + "print value-history\[MAX-1\] using inplicit index \$\$" gdb_test "print \$\$" "\\\$5 = 103" \ - "Print value-history\[MAX-1\] again using implicit index \$\$" + "print value-history\[MAX-1\] again using implicit index \$\$" gdb_test "print \$" "\\\$6 = 103" \ - "Print value-history\[MAX\] using implicit index \$" + "print value-history\[MAX\] using implicit index \$" gdb_test "print \$\$2" "\\\$7 = 102" \ - "Print value-history\[MAX-2\] using explicit index \$\$2" + "print value-history\[MAX-2\] using explicit index \$\$2" gdb_test "print \$0" "\\\$8 = 102" \ - "Print value-history\[MAX\] using explicit index \$0" + "print value-history\[MAX\] using explicit index \$0" gdb_test "print 108" "\\\$9 = 108" gdb_test "print \$\$0" "\\\$10 = 108" \ - "Print value-history\[MAX\] using explicit index \$\$0" + "print value-history\[MAX\] using explicit index \$\$0" gdb_test "print \$1" "\\\$11 = 101" \ - "Print value-history\[1\] using explicit index \$1" + "print value-history\[1\] using explicit index \$1" gdb_test "print \$2" "\\\$12 = 102" \ - "Print value-history\[2\] using explicit index \$2" + "print value-history\[2\] using explicit index \$2" gdb_test "print \$3" "\\\$13 = 103" \ - "Print value-history\[3\] using explicit index \$3" + "print value-history\[3\] using explicit index \$3" gdb_test "print \$-3" "\\\$14 = 100" \ - "Print (value-history\[MAX\] - 3) using implicit index \$" + "print (value-history\[MAX\] - 3) using implicit index \$" gdb_test "print \$1 + 3" "\\\$15 = 104" \ - "Use value-history element in arithmetic expression" + "use value-history element in arithmetic expression" } proc test_with_program {} { global hex gdb_test_no_output "set \$prog_var = p" \ - "Set a new convenience variable to a program variable" + "set a new convenience variable to a program variable" gdb_test "print /x \$prog_var" " = $hex" \ - "Print contents of new convenience variable of program variable" + "print contents of new convenience variable of program variable" # Test $_thread/$_inferior convenience variables in various commands. gdb_test "info threads \$_thread" "\\* 1 .* main.*" diff --git a/gdb/testsuite/gdb.base/global-var-nested-by-dso-solib1.c b/gdb/testsuite/gdb.base/global-var-nested-by-dso-solib1.c index c467fdb..0048db6 100644 --- a/gdb/testsuite/gdb.base/global-var-nested-by-dso-solib1.c +++ b/gdb/testsuite/gdb.base/global-var-nested-by-dso-solib1.c @@ -1,4 +1,4 @@ -/* Copyright 2014-2024 Free Software Foundation, Inc. +/* Copyright 2014-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/global-var-nested-by-dso-solib2.c b/gdb/testsuite/gdb.base/global-var-nested-by-dso-solib2.c index aedbabc..b592ae7 100644 --- a/gdb/testsuite/gdb.base/global-var-nested-by-dso-solib2.c +++ b/gdb/testsuite/gdb.base/global-var-nested-by-dso-solib2.c @@ -1,4 +1,4 @@ -/* Copyright 2014-2024 Free Software Foundation, Inc. +/* Copyright 2014-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/global-var-nested-by-dso.c b/gdb/testsuite/gdb.base/global-var-nested-by-dso.c index c7ce3cb..247ae9f 100644 --- a/gdb/testsuite/gdb.base/global-var-nested-by-dso.c +++ b/gdb/testsuite/gdb.base/global-var-nested-by-dso.c @@ -1,4 +1,4 @@ -/* Copyright 2014-2024 Free Software Foundation, Inc. +/* Copyright 2014-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp b/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp index 1b79576..3d1bccf 100644 --- a/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp +++ b/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -25,24 +25,22 @@ set lib2name $testfile-solib2 set srcfile_lib2 $srcdir/$subdir/$lib2name.c set binfile_lib2 [standard_output_file $lib2name.so] -if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \ - [list debug]] != "" } { - untested "failed to compile shared library 1" - return -1 + +if { [build_executable "build shlib 1" $binfile_lib1 \ + $srcfile_lib1 [list debug shlib]] != 0 } { + return } -if { [gdb_compile_shlib $srcfile_lib2 $binfile_lib2 \ - [list debug]] != "" } { - untested "failed to compile shared library 2" - return -1 +if { [build_executable "build shlib 2" $binfile_lib2 \ + $srcfile_lib2 [list debug shlib]] != 0 } { + return } -if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable \ - [list debug shlib=$binfile_lib1 shlib=$binfile_lib2]] != "" } { - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile \ + [list debug shlib=$binfile_lib1 shlib=$binfile_lib2]] != 0 } { + return } -clean_restart $binfile gdb_load_shlib $binfile_lib1 gdb_load_shlib $binfile_lib2 diff --git a/gdb/testsuite/gdb.base/gnu-debugdata.c b/gdb/testsuite/gdb.base/gnu-debugdata.c index 1b7c13e..6366cfa 100644 --- a/gdb/testsuite/gdb.base/gnu-debugdata.c +++ b/gdb/testsuite/gdb.base/gnu-debugdata.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/gnu-debugdata.exp b/gdb/testsuite/gdb.base/gnu-debugdata.exp index e55d113..2fabd45 100644 --- a/gdb/testsuite/gdb.base/gnu-debugdata.exp +++ b/gdb/testsuite/gdb.base/gnu-debugdata.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -15,7 +15,7 @@ standard_testfile -if [build_executable ${testfile}.exp $testfile] { +if {[build_executable ${testfile}.exp $testfile]} { return -1 } diff --git a/gdb/testsuite/gdb.base/gnu-ifunc-final.c b/gdb/testsuite/gdb.base/gnu-ifunc-final.c index f9045f8..0d4b976 100644 --- a/gdb/testsuite/gdb.base/gnu-ifunc-final.c +++ b/gdb/testsuite/gdb.base/gnu-ifunc-final.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/gnu-ifunc-lib.c b/gdb/testsuite/gdb.base/gnu-ifunc-lib.c index 0191182..007df1a 100644 --- a/gdb/testsuite/gdb.base/gnu-ifunc-lib.c +++ b/gdb/testsuite/gdb.base/gnu-ifunc-lib.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/gnu-ifunc.c b/gdb/testsuite/gdb.base/gnu-ifunc.c index c78bc0a..2d7595f 100644 --- a/gdb/testsuite/gdb.base/gnu-ifunc.c +++ b/gdb/testsuite/gdb.base/gnu-ifunc.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 @@ -49,7 +49,7 @@ main (void) int i; gnu_ifunc_pre (); - + i = gnu_ifunc (1); /* break-at-call */ assert (i == 2); diff --git a/gdb/testsuite/gdb.base/gnu-ifunc.exp b/gdb/testsuite/gdb.base/gnu-ifunc.exp index ff1d561..ab26371 100644 --- a/gdb/testsuite/gdb.base/gnu-ifunc.exp +++ b/gdb/testsuite/gdb.base/gnu-ifunc.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# Copyright (C) 2009-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 @@ -89,14 +89,14 @@ proc build {resolver_attr resolver_debug final_debug} { # ifunc is resolved. For the description of RESOLVER_ATTR, # RESOLVER_DEBUG and FINAL_DEBUG, see the "build" procedure above. proc_with_prefix set-break {resolver_attr resolver_debug final_debug} { - global binfile libfile lib_so + global libfile lib_so global hex decimal global gdb_prompt set suffix [make_binsuffix $resolver_attr $resolver_debug $final_debug] set lib_so [standard_output_file ${libfile}-$suffix.so] - clean_restart $binfile-$suffix + clean_restart $::testfile-$suffix gdb_load_shlib ${lib_so} if {![runto_main]} { @@ -185,12 +185,17 @@ proc_with_prefix set-break {resolver_attr resolver_debug final_debug} { # other two locations. gdb_test "info breakpoints" "$location\r\n.*$location\r\n$location" } + + # At one point a bug existed such that GDB would trigger an assert + # while restarting the inferior with ifunc breakpoints set. + gdb_run_cmd + gdb_test "" "Breakpoint $::decimal,.*final \\(\[^\r\n\]*\\).*" "restart, run until breakpoint" } # Misc GNU ifunc tests. For the description of RESOLVER_ATTR, # RESOLVER_DEBUG and FINAL_DEBUG, see the "build" procedure above. proc misc_tests {resolver_attr resolver_debug final_debug} { - global srcdir subdir srcfile binfile + global srcdir subdir srcfile global libsrc lib_so libfile global exec_opts executable global hex gdb_prompt @@ -218,7 +223,7 @@ proc misc_tests {resolver_attr resolver_debug final_debug} { # Start with a fresh gdb. - clean_restart $binfile-$suffix + clean_restart $::testfile-$suffix gdb_load_shlib ${lib_so} if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/gnu_vector.c b/gdb/testsuite/gdb.base/gnu_vector.c index 7007d9a..f738978 100644 --- a/gdb/testsuite/gdb.base/gnu_vector.c +++ b/gdb/testsuite/gdb.base/gnu_vector.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/gnu_vector.exp b/gdb/testsuite/gdb.base/gnu_vector.exp index cd2bb9b..a9b70d6 100644 --- a/gdb/testsuite/gdb.base/gnu_vector.exp +++ b/gdb/testsuite/gdb.base/gnu_vector.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -40,7 +40,7 @@ if { [do_compile {-mcpu=native}] != "" return -1 } -clean_restart ${binfile} +clean_restart $testfile if { ![runto_main] } { return -1 diff --git a/gdb/testsuite/gdb.base/gold-gdb-index.exp b/gdb/testsuite/gdb.base/gold-gdb-index.exp deleted file mode 100644 index 0309dd3..0000000 --- a/gdb/testsuite/gdb.base/gold-gdb-index.exp +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2020-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/>. */ - -# This tests the gdb workaround for PR binutils/15646. - -standard_testfile .c gold-gdb-index-2.c - -if { [have_fuse_ld_gold] == 0} { - return -1 -} - -if {[prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" \ - {debug c++ additional_flags=-fuse-ld=gold \ - ldflags=-Wl,--gdb-index \ - additional_flags=-ggnu-pubnames}]} { - return -1 -} - -if { [have_index $binfile] != "gdb_index" } { - return -1 -} - -if {![runto_main]} { - return 0 -} - -gdb_test_no_output "nosharedlibrary" - -gdb_test_no_output "set breakpoint pending off" -gdb_test "break N1::misspelled" "Function \"N1::misspelled\" not defined\." - -gdb_test_multiple "maint info symtabs" "" { - -re -wrap "\{ symtab \[^\r\n\]*gold-gdb-index-2.c.*" { - fail $gdb_test_name - } - -re -wrap "" { - pass $gdb_test_name - } -} diff --git a/gdb/testsuite/gdb.base/grbx.c b/gdb/testsuite/gdb.base/grbx.c index 58034bb..b4b754b 100644 --- a/gdb/testsuite/gdb.base/grbx.c +++ b/gdb/testsuite/gdb.base/grbx.c @@ -7,4 +7,3 @@ int grbx (int x) else return 0; } - diff --git a/gdb/testsuite/gdb.base/gstack.c b/gdb/testsuite/gdb.base/gstack.c index a871670..aa5ce43 100644 --- a/gdb/testsuite/gdb.base/gstack.c +++ b/gdb/testsuite/gdb.base/gstack.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/gstack.exp b/gdb/testsuite/gdb.base/gstack.exp index 8df36b1..89be676 100644 --- a/gdb/testsuite/gdb.base/gstack.exp +++ b/gdb/testsuite/gdb.base/gstack.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2024 Free Software Foundation, Inc. +# Copyright (C) 2024-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 @@ -62,8 +62,10 @@ if { ![gdb_assert { ![expr {$res < 0 || $res == ""}] } $test] } { set test "got backtrace" set saw_backtrace false set no_awk false +set location_re ${srcfile}:${decimal} + gdb_expect { - -i "$res" -re "#0 +(0x\[0-9a-f\]+ in )?main \(\).*\r\nGSTACK-END\r\n\$" { + -i "$res" -re "#0 +(0x\[0-9a-f\]+ in )?main \(\).*$location_re.*\r\nGSTACK-END\r\n\$" { set saw_backtrace true pass $test exp_continue diff --git a/gdb/testsuite/gdb.base/hashline1.exp b/gdb/testsuite/gdb.base/hashline1.exp index e2f18b5..7843e75 100644 --- a/gdb/testsuite/gdb.base/hashline1.exp +++ b/gdb/testsuite/gdb.base/hashline1.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -37,7 +37,7 @@ if { [gdb_compile $compile_name "${binfile}" executable {debug}] != "" } { return -1 } -clean_restart ${binfile} +clean_restart $testfile set bp_location [gdb_get_line_number "set breakpoint here" $new_srcfile] diff --git a/gdb/testsuite/gdb.base/hashline2.exp b/gdb/testsuite/gdb.base/hashline2.exp index 8a91a7d..39a1f32 100644 --- a/gdb/testsuite/gdb.base/hashline2.exp +++ b/gdb/testsuite/gdb.base/hashline2.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -34,7 +34,7 @@ if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } { return -1 } -clean_restart $binfile +clean_restart $testfile set bp_location [gdb_get_line_number "set breakpoint here" ${new_srcfile}] diff --git a/gdb/testsuite/gdb.base/hashline3.exp b/gdb/testsuite/gdb.base/hashline3.exp index 8686901..b7f2239 100644 --- a/gdb/testsuite/gdb.base/hashline3.exp +++ b/gdb/testsuite/gdb.base/hashline3.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -35,7 +35,7 @@ if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } { return -1 } -clean_restart $binfile +clean_restart $testfile set bp_location [gdb_get_line_number "set breakpoint here" $new_srcfile] diff --git a/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c b/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c index 57031ac..eb9410b 100644 --- a/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c +++ b/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.c b/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.c index 8808e23..fff2953 100644 --- a/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.c +++ b/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp b/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp index e90f352..c100197 100644 --- a/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp +++ b/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -25,16 +25,17 @@ standard_testfile ${main_src} ${lib_src} set lib_basename hbreak-in-shr-unsupported-shr.so set lib_so [standard_output_file ${lib_basename}] -set lib_opts "debug" +set lib_opts [list debug shlib] set exec_opts [list debug shlib=${lib_so}] -if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib_src} ${lib_so} $lib_opts] != "" - || [gdb_compile ${srcdir}/${subdir}/${main_src} ${binfile} executable $exec_opts] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build shlib" $lib_so $lib_src $lib_opts] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $main_src $exec_opts] != 0 } { + return } -clean_restart $binfile gdb_load_shlib $lib_so if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/hbreak-unmapped.c b/gdb/testsuite/gdb.base/hbreak-unmapped.c index c38538d..120c08d 100644 --- a/gdb/testsuite/gdb.base/hbreak-unmapped.c +++ b/gdb/testsuite/gdb.base/hbreak-unmapped.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/hbreak-unmapped.exp b/gdb/testsuite/gdb.base/hbreak-unmapped.exp index b28af6d..80c7aa8 100644 --- a/gdb/testsuite/gdb.base/hbreak-unmapped.exp +++ b/gdb/testsuite/gdb.base/hbreak-unmapped.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -21,7 +21,7 @@ if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/hbreak.c b/gdb/testsuite/gdb.base/hbreak.c index 86d73cf..640e1f2 100644 --- a/gdb/testsuite/gdb.base/hbreak.c +++ b/gdb/testsuite/gdb.base/hbreak.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/hbreak.exp b/gdb/testsuite/gdb.base/hbreak.exp index 73a3e2a..6a9bcbe 100644 --- a/gdb/testsuite/gdb.base/hbreak.exp +++ b/gdb/testsuite/gdb.base/hbreak.exp @@ -1,4 +1,4 @@ -# Copyright 2009-2024 Free Software Foundation, Inc. +# Copyright 2009-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 @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${test} ${srcfile}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/hbreak2.exp b/gdb/testsuite/gdb.base/hbreak2.exp index 37c001a..65f08e2 100644 --- a/gdb/testsuite/gdb.base/hbreak2.exp +++ b/gdb/testsuite/gdb.base/hbreak2.exp @@ -1,4 +1,4 @@ -# Copyright 1988-2024 Free Software Foundation, Inc. +# Copyright 1988-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 @@ -477,7 +477,7 @@ proc test_next_with_recursion {} { delete_breakpoints - if [istarget "mips*tx39-*"] { + if {[istarget "mips*tx39-*"]} { set timeout 60 } # We used to set timeout here for all other targets as well. This diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp index 056e352..ec41382 100644 --- a/gdb/testsuite/gdb.base/help.exp +++ b/gdb/testsuite/gdb.base/help.exp @@ -1,4 +1,4 @@ -# Copyright 1988-2024 Free Software Foundation, Inc. +# Copyright 1988-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 diff --git a/gdb/testsuite/gdb.base/history-duplicates.exp b/gdb/testsuite/gdb.base/history-duplicates.exp index 5ac4a35..2f80ecc 100644 --- a/gdb/testsuite/gdb.base/history-duplicates.exp +++ b/gdb/testsuite/gdb.base/history-duplicates.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/hook-stop.c b/gdb/testsuite/gdb.base/hook-stop.c index 3e552f8..22d1c27 100644 --- a/gdb/testsuite/gdb.base/hook-stop.c +++ b/gdb/testsuite/gdb.base/hook-stop.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/hook-stop.exp b/gdb/testsuite/gdb.base/hook-stop.exp index 864e034..7f4bcc9 100644 --- a/gdb/testsuite/gdb.base/hook-stop.exp +++ b/gdb/testsuite/gdb.base/hook-stop.exp @@ -1,4 +1,4 @@ -# Copyright 2009-2024 Free Software Foundation, Inc. +# Copyright 2009-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 @@ -35,9 +35,9 @@ proc define_hook_stop {commands} { # caller's caller directly. proc setup {commands} { - global srcfile binfile + global srcfile - clean_restart $binfile + clean_restart $::testfile if {![runto_main]} { return -code return diff --git a/gdb/testsuite/gdb.base/huge.exp b/gdb/testsuite/gdb.base/huge.exp index ecc4d2d..4d16466 100644 --- a/gdb/testsuite/gdb.base/huge.exp +++ b/gdb/testsuite/gdb.base/huge.exp @@ -1,4 +1,4 @@ -# Copyright 2001-2024 Free Software Foundation, Inc. +# Copyright 2001-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 @@ -23,14 +23,14 @@ require {!target_info exists gdb,skip_huge_test} standard_testfile .c -set max [expr 2 * 1024 * 1024] +set max [expr {2 * 1024 * 1024}] set min 16 set opts {} lappend opts debug set compilation_succeeded 0 -for { set size $max } { $size >= $min } { set size [expr $size / 2] } { +for { set size $max } { $size >= $min } { set size [expr {$size / 2}] } { set try_opts [concat $opts [list additional_flags=-DCRASH_GDB=$size]] if { [build_executable $testfile.exp $testfile $srcfile $try_opts] == -1 } { continue @@ -39,10 +39,10 @@ for { set size $max } { $size >= $min } { set size [expr $size / 2] } { set compilation_succeeded 1 break } -require {expr $compilation_succeeded} +require {expr {$compilation_succeeded}} # Start with a fresh gdb. -clean_restart ${binfile} +clean_restart $testfile save_vars { timeout } { set timeout 30 @@ -83,6 +83,6 @@ save_vars { timeout } { unsupported $test } else { # At 56 passes with and without the fix, so use 55. - gdb_assert {$space_used < [expr 55 * 4 * $size] } $test + gdb_assert {$space_used < [expr {55 * 4 * $size}] } $test } } diff --git a/gdb/testsuite/gdb.base/hw-sw-break-same-address.exp b/gdb/testsuite/gdb.base/hw-sw-break-same-address.exp index 657e55c..a342104 100644 --- a/gdb/testsuite/gdb.base/hw-sw-break-same-address.exp +++ b/gdb/testsuite/gdb.base/hw-sw-break-same-address.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" ${test} ${srcfile}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/ifelse.exp b/gdb/testsuite/gdb.base/ifelse.exp index d91ac98..f1dc9d2 100644 --- a/gdb/testsuite/gdb.base/ifelse.exp +++ b/gdb/testsuite/gdb.base/ifelse.exp @@ -1,4 +1,4 @@ -# Copyright 2006-2024 Free Software Foundation, Inc. +# Copyright 2006-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 diff --git a/gdb/testsuite/gdb.base/include-main.c b/gdb/testsuite/gdb.base/include-main.c index 6290ae0..f54e268 100644 --- a/gdb/testsuite/gdb.base/include-main.c +++ b/gdb/testsuite/gdb.base/include-main.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/include-main.exp b/gdb/testsuite/gdb.base/include-main.exp index 7247b1c..5cded4b 100644 --- a/gdb/testsuite/gdb.base/include-main.exp +++ b/gdb/testsuite/gdb.base/include-main.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/included.c b/gdb/testsuite/gdb.base/included.c index 4f43e61..ab8edf4 100644 --- a/gdb/testsuite/gdb.base/included.c +++ b/gdb/testsuite/gdb.base/included.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2007-2024 Free Software Foundation, Inc. + Copyright 2007-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 diff --git a/gdb/testsuite/gdb.base/included.exp b/gdb/testsuite/gdb.base/included.exp index c33d695..a125a27 100644 --- a/gdb/testsuite/gdb.base/included.exp +++ b/gdb/testsuite/gdb.base/included.exp @@ -1,4 +1,4 @@ -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 @@ -26,7 +26,7 @@ gdb_test_no_output "set listsize 1" gdb_test "list -q main" ".*" get_debug_format -set non_dwarf [expr ! [test_debug_format "DWARF \[0-9\]"]] +set non_dwarf [expr {! [test_debug_format "DWARF \[0-9\]"]}] # We should be able to find the source file containing the definition, # even though it was an included header. diff --git a/gdb/testsuite/gdb.base/included.h b/gdb/testsuite/gdb.base/included.h index fd8d23d..c16083a 100644 --- a/gdb/testsuite/gdb.base/included.h +++ b/gdb/testsuite/gdb.base/included.h @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2007-2024 Free Software Foundation, Inc. + Copyright 2007-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 diff --git a/gdb/testsuite/gdb.base/index-cache-2.c b/gdb/testsuite/gdb.base/index-cache-2.c index 27303b6..6706d5b 100644 --- a/gdb/testsuite/gdb.base/index-cache-2.c +++ b/gdb/testsuite/gdb.base/index-cache-2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2023-2024 Free Software Foundation, Inc. + Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/index-cache.c b/gdb/testsuite/gdb.base/index-cache.c index 1e3b8fd..7c22825 100644 --- a/gdb/testsuite/gdb.base/index-cache.c +++ b/gdb/testsuite/gdb.base/index-cache.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 @@ -22,4 +22,3 @@ main (void) { return foo (); } - diff --git a/gdb/testsuite/gdb.base/index-cache.exp b/gdb/testsuite/gdb.base/index-cache.exp index e64495a..b862e0c 100644 --- a/gdb/testsuite/gdb.base/index-cache.exp +++ b/gdb/testsuite/gdb.base/index-cache.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -29,8 +29,8 @@ if { [build_executable "failed to prepare" $testfile [list $srcfile $srcfile2] \ # - the binary already has an index section # - we use the -readnow switch set has_index_section [exec_has_index_section $binfile] -set uses_readnow [expr [string first "-readnow" $GDBFLAGS] != -1] -set expecting_index_cache_use [expr !$has_index_section && !$uses_readnow] +set uses_readnow [expr {[string first "-readnow" $GDBFLAGS] != -1}] +set expecting_index_cache_use [expr {!$has_index_section && !$uses_readnow}] # List the files in DIR on the host (where GDB-under-test runs). # Return a list of two elements: @@ -117,12 +117,12 @@ proc_with_prefix test_basic_stuff { } { "index-cache is now enabled" with_test_prefix "deprecated commands" { - gdb_test "set index-cache off" ".*is deprecated.*" "disable index cache" + gdb_test "set index-cache off" ".*is deprecated.*" "disable index cache" gdb_test \ "show index-cache enabled" \ "The index cache is off." \ "index-cache is now disabled" - gdb_test "set index-cache on" ".*is deprecated.*" "enable index cache" + gdb_test "set index-cache on" ".*is deprecated.*" "enable index cache" gdb_test \ "show index-cache enabled" \ "The index cache is on." \ diff --git a/gdb/testsuite/gdb.base/infcall-exec.c b/gdb/testsuite/gdb.base/infcall-exec.c index e79b4f7..769192c 100644 --- a/gdb/testsuite/gdb.base/infcall-exec.c +++ b/gdb/testsuite/gdb.base/infcall-exec.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/infcall-exec.exp b/gdb/testsuite/gdb.base/infcall-exec.exp index 354bdbc..a4d2241 100644 --- a/gdb/testsuite/gdb.base/infcall-exec.exp +++ b/gdb/testsuite/gdb.base/infcall-exec.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 @@ -23,12 +23,11 @@ set srcfile2 "${testfile2}.c" set binfile2 [standard_output_file $testfile2] # Build the two executables for the test. -if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable debug] != ""} { - untested "could not build $binfile" +if {[build_executable "build exec'd file" $testfile2 $srcfile2] != 0} { return -1 } -if {[gdb_compile $srcdir/$subdir/$srcfile2 $binfile2 executable debug] != ""} { - untested "could not build $binfile2" + +if {[prepare_for_testing "prepare" $testfile $srcfile] != 0} { return -1 } @@ -36,8 +35,6 @@ if { [is_remote target] } { set binfile2 [gdb_remote_download target $binfile2] } -clean_restart $binfile - if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/infcall-exec2.c b/gdb/testsuite/gdb.base/infcall-exec2.c index 30eb2b4..9b81ef7 100644 --- a/gdb/testsuite/gdb.base/infcall-exec2.c +++ b/gdb/testsuite/gdb.base/infcall-exec2.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/infcall-failure-2.exp b/gdb/testsuite/gdb.base/infcall-failure-2.exp new file mode 100644 index 0000000..2a7d784 --- /dev/null +++ b/gdb/testsuite/gdb.base/infcall-failure-2.exp @@ -0,0 +1,37 @@ +# 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/>. + +standard_testfile infcall-failure.c + +if { [prepare_for_testing "failed to prepare" $testfile $srcfile] == -1 } { + return +} + +if { ![runto_main] } { + return +} + +if { ![gdb_breakpoint "*0x1" message] } { + return +} + +gdb_test "p foo ()" \ + [multi_line \ + [string_to_regexp "Command aborted."] \ + ".*" ] + +# Check that gdb is still responsive. Regression test for PR gdb/33068. +gdb_test "p 1 + 1" \ + " = 2" diff --git a/gdb/testsuite/gdb.base/infcall-failure.c b/gdb/testsuite/gdb.base/infcall-failure.c index f0af35d..33db345 100644 --- a/gdb/testsuite/gdb.base/infcall-failure.c +++ b/gdb/testsuite/gdb.base/infcall-failure.c @@ -1,4 +1,4 @@ -/* Copyright 2022-2024 Free Software Foundation, Inc. +/* Copyright 2022-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/infcall-failure.exp b/gdb/testsuite/gdb.base/infcall-failure.exp index 8d08555..eb4937e 100644 --- a/gdb/testsuite/gdb.base/infcall-failure.exp +++ b/gdb/testsuite/gdb.base/infcall-failure.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -39,7 +39,7 @@ proc start_gdb_and_runto_main { target_async target_non_stop } { append ::GDBFLAGS \ " -ex \"maintenance set target-async ${target_async}\"" - clean_restart ${::binfile} + clean_restart $::testfile } if { ![runto_main] } { @@ -131,7 +131,13 @@ proc_with_prefix run_cond_hits_segfault_test { async_p non_stop_p } { [multi_line \ "Continuing\\." \ "" \ - "Program received signal SIGSEGV, Segmentation fault\\." \ + [string cat \ + [string_to_regexp \ + "Program received signal SIGSEGV, Segmentation fault."] \ + "("] \ + [string cat \ + [string_to_regexp "Address not mapped to object."] \ + ")?"] \ "${::hex} in func_segfault \\(\\) at \[^\r\n\]+:${::segv_line}" \ "${::decimal}\\s+\[^\r\n\]+Segfault here\[^\r\n\]+" \ "Error in testing condition for breakpoint ${bp_1_num}:" \ @@ -161,7 +167,13 @@ proc_with_prefix run_call_hits_segfault_test { async_p non_stop_p } { gdb_test "call func_segfault ()" \ [multi_line \ "" \ - "Program received signal SIGSEGV, Segmentation fault\\." \ + [string cat \ + [string_to_regexp \ + "Program received signal SIGSEGV, Segmentation fault."] \ + "("] \ + [string cat \ + [string_to_regexp "Address not mapped to object."] \ + ")?"] \ "${::hex} in func_segfault \\(\\) at \[^\r\n\]+:${::segv_line}" \ "${::decimal}\\s+\[^\r\n\]+Segfault here\[^\r\n\]+" \ "The program being debugged was signaled while in a function called from GDB\\." \ diff --git a/gdb/testsuite/gdb.base/infcall-input.c b/gdb/testsuite/gdb.base/infcall-input.c index 8352d39..4cf513c 100644 --- a/gdb/testsuite/gdb.base/infcall-input.c +++ b/gdb/testsuite/gdb.base/infcall-input.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/infcall-input.exp b/gdb/testsuite/gdb.base/infcall-input.exp index 9f86a97..dea3b85 100644 --- a/gdb/testsuite/gdb.base/infcall-input.exp +++ b/gdb/testsuite/gdb.base/infcall-input.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs-c++.exp b/gdb/testsuite/gdb.base/infcall-nested-structs-c++.exp index 4fe7505..706acc4 100644 --- a/gdb/testsuite/gdb.base/infcall-nested-structs-c++.exp +++ b/gdb/testsuite/gdb.base/infcall-nested-structs-c++.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs-c.exp b/gdb/testsuite/gdb.base/infcall-nested-structs-c.exp index ce0ef4a..1f76598 100644 --- a/gdb/testsuite/gdb.base/infcall-nested-structs-c.exp +++ b/gdb/testsuite/gdb.base/infcall-nested-structs-c.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs.c b/gdb/testsuite/gdb.base/infcall-nested-structs.c index 242ef78..98568a3 100644 --- a/gdb/testsuite/gdb.base/infcall-nested-structs.c +++ b/gdb/testsuite/gdb.base/infcall-nested-structs.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl b/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl index 5d04f38..5d0e8d0 100644 --- a/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl +++ b/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -18,7 +18,7 @@ # Some targets can't call functions, so don't even bother with this # test. -if [target_info exists gdb,cannot_call_functions] { +if {[target_info exists gdb,cannot_call_functions]} { unsupported "this target can not call functions" continue } @@ -28,7 +28,7 @@ set float_types { tf td tld } set complex_types { tfc tdc tldc } set compile_flags {debug} -if [support_complex_tests] { +if {[support_complex_tests]} { lappend compile_flags "additional_flags=-DTEST_COMPLEX" lappend compile_flags "additional_flags=-Wno-psabi" } @@ -56,9 +56,6 @@ proc I2A { n } { proc start_nested_structs_test { lang types } { global testfile global srcfile - global binfile - global subdir - global srcdir global compile_flags standard_testfile infcall-nested-structs.c @@ -75,14 +72,11 @@ proc start_nested_structs_test { lang types } { append testfile "-" "$t" } - if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags}"] != "" } { - unresolved "failed to compile" + if { [prepare_for_testing "prepare for testing" \ + $testfile $srcfile $flags] } { return 0 } - # Start with a fresh gdb. - clean_restart ${binfile} - # Make certain that the output is consistent gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set print address off" @@ -91,7 +85,7 @@ proc start_nested_structs_test { lang types } { gdb_test_no_output "set print elements 300" # Advance to main - if { ![runto_main] } then { + if { ![runto_main] } { return 0 } @@ -112,12 +106,12 @@ proc run_tests { lang types } { global gdb_prompt foreach {name} {struct_01_01 struct_01_02 struct_01_03 struct_01_04 - struct_02_01 struct_02_02 struct_02_03 struct_02_04 - struct_04_01 struct_04_02 struct_04_03 struct_04_04 - struct_05_01 struct_05_02 struct_05_03 struct_05_04 - struct_static_02_01 struct_static_02_02 struct_static_02_03 struct_static_02_04 - struct_static_04_01 struct_static_04_02 struct_static_04_03 struct_static_04_04 - struct_static_06_01 struct_static_06_02 struct_static_06_03 struct_static_06_04} { + struct_02_01 struct_02_02 struct_02_03 struct_02_04 + struct_04_01 struct_04_02 struct_04_03 struct_04_04 + struct_05_01 struct_05_02 struct_05_03 struct_05_04 + struct_static_02_01 struct_static_02_02 struct_static_02_03 struct_static_02_04 + struct_static_04_01 struct_static_04_02 struct_static_04_03 struct_static_04_04 + struct_static_06_01 struct_static_06_02 struct_static_06_03 struct_static_06_04} { # Only run static member tests on C++ if { $lang == "c" && [regexp "static" $name match] } { @@ -163,7 +157,7 @@ foreach ta $int_types { start_gdb_and_run_tests $lang $ta } -if [support_complex_tests] { +if {[support_complex_tests]} { foreach ta $complex_types { start_gdb_and_run_tests $lang $ta } diff --git a/gdb/testsuite/gdb.base/infcall-timeout.c b/gdb/testsuite/gdb.base/infcall-timeout.c index 61f64c5..934366c 100644 --- a/gdb/testsuite/gdb.base/infcall-timeout.c +++ b/gdb/testsuite/gdb.base/infcall-timeout.c @@ -1,4 +1,4 @@ -/* Copyright 2022-2024 Free Software Foundation, Inc. +/* Copyright 2022-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/infcall-timeout.exp b/gdb/testsuite/gdb.base/infcall-timeout.exp index ad4dbe3..b2c7a13 100644 --- a/gdb/testsuite/gdb.base/infcall-timeout.exp +++ b/gdb/testsuite/gdb.base/infcall-timeout.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -41,7 +41,7 @@ proc run_test { target_async target_non_stop non_stop unwind } { append ::GDBFLAGS \ " -ex \"maintenance set target-async ${target_async}\"" - clean_restart ${::binfile} + clean_restart $::testfile } if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/inferior-args.c b/gdb/testsuite/gdb.base/inferior-args.c index e06c393..faa3183 100644 --- a/gdb/testsuite/gdb.base/inferior-args.c +++ b/gdb/testsuite/gdb.base/inferior-args.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/inferior-args.exp b/gdb/testsuite/gdb.base/inferior-args.exp index a1977db..036dd20 100644 --- a/gdb/testsuite/gdb.base/inferior-args.exp +++ b/gdb/testsuite/gdb.base/inferior-args.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -17,6 +17,7 @@ # This does not work on boards that don't support inferior arguments. require {!target_info exists noargs} +require {expr {[have_startup_shell] != -1}} standard_testfile .c @@ -40,9 +41,9 @@ if {[build_executable "failed to prepare" $testfile $srcfile \ # that are problematic, STUB_SUITABLE is false. proc do_test { method startup_with_shell inferior_args expected_results \ stub_suitable } { - global binfile hex + global hex - clean_restart $binfile + clean_restart $::testfile gdb_test_no_output "set startup-with-shell $startup_with_shell" @@ -125,13 +126,13 @@ proc do_test { method startup_with_shell inferior_args expected_results \ error "invalid method $method" } - set argc [expr [llength $expected_results] + 1] + set argc [expr {[llength $expected_results] + 1}] # Now that we are stopped at main, inspect argc/argv. gdb_test "print argc" " = $argc" gdb_test "print argv\[0\]" " = $hex \"\[^\r\n\]+\"" for { set i 1 } { $i < $argc } { incr i } { - set idx [expr $i - 1] + set idx [expr {$i - 1}] gdb_test "print argv\[$i\]" " = [lindex $expected_results $idx]" } } @@ -168,8 +169,7 @@ lappend test_desc_list [list "test one" \ # the rest of this mess in order to avoid TCL escaping the quote for # me. It's super important that what we send to GDB is '"' not '\"'. set item [list "test two" false] -set cmd [format "lappend item \{ '%c' '\\%c' \}" 34 34] -eval $cmd +lappend item [format { '%c' '\%c' } 34 34] set bs "\\\\" lappend item [list "$hex \"$bs\"\"" "$hex \"$bs$bs$bs\"\""] lappend test_desc_list $item @@ -211,14 +211,31 @@ lappend test_desc_list [list "test four" \ [list "$hex \"'\"" \ "$hex \"\\\\\"\""]] -foreach desc $test_desc_list { - lassign $desc name stub_suitable args re_list - with_test_prefix $name { - foreach_with_prefix set_method { "start" "starti" "run" "set args" } { - foreach_with_prefix startup_with_shell { on off } { - do_test $set_method $startup_with_shell $args $re_list \ - $stub_suitable +# Run all tests in the global TEST_DESC_LIST. +proc run_all_tests {} { + foreach desc $::test_desc_list { + lassign $desc name stub_suitable args re_list + with_test_prefix $name { + foreach_with_prefix set_method { "start" "starti" "run" "set args" } { + foreach_with_prefix startup_with_shell { on off } { + do_test $set_method $startup_with_shell $args $re_list \ + $stub_suitable + } } } } } + +run_all_tests + +# For extended-remote targets, disable the packet which passes +# inferior arguments as a single string. This changes how the vRun +# (extended-remote only) packet works. +if {[target_info gdb_protocol] == "extended-remote"} { + with_test_prefix "single-inferior-arg disabled" { + save_vars { GDBFLAGS } { + append GDBFLAGS " -ex \"set remote single-inferior-argument-feature-packet off\"" + run_all_tests + } + } +} diff --git a/gdb/testsuite/gdb.base/inferior-clone.exp b/gdb/testsuite/gdb.base/inferior-clone.exp index 4b8b772..e356421 100644 --- a/gdb/testsuite/gdb.base/inferior-clone.exp +++ b/gdb/testsuite/gdb.base/inferior-clone.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2021-2024 Free Software Foundation, Inc. +# Copyright (C) 2021-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 diff --git a/gdb/testsuite/gdb.base/inferior-died.c b/gdb/testsuite/gdb.base/inferior-died.c index 9aa5adb..f7cb9d5 100644 --- a/gdb/testsuite/gdb.base/inferior-died.c +++ b/gdb/testsuite/gdb.base/inferior-died.c @@ -1,6 +1,6 @@ /* Test for fork-related gdb bug - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/inferior-died.exp b/gdb/testsuite/gdb.base/inferior-died.exp index 9fa1c99..adcaff5 100644 --- a/gdb/testsuite/gdb.base/inferior-died.exp +++ b/gdb/testsuite/gdb.base/inferior-died.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -13,10 +13,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/>. -# Until "set follow-fork-mode" and "catch fork" are implemented on -# other targets... -# -require {istarget "*-*-linux*"} +require allow_fork_tests require support_displaced_stepping @@ -28,12 +25,12 @@ if { [build_executable "failed to build" ${testfile} ${testfile}.c] } { save_vars { GDBFLAGS } { append GDBFLAGS " -ex \"set non-stop on\"" - clean_restart ${binfile} + clean_restart $testfile } gdb_test_no_output "set detach-on-fork off" -if ![runto_main] { +if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/inferior-noarg.c b/gdb/testsuite/gdb.base/inferior-noarg.c index 7b7b92a..a8d19f2 100644 --- a/gdb/testsuite/gdb.base/inferior-noarg.c +++ b/gdb/testsuite/gdb.base/inferior-noarg.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/inferior-noarg.exp b/gdb/testsuite/gdb.base/inferior-noarg.exp index b377742..51b9b24 100644 --- a/gdb/testsuite/gdb.base/inferior-noarg.exp +++ b/gdb/testsuite/gdb.base/inferior-noarg.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/infnan.c b/gdb/testsuite/gdb.base/infnan.c index 3a86843..04efda7 100644 --- a/gdb/testsuite/gdb.base/infnan.c +++ b/gdb/testsuite/gdb.base/infnan.c @@ -1,6 +1,6 @@ /* This test file is part of GDB, the GNU debugger. - Copyright 2007-2024 Free Software Foundation, Inc. + Copyright 2007-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 diff --git a/gdb/testsuite/gdb.base/infnan.exp b/gdb/testsuite/gdb.base/infnan.exp index cef7fba..11470f1 100644 --- a/gdb/testsuite/gdb.base/infnan.exp +++ b/gdb/testsuite/gdb.base/infnan.exp @@ -1,4 +1,4 @@ -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 diff --git a/gdb/testsuite/gdb.base/info-fun-solib.c b/gdb/testsuite/gdb.base/info-fun-solib.c index 81bb12c..4f3211c 100644 --- a/gdb/testsuite/gdb.base/info-fun-solib.c +++ b/gdb/testsuite/gdb.base/info-fun-solib.c @@ -1,4 +1,4 @@ -/* Copyright 2012-2024 Free Software Foundation, Inc. +/* Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/info-fun.c b/gdb/testsuite/gdb.base/info-fun.c index 987e1f9..5efdd64 100644 --- a/gdb/testsuite/gdb.base/info-fun.c +++ b/gdb/testsuite/gdb.base/info-fun.c @@ -1,4 +1,4 @@ -/* Copyright 2012-2024 Free Software Foundation, Inc. +/* Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/info-fun.exp b/gdb/testsuite/gdb.base/info-fun.exp index 6cd7680..884496c 100644 --- a/gdb/testsuite/gdb.base/info-fun.exp +++ b/gdb/testsuite/gdb.base/info-fun.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/info-locals-unused-static-var.c b/gdb/testsuite/gdb.base/info-locals-unused-static-var.c index 5bb1e91..324cf20 100644 --- a/gdb/testsuite/gdb.base/info-locals-unused-static-var.c +++ b/gdb/testsuite/gdb.base/info-locals-unused-static-var.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/info-locals-unused-static-var.exp b/gdb/testsuite/gdb.base/info-locals-unused-static-var.exp index de7077b..cf6b050 100644 --- a/gdb/testsuite/gdb.base/info-locals-unused-static-var.exp +++ b/gdb/testsuite/gdb.base/info-locals-unused-static-var.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/info-macros.c b/gdb/testsuite/gdb.base/info-macros.c index 4a6c960..8fc1373 100644 --- a/gdb/testsuite/gdb.base/info-macros.c +++ b/gdb/testsuite/gdb.base/info-macros.c @@ -68,4 +68,3 @@ int main (int argc, const char **argv) return 0; } #endif - diff --git a/gdb/testsuite/gdb.base/info-macros.exp b/gdb/testsuite/gdb.base/info-macros.exp index 2ace202..1e10604 100644 --- a/gdb/testsuite/gdb.base/info-macros.exp +++ b/gdb/testsuite/gdb.base/info-macros.exp @@ -1,4 +1,4 @@ -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 @@ -22,7 +22,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug macr return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/info-os.c b/gdb/testsuite/gdb.base/info-os.c index 122c318..61dde68 100644 --- a/gdb/testsuite/gdb.base/info-os.c +++ b/gdb/testsuite/gdb.base/info-os.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 @@ -117,14 +117,14 @@ main (void) /* Lock the mutex to prevent the new thread from finishing immediately. */ pthread_mutex_lock (&mutex); pthread_create (&thread, NULL, thread_proc, 0); - + sock = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock < 0) { printf ("Cannot create socket.\n"); return 1; } - + sock_addr.sin_family = AF_INET; sock_addr.sin_port = 0; /* Bind to a free port. */ sock_addr.sin_addr.s_addr = htonl (INADDR_ANY); diff --git a/gdb/testsuite/gdb.base/info-os.exp b/gdb/testsuite/gdb.base/info-os.exp index 22e9819..be7a746 100644 --- a/gdb/testsuite/gdb.base/info-os.exp +++ b/gdb/testsuite/gdb.base/info-os.exp @@ -1,4 +1,4 @@ -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 @@ -128,7 +128,7 @@ proc expect_multiline { command expect test } { exp_continue } -re "^$gdb_prompt $" { - if $found { + if {$found} { set ok 1 } # Exit the loop. diff --git a/gdb/testsuite/gdb.base/info-proc.exp b/gdb/testsuite/gdb.base/info-proc.exp index af7f1dcd..197c8e5 100644 --- a/gdb/testsuite/gdb.base/info-proc.exp +++ b/gdb/testsuite/gdb.base/info-proc.exp @@ -1,4 +1,4 @@ -# Copyright 2002-2024 Free Software Foundation, Inc. +# Copyright 2002-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 @@ -63,7 +63,7 @@ if {[istarget "*-*-linux*"]} { } set gcorefile [standard_output_file $testfile.gcore] if {[gdb_gcore_cmd $gcorefile "save a core file"]} { - clean_restart $binfile + clean_restart $testfile gdb_test "core $gcorefile" "Core was generated by.*" \ "core [file tail $gcorefile]" diff --git a/gdb/testsuite/gdb.base/info-program.c b/gdb/testsuite/gdb.base/info-program.c index a61bc9f..c90bbb4 100644 --- a/gdb/testsuite/gdb.base/info-program.c +++ b/gdb/testsuite/gdb.base/info-program.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/info-program.exp b/gdb/testsuite/gdb.base/info-program.exp index b31985d..b8c3809 100644 --- a/gdb/testsuite/gdb.base/info-program.exp +++ b/gdb/testsuite/gdb.base/info-program.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -35,7 +35,7 @@ standard_testfile proc do_test { threads non-stop } { save_vars { ::GDBFLAGS } { append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\"" - clean_restart $::binfile-$threads + clean_restart $::testfile-$threads } gdb_test "info program" \ diff --git a/gdb/testsuite/gdb.base/info-shared-solib1.c b/gdb/testsuite/gdb.base/info-shared-solib1.c index 584218b..d5f7478 100644 --- a/gdb/testsuite/gdb.base/info-shared-solib1.c +++ b/gdb/testsuite/gdb.base/info-shared-solib1.c @@ -1,4 +1,4 @@ -/* Copyright 2012-2024 Free Software Foundation, Inc. +/* Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/info-shared-solib2.c b/gdb/testsuite/gdb.base/info-shared-solib2.c index 7a0aa40c..ad4d1be 100644 --- a/gdb/testsuite/gdb.base/info-shared-solib2.c +++ b/gdb/testsuite/gdb.base/info-shared-solib2.c @@ -1,4 +1,4 @@ -/* Copyright 2012-2024 Free Software Foundation, Inc. +/* Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/info-shared.c b/gdb/testsuite/gdb.base/info-shared.c index 562e880..7d62e04 100644 --- a/gdb/testsuite/gdb.base/info-shared.c +++ b/gdb/testsuite/gdb.base/info-shared.c @@ -1,4 +1,4 @@ -/* Copyright 2012-2024 Free Software Foundation, Inc. +/* Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/info-shared.exp b/gdb/testsuite/gdb.base/info-shared.exp index a96dd3c..7475749 100644 --- a/gdb/testsuite/gdb.base/info-shared.exp +++ b/gdb/testsuite/gdb.base/info-shared.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -79,9 +79,12 @@ proc check_info_shared { test expect1 expect2 } { } } +# Check that "info shared" before running doesn't crash. +check_info_shared "info sharedlibrary before running" 0 0 + # Start the inferior, and check neither of the libraries are loaded at # the start. -if ![runto_main] { +if {![runto_main]} { return 0 } check_info_shared "info sharedlibrary #1" 0 0 diff --git a/gdb/testsuite/gdb.base/info-target.exp b/gdb/testsuite/gdb.base/info-target.exp index 7dfe074..6e74320 100644 --- a/gdb/testsuite/gdb.base/info-target.exp +++ b/gdb/testsuite/gdb.base/info-target.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -27,4 +27,4 @@ set eol "\r\n" # it is formatted properly. For instance, make sure that no '\n' is # missing at the end some lines. gdb_test "info target" \ - "Symbols from \".*${testfile}.*\"\\..*${eol}Local exec file:${eol}.*Entry point: 0x\[0-9a-zA-Z\]+${eol}.*" + "Symbols from \".*${testfile}.*\"\\..*${eol}Local exec file:${eol}.*Entry point: 0x\[0-9a-zA-Z\]+${eol}.*" diff --git a/gdb/testsuite/gdb.base/info-types-c++.exp b/gdb/testsuite/gdb.base/info-types-c++.exp index b0a2637..c538436 100644 --- a/gdb/testsuite/gdb.base/info-types-c++.exp +++ b/gdb/testsuite/gdb.base/info-types-c++.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/info-types-c.exp b/gdb/testsuite/gdb.base/info-types-c.exp index 7e6108c..9b363a2 100644 --- a/gdb/testsuite/gdb.base/info-types-c.exp +++ b/gdb/testsuite/gdb.base/info-types-c.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/info-types.c b/gdb/testsuite/gdb.base/info-types.c index 1e1d354..eee32d4 100644 --- a/gdb/testsuite/gdb.base/info-types.c +++ b/gdb/testsuite/gdb.base/info-types.c @@ -1,4 +1,4 @@ -/* Copyright 2019-2024 Free Software Foundation, Inc. +/* Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/info-types.exp.tcl b/gdb/testsuite/gdb.base/info-types.exp.tcl index 0a33afe..a609ae4 100644 --- a/gdb/testsuite/gdb.base/info-types.exp.tcl +++ b/gdb/testsuite/gdb.base/info-types.exp.tcl @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -33,7 +33,7 @@ proc run_test { lang } { return -1 } - if ![runto_main] then { + if { ![runto_main] } { return 0 } @@ -90,6 +90,7 @@ proc run_test { lang } { "28:\[\t \]+typedef struct baz_t baz;" \ "31:\[\t \]+typedef struct baz_t \\* baz_ptr;" \ "21:\[\t \]+struct baz_t;" \ + "27:\[\t \]+typedef struct baz_t baz_t;" \ "\[\t \]+double" \ "33:\[\t \]+enum enum_t;" \ "\[\t \]+float" \ diff --git a/gdb/testsuite/gdb.base/info-var-f1.c b/gdb/testsuite/gdb.base/info-var-f1.c index 1e38bda..a4c18aa 100644 --- a/gdb/testsuite/gdb.base/info-var-f1.c +++ b/gdb/testsuite/gdb.base/info-var-f1.c @@ -1,4 +1,4 @@ -/* Copyright 2019-2024 Free Software Foundation, Inc. +/* Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/info-var-f2.c b/gdb/testsuite/gdb.base/info-var-f2.c index 5744571..75b4393 100644 --- a/gdb/testsuite/gdb.base/info-var-f2.c +++ b/gdb/testsuite/gdb.base/info-var-f2.c @@ -1,4 +1,4 @@ -/* Copyright 2019-2024 Free Software Foundation, Inc. +/* Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/info-var.exp b/gdb/testsuite/gdb.base/info-var.exp index 4a8a59d..7c2d0f7 100644 --- a/gdb/testsuite/gdb.base/info-var.exp +++ b/gdb/testsuite/gdb.base/info-var.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/info-var.h b/gdb/testsuite/gdb.base/info-var.h index 307568d..89e5fae 100644 --- a/gdb/testsuite/gdb.base/info-var.h +++ b/gdb/testsuite/gdb.base/info-var.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2024 Free Software Foundation, Inc. +/* Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/info_minsym.c b/gdb/testsuite/gdb.base/info_minsym.c index 859f5dc..e380c5a 100644 --- a/gdb/testsuite/gdb.base/info_minsym.c +++ b/gdb/testsuite/gdb.base/info_minsym.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/info_minsym.exp b/gdb/testsuite/gdb.base/info_minsym.exp index 9b0fcdf..33413ed 100644 --- a/gdb/testsuite/gdb.base/info_minsym.exp +++ b/gdb/testsuite/gdb.base/info_minsym.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2018-2024 Free Software Foundation, Inc. +# Copyright (C) 2018-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 diff --git a/gdb/testsuite/gdb.base/info_qt.c b/gdb/testsuite/gdb.base/info_qt.c index 5ec4b51..47c707c 100644 --- a/gdb/testsuite/gdb.base/info_qt.c +++ b/gdb/testsuite/gdb.base/info_qt.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/info_qt.exp b/gdb/testsuite/gdb.base/info_qt.exp index f53a620..0cf5386 100644 --- a/gdb/testsuite/gdb.base/info_qt.exp +++ b/gdb/testsuite/gdb.base/info_qt.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/info_sources.c b/gdb/testsuite/gdb.base/info_sources.c index baedf66..fb5a1cc 100644 --- a/gdb/testsuite/gdb.base/info_sources.c +++ b/gdb/testsuite/gdb.base/info_sources.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/info_sources.exp b/gdb/testsuite/gdb.base/info_sources.exp index 6ef711f..3340c83 100644 --- a/gdb/testsuite/gdb.base/info_sources.exp +++ b/gdb/testsuite/gdb.base/info_sources.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -68,7 +68,7 @@ proc test_info_sources {args expect_seen_info_sources \ } } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/info_sources_2-header.h b/gdb/testsuite/gdb.base/info_sources_2-header.h index cbf127b..cc81eb7 100644 --- a/gdb/testsuite/gdb.base/info_sources_2-header.h +++ b/gdb/testsuite/gdb.base/info_sources_2-header.h @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/info_sources_2-lib.c b/gdb/testsuite/gdb.base/info_sources_2-lib.c index 832e84e..6befc8d 100644 --- a/gdb/testsuite/gdb.base/info_sources_2-lib.c +++ b/gdb/testsuite/gdb.base/info_sources_2-lib.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/info_sources_2-test.c b/gdb/testsuite/gdb.base/info_sources_2-test.c index 4d34235..8328ae9 100644 --- a/gdb/testsuite/gdb.base/info_sources_2-test.c +++ b/gdb/testsuite/gdb.base/info_sources_2-test.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/info_sources_2.exp b/gdb/testsuite/gdb.base/info_sources_2.exp index 90442d0..8625e44 100644 --- a/gdb/testsuite/gdb.base/info_sources_2.exp +++ b/gdb/testsuite/gdb.base/info_sources_2.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 @@ -23,23 +23,19 @@ set is_remote_target [is_remote target] standard_testfile -test.c -lib.c set solib_name [standard_output_file ${testfile}-lib.so] -if { [gdb_compile_shlib ${srcdir}/${subdir}/${srcfile2} ${solib_name} \ - {debug}] != "" } { - untested "failed to compile shared library" - return -1 -} -if {[gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable \ - [list debug shlib=${solib_name} ]] != ""} { - untested "failed to compile executable" - return -1 +if { [build_executable "build shlib" $solib_name $srcfile2 {debug shlib}] != 0 } { + return } -clean_restart ${binfile} +if { [prepare_for_testing "prepare" $testfile $srcfile \ + [list debug shlib=${solib_name} ]] != 0} { + return +} set solib_name [gdb_load_shlib $solib_name] -if ![runto foo] { +if {![runto foo]} { untested "failed to run to function foo" return -1 } @@ -72,13 +68,18 @@ proc run_info_sources { extra_args args } { set objfile_name "" set source_files {} set files {} + # Note below we sanitize paths so we can compare against the + # host_file_normalize'd paths later. Note we sanitize, but + # don't normalize here, as the latter would turn a relative + # path into an absolute path, and this testcase wants to make + # sure that GDB prints the absolute path. gdb_test_multiple $cmd "" { -re "${command_regex}\r\n" { exp_continue } -re "^(\[^\r\n\]+):\r\n" { - set objfile_name $expect_out(1,string) + set objfile_name [host_file_sanitize $expect_out(1,string)] if { $is_remote_target } { set objfile_name [file tail $objfile_name] } @@ -101,7 +102,7 @@ proc run_info_sources { extra_args args } { } -re "^(\[^,\r\n\]+), " { - set f $expect_out(1,string) + set f [host_file_sanitize $expect_out(1,string)] lappend files $f exp_continue } @@ -111,7 +112,7 @@ proc run_info_sources { extra_args args } { return } - set f $expect_out(1,string) + set f [host_file_sanitize $expect_out(1,string)] lappend files $f set info_sources($objfile_name) $files set $objfile_name "" @@ -133,7 +134,7 @@ proc run_info_sources { extra_args args } { } # Figure out the path for SOURCEFILE that we're looking for. - set sourcepath [file normalize ${srcdir}/${subdir}/${sourcefile}] + set sourcepath [host_file_normalize ${srcdir}/${subdir}/${sourcefile}] if { $is_remote_target } { set objfile [file tail $objfile] @@ -142,7 +143,7 @@ proc run_info_sources { extra_args args } { # Make sure we handle the case where there are no source files # associated with a particular objfile. set source_list {} - if [info exists info_sources($objfile)] { + if {[info exists info_sources($objfile)]} { set source_list $info_sources($objfile) } @@ -156,32 +157,34 @@ proc run_info_sources { extra_args args } { # The actual tests. +set host_binfile [host_file_normalize $binfile$EXEEXT] + run_info_sources "" \ - ${binfile} ${srcfile} \ - ${binfile} ${testfile}-header.h \ + ${host_binfile} ${srcfile} \ + ${host_binfile} ${testfile}-header.h \ ${solib_name} ${srcfile2} \ ${solib_name} ${testfile}-header.h run_info_sources "-basename info_sources_2" \ - ${binfile} ${srcfile} \ - ${binfile} ${testfile}-header.h \ + ${host_binfile} ${srcfile} \ + ${host_binfile} ${testfile}-header.h \ ${solib_name} ${srcfile2} \ ${solib_name} ${testfile}-header.h run_info_sources "-basename \\.c" \ - ${binfile} ${srcfile} \ - ${binfile} !${testfile}-header.h \ + ${host_binfile} ${srcfile} \ + ${host_binfile} !${testfile}-header.h \ ${solib_name} ${srcfile2} \ ${solib_name} !${testfile}-header.h run_info_sources "-basename -- -test\\.c" \ - ${binfile} ${srcfile} \ - ${binfile} !${testfile}-header.h \ + ${host_binfile} ${srcfile} \ + ${host_binfile} !${testfile}-header.h \ ${solib_name} !${srcfile2} \ ${solib_name} !${testfile}-header.h run_info_sources "-basename -- -lib\\.c" \ - ${binfile} !${srcfile} \ - ${binfile} !${testfile}-header.h \ + ${host_binfile} !${srcfile} \ + ${host_binfile} !${testfile}-header.h \ ${solib_name} ${srcfile2} \ ${solib_name} !${testfile}-header.h diff --git a/gdb/testsuite/gdb.base/info_sources_base.c b/gdb/testsuite/gdb.base/info_sources_base.c index 3afe60c..fa955b9 100644 --- a/gdb/testsuite/gdb.base/info_sources_base.c +++ b/gdb/testsuite/gdb.base/info_sources_base.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 @@ -19,4 +19,3 @@ void some_other_func (void) { return; } - diff --git a/gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.c b/gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.c index 3615b56..f04d0eb 100644 --- a/gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.c +++ b/gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.exp b/gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.exp index e12244f..90300c8 100644 --- a/gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.exp +++ b/gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -51,6 +51,6 @@ gdb_test "add-symbol-file $binfile 0xffff0000" \ "add symbol table from file \".*\" at.*\\(y or n\\) " "y" # Check if we are able to read offset adjusted line information of main - + gdb_test "info line main" \ "Line.*starts at address 0xffff0000.*and ends at.*" diff --git a/gdb/testsuite/gdb.base/infoline.c b/gdb/testsuite/gdb.base/infoline.c index c0840fe..fb37f66 100644 --- a/gdb/testsuite/gdb.base/infoline.c +++ b/gdb/testsuite/gdb.base/infoline.c @@ -1,4 +1,4 @@ -/* Copyright 2011-2024 Free Software Foundation, Inc. +/* Copyright 2011-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/infoline.exp b/gdb/testsuite/gdb.base/infoline.exp index 67aa6e3..fb19feb 100644 --- a/gdb/testsuite/gdb.base/infoline.exp +++ b/gdb/testsuite/gdb.base/infoline.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2024 Free Software Foundation, Inc. +# Copyright (C) 2011-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 @@ -24,4 +24,4 @@ if { [prepare_for_testing "failed to prepare" ${testfile}] } { # at <twice+N> where N is different from zero. set fun_decl_line [gdb_get_line_number "THIS LINE"] gdb_test "info line ${srcfile}:${fun_decl_line}" \ - "Line ${fun_decl_line} of \".*${testfile}\.c\" starts at address 0x\[0-9a-f\]+ <twice> and ends at .*" + "Line ${fun_decl_line} of \".*${testfile}\.c\" starts at address 0x\[0-9a-f\]+ <twice> and ends at .*" diff --git a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.c b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.c index c912663..d8326ef 100644 --- a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.c +++ b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp index 45086f6..7fc47af 100644 --- a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp +++ b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2021-2024 Free Software Foundation, Inc. +# Copyright (C) 2021-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 @@ -72,77 +72,89 @@ gdb_continue_to_breakpoint "stop at test breakpoint" gdb_test_no_output "source ${pyfile}"\ "import python scripts" -# Check the unbroken stack. -gdb_test_sequence "bt" "backtrace when the unwind is left unbroken" { - "\\r\\n#0 \[^\r\n\]* inline_func \\(\\) at " - "\\r\\n#1 \[^\r\n\]* normal_func \\(\\) at " - "\\r\\n#2 \[^\r\n\]* inline_func \\(\\) at " - "\\r\\n#3 \[^\r\n\]* normal_func \\(\\) at " - "\\r\\n#4 \[^\r\n\]* inline_func \\(\\) at " - "\\r\\n#5 \[^\r\n\]* normal_func \\(\\) at " - "\\r\\n#6 \[^\r\n\]* main \\(\\) at " -} +# Test with and without filters. +foreach bt_cmd { "bt" "bt -no-filters" } { + with_test_prefix "$bt_cmd" { -with_test_prefix "cycle at level 5" { - # Arrange to introduce a stack cycle at frame 5. - gdb_test_no_output "python stop_at_level=5" - gdb_test "maint flush register-cache" \ - "Register cache flushed\\." - gdb_test_lines "bt" "backtrace when the unwind is broken at frame 5" \ - [multi_line \ - "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \ - "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \ - "#2 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \ - "#3 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \ - "#4 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \ - "#5 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \ - "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"] -} + # Check the unbroken stack. + gdb_test_sequence "$bt_cmd" "backtrace when the unwind is left unbroken" { + "\\r\\n#0 \[^\r\n\]* inline_func \\(\\) at " + "\\r\\n#1 \[^\r\n\]* normal_func \\(\\) at " + "\\r\\n#2 \[^\r\n\]* inline_func \\(\\) at " + "\\r\\n#3 \[^\r\n\]* normal_func \\(\\) at " + "\\r\\n#4 \[^\r\n\]* inline_func \\(\\) at " + "\\r\\n#5 \[^\r\n\]* normal_func \\(\\) at " + "\\r\\n#6 \[^\r\n\]* main \\(\\) at " + } -with_test_prefix "cycle at level 3" { - # Arrange to introduce a stack cycle at frame 3. - gdb_test_no_output "python stop_at_level=3" - gdb_test "maint flush register-cache" \ - "Register cache flushed\\." - gdb_test_lines "bt" "backtrace when the unwind is broken at frame 3" \ - [multi_line \ - "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \ - "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \ - "#2 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \ - "#3 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \ - "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"] -} + with_test_prefix "cycle at level 5" { + # Arrange to introduce a stack cycle at frame 5. + gdb_test_no_output "python stop_at_level=5" + gdb_test "maint flush register-cache" \ + "Register cache flushed\\." + gdb_test_lines "$bt_cmd" "backtrace when the unwind is broken at frame 5" \ + [multi_line \ + "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \ + "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \ + "#2 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \ + "#3 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \ + "#4 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \ + "#5 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \ + "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"] + } -with_test_prefix "cycle at level 1" { - # Arrange to introduce a stack cycle at frame 1. - gdb_test_no_output "python stop_at_level=1" - gdb_test "maint flush register-cache" \ - "Register cache flushed\\." - gdb_test_lines "bt" "backtrace when the unwind is broken at frame 1" \ - [multi_line \ - "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \ - "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \ - "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"] -} + with_test_prefix "cycle at level 3" { + # Arrange to introduce a stack cycle at frame 3. + gdb_test_no_output "python stop_at_level=3" + gdb_test "maint flush register-cache" \ + "Register cache flushed\\." + gdb_test_lines "$bt_cmd" "backtrace when the unwind is broken at frame 3" \ + [multi_line \ + "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \ + "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \ + "#2 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \ + "#3 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \ + "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"] + } -# Flush the register cache (which also flushes the frame cache) so we -# get a full backtrace again, then switch on frame debugging and try -# to back trace. At one point this triggered an assertion. -gdb_test "maint flush register-cache" \ - "Register cache flushed\\." "" -gdb_test_no_output "set debug frame 1" -set ok 1 -gdb_test_multiple "bt" "backtrace with debugging on" { - -re "^$gdb_prompt $" { - gdb_assert { $ok } $gdb_test_name - } - -re "Python Exception <class 'gdb.error'>: \[^\r\n\]*\r\n" { - set ok 0 - exp_continue - } - -re "\[^\r\n\]+\r\n" { - exp_continue + with_test_prefix "cycle at level 1" { + # Arrange to introduce a stack cycle at frame 1. + gdb_test_no_output "python stop_at_level=1" + gdb_test "maint flush register-cache" \ + "Register cache flushed\\." + gdb_test_lines "$bt_cmd" "backtrace when the unwind is broken at frame 1" \ + [multi_line \ + "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \ + "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \ + "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"] + } + + # Flush the register cache (which also flushes the frame cache) so we + # get a full backtrace again, then switch on frame debugging and try + # to back trace. At one point this triggered an assertion. + gdb_test "maint flush register-cache" \ + "Register cache flushed\\." "" + gdb_test_no_output "set debug frame 1" + set ok 1 + gdb_test_multiple "$bt_cmd" "backtrace with debugging on" { + -re "^$gdb_prompt $" { + gdb_assert { $ok } $gdb_test_name + } + -re "Python Exception <class 'gdb.error'>: \[^\r\n\]*\r\n" { + set ok 0 + exp_continue + } + -re "\[^\r\n\]+\r\n" { + exp_continue + } + } + gdb_test "p 1 + 2 + 3" " = 6" \ + "ensure GDB is still alive" + + # Prepare for the next iteration of the test loop + gdb_test_no_output "set debug frame 0" + gdb_test_no_output "python stop_at_level=None" + gdb_test "maint flush register-cache" \ + "Register cache flushed\\." "maint flush register-cache at (loop end)" } } -gdb_test "p 1 + 2 + 3" " = 6" \ - "ensure GDB is still alive" diff --git a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py index 278fa85..55dea98 100644 --- a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py +++ b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py @@ -1,4 +1,4 @@ -# Copyright (C) 2021-2024 Free Software Foundation, Inc. +# Copyright (C) 2021-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 @@ -46,16 +46,13 @@ class TestUnwinder(Unwinder): Unwinder.__init__(self, "stop at level") def __call__(self, pending_frame): - global stop_at_level - global stack_adjust - if stop_at_level is None or pending_frame.level() != stop_at_level: return None if stack_adjust is None: raise gdb.GdbError("invalid stack_adjust") - if not stop_at_level in [1, 3, 5]: + if stop_at_level not in [1, 3, 5]: raise gdb.GdbError("invalid stop_at_level") sp_desc = pending_frame.architecture().registers().find("sp") @@ -65,6 +62,10 @@ class TestUnwinder(Unwinder): for reg in pending_frame.architecture().registers("general"): val = pending_frame.read_register(reg) + # Having unavailable registers leads to a fall back to the standard + # unwinders. Don't add unavailable registers to avoid this. + if str(val) == "<unavailable>": + continue unwinder.add_saved_register(reg, val) return unwinder diff --git a/gdb/testsuite/gdb.base/int-type.c b/gdb/testsuite/gdb.base/int-type.c index da7eec0..ccf32d7 100644 --- a/gdb/testsuite/gdb.base/int-type.c +++ b/gdb/testsuite/gdb.base/int-type.c @@ -8,13 +8,12 @@ int w; int main () { - + x = 14; y = 3; z = 2; w = 2; return 0; - -} +} diff --git a/gdb/testsuite/gdb.base/interact.exp b/gdb/testsuite/gdb.base/interact.exp index 5779efc..748e535 100644 --- a/gdb/testsuite/gdb.base/interact.exp +++ b/gdb/testsuite/gdb.base/interact.exp @@ -1,4 +1,4 @@ -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 @@ -34,10 +34,10 @@ gdb_start # change of the interactive-mode setting. gdb_test_no_output "set interactive-mode auto" gdb_test "source $script" "$script_output" \ - "source script with interactive-mode auto" + "source script with interactive-mode auto" gdb_test "print 3" "= 3" "sanity check with interactive-mode auto" gdb_test "show interactive-mode" \ - "Debugger's interactive mode is auto \\(currently .*\\)\\." \ + "Debugger's interactive mode is auto \\(currently .*\\)\\." \ "show interactive-mode, auto" # Test sourcing of the script with interactive mode `on'. @@ -45,10 +45,10 @@ gdb_test "show interactive-mode" \ # change of the interactive-mode setting. gdb_test_no_output "set interactive-mode on" gdb_test "source $script" "$script_output" \ - "source script with interactive-mode on" + "source script with interactive-mode on" gdb_test "print 4" "= 4" "sanity check with interactive-mode on" gdb_test "show interactive-mode" \ - "Debugger's interactive mode is on\\." \ + "Debugger's interactive mode is on\\." \ "show interactive-mode, on" # Test sourcing of the script with interactive mode `off'. @@ -56,9 +56,8 @@ gdb_test "show interactive-mode" \ # change of the interactive-mode setting. gdb_test_no_output "set interactive-mode off" gdb_test "source $script" "$script_output" \ - "source script with interactive-mode off" + "source script with interactive-mode off" gdb_test "print 5" "= 5" "sanity check with interactive-mode off" gdb_test "show interactive-mode" \ - "Debugger's interactive mode is off\\." \ + "Debugger's interactive mode is off\\." \ "show interactive-mode, off" - diff --git a/gdb/testsuite/gdb.base/internal-functions-ptype.exp b/gdb/testsuite/gdb.base/internal-functions-ptype.exp index 9c77868..7bf03d8 100644 --- a/gdb/testsuite/gdb.base/internal-functions-ptype.exp +++ b/gdb/testsuite/gdb.base/internal-functions-ptype.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/internal-string-values.c b/gdb/testsuite/gdb.base/internal-string-values.c index 2046b56..d4e358e 100644 --- a/gdb/testsuite/gdb.base/internal-string-values.c +++ b/gdb/testsuite/gdb.base/internal-string-values.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/internal-string-values.exp b/gdb/testsuite/gdb.base/internal-string-values.exp index 9ecb59e..ae362a2 100644 --- a/gdb/testsuite/gdb.base/internal-string-values.exp +++ b/gdb/testsuite/gdb.base/internal-string-values.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 @@ -250,7 +250,7 @@ proc_with_prefix test_internal_var { } { return } - clean_restart $::binfile + clean_restart $::testfile if {![runto_main]} { fail "could not run to main" diff --git a/gdb/testsuite/gdb.base/interp.c b/gdb/testsuite/gdb.base/interp.c index 8526473..3c41234 100644 --- a/gdb/testsuite/gdb.base/interp.c +++ b/gdb/testsuite/gdb.base/interp.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/interp.exp b/gdb/testsuite/gdb.base/interp.exp index 5e3488e..e6cfe77 100644 --- a/gdb/testsuite/gdb.base/interp.exp +++ b/gdb/testsuite/gdb.base/interp.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/interpreter-exec.gdb b/gdb/testsuite/gdb.base/interpreter-exec.gdb index 24d4bbe..5e26b6d 100644 --- a/gdb/testsuite/gdb.base/interpreter-exec.gdb +++ b/gdb/testsuite/gdb.base/interpreter-exec.gdb @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/interrupt-a.c b/gdb/testsuite/gdb.base/interrupt-a.c index 9b647e3..09cc014 100644 --- a/gdb/testsuite/gdb.base/interrupt-a.c +++ b/gdb/testsuite/gdb.base/interrupt-a.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/interrupt-a.exp b/gdb/testsuite/gdb.base/interrupt-a.exp index eabfb2b..87c856b 100644 --- a/gdb/testsuite/gdb.base/interrupt-a.exp +++ b/gdb/testsuite/gdb.base/interrupt-a.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2022-2024 Free Software Foundation, Inc. +# Copyright (C) 2022-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 diff --git a/gdb/testsuite/gdb.base/interrupt-daemon-attach.c b/gdb/testsuite/gdb.base/interrupt-daemon-attach.c index beb4089..dca6c9b 100644 --- a/gdb/testsuite/gdb.base/interrupt-daemon-attach.c +++ b/gdb/testsuite/gdb.base/interrupt-daemon-attach.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/interrupt-daemon-attach.exp b/gdb/testsuite/gdb.base/interrupt-daemon-attach.exp index ae81b0f..88b3cb9 100644 --- a/gdb/testsuite/gdb.base/interrupt-daemon-attach.exp +++ b/gdb/testsuite/gdb.base/interrupt-daemon-attach.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -36,7 +36,7 @@ proc do_test {} { # Attach to the parent, run it to a known point, extract the # child's PID, and detach. with_test_prefix "parent" { - clean_restart ${binfile} + clean_restart $::testfile gdb_test "attach $parent_pid" \ "Attaching to program.*, process $parent_pid.*" \ @@ -60,7 +60,7 @@ proc do_test {} { with_test_prefix "child" { global gdb_prompt - clean_restart $binfile + clean_restart $::testfile gdb_test "attach $child_pid" \ "Attaching to program.*, process $child_pid.*" \ diff --git a/gdb/testsuite/gdb.base/interrupt-daemon.c b/gdb/testsuite/gdb.base/interrupt-daemon.c index f397f9f..4c20c34 100644 --- a/gdb/testsuite/gdb.base/interrupt-daemon.c +++ b/gdb/testsuite/gdb.base/interrupt-daemon.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/interrupt-daemon.exp b/gdb/testsuite/gdb.base/interrupt-daemon.exp index 8327294..6de869c 100644 --- a/gdb/testsuite/gdb.base/interrupt-daemon.exp +++ b/gdb/testsuite/gdb.base/interrupt-daemon.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -16,6 +16,8 @@ # Make sure that we can interrupt an inferior that forks and moves to # its own session. +require allow_fork_tests + standard_testfile if {[build_executable "failed to build" $testfile $srcfile {debug}]} { @@ -25,14 +27,13 @@ if {[build_executable "failed to build" $testfile $srcfile {debug}]} { # The test proper. proc do_test {} { - global binfile global gdb_prompt - clean_restart $binfile + clean_restart $::testfile gdb_test "set follow-fork-mode child" ".*" - if ![runto "daemon_main"] { + if {![runto "daemon_main"]} { return } diff --git a/gdb/testsuite/gdb.base/interrupt-noterm.c b/gdb/testsuite/gdb.base/interrupt-noterm.c index c247c01..5d6f97e 100644 --- a/gdb/testsuite/gdb.base/interrupt-noterm.c +++ b/gdb/testsuite/gdb.base/interrupt-noterm.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2013-2024 Free Software Foundation, Inc. + Copyright (C) 2013-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 diff --git a/gdb/testsuite/gdb.base/interrupt-noterm.exp b/gdb/testsuite/gdb.base/interrupt-noterm.exp index 399b4f6..c09a84c 100644 --- a/gdb/testsuite/gdb.base/interrupt-noterm.exp +++ b/gdb/testsuite/gdb.base/interrupt-noterm.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2024 Free Software Foundation, Inc. +# Copyright (C) 2013-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 @@ -15,15 +15,15 @@ standard_testfile -if [prepare_for_testing "failed to prepare for testing" \ - ${testfile} ${srcfile} {debug}] { +if {[prepare_for_testing "failed to prepare for testing" \ + ${testfile} ${srcfile} {debug}]} { return -1 } # Pretend there's no terminal. gdb_test_no_output "set interactive-mode off" -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/interrupt.exp b/gdb/testsuite/gdb.base/interrupt.exp index 417cf21..dd790fd 100644 --- a/gdb/testsuite/gdb.base/interrupt.exp +++ b/gdb/testsuite/gdb.base/interrupt.exp @@ -1,4 +1,4 @@ -# Copyright 1994-2024 Free Software Foundation, Inc. +# Copyright 1994-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 @@ -154,7 +154,7 @@ if {![file exists $binfile]} { } } - if { ! [target_info exists gdb,nosignals] } { + if { ! [target_info exists gdb,nosignals] } { # Wait until the program is in the read system call again. sleep 2 diff --git a/gdb/testsuite/gdb.base/jit-attach-pie.c b/gdb/testsuite/gdb.base/jit-attach-pie.c index 27c6b32..7e9f1c4 100644 --- a/gdb/testsuite/gdb.base/jit-attach-pie.c +++ b/gdb/testsuite/gdb.base/jit-attach-pie.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/jit-attach-pie.exp b/gdb/testsuite/gdb.base/jit-attach-pie.exp index d2dda69..ff71e86 100644 --- a/gdb/testsuite/gdb.base/jit-attach-pie.exp +++ b/gdb/testsuite/gdb.base/jit-attach-pie.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2024 Free Software Foundation, Inc. +# Copyright (C) 2016-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 diff --git a/gdb/testsuite/gdb.base/jit-bfd-name.exp b/gdb/testsuite/gdb.base/jit-bfd-name.exp index 36c82a1..723922c 100644 --- a/gdb/testsuite/gdb.base/jit-bfd-name.exp +++ b/gdb/testsuite/gdb.base/jit-bfd-name.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -46,18 +46,19 @@ if { [compile_jit_main ${main_srcfile} ${main_binfile} {}] != 0 } { return } -clean_restart $::main_binfile +clean_restart +gdb_load $::main_binfile if { ![runto_main] } { return } # Poke desired values directly into inferior instead of using "set # args" because "set args" does not work under gdbserver. -set count [expr [llength $jit_solibs_target] + 1] +set count [expr {[llength $jit_solibs_target] + 1}] gdb_test_no_output "set var argc=$count" "forging argc" gdb_test_no_output "set var argv=fake_argv" "forging argv" for {set i 1} {$i < $count} {incr i} { - set jit_solib_target [lindex $jit_solibs_target [expr $i-1]] + set jit_solib_target [lindex $jit_solibs_target [expr {$i-1}]] gdb_test_no_output "set var argv\[$i\]=\"${jit_solib_target}\"" \ "forging argv\[$i\]" } @@ -67,11 +68,13 @@ gdb_breakpoint [gdb_get_line_number "break here 1" $::main_srcfile] gdb_continue_to_breakpoint "break here 1" # Confirm that the two expected functions are available. +set re_f1 [string_to_regexp "int jit_function_0001(void)"] +set re_f2 [string_to_regexp "int jit_function_0002(void)"] gdb_test "info function ^jit_function" \ [multi_line \ "File \[^\r\n\]+jit-elf-solib.c:" \ - "${decimal}:\\s+int jit_function_0001\\(\\);" \ - "${decimal}:\\s+int jit_function_0002\\(\\);"] + "${decimal}:\\s+$re_f1;" \ + "${decimal}:\\s+$re_f2;"] # Capture the addresses of each JIT symfile. set symfile_addrs {} @@ -121,7 +124,7 @@ set count 0 foreach addr $symfile_addrs len $symfile_lengths { incr count set output [standard_output_file "dump-elf-solib.${count}.so"] - set end [expr $addr + $len] + set end [expr {$addr + $len}] gdb_test_no_output "dump binary memory $output $addr $end" \ "dump jit solib $count" @@ -138,7 +141,7 @@ foreach addr $symfile_addrs len $symfile_lengths { set start [format 0x%x $addr] # Calculate the end address. - set end [format 0x%x [expr $addr + $len]] + set end [format 0x%x [expr {$addr + $len}]] # This is what we expect the address range to look like in the BFD # filename. diff --git a/gdb/testsuite/gdb.base/jit-elf-fork-main.c b/gdb/testsuite/gdb.base/jit-elf-fork-main.c index fd0173d..dea21c9 100644 --- a/gdb/testsuite/gdb.base/jit-elf-fork-main.c +++ b/gdb/testsuite/gdb.base/jit-elf-fork-main.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/jit-elf-fork-solib.c b/gdb/testsuite/gdb.base/jit-elf-fork-solib.c index f98d1d1..690d7a0 100644 --- a/gdb/testsuite/gdb.base/jit-elf-fork-solib.c +++ b/gdb/testsuite/gdb.base/jit-elf-fork-solib.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/jit-elf-fork.exp b/gdb/testsuite/gdb.base/jit-elf-fork.exp index 3fccf17..92e7dc6 100644 --- a/gdb/testsuite/gdb.base/jit-elf-fork.exp +++ b/gdb/testsuite/gdb.base/jit-elf-fork.exp @@ -1,4 +1,4 @@ -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 @@ -15,6 +15,7 @@ # Test fork handling of an inferior that has JIT-ed objfiles. +require allow_fork_tests require allow_shlib_tests load_lib jit-elf-helpers.exp @@ -53,7 +54,8 @@ if { [compile_jit_main ${main_srcfile} ${main_binfile} {}] != 0 } { # that the callers can continue execution until there. proc do_setup { detach-on-fork follow-fork-mode } { - clean_restart ${::main_binfile} + clean_restart + gdb_load $::main_binfile gdb_test_no_output "set detach-on-fork ${detach-on-fork}" gdb_test_no_output "set follow-fork-mode ${follow-fork-mode}" diff --git a/gdb/testsuite/gdb.base/jit-elf-main.c b/gdb/testsuite/gdb.base/jit-elf-main.c index 7e51705..562df7a 100644 --- a/gdb/testsuite/gdb.base/jit-elf-main.c +++ b/gdb/testsuite/gdb.base/jit-elf-main.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/jit-elf-so.exp b/gdb/testsuite/gdb.base/jit-elf-so.exp index 2759c64..a709c0c 100644 --- a/gdb/testsuite/gdb.base/jit-elf-so.exp +++ b/gdb/testsuite/gdb.base/jit-elf-so.exp @@ -1,4 +1,4 @@ -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 @@ -73,7 +73,8 @@ proc one_jit_test {solib_binfiles_target match_str} { global main_loader_binfile main_loader_srcfile global main_solib_binfile main_solib_binfile_target main_solib_srcfile - clean_restart $main_loader_binfile + clean_restart + gdb_load $main_loader_binfile gdb_locate_shlib $main_solib_binfile # This is just to help debugging when things fail @@ -101,10 +102,10 @@ proc one_jit_test {solib_binfiles_target match_str} { # Poke desired values directly into inferior instead of using "set args" # because "set args" does not work under gdbserver. - gdb_test_no_output "set var argc=[expr $count + 1]" "forging argc" + gdb_test_no_output "set var argc=[expr {$count + 1}]" "forging argc" gdb_test_no_output "set var argv=fake_argv" "forging argv" for {set i 1} {$i <= $count} {incr i} { - set binfile_target [lindex $solib_binfiles_target [expr $i-1]] + set binfile_target [lindex $solib_binfiles_target [expr {$i-1}]] gdb_test_no_output "set var argv\[$i\]=\"${binfile_target}\"" \ "forging argv\[$i\]" } diff --git a/gdb/testsuite/gdb.base/jit-elf-solib.c b/gdb/testsuite/gdb.base/jit-elf-solib.c index f98d1d1..c6fcb89 100644 --- a/gdb/testsuite/gdb.base/jit-elf-solib.c +++ b/gdb/testsuite/gdb.base/jit-elf-solib.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 @@ -22,4 +22,4 @@ #error "Must define the FUNCTION_NAME macro to set a jited function name" #endif -int FUNCTION_NAME() { return 42; } +int FUNCTION_NAME(void) { return 42; } diff --git a/gdb/testsuite/gdb.base/jit-elf-util.h b/gdb/testsuite/gdb.base/jit-elf-util.h index 13cebeb..8bede15 100644 --- a/gdb/testsuite/gdb.base/jit-elf-util.h +++ b/gdb/testsuite/gdb.base/jit-elf-util.h @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 @@ -70,7 +70,7 @@ load_symbol (void *addr, const char *sym_name) { const char *s = strtab + p->st_name; if (strcmp (s, sym_name) == 0) - return (void *) p->st_value; + return (void *) p->st_value; } } } @@ -101,7 +101,7 @@ load_elf (const char *libname, size_t *size, void *load_addr) } void *addr = mmap (load_addr, st.st_size, - PROT_READ | PROT_WRITE | PROT_EXEC, + PROT_READ | PROT_WRITE | PROT_EXEC, load_addr != NULL ? MAP_PRIVATE | MAP_FIXED : MAP_PRIVATE, fd, 0); close (fd); diff --git a/gdb/testsuite/gdb.base/jit-elf.exp b/gdb/testsuite/gdb.base/jit-elf.exp index 85874fc..2ce9c77 100644 --- a/gdb/testsuite/gdb.base/jit-elf.exp +++ b/gdb/testsuite/gdb.base/jit-elf.exp @@ -1,4 +1,4 @@ -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 @@ -48,7 +48,8 @@ proc clean_reattach {} { gdb_test_no_output "set var wait_for_gdb = 1" gdb_test "detach" "Detaching from .*" - clean_restart ${main_binfile} + clean_restart + gdb_load $main_binfile if { ![gdb_attach $testpid \ -pattern "main.*at .*$::main_basename.c:.*"] } { @@ -84,7 +85,8 @@ proc one_jit_test {jit_solibs_target match_str reattach} { global test_verbose global main_binfile main_srcfile - clean_restart ${main_binfile} + clean_restart + gdb_load $main_binfile # This is just to help debugging when things fail if {$test_verbose > 0} { @@ -101,7 +103,7 @@ proc one_jit_test {jit_solibs_target match_str reattach} { gdb_test_no_output "set var argc=$count" "forging argc" gdb_test_no_output "set var argv=fake_argv" "forging argv" for {set i 1} {$i < $count} {incr i} { - set jit_solib_target [lindex $jit_solibs_target [expr $i-1]] + set jit_solib_target [lindex $jit_solibs_target [expr {$i-1}]] gdb_test_no_output "set var argv\[$i\]=\"${jit_solib_target}\"" \ "forging argv\[$i\]" } diff --git a/gdb/testsuite/gdb.base/jit-protocol.h b/gdb/testsuite/gdb.base/jit-protocol.h index 3e85c19..99bb72c 100644 --- a/gdb/testsuite/gdb.base/jit-protocol.h +++ b/gdb/testsuite/gdb.base/jit-protocol.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2024 Free Software Foundation, Inc. +/* Copyright (C) 2009-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -17,8 +17,8 @@ #ifdef JIT_H #error "We don't include jit.h directly since we'd like the jit-reader unit \ - tests to break if we make ABI incompatible changes to the structures \ - re-declared here." + tests to break if we make ABI incompatible changes to the structures \ + re-declared here." #endif #ifndef JIT_PROTOCOL_H diff --git a/gdb/testsuite/gdb.base/jit-reader-exec.c b/gdb/testsuite/gdb.base/jit-reader-exec.c index 966ba13..a7ac4be 100644 --- a/gdb/testsuite/gdb.base/jit-reader-exec.c +++ b/gdb/testsuite/gdb.base/jit-reader-exec.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/jit-reader-exec.exp b/gdb/testsuite/gdb.base/jit-reader-exec.exp index 06e2c90..adee450 100644 --- a/gdb/testsuite/gdb.base/jit-reader-exec.exp +++ b/gdb/testsuite/gdb.base/jit-reader-exec.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -25,10 +25,8 @@ set testfile2 "jit-reader-execd" set srcfile2 ${testfile2}.c set binfile2 [standard_output_file ${testfile2}] -if {[gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" \ - executable {debug}] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build exec'd file" $testfile2 $srcfile2] != 0 } { + return } if { [is_remote target] } { @@ -37,14 +35,10 @@ if { [is_remote target] } { set compile_options [list debug additional_flags=-DPROGRAM=\"$binfile2\"] -if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ - executable $compile_options] != ""} { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile $compile_options] != 0 } { + return } -clean_restart $binfile - if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/jit-reader-execd.c b/gdb/testsuite/gdb.base/jit-reader-execd.c index 9eccc49..34ff03a 100644 --- a/gdb/testsuite/gdb.base/jit-reader-execd.c +++ b/gdb/testsuite/gdb.base/jit-reader-execd.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/jit-reader-host.c b/gdb/testsuite/gdb.base/jit-reader-host.c index 359935a..a106dad 100644 --- a/gdb/testsuite/gdb.base/jit-reader-host.c +++ b/gdb/testsuite/gdb.base/jit-reader-host.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2024 Free Software Foundation, Inc. +/* Copyright (C) 2009-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/jit-reader-host.h b/gdb/testsuite/gdb.base/jit-reader-host.h index da15ade..62750d5 100644 --- a/gdb/testsuite/gdb.base/jit-reader-host.h +++ b/gdb/testsuite/gdb.base/jit-reader-host.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2024 Free Software Foundation, Inc. +/* Copyright (C) 2009-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/jit-reader-simple-dl.c b/gdb/testsuite/gdb.base/jit-reader-simple-dl.c index df92291..b5e2a2a 100644 --- a/gdb/testsuite/gdb.base/jit-reader-simple-dl.c +++ b/gdb/testsuite/gdb.base/jit-reader-simple-dl.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/jit-reader-simple-jit.c b/gdb/testsuite/gdb.base/jit-reader-simple-jit.c index 42b727f..56874f8 100644 --- a/gdb/testsuite/gdb.base/jit-reader-simple-jit.c +++ b/gdb/testsuite/gdb.base/jit-reader-simple-jit.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/jit-reader-simple.c b/gdb/testsuite/gdb.base/jit-reader-simple.c index 32f322e..8968469 100644 --- a/gdb/testsuite/gdb.base/jit-reader-simple.c +++ b/gdb/testsuite/gdb.base/jit-reader-simple.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/jit-reader-simple.exp b/gdb/testsuite/gdb.base/jit-reader-simple.exp index f3c0125..eebab22 100644 --- a/gdb/testsuite/gdb.base/jit-reader-simple.exp +++ b/gdb/testsuite/gdb.base/jit-reader-simple.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -103,9 +103,11 @@ proc jit_test_reread {standalone change_addr} { with_test_prefix "initial run" { if {$standalone} { - clean_restart $binfile + clean_restart + gdb_load $binfile } else { - clean_restart $binfile_dl + clean_restart + gdb_load $binfile_dl } runto_main @@ -124,7 +126,7 @@ proc jit_test_reread {standalone change_addr} { # second, gdb might not reload the executable automatically. sleep 1 - if ${change_addr} { + if {${change_addr}} { set options "additional_flags=-DSPACER" if {$standalone} { gdb_rename_execfile $binfile ${binfile}x @@ -153,7 +155,7 @@ proc jit_test_reread {standalone change_addr} { "maint info breakpoints shows jit breakpoint" } - if ${change_addr} { + if {${change_addr}} { gdb_assert {$addr_before != $addr_after} "address changed" } else { gdb_assert {$addr_before == $addr_after} "address didn't change" @@ -161,7 +163,7 @@ proc jit_test_reread {standalone change_addr} { } foreach standalone {1 0} { - with_test_prefix [expr ($standalone)?"standalone":"shared"] { + with_test_prefix [expr {($standalone)?"standalone":"shared"}] { with_test_prefix "change addr" { jit_test_reread $standalone 1 } @@ -175,7 +177,8 @@ foreach standalone {1 0} { # see JIT breakpoints defined for both. with_test_prefix "two JITers" { - clean_restart $binfile_dl2 + clean_restart + gdb_load $binfile_dl2 if {![runto_main]} { return -1 diff --git a/gdb/testsuite/gdb.base/jit-reader.c b/gdb/testsuite/gdb.base/jit-reader.c index 78117f0..e5868f6 100644 --- a/gdb/testsuite/gdb.base/jit-reader.c +++ b/gdb/testsuite/gdb.base/jit-reader.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2024 Free Software Foundation, Inc. +/* Copyright (C) 2009-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -43,7 +43,7 @@ struct reader_state static enum gdb_status read_debug_info (struct gdb_reader_funcs *self, struct gdb_symbol_callbacks *cbs, - void *memory, long memory_sz) + void *memory, long memory_sz) { struct jithost_abi *symfile = memory; struct gdb_object *object = cbs->object_open (cbs); @@ -92,7 +92,7 @@ free_reg_value (struct gdb_reg_value *value) static void write_register (struct gdb_unwind_callbacks *callbacks, int dw_reg, - uintptr_t value) + uintptr_t value) { const int size = sizeof (uintptr_t); struct gdb_reg_value *reg_val = diff --git a/gdb/testsuite/gdb.base/jit-reader.exp b/gdb/testsuite/gdb.base/jit-reader.exp index 2a96207..df2dd74 100644 --- a/gdb/testsuite/gdb.base/jit-reader.exp +++ b/gdb/testsuite/gdb.base/jit-reader.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -102,7 +102,8 @@ proc jit_reader_test {} { set any "\[^\r\n\]*" - clean_restart $jit_host_bin + clean_restart + gdb_load $jit_host_bin gdb_load_shlib $jit_reader_bin if {$test_verbose > 0} { @@ -233,6 +234,15 @@ proc jit_reader_test {} { gdb_test "python print( \[o for o in gdb.objfiles() if o.filename.startswith('<< JIT compiled code')\]\[0\].build_id )" \ "None" \ "python gdb.Objfile.build_id" + + # Check that Progspace.objfile_for_address () finds "jitted" + # objfile + gdb_test "frame 0" \ + "#0 $hex in jit_function_stack_mangle ()$any" \ + "select frame 0" + gdb_test "python print( gdb.current_progspace().objfile_for_address(gdb.parse_and_eval('\$pc')) )" \ + "<gdb.Objfile filename=<< JIT compiled code at $hex >>>" \ + "python gdb.Progspace.objfile_for_address" } } } diff --git a/gdb/testsuite/gdb.base/jump-inline.c b/gdb/testsuite/gdb.base/jump-inline.c index 8c0fcdd..a5744e5 100644 --- a/gdb/testsuite/gdb.base/jump-inline.c +++ b/gdb/testsuite/gdb.base/jump-inline.c @@ -1,4 +1,4 @@ -/* Copyright 2021-2024 Free Software Foundation, Inc. +/* Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/jump-inline.exp b/gdb/testsuite/gdb.base/jump-inline.exp index ec1d2a1..7c36479 100644 --- a/gdb/testsuite/gdb.base/jump-inline.exp +++ b/gdb/testsuite/gdb.base/jump-inline.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/jump.exp b/gdb/testsuite/gdb.base/jump.exp index 735aeeb..ee3c1c3 100644 --- a/gdb/testsuite/gdb.base/jump.exp +++ b/gdb/testsuite/gdb.base/jump.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 diff --git a/gdb/testsuite/gdb.base/jump_multiple_objfiles-foo.c b/gdb/testsuite/gdb.base/jump_multiple_objfiles-foo.c index 6f39dec..98ddb23 100755 --- a/gdb/testsuite/gdb.base/jump_multiple_objfiles-foo.c +++ b/gdb/testsuite/gdb.base/jump_multiple_objfiles-foo.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/jump_multiple_objfiles.c b/gdb/testsuite/gdb.base/jump_multiple_objfiles.c index 7d87a28..492b415 100755 --- a/gdb/testsuite/gdb.base/jump_multiple_objfiles.c +++ b/gdb/testsuite/gdb.base/jump_multiple_objfiles.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/jump_multiple_objfiles.exp b/gdb/testsuite/gdb.base/jump_multiple_objfiles.exp index 0c8c345..868777f 100755 --- a/gdb/testsuite/gdb.base/jump_multiple_objfiles.exp +++ b/gdb/testsuite/gdb.base/jump_multiple_objfiles.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/jump_multiple_objfiles.h b/gdb/testsuite/gdb.base/jump_multiple_objfiles.h index 62792df..cc82d6b 100755 --- a/gdb/testsuite/gdb.base/jump_multiple_objfiles.h +++ b/gdb/testsuite/gdb.base/jump_multiple_objfiles.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021-2024 Free Software Foundation, Inc. +/* Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/kill-after-signal.c b/gdb/testsuite/gdb.base/kill-after-signal.c index 0b5ae03..50186c5 100644 --- a/gdb/testsuite/gdb.base/kill-after-signal.c +++ b/gdb/testsuite/gdb.base/kill-after-signal.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/kill-after-signal.exp b/gdb/testsuite/gdb.base/kill-after-signal.exp index 4293d59..de0093e 100644 --- a/gdb/testsuite/gdb.base/kill-after-signal.exp +++ b/gdb/testsuite/gdb.base/kill-after-signal.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2024 Free Software Foundation, Inc. +# Copyright (C) 2011-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 @@ -19,13 +19,13 @@ require can_single_step_to_signal_handler require {!target_info exists gdb,nosignals} -if [prepare_for_testing "failed to prepare" ${testfile}] { +if {[prepare_for_testing "failed to prepare" ${testfile}]} { return -1 } gdb_test "handle SIGUSR1 stop print pass" "SIGUSR1\[ \t\]+Yes\[ \t\]+Yes\[ \t\]+Yes\[ \t\]+.*" -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.c b/gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.c index 3aa16f5..78b0e7b 100644 --- a/gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.c +++ b/gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.exp b/gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.exp index 8c4f3c0..b97d2c2 100644 --- a/gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.exp +++ b/gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. # -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -19,11 +19,12 @@ # commands. require can_spawn_for_attach +require allow_multi_inferior_tests standard_testfile set executable $testfile -if [prepare_for_testing "failed to prepare" $executable] { +if {[prepare_for_testing "failed to prepare" $executable]} { return -1 } diff --git a/gdb/testsuite/gdb.base/kill-during-detach.c b/gdb/testsuite/gdb.base/kill-during-detach.c index 416150a..590bcc4 100644 --- a/gdb/testsuite/gdb.base/kill-during-detach.c +++ b/gdb/testsuite/gdb.base/kill-during-detach.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2023-2024 Free Software Foundation, Inc. + Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/kill-during-detach.exp b/gdb/testsuite/gdb.base/kill-during-detach.exp index d9ab8ee..77d9c39 100644 --- a/gdb/testsuite/gdb.base/kill-during-detach.exp +++ b/gdb/testsuite/gdb.base/kill-during-detach.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 @@ -76,7 +76,7 @@ set checkpoint_line [gdb_get_line_number "Checkpoint here"] proc run_test { exit_p checkpoint_p } { save_vars { ::GDBFLAGS } { append ::GDBFLAGS " -ex \"set non-stop on\"" - clean_restart $::binfile + clean_restart $::testfile } if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/killed-outside.c b/gdb/testsuite/gdb.base/killed-outside.c index 706746d..f8d9c77 100644 --- a/gdb/testsuite/gdb.base/killed-outside.c +++ b/gdb/testsuite/gdb.base/killed-outside.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/killed-outside.exp b/gdb/testsuite/gdb.base/killed-outside.exp index 88f4afe..156643a 100644 --- a/gdb/testsuite/gdb.base/killed-outside.exp +++ b/gdb/testsuite/gdb.base/killed-outside.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -31,7 +31,7 @@ proc get_value {var msg} { -re ".*= ($decimal).*\r\n$gdb_prompt $" { set value $expect_out(1,string) pass "$msg" - } + } } return ${value} } @@ -42,13 +42,12 @@ proc get_value {var msg} { # and then quits GDB. proc test {cmds_after_kill} { - global binfile global gdb_prompt global decimal - clean_restart ${binfile} + clean_restart $::testfile - if ![runto done] { + if {![runto done]} { return } diff --git a/gdb/testsuite/gdb.base/label-without-address.c b/gdb/testsuite/gdb.base/label-without-address.c index 038d8ae..37865bf 100644 --- a/gdb/testsuite/gdb.base/label-without-address.c +++ b/gdb/testsuite/gdb.base/label-without-address.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/label-without-address.exp b/gdb/testsuite/gdb.base/label-without-address.exp index 9d8470f..74bebd3 100644 --- a/gdb/testsuite/gdb.base/label-without-address.exp +++ b/gdb/testsuite/gdb.base/label-without-address.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/label.c b/gdb/testsuite/gdb.base/label.c index c15e3bf..98e78f4 100644 --- a/gdb/testsuite/gdb.base/label.c +++ b/gdb/testsuite/gdb.base/label.c @@ -9,7 +9,7 @@ main (int argc, char **argv) here: printf("not here\n"); i = 1; - + there: printf("but here\n"); if (i == 0) @@ -18,4 +18,3 @@ there: done: return 0; } - diff --git a/gdb/testsuite/gdb.base/label.exp b/gdb/testsuite/gdb.base/label.exp index 7325789..fff16e07 100644 --- a/gdb/testsuite/gdb.base/label.exp +++ b/gdb/testsuite/gdb.base/label.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/langs.exp b/gdb/testsuite/gdb.base/langs.exp index 862741b..4f86aeb 100644 --- a/gdb/testsuite/gdb.base/langs.exp +++ b/gdb/testsuite/gdb.base/langs.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2024 Free Software Foundation, Inc. +# Copyright (C) 1997-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 @@ -16,7 +16,7 @@ standard_testfile langs0.c langs1.c langs2.c -if [is_remote host] { +if {[is_remote host]} { remote_download host ${srcdir}/${subdir}/langs1.f remote_download host ${srcdir}/${subdir}/langs2.cxx } @@ -88,12 +88,12 @@ if {[runto csub]} { gdb_test "show language" "currently $lang\".*" \ "show language at main" - if [target_info exists gdb,noresults] { return } + if {[target_info exists gdb,noresults]} { return } gdb_continue_to_end "first session" } -clean_restart $binfile +clean_restart $testfile # Try exercising the "minimal" language a bit... @@ -101,7 +101,7 @@ if {[runto csub]} { # Also test warn-language-frame-mismatch. gdb_test_no_output "set warn-language-frame-mismatch off" gdb_test_no_output "set lang minimal" "set lang to minimal" - + gdb_test "print x" " = 5000" "print parameter value" # Ensure this at least does not crash. diff --git a/gdb/testsuite/gdb.base/langs1.c b/gdb/testsuite/gdb.base/langs1.c index 7b6b229..80f9d0d 100644 --- a/gdb/testsuite/gdb.base/langs1.c +++ b/gdb/testsuite/gdb.base/langs1.c @@ -30,4 +30,3 @@ static integer c__10000 = 10000; return cppsub_(&c__10000); #line 7 "langs1.f" } /* fsub_ */ - diff --git a/gdb/testsuite/gdb.base/langs1.f b/gdb/testsuite/gdb.base/langs1.f index aa290d9..b89210a 100644 --- a/gdb/testsuite/gdb.base/langs1.f +++ b/gdb/testsuite/gdb.base/langs1.f @@ -1,4 +1,4 @@ -c Copyright (C) 1999-2024 Free Software Foundation, Inc. +c Copyright (C) 1999-2025 Free Software Foundation, Inc. c This program is free software; you can redistribute it and/or modify c it under the terms of the GNU General Public License as published by diff --git a/gdb/testsuite/gdb.base/large-frame-1.c b/gdb/testsuite/gdb.base/large-frame-1.c index 37967bc..2f258a1 100644 --- a/gdb/testsuite/gdb.base/large-frame-1.c +++ b/gdb/testsuite/gdb.base/large-frame-1.c @@ -1,6 +1,6 @@ /* This file is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/large-frame-2.c b/gdb/testsuite/gdb.base/large-frame-2.c index c75ef67..541b180 100644 --- a/gdb/testsuite/gdb.base/large-frame-2.c +++ b/gdb/testsuite/gdb.base/large-frame-2.c @@ -1,6 +1,6 @@ /* This file is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/large-frame.exp b/gdb/testsuite/gdb.base/large-frame.exp index 5e4a204..553afea 100644 --- a/gdb/testsuite/gdb.base/large-frame.exp +++ b/gdb/testsuite/gdb.base/large-frame.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -28,12 +28,12 @@ if { [is_remote host] } { # the test. proc run_test { opt_level } { - global srcfile srcfile2 binfile hex + global srcfile srcfile2 hex standard_testfile large-frame-1.c large-frame-2.c if {[prepare_for_testing_full "failed to prepare" \ - [list ${binfile}-${opt_level} debug \ + [list $::testfile-$opt_level debug \ $srcfile [list debug] \ $srcfile2 [list nodebug optimize=-$opt_level]]]} { return @@ -57,4 +57,3 @@ foreach opt { O0 O1 O2 } { run_test $opt } } - diff --git a/gdb/testsuite/gdb.base/large-frame.h b/gdb/testsuite/gdb.base/large-frame.h index 1baa1dd..881a1e8 100644 --- a/gdb/testsuite/gdb.base/large-frame.h +++ b/gdb/testsuite/gdb.base/large-frame.h @@ -1,6 +1,6 @@ /* This file is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/ldbl_e308.c b/gdb/testsuite/gdb.base/ldbl_e308.c index 2ebbb40..e3329e0 100644 --- a/gdb/testsuite/gdb.base/ldbl_e308.c +++ b/gdb/testsuite/gdb.base/ldbl_e308.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2024 Free Software Foundation, Inc. +/* Copyright (C) 2012-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/ldbl_e308.exp b/gdb/testsuite/gdb.base/ldbl_e308.exp index 3eb313e..1a4e9fc 100644 --- a/gdb/testsuite/gdb.base/ldbl_e308.exp +++ b/gdb/testsuite/gdb.base/ldbl_e308.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2024 Free Software Foundation, Inc. +# Copyright (C) 2012-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 @@ -19,12 +19,11 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } gdb_test_no_output "set variable ldbl_308 = 1.6e+308l" gdb_test "print ldbl_308" \ - "= 1\..*e\\+308" - + "= 1\..*e\\+308" diff --git a/gdb/testsuite/gdb.base/libsegfault.exp b/gdb/testsuite/gdb.base/libsegfault.exp index 61a54ff..a3883e1 100644 --- a/gdb/testsuite/gdb.base/libsegfault.exp +++ b/gdb/testsuite/gdb.base/libsegfault.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -24,6 +24,15 @@ # the local machine. require {!is_remote host} +# On Cygwin, the testcase would somehow end up trying to preload +# libSegFault.so into the Expect process, which would fail and crash +# it. Since libSegFault.so is a glibc feature that doesn't exist on +# Cygwin, just skip testing there. +require {!expr {[isbuild "*-*-cygwin*"] && [ishost "*-*-cygwin*"]}} +# Same when testing MinGW with MSYS2, as MSYS2 is really a Cygwin +# fork. +require {!expr {[isbuild "*-*-mingw*"] && [ishost "*-*-mingw*"]}} + # Spawn GDB with LIB preloaded with LD_PRELOAD. CMDLINE_OPTS are # command line options passed to GDB. diff --git a/gdb/testsuite/gdb.base/limited-length.c b/gdb/testsuite/gdb.base/limited-length.c index c8ece16..28ac703 100644 --- a/gdb/testsuite/gdb.base/limited-length.c +++ b/gdb/testsuite/gdb.base/limited-length.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2023-2024 Free Software Foundation, Inc. + Copyright (C) 2023-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 diff --git a/gdb/testsuite/gdb.base/limited-length.exp b/gdb/testsuite/gdb.base/limited-length.exp index 2d160e1..3b0857d 100644 --- a/gdb/testsuite/gdb.base/limited-length.exp +++ b/gdb/testsuite/gdb.base/limited-length.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 @@ -74,7 +74,7 @@ with_test_prefix "with standard max-value size" { # Set the max-value-size so we can only print 51 elements. set elements 51 set int_size [get_valueof "/d" "sizeof(large_1d_array\[0\])" "*unknown*"] -gdb_test_no_output "set max-value-size [expr $int_size * $elements]" +gdb_test_no_output "set max-value-size [expr {$int_size * $elements}]" with_test_prefix "with reduced max-value size" { gdb_test "print large_1d_array" \ diff --git a/gdb/testsuite/gdb.base/line-symtabs.c b/gdb/testsuite/gdb.base/line-symtabs.c index 8f62a1c..75b0c5b 100644 --- a/gdb/testsuite/gdb.base/line-symtabs.c +++ b/gdb/testsuite/gdb.base/line-symtabs.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/line-symtabs.exp b/gdb/testsuite/gdb.base/line-symtabs.exp index 9a405c3..f937b32 100644 --- a/gdb/testsuite/gdb.base/line-symtabs.exp +++ b/gdb/testsuite/gdb.base/line-symtabs.exp @@ -1,5 +1,5 @@ # Test handling of line symbol tables (non-primary symtabs). -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/line-symtabs.h b/gdb/testsuite/gdb.base/line-symtabs.h index cec5553..50e51d7 100644 --- a/gdb/testsuite/gdb.base/line-symtabs.h +++ b/gdb/testsuite/gdb.base/line-symtabs.h @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/line65535.c b/gdb/testsuite/gdb.base/line65535.c index 2cef12a..5ca8402 100644 --- a/gdb/testsuite/gdb.base/line65535.c +++ b/gdb/testsuite/gdb.base/line65535.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/line65535.exp b/gdb/testsuite/gdb.base/line65535.exp index e2dda0a..1e6a6be 100644 --- a/gdb/testsuite/gdb.base/line65535.exp +++ b/gdb/testsuite/gdb.base/line65535.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -24,5 +24,5 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { } gdb_test "break $srcfile:65535" \ - ".*Breakpoint 1 at .*: file .*$srcfile, line 65535\\..*" \ + ".*Breakpoint 1 at .*: file .*$srcfile, line 65535\\..*" \ "break at line 65535" diff --git a/gdb/testsuite/gdb.base/lineinc.exp b/gdb/testsuite/gdb.base/lineinc.exp index df5e967..24cb008 100644 --- a/gdb/testsuite/gdb.base/lineinc.exp +++ b/gdb/testsuite/gdb.base/lineinc.exp @@ -1,5 +1,5 @@ # Test macro handling of #included files. -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 @@ -21,7 +21,7 @@ # # Compiling lineinc.c with Dwarf 2 macro information will produce # something like this: -# +# # $ gcc -g3 lineinc.c -o lineinc # $ readelf -wml lineinc # ... @@ -33,10 +33,10 @@ # 4 0 0 0 lineinc3.h # ... # Contents of the .debug_macinfo section: -# +# # DW_MACINFO_start_file - lineno: 0 filenum: 1 # DW_MACINFO_define - lineno : 1 macro : __VERSION__ "3.2 20020903 (Red Hat Linux 8.0 3.2-7)" -# DW_MACINFO_define - lineno : 2 macro : __USER_LABEL_PREFIX__ +# DW_MACINFO_define - lineno : 2 macro : __USER_LABEL_PREFIX__ # ... # DW_MACINFO_define - lineno : 1 macro : __i386__ 1 # DW_MACINFO_define - lineno : 1 macro : __tune_i386__ 1 @@ -52,7 +52,7 @@ # DW_MACINFO_define - lineno : 2 macro : FOO 3 # DW_MACINFO_end_file # DW_MACINFO_end_file -# $ +# $ # # Note how the inclusions of lineinc1.h and lineinc2.h are both # attributed to line 10 of lineinc.c, and the #inclusion of lineinc3.h @@ -80,34 +80,30 @@ standard_testfile .c -if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable \ - {debug macros}] != ""} { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile {debug macros}] != 0 } { + return } -clean_restart ${binfile} - # Any command that causes GDB to read the debugging info for the # lineinc.c compilation unit will do here. set test_name "tolerate macro info with multiple #inclusions per line" gdb_test_multiple "break -q main" $test_name { -re "Breakpoint 1 at 0x.*: file .*lineinc.c.*\\.\r\n${gdb_prompt}" { - pass $test_name + pass $test_name } -re ".*internal-error:.*.y or n. " { - fail $test_name - send_gdb "y\n" - gdb_expect { - -re ".*.y or n. " { - send_gdb "n\n" - exp_continue - } - -re "$gdb_prompt" { - } - timeout { - fail "$test_name (timeout)" - } - } + fail $test_name + send_gdb "y\n" + gdb_expect { + -re ".*.y or n. " { + send_gdb "n\n" + exp_continue + } + -re "$gdb_prompt" { + } + timeout { + fail "$test_name (timeout)" + } + } } } diff --git a/gdb/testsuite/gdb.base/list-ambiguous-readnow.exp b/gdb/testsuite/gdb.base/list-ambiguous-readnow.exp index b5b79d3..82b68cc 100644 --- a/gdb/testsuite/gdb.base/list-ambiguous-readnow.exp +++ b/gdb/testsuite/gdb.base/list-ambiguous-readnow.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/list-ambiguous.exp b/gdb/testsuite/gdb.base/list-ambiguous.exp index ef62697..e3c821d 100644 --- a/gdb/testsuite/gdb.base/list-ambiguous.exp +++ b/gdb/testsuite/gdb.base/list-ambiguous.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -48,8 +48,8 @@ proc test_list_ambiguous_symbol {symbol_line symbol} { set lineno0 [gdb_get_line_number $symbol_line $srcfile] set lineno1 [gdb_get_line_number $symbol_line $srcfile2] - set lines0_re [line_range_pattern [expr $lineno0 - 5] [expr $lineno0 + 4]] - set lines1_re [line_range_pattern [expr $lineno1 - 5] [expr $lineno1 + 4]] + set lines0_re [line_range_pattern [expr {$lineno0 - 5}] [expr {$lineno0 + 4}]] + set lines1_re [line_range_pattern [expr {$lineno1 - 5}] [expr {$lineno1 + 4}]] set any "\[^\r\n\]*" set h0_re "file: \"${any}list-ambiguous0.c\", line number: $lineno0, symbol: \"$symbol\"" diff --git a/gdb/testsuite/gdb.base/list-ambiguous0.c b/gdb/testsuite/gdb.base/list-ambiguous0.c index db11702..bdd674c 100644 --- a/gdb/testsuite/gdb.base/list-ambiguous0.c +++ b/gdb/testsuite/gdb.base/list-ambiguous0.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/list-ambiguous1.c b/gdb/testsuite/gdb.base/list-ambiguous1.c index b7587df..ccf5c7b 100644 --- a/gdb/testsuite/gdb.base/list-ambiguous1.c +++ b/gdb/testsuite/gdb.base/list-ambiguous1.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/list-before-start.exp b/gdb/testsuite/gdb.base/list-before-start.exp index 5499257..c047827 100644 --- a/gdb/testsuite/gdb.base/list-before-start.exp +++ b/gdb/testsuite/gdb.base/list-before-start.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/list-dot-nodebug-extra.c b/gdb/testsuite/gdb.base/list-dot-nodebug-extra.c index 58c1b64..77cff18 100644 --- a/gdb/testsuite/gdb.base/list-dot-nodebug-extra.c +++ b/gdb/testsuite/gdb.base/list-dot-nodebug-extra.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/list-dot-nodebug.c b/gdb/testsuite/gdb.base/list-dot-nodebug.c index 5d2a1a3..5be8099 100644 --- a/gdb/testsuite/gdb.base/list-dot-nodebug.c +++ b/gdb/testsuite/gdb.base/list-dot-nodebug.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/list-dot-nodebug.exp b/gdb/testsuite/gdb.base/list-dot-nodebug.exp index e15e2bd..a5bc313 100644 --- a/gdb/testsuite/gdb.base/list-dot-nodebug.exp +++ b/gdb/testsuite/gdb.base/list-dot-nodebug.exp @@ -1,4 +1,4 @@ -# Copyright 2005-2024 Free Software Foundation, Inc. +# Copyright 2005-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 diff --git a/gdb/testsuite/gdb.base/list-missing-source.exp b/gdb/testsuite/gdb.base/list-missing-source.exp index 01155d8..d73b37d 100644 --- a/gdb/testsuite/gdb.base/list-missing-source.exp +++ b/gdb/testsuite/gdb.base/list-missing-source.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -43,7 +43,7 @@ if { [gdb_compile "${srcfile}" "${binfile}" \ remote_file host delete $srcfile # Now start GDB, run to main and try to list the source. -clean_restart ${binfile} +clean_restart $testfile if {![runto_main]} { return 0 @@ -60,4 +60,3 @@ gdb_test "info source" \ "Producer is \[^\n\r\]+" \ "Compiled with DWARF $decimal debugging format." \ "Does not include preprocessor macro info." ] - diff --git a/gdb/testsuite/gdb.base/list-multi-source.c b/gdb/testsuite/gdb.base/list-multi-source.c new file mode 100644 index 0000000..ab2b6a0 --- /dev/null +++ b/gdb/testsuite/gdb.base/list-multi-source.c @@ -0,0 +1,60 @@ +/* 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/>. */ + +extern int function_a (void); +extern int function_b (void); + +#ifdef MAIN +int +main (void) +{ + int res; + + res = function_a (); + + res += function_b (); + + return res; +} +#endif + +#if defined FILE_A || defined FILE_B +static int +get_value_common (void) +{ + /* NOTE: When reading this file in the source tree, the variable used in + the return statement below will be replaced by a constant value when + the file is copied into the source tree. */ + return value_to_return; /* List this line. */ +} +#endif + +#ifdef FILE_A +int +function_a (void) +{ + return get_value_common (); +} +#endif + +#ifdef FILE_B +int +function_b (void) +{ + return get_value_common (); +} +#endif diff --git a/gdb/testsuite/gdb.base/list-multi-source.exp b/gdb/testsuite/gdb.base/list-multi-source.exp new file mode 100644 index 0000000..887ff96 --- /dev/null +++ b/gdb/testsuite/gdb.base/list-multi-source.exp @@ -0,0 +1,129 @@ +# 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/>. + +# Test that 'list FILE:LINE' can print multiple results if FILE +# matches multiple files from the source tree. +# +# Then test that we can use 'list DIR/FILE:LINE' to restrict the +# results to a single source file. + +# With a remote host, source files are automatically copied to the +# host by dejagnu, and this drops the directory structure that is +# needed for this test to work, i.e. we need a/foo.c and b/foo.c, but +# dejagnu's automatic copying just gives us a single foo.c. Instead +# of trying to fix this, for now at least, just skip remote host +# testing. +require {!is_remote host} + +# This test uses a single source file that is copied into the build +# tree 3 times. The three copies are then copied with different +# defines set so that we see different functions in each copy. +standard_testfile .c + +# Create the source tree within the build directory. +set src_root [standard_output_file "src"] +set src_a "$src_root/a" +set src_b "$src_root/b" +set file_a "$src_a/foo.c" +set file_b "$src_b/foo.c" +set file_main "$src_root/main.c" +file mkdir "$src_root" +file mkdir "$src_a" +file mkdir "$src_b" + +# Helper proc. Copy global SRCFILE to DEST, replacing +# 'value_to_return' with VALUE during the copy. +proc copy_and_update_source_file { dest value } { + # Open the source file for reading. + set in [open "$::srcdir/$::subdir/$::srcfile" r] + + # Read in the entire contents of the file. This should be fine as + # the input file is not large. + set file_content [read $in] + + # Close the input file. + close $in + + # Perform the replacement over the entire file contents. + set updated_content [string map \ + [list "value_to_return" $value] \ + $file_content] + + # Open the destination file for writing. + set out [open $dest w] + + # Write the modified content to the destination file. + puts -nonewline $out $updated_content + + # Close the output file. + close $out +} + +# Make three copies of the single source file in the build directory +# based source tree. Two of the source files are modified slighly to +# make the output of 'list' unique for each copy. +file copy "$srcdir/$subdir/$srcfile" "$file_main" +copy_and_update_source_file $file_a "3" +copy_and_update_source_file $file_b "-3" + +# Build the executable. Use defines to make the source files +# different. +if { [prepare_for_testing_full "failed to prepare" \ + [list $testfile debug \ + $file_main [list debug additional_flags=-DMAIN] \ + $file_a [list debug additional_flags=-DFILE_A] \ + $file_b [list debug additional_flags=-DFILE_B]]]} { + return +} + +# The LINENUM we should list, and the first and last lines that should +# appear in the list output. +set linenum [gdb_get_line_number "List this line"] +set first_linenum [expr {$linenum - 5}] +set last_linenum [expr {$linenum + 4}] + +# List using FILE:LINE for a filename that is ambiguous. +gdb_test "list foo.c:$linenum" \ + [multi_line \ + "file: \"\[^\r\n\]+/a/foo.c\", line number: $linenum, symbol: \"get_value_common\"" \ + "$first_linenum\\s+\[^\r\n\]+" \ + ".*" \ + "$linenum\\s+[string_to_regexp {return 3; /* List this line. */}]" \ + ".*" \ + "$last_linenum\\s+\[^\r\n\]+" \ + "file: \"\[^\r\n\]+/b/foo.c\", line number: $linenum, symbol: \"get_value_common\"" \ + "$first_linenum\\s+\[^\r\n\]+" \ + ".*" \ + "$linenum\\s+[string_to_regexp {return -3; /* List this line. */}]" \ + ".*" \ + "$last_linenum\\s+\[^\r\n\]+"] + +# Now list using a more acurate filename, we should only get a single +# result. +gdb_test "list a/foo.c:$linenum" \ + [multi_line \ + "^$first_linenum\\s+\[^\r\n\]+" \ + ".*" \ + "$linenum\\s+[string_to_regexp {return 3; /* List this line. */}]" \ + ".*" \ + "$last_linenum\\s+\[^\r\n\]+"] + +gdb_test "list b/foo.c:$linenum" \ + [multi_line \ + "^$first_linenum\\s+\[^\r\n\]+" \ + ".*" \ + "$linenum\\s+[string_to_regexp {return -3; /* List this line. */}]" \ + ".*" \ + "$last_linenum\\s+\[^\r\n\]+"] diff --git a/gdb/testsuite/gdb.base/list-nodebug-2.c b/gdb/testsuite/gdb.base/list-nodebug-2.c index 861e614..747abb2 100644 --- a/gdb/testsuite/gdb.base/list-nodebug-2.c +++ b/gdb/testsuite/gdb.base/list-nodebug-2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/list-nodebug.c b/gdb/testsuite/gdb.base/list-nodebug.c index d4ae678..8df8f3f 100644 --- a/gdb/testsuite/gdb.base/list-nodebug.c +++ b/gdb/testsuite/gdb.base/list-nodebug.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/list-nodebug.exp b/gdb/testsuite/gdb.base/list-nodebug.exp index e07fa9e..d92201b 100644 --- a/gdb/testsuite/gdb.base/list-nodebug.exp +++ b/gdb/testsuite/gdb.base/list-nodebug.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp index f628784..3640dfe 100644 --- a/gdb/testsuite/gdb.base/list.exp +++ b/gdb/testsuite/gdb.base/list.exp @@ -1,4 +1,4 @@ -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -44,14 +44,14 @@ proc set_listsize { arg } { global set_listsize_count incr set_listsize_count - if [gdb_test_no_output "set listsize $arg" "setting listsize to $arg #$set_listsize_count"] { + if {[gdb_test_no_output "set listsize $arg" "setting listsize to $arg #$set_listsize_count"]} { return 0 } if { $arg == 0 } { set arg "unlimited" } - if [gdb_test "show listsize" "Number of source lines.* is ${arg}.*" "show listsize $arg #$set_listsize_count"] { + if {[gdb_test "show listsize" "Number of source lines.* is ${arg}.*" "show listsize $arg #$set_listsize_count"]} { return 0 } return 1 @@ -68,21 +68,21 @@ proc test_listsize {} { # Show default size gdb_test "show listsize" "Number of source lines gdb will list by default is 10.*" "show default list size" - + # Show the default lines gdb_test "list" "(1\[ \t\]+#include \"list0.h\".*7\[ \t\]+x = 0;\r\n.*10\[ \t\]+foo .x\[+)\]+;)" "list default lines around main" # Ensure we can limit printouts to one line - if [set_listsize 1] { + if {[set_listsize 1]} { gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"" "list line 1 with listsize 1" gdb_test "list 2" "2\[ \t\]+" "list line 2 with listsize 1" - } + } # Try just two lines - - if [ set_listsize 2 ] { + + if {[ set_listsize 2 ]} { gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+" "list line 1 with listsize 2" gdb_test "list 2" "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+" "list line 2 with listsize 2" gdb_test "list 3" "2\[ \t\]+\r\n3\[ \t\]+int main \[)(\]+" "list line 3 with listsize 2" @@ -90,7 +90,7 @@ proc test_listsize {} { # Try small listsize > 1 that is an odd number - if [ set_listsize 3 ] { + if {[ set_listsize 3 ]} { gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+int main \[)(\]+" "list line 1 with listsize 3" gdb_test "list 2" "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+int main \[)(\]+" "list line 2 with listsize 3" gdb_test "list 3" "2\[ \t\]+\r\n3\[ \t\]+int main \[(\]+\[)\]+\r\n4\[ \t\]+\{" "list line 3 with listsize 3" @@ -101,7 +101,7 @@ proc test_listsize {} { if {[set_listsize 4]} { gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "list line 1 with listsize 4" gdb_test "list 2" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "list line 2 with listsize 4" - + gdb_test "list 3" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "list line 3 with listsize 4" gdb_test "list 4" "2\[ \t\]+\r\n.*5\[ \t\]+int x;.*" "list line 4 with listsize 4" } @@ -110,7 +110,7 @@ proc test_listsize {} { if {[set_listsize 100]} { gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*\r\n${last_line_re}" "list line 1 with listsize 100" - + gdb_test "list 10" "1\[ \t\]+#include \"list0.h\".*\r\n${last_line_re}" "list line 10 with listsize 100" } @@ -182,7 +182,7 @@ proc_with_prefix test_list_forward {} { # Test that repeating the list linenum command doesn't print the same # lines over again. Note that this test makes sure that the argument # linenum is dropped, when we repeat the previous command. 'x/5i $pc' -# works the same way. +# works the same way. proc_with_prefix test_repeat_list_command {} { global last_line_re @@ -227,8 +227,8 @@ proc test_list_range {} { # gdb_test "list -100,-40" "Line number -60 out of range; .*list0.c has 39 lines." "list range; both bounds negative" - set past_end [expr ${last_line} + 10] - set much_past_end [expr ${past_end} + 10] + set past_end [expr {${last_line} + 10}] + set much_past_end [expr {${past_end} + 10}] gdb_test "list 30,${past_end}" "30\[ \t\]+foo \(.*\);.*${last_line_re}" "list range; upper bound past EOF" @@ -323,7 +323,7 @@ proc test_list_filename_and_function {} { # Test some invalid specs # The following test takes the FIXME result on most systems using # DWARF. It fails to notice that main() is not in the file requested. - + setup_xfail "*-*-*" # Does this actually work ANYWHERE? I believe not, as this is an `aspect' of @@ -369,7 +369,7 @@ proc test_forward_reverse_search {} { # Test that GDB won't crash if the line being searched is extremely long. set oldtimeout $timeout - set timeout [expr "$timeout + 300"] + set timeout [expr {$timeout + 300}] verbose "Timeout is now $timeout seconds" 2 gdb_test "search 1234" ".*1234.*" "search extremely long line (> 5000 chars)" set timeout $oldtimeout @@ -383,9 +383,7 @@ proc test_only_end {} { } proc test_list_invalid_args {} { - global binfile - - clean_restart ${binfile} + clean_restart $::testfile gdb_test "list -INVALID" \ "invalid explicit location argument, \"-INVALID\"" \ "first use of \"list -INVALID\"" @@ -393,7 +391,7 @@ proc test_list_invalid_args {} { "invalid explicit location argument, \"-INVALID\"" \ "second use of \"list -INVALID\"" - clean_restart ${binfile} + clean_restart $::testfile gdb_test "list +INVALID" "Function \"\\+INVALID\" not defined." \ "first use of \"list +INVALID\"" gdb_test "list +INVALID" "Function \"\\+INVALID\" not defined." \ @@ -497,9 +495,7 @@ proc build_pattern { range_spec } { proc test_list {command listsize1 listsize2 linerange1 linerange2} { with_test_prefix "$command after stop: $listsize1, $listsize2" { - global binfile - - clean_restart $binfile + clean_restart $::testfile if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/load-command.c b/gdb/testsuite/gdb.base/load-command.c index b52616f..8d1d628 100644 --- a/gdb/testsuite/gdb.base/load-command.c +++ b/gdb/testsuite/gdb.base/load-command.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/load-command.exp b/gdb/testsuite/gdb.base/load-command.exp index 2d3656e..8111404 100644 --- a/gdb/testsuite/gdb.base/load-command.exp +++ b/gdb/testsuite/gdb.base/load-command.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -17,7 +17,7 @@ standard_testfile -if [gdb_protocol_is_native] { +if {[gdb_protocol_is_native]} { unsupported "the native target does not support the load command" return } @@ -27,11 +27,11 @@ if [gdb_protocol_is_native] { set opts {debug nopie} -if [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] { +if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/local-env.exp b/gdb/testsuite/gdb.base/local-env.exp new file mode 100644 index 0000000..fedcf9b --- /dev/null +++ b/gdb/testsuite/gdb.base/local-env.exp @@ -0,0 +1,133 @@ +# Copyright 1997-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 "local-environment" commands. + +save_vars { env(GDB_TEST_ENV_VAR) } { + setenv GDB_TEST_ENV_VAR abc + gdb_start +} + +proc test_set_show_env_var { name value test_name } { + gdb_test_no_output "set local-environment $name $value" "$test_name" + gdb_test "show local-environment $name" "$name = $value" \ + "confirm $test_name" +} + +proc test_set_show_env_var_equal { name value test_name } { + gdb_test_no_output "set local-environment $name = $value" "$test_name" + gdb_test "show local-environment $name" "$name = $value" \ + "confirm $test_name" +} + +# Verify that we can show all currently-set environment variables. +# It's hard to do this verification since we can't really compare each +# entry with the current environment. So we just check to see if +# there is anything that looks like an environment variable being +# printed. +set saw_env 0 +gdb_test_multiple "show environment" "show environment works" -lbl { + -re "\r\nGDB_TEST_ENV_VAR=abc" { + incr saw_env 1 + exp_continue + } + + -re "\r\n$gdb_prompt $" { + } +} + +gdb_assert {$saw_env == 1} "show environment displayed variable" + +# Verify that we can unset a specific environment variable. +gdb_test_no_output "unset local-environment EDITOR" \ + "unset environment variable" + +gdb_test "show local-environment EDITOR" \ + "Environment variable \"EDITOR\" not defined\." \ + "confirm unset environment variable worked" + +# Verify that we can unset all environment variables. +gdb_test "unset local-environment" "" "unset all environment variables" \ + "Delete all environment variables. .y or n. $" \ + "y" + +gdb_test_no_output "show local-environment" \ + "all environment variables have been unset" + +# Verify that we can set a specific environment variable. +test_set_show_env_var "EDITOR" "emacs" "set environment variable" + +# Verify that GDB responds gracefully to a request to set environment, +# with no variable name. +gdb_test "set local-environment" \ + "Argument required \\\(environment variable and value\\\)\." \ + "set environment without arguments" + +# I'm not sure just what GDB has in mind in explicitly checking +# for this variant, but since GDB handles it, test it. +gdb_test "set local-environment =" \ + "Argument required \\\(environment variable to set\\\)\." \ + "set environment without variable name" + +# Setting an environment variable without a value sets it to a NULL +# value. +gdb_test "set local-environment EDITOR" \ + "Setting environment variable \"EDITOR\" to null value\." \ + "set environment variable to null value" +gdb_test "show local-environment EDITOR" "EDITOR = " \ + "show null environment variable" + +# Verify that GDB responds gracefully to an attempt to show a +# non-existent environment variable. (We hope this variable is +# undefined!) +gdb_test "show local-environment FOOBARBAZGRUNGESPAZBALL" \ + "Environment variable \"FOOBARBAZGRUNGESPAZBALL\" not defined\." \ + "show non-existent environment variable" + +# Verify that GDB can set an environment variable hitherto undefined. +test_set_show_env_var "FOOBARBAZGRUNGESPAZBALL" "t" \ + "set environment variable previously undefined" + +# Verify that GDB can also set an environment variable using the "=" +# syntax. +test_set_show_env_var_equal "FOOBARBAZGRUNGESPAZBALL" "y" \ + "set environment variable using = syntax" + +# Verify that GDB can set an environment variable to a value that has +# an embedded (trailing, in this case) equals. +test_set_show_env_var_equal "FOOBARBAZGRUNGESPAZBALL" "t=" \ + "set environment variable with trailing equals" + +# Verify that GDB can set an environment variable to a value preceded +# by whitespace, and that such whitespace is ignored (not included +# in the set value). +gdb_test_no_output \ + "set local-environment FOOBARBAZGRUNGESPAZBALL = foo" \ + "set environment variable with trailing whitespace" +gdb_test "show local-environment FOOBARBAZGRUNGESPAZBALL" \ + "FOOBARBAZGRUNGESPAZBALL = foo" \ + "confirm set environment variable with trailing whitespace" + +# Verify that the setting affects the "pipe" command. +gdb_test "pipe print 23 | printenv | grep FOOBARBAZGRUNGESPAZBALL" \ + "FOOBARBAZGRUNGESPAZBALL=foo" \ + "set local-environment affects pipe" + +# Verify that the setting affects "shell". +gdb_test "shell printenv | grep FOOBARBAZGRUNGESPAZBALL" \ + "FOOBARBAZGRUNGESPAZBALL=foo" \ + "set local-environment affects shell" + +gdb_exit diff --git a/gdb/testsuite/gdb.base/logical.exp b/gdb/testsuite/gdb.base/logical.exp index 18352a8..2641be4 100644 --- a/gdb/testsuite/gdb.base/logical.exp +++ b/gdb/testsuite/gdb.base/logical.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -27,14 +27,10 @@ standard_testfile int-type.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile { debug nowarnings }] != 0 } { + return } -clean_restart ${binfile} - - # # set it up at a breakpoint so we can play with the variable values # @@ -48,7 +44,7 @@ proc evaluate { vars ops } { set var [lindex $vars $vari] for {set opi 0} {$opi < [llength $ops]} {incr opi} { set op [lindex [lindex $ops $opi] 0] - set val [lindex [lindex $ops $opi] [expr $vari + 1]] + set val [lindex [lindex $ops $opi] [expr {$vari + 1}]] gdb_test "print $var, $op" " = $val" "evaluate $op; variables $var; expecting $val" } } diff --git a/gdb/testsuite/gdb.base/long-inferior-output.c b/gdb/testsuite/gdb.base/long-inferior-output.c index c032190..031cb24 100644 --- a/gdb/testsuite/gdb.base/long-inferior-output.c +++ b/gdb/testsuite/gdb.base/long-inferior-output.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/long-inferior-output.exp b/gdb/testsuite/gdb.base/long-inferior-output.exp index db31078..df48619 100644 --- a/gdb/testsuite/gdb.base/long-inferior-output.exp +++ b/gdb/testsuite/gdb.base/long-inferior-output.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -32,7 +32,7 @@ require {!target_info exists gdb,noinferiorio} standard_testfile -if [prepare_for_testing "failed to prepare" $testfile {} {debug}] { +if {[prepare_for_testing "failed to prepare" $testfile {} {debug}]} { return -1 } @@ -54,7 +54,7 @@ while {$more} { -i $inferior_spawn_id -ex "this is line number $i" { incr i - if {$i != $expected_lines} { + if {$i != $expected_lines} { set more 1 } } diff --git a/gdb/testsuite/gdb.base/long_long.c b/gdb/testsuite/gdb.base/long_long.c index e54b0e0..762e02b 100644 --- a/gdb/testsuite/gdb.base/long_long.c +++ b/gdb/testsuite/gdb.base/long_long.c @@ -1,6 +1,6 @@ /* This test script is part of GDB, the GNU debugger. - Copyright 1999-2024 Free Software Foundation, Inc. + Copyright 1999-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 @@ -63,7 +63,7 @@ int known_types() /* A union is used here as, hopefully it has well defined packing rules. */ struct { - long long bin, oct, dec, hex; + long long bin, oct, dec, hex; } val; memset (&val, 0, sizeof val); @@ -94,6 +94,6 @@ int main() { pack (ll, sizeof (long long), 2); known_types(); - + return 0; } diff --git a/gdb/testsuite/gdb.base/long_long.exp b/gdb/testsuite/gdb.base/long_long.exp index 81ba543..38d1934 100644 --- a/gdb/testsuite/gdb.base/long_long.exp +++ b/gdb/testsuite/gdb.base/long_long.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -16,24 +16,18 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. */ # long_long.exp Test printing of 64-bit things in 32-bit gdb. -# Also test differnet kinds of formats. +# Also test different kinds of formats. # require {!target_info exists no_long_long} standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [concat debug nowarnings]] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile {debug nowarnings}] != 0 } { + return } -# use this to debug: -#log_user 1 - -clean_restart ${binfile} - if {![runto known_types]} { - return + return } # Detect the size of the target's basic types. @@ -52,7 +46,7 @@ set sizeof_long_double [get_sizeof "long double" 8] proc pat2 { n pats } { set i 0 while { $n > 1 } { - set n [expr $n / 2] + set n [expr {$n / 2}] incr i } return [lindex $pats $i] @@ -139,25 +133,11 @@ gdb_test_ptr "p/a val.oct" "" "" "0x77053977" "0xa72ee53977053977" gdb_test "p/c val.oct" "'w'" if { $sizeof_double == 8 || $sizeof_long_double == 8 } { - # ARM FPA floating point numbers are not strictly little endian or big - # endian, but a hybrid. They are in little endian format with the two - # words swapped in big endian format. - # EABI targets default to natural-endian VFP format. - - if { ([istarget "arm*-*-*"]) \ - && !([istarget "*-*-*eabi*"] || \ - [istarget "*-*-mingw32ce*"] || \ - [istarget "*-*-openbsd*"]) } then { - # assume the long long represents a floating point double in ARM format - gdb_test "p/f val.oct" "2.1386676354387559e\\+265" - } else { - # assume the long long represents a floating point double in little - # endian format - gdb_test "p/f val.oct" "-5.9822653797615723e-120" - } + set re_val_oct_f [string_to_regexp "-5.9822653797615723e-120"] } else { - gdb_test "p/f val.oct" "-2.42716126e-15" + set re_val_oct_f [string_to_regexp "-2.42716126e-15"] } +gdb_test "p/f val.oct" $re_val_oct_f gdb_test_char "p/x *(char *)c" "0x1" gdb_test_char "p/d *(char *)c" "1" @@ -204,7 +184,7 @@ gdb_test_ptr "p/a *(long long *)ll" "" "" "0x89abcdef" "0x123456789abcdef" gdb_test_long_long "p/f *(long long *)ll" "" "" "" "3.5127005640885037e-303" gdb_test_long_long "p/c *(long long *)ll" "" "" "" "-17 '.*'" -# Implict Word size (except for a, c, and f) +# Implicit Word size (except for a, c, and f) gdb_test "x/w w" ".*" "set examine size to w" gdb_test "x/x w" "0x01234567" @@ -214,13 +194,9 @@ gdb_test "x/o w" "0110642547" gdb_test "x/t w" "00000001001000110100010101100111" gdb_test_xptr "x/a" { b "" } { h "" } { w "0x1234567" } { g "0x123456789abcdef" } gdb_test "x/c b" "1 '.001'" -if { $sizeof_double == 8 || $sizeof_long_double == 8 } { - gdb_test "x/f &val.oct" "-5.9822653797615723e-120" -} else { - gdb_test "x/f &val.oct" "-2.42716126e-15" -} +gdb_test "x/f &val.oct" $re_val_oct_f -# Implict Giant size (except for a, c, and f) +# Implicit Giant size (except for a, c, and f) gdb_test "x/g g" ".*" "set examine size to g" gdb_test "x/2x g" "0x0123456789abcdef.*0xa72ee53977053977" @@ -231,9 +207,9 @@ gdb_test "x/2t g" "0000000100100011010001010110011110001001101010111100110111101 gdb_test_xptr "x/2a" { b "" } { h "" } { w "0x1234567.*0xa72ee539" } { g "0x123456789abcdef.*0xa72ee53977053977" } gdb_test "x/2c b" "1 '.001'.*-89 '.\[0-9\]*'" if { $sizeof_double == 8 || $sizeof_long_double == 8 } { - gdb_test "x/2f &val.oct" "-5.9822653797615723e-120.*-5.9041889495880968e-100" + gdb_test "x/2f &val.oct" "$re_val_oct_f.*-5.9041889495880968e-100" } else { - gdb_test "x/2f &val.oct" "-2.42716126e-15" + gdb_test "x/2f &val.oct" "$re_val_oct_f" } # Explicit sizes, and two memory locations ... @@ -272,7 +248,7 @@ gdb_test "x/2go g" "04432126361152746757.*01234567123456701234567" gdb_test "x/2gt g" "0000000100100011010001010110011110001001101010111100110111101111.*1010011100101110111001010011100101110111000001010011100101110111" gdb_test_ptr "x/2ga g" "" "" "0x89abcdef.*0x77053977" "0x123456789abcdef.*0xa72ee53977053977" gdb_test "x/2gc g" "-17 '.\[0-9\]*'.*119 'w'" -gdb_test "x/2gf g" "3.5127005640885037e-303.*-5.9822653797615723e-120" +gdb_test "x/2gf g" "3.5127005640885037e-303.*$re_val_oct_f" # Repeat behavior. gdb_test "x/2bx b" "0x01.*0xa7" "set up for repeat" diff --git a/gdb/testsuite/gdb.base/longest-types.c b/gdb/testsuite/gdb.base/longest-types.c index 73fd7ab..304982b 100644 --- a/gdb/testsuite/gdb.base/longest-types.c +++ b/gdb/testsuite/gdb.base/longest-types.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/longest-types.exp b/gdb/testsuite/gdb.base/longest-types.exp index 4390908..5b8c16d 100644 --- a/gdb/testsuite/gdb.base/longest-types.exp +++ b/gdb/testsuite/gdb.base/longest-types.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/longjmp-until-in-main.c b/gdb/testsuite/gdb.base/longjmp-until-in-main.c index 2cd21aa..eb6b3f5 100644 --- a/gdb/testsuite/gdb.base/longjmp-until-in-main.c +++ b/gdb/testsuite/gdb.base/longjmp-until-in-main.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/longjmp-until-in-main.exp b/gdb/testsuite/gdb.base/longjmp-until-in-main.exp index 2e308f5..8ce647b 100644 --- a/gdb/testsuite/gdb.base/longjmp-until-in-main.exp +++ b/gdb/testsuite/gdb.base/longjmp-until-in-main.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/longjmp.c b/gdb/testsuite/gdb.base/longjmp.c index e3b0249..91552b4 100644 --- a/gdb/testsuite/gdb.base/longjmp.c +++ b/gdb/testsuite/gdb.base/longjmp.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/longjmp.exp b/gdb/testsuite/gdb.base/longjmp.exp index 00a3fcb..90661db 100644 --- a/gdb/testsuite/gdb.base/longjmp.exp +++ b/gdb/testsuite/gdb.base/longjmp.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -26,7 +26,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb } proc do_test { with_probes } { - clean_restart ${::binfile} + clean_restart $::testfile if { !$with_probes } { gdb_test "maint ignore-probes libc ^longjmp$" diff --git a/gdb/testsuite/gdb.base/m32r.ld b/gdb/testsuite/gdb.base/m32r.ld index 3358f4c..1e917c8 100644 --- a/gdb/testsuite/gdb.base/m32r.ld +++ b/gdb/testsuite/gdb.base/m32r.ld @@ -85,7 +85,7 @@ SECTIONS { *(.data) *(.gnu.linkonce.d*) - _ovly_table = .; + _ovly_table = .; _ovly0_entry = .; LONG(ABSOLUTE(ADDR(.ovly0))); LONG(SIZEOF(.ovly0)); diff --git a/gdb/testsuite/gdb.base/macro-source-path.c b/gdb/testsuite/gdb.base/macro-source-path.c index cf440c1..b1e9eba 100644 --- a/gdb/testsuite/gdb.base/macro-source-path.c +++ b/gdb/testsuite/gdb.base/macro-source-path.c @@ -1,4 +1,4 @@ -/* Copyright 2022-2024 Free Software Foundation, Inc. +/* Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/macro-source-path.exp b/gdb/testsuite/gdb.base/macro-source-path.exp index 33fb40f..9c84227 100644 --- a/gdb/testsuite/gdb.base/macro-source-path.exp +++ b/gdb/testsuite/gdb.base/macro-source-path.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -33,7 +33,7 @@ require {!is_remote host} # Set the current working directory to $out/cwd, so that we can test compiling # using relative paths. -set out_dir [standard_output_file ""] +set out_dir [build_standard_output_file ""] file mkdir $out_dir/cwd file mkdir $out_dir/other file copy -force $srcdir/$subdir/$srcfile $out_dir/cwd @@ -53,7 +53,8 @@ proc test { src name } { return } - clean_restart $binfile + clean_restart + gdb_load [host_file_normalize $binfile] if { ![runto_main] } { return diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp index 388b2fc..1d75281 100644 --- a/gdb/testsuite/gdb.base/macscp.exp +++ b/gdb/testsuite/gdb.base/macscp.exp @@ -1,5 +1,5 @@ # Test macro scoping. -# Copyright 2002-2024 Free Software Foundation, Inc. +# Copyright 2002-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 @@ -29,7 +29,7 @@ if {[gdb_compile "${srcdir}/${subdir}/macscp1.c" "${objfile}" \ return -1 } -clean_restart ${binfile} +clean_restart $testfile # Ask GDB to show the current definition of MACRO, and return a list @@ -43,7 +43,7 @@ clean_restart ${binfile} # # If GDB complains that it doesn't have any information about # preprocessor macro definitions, return the string `no-macro-info'. -# +# # If expect times out waiting for GDB, we return the string `timeout'. # # If GDB's output doesn't otherwise match what we're expecting, we @@ -66,87 +66,87 @@ proc info_macro {macro} { if {$debug_me} {exp_internal 1} gdb_expect { - -re "Defined at \[^\r\n\]*(${filepat}):${nonzero}\[\r\n\]" { - # `location' and `definition' should be empty when we see - # this message. - if {[llength $location] == 0 && [llength $definition] == 0} { - set location $expect_out(1,string) - exp_continue - } else { - # Exit this expect loop, with a result indicating failure. - set definition {} - } - } - -re "The symbol `${macro}' has no definition as a C/C\\+\\+ preprocessor macro\[^\r\n\]*\[\r\n\]" { - # `location' and `definition' should be empty when we see - # this message. - if {[llength $location] == 0 && [llength $definition] == 0} { - set definition undefined - exp_continue - } else { - # Exit this expect loop, with a result indicating failure. - set definition {} - } - } - -re "^\[\r\n\]* included at \[^\r\n\]*(${filepat}):${nonzero}\[\r\n\]" { - # `location' should *not* be empty when we see this - # message. It should have recorded at least the initial - # `Defined at ' message (for definitions) or ` at' message - # (for undefined symbols). - if {[llength $location] != 0} { - lappend location $expect_out(1,string) - exp_continue - } else { - # Exit this expect loop, with a result indicating failure. - set definition {} - } - } - -re "^\[\r\n\]*at \[^\r\n\]*(${filepat}):${nonzero}\[\r\n\]" { - # This appears after a `has no definition' message. - # `location' should be empty when we see it. - if {[string compare $definition undefined] == 0 \ - && [llength $location] == 0} { - set location $expect_out(1,string) - exp_continue - } else { - # Exit this expect loop, with a result indicating failure. - set definition {} - } - } - -re "#define ${macro} (\[^\r\n\]*)\[\r\n\]" { - # `definition' should be empty when we see this message. - if {[string compare $definition ""] == 0} { - set definition $expect_out(1,string) - exp_continue - } else { - # Exit this expect loop, with a result indicating failure. - set definition {} - } - } - -re "has no preprocessor macro information.*$gdb_prompt $" { - set definition no-macro-info - } - -re "$gdb_prompt $" { - # Exit the expect loop; let the existing value of `definition' - # indicate failure or success. - } - timeout { - set definition timeout - } + -re "Defined at \[^\r\n\]*(${filepat}):${nonzero}\[\r\n\]" { + # `location' and `definition' should be empty when we see + # this message. + if {[llength $location] == 0 && [llength $definition] == 0} { + set location $expect_out(1,string) + exp_continue + } else { + # Exit this expect loop, with a result indicating failure. + set definition {} + } + } + -re "The symbol `${macro}' has no definition as a C/C\\+\\+ preprocessor macro\[^\r\n\]*\[\r\n\]" { + # `location' and `definition' should be empty when we see + # this message. + if {[llength $location] == 0 && [llength $definition] == 0} { + set definition undefined + exp_continue + } else { + # Exit this expect loop, with a result indicating failure. + set definition {} + } + } + -re "^\[\r\n\]* included at \[^\r\n\]*(${filepat}):${nonzero}\[\r\n\]" { + # `location' should *not* be empty when we see this + # message. It should have recorded at least the initial + # `Defined at ' message (for definitions) or ` at' message + # (for undefined symbols). + if {[llength $location] != 0} { + lappend location $expect_out(1,string) + exp_continue + } else { + # Exit this expect loop, with a result indicating failure. + set definition {} + } + } + -re "^\[\r\n\]*at \[^\r\n\]*(${filepat}):${nonzero}\[\r\n\]" { + # This appears after a `has no definition' message. + # `location' should be empty when we see it. + if {[string compare $definition undefined] == 0 \ + && [llength $location] == 0} { + set location $expect_out(1,string) + exp_continue + } else { + # Exit this expect loop, with a result indicating failure. + set definition {} + } + } + -re "#define ${macro} (\[^\r\n\]*)\[\r\n\]" { + # `definition' should be empty when we see this message. + if {[string compare $definition ""] == 0} { + set definition $expect_out(1,string) + exp_continue + } else { + # Exit this expect loop, with a result indicating failure. + set definition {} + } + } + -re "has no preprocessor macro information.*$gdb_prompt $" { + set definition no-macro-info + } + -re "$gdb_prompt $" { + # Exit the expect loop; let the existing value of `definition' + # indicate failure or success. + } + timeout { + set definition timeout + } } if {$debug_me} {exp_internal 0} switch -exact -- $definition { - no-macro-info { return no-macro-info } - timeout { return timeout } - undefined { return undefined } - default { - if {[llength $location] >= 1} { - return [concat $location [list $definition]] - } else { - return {} - } - } + no-macro-info { return no-macro-info } + timeout { return timeout } + undefined { return undefined } + default { + if {[llength $location] >= 1} { + return [concat $location [list $definition]] + } else { + return {} + } + } } } @@ -158,24 +158,24 @@ proc info_macro {macro} { proc check_macro {macro expected where} { set func_def [info_macro $macro] if {[string compare $func_def $expected] == 0} { - pass "info macro $macro $where" + pass "info macro $macro $where" } else { - switch -exact -- $func_def { - no-macro-info { - xfail "executable includes no macro debugging information" - return 1 - } + switch -exact -- $func_def { + no-macro-info { + xfail "executable includes no macro debugging information" + return 1 + } undefined { fail "info macro $macro $where (undefined)" return 1 } - timeout { - fail "info macro $macro $where (timeout)" - } - default { - fail "info macro $macro $where" - } - } + timeout { + fail "info macro $macro $where (timeout)" + } + default { + fail "info macro $macro $where" + } + } } return 0 } @@ -207,7 +207,7 @@ if {$macro_support == 0} { unsupported "skipping test because debug information does not include macro information." return 0 } - + list_and_check_macro main WHERE {macscp1.c {before macscp1_3}} list_and_check_macro macscp2_2 WHERE {macscp2.h macscp1.c {before macscp2_2}} list_and_check_macro macscp3_2 WHERE {macscp3.h macscp1.c {before macscp3_2}} @@ -230,14 +230,14 @@ gdb_test "info macro __LINE__" "#define __LINE__ 26" \ gdb_test "list macscp4_2_from_macscp2" ".*macscp4_2_, MACSCP4_INCLUSION.*" switch -exact -- [info_macro WHERE] { {macscp4.h macscp2.h macscp1.c {before macscp4_2_..., from macscp2.h}} { - pass "info macro WHERE after `list macscp_4_2_from_macscp2'" + pass "info macro WHERE after `list macscp_4_2_from_macscp2'" } {macscp4.h macscp3.h macscp1.c {before macscp4_2_..., from macscp3.h}} { - setup_kfail "gdb/7660" *-*-* - fail "info macro WHERE after `list macscp_4_2_from_macscp2' (gdb/7660)" + setup_kfail "gdb/7660" *-*-* + fail "info macro WHERE after `list macscp_4_2_from_macscp2' (gdb/7660)" } - timeout { - fail "info macro WHERE after `list macscp_4_2_from_macscp2' (timeout)" + timeout { + fail "info macro WHERE after `list macscp_4_2_from_macscp2' (timeout)" } default { fail "info macro WHERE after `list macscp_4_2_from_macscp2'" } } @@ -245,14 +245,14 @@ switch -exact -- [info_macro WHERE] { gdb_test "list macscp4_2_from_macscp3" ".*macscp4_2_, MACSCP4_INCLUSION.*" switch -exact -- [info_macro WHERE] { {macscp4.h macscp3.h macscp1.c {before macscp4_2_..., from macscp3.h}} { - pass "info macro WHERE after `list macscp_4_2_from_macscp3'" + pass "info macro WHERE after `list macscp_4_2_from_macscp3'" } {macscp4.h macscp2.h macscp1.c {before macscp4_2_..., from macscp2.h}} { - setup_kfail "gdb/7660" *-*-* - fail "info macro WHERE after `list macscp_4_2_from_macscp3' (gdb/7660)" + setup_kfail "gdb/7660" *-*-* + fail "info macro WHERE after `list macscp_4_2_from_macscp3' (gdb/7660)" } timeout { - fail "info macro WHERE after `list macscp_4_2_from_macscp3' (timeout)" + fail "info macro WHERE after `list macscp_4_2_from_macscp3' (timeout)" } default { fail "info macro WHERE after `list macscp_4_2_from_macscp3'" } } @@ -273,52 +273,52 @@ switch -exact -- [info_macro WHERE] { set funcs { { - macscp1_1 - {macscp1.c {before macscp1_1}} + macscp1_1 + {macscp1.c {before macscp1_1}} } { - macscp2_1 - {macscp2.h macscp1.c {before macscp2_1}} + macscp2_1 + {macscp2.h macscp1.c {before macscp2_1}} } { - macscp4_1_from_macscp2 - {macscp4.h macscp2.h macscp1.c {before macscp4_1_..., from macscp2.h}} - {macscp4.h macscp3.h macscp1.c {before macscp4_1_..., from macscp3.h}} + macscp4_1_from_macscp2 + {macscp4.h macscp2.h macscp1.c {before macscp4_1_..., from macscp2.h}} + {macscp4.h macscp3.h macscp1.c {before macscp4_1_..., from macscp3.h}} } { - macscp4_2_from_macscp2 - {macscp4.h macscp2.h macscp1.c {before macscp4_2_..., from macscp2.h}} - {macscp4.h macscp3.h macscp1.c {before macscp4_2_..., from macscp3.h}} + macscp4_2_from_macscp2 + {macscp4.h macscp2.h macscp1.c {before macscp4_2_..., from macscp2.h}} + {macscp4.h macscp3.h macscp1.c {before macscp4_2_..., from macscp3.h}} } { - macscp2_2 - {macscp2.h macscp1.c {before macscp2_2}} + macscp2_2 + {macscp2.h macscp1.c {before macscp2_2}} } { - macscp1_2 - {macscp1.c {before macscp1_2}} + macscp1_2 + {macscp1.c {before macscp1_2}} } { - macscp3_1 - {macscp3.h macscp1.c {before macscp3_1}} + macscp3_1 + {macscp3.h macscp1.c {before macscp3_1}} } { - macscp4_1_from_macscp3 - {macscp4.h macscp3.h macscp1.c {before macscp4_1_..., from macscp3.h}} - {macscp4.h macscp2.h macscp1.c {before macscp4_1_..., from macscp2.h}} + macscp4_1_from_macscp3 + {macscp4.h macscp3.h macscp1.c {before macscp4_1_..., from macscp3.h}} + {macscp4.h macscp2.h macscp1.c {before macscp4_1_..., from macscp2.h}} } { - macscp4_2_from_macscp3 - {macscp4.h macscp3.h macscp1.c {before macscp4_2_..., from macscp3.h}} - {macscp4.h macscp2.h macscp1.c {before macscp4_2_..., from macscp2.h}} + macscp4_2_from_macscp3 + {macscp4.h macscp3.h macscp1.c {before macscp4_2_..., from macscp3.h}} + {macscp4.h macscp2.h macscp1.c {before macscp4_2_..., from macscp2.h}} } { - macscp3_2 - {macscp3.h macscp1.c {before macscp3_2}} + macscp3_2 + {macscp3.h macscp1.c {before macscp3_2}} } { - macscp1_3 - {macscp1.c {before macscp1_3}} + macscp1_3 + {macscp1.c {before macscp1_3}} } } @@ -357,71 +357,71 @@ for {set i 0} {$i < [llength $funcs]} {incr i} { # Check the macro WHERE. set result [info_macro WHERE] if {[string compare $result $expected] == 0} { - pass "info macro WHERE stopped in $func" + pass "info macro WHERE stopped in $func" } elseif {[string compare $result $kfail_expected] == 0} { - setup_kfail "gdb/7660" *-*-* - fail "info macro WHERE stopped in $func (gdb/7660)" + setup_kfail "gdb/7660" *-*-* + fail "info macro WHERE stopped in $func (gdb/7660)" } elseif {[string compare $result timeout] == 0} { - fail "info macro WHERE stopped in $func (timeout)" + fail "info macro WHERE stopped in $func (timeout)" } else { - fail "info macro WHERE stopped in $func" + fail "info macro WHERE stopped in $func" } # Check that the BEFORE_<func> macros for all prior functions are # #defined, and that those for all subsequent functions are not. for {set j 0} {$j < [llength $funcs]} {incr j} { - if {$j != $i} { - set func_j_entry [lindex $funcs $j] - set func_j [lindex $func_j_entry 0] - - set before_macro "BEFORE_[string toupper $func_j]" - set test_name \ - "$before_macro defined/undefined when stopped at $func" - set result [info_macro $before_macro] - - if {$j < $i} { - if {[llength $result] >= 2 && \ - [string compare [lindex $result end] {}] == 0} { - pass $test_name - } elseif {[string compare $result timeout] == 0} { - fail "$test_name (timeout)" - } else { - maybe_kfail $func "$test_name" - } - } elseif {$j > $i} { - switch -- [lindex $result end] { - undefined { pass $test_name } - timeout { fail "$test_name (timeout)" } - default { - maybe_kfail $func "$test_name" - } - } - } - - set until_macro "UNTIL_[string toupper $func_j]" - set test_name \ - "$until_macro defined/undefined when stopped at $func" - set result [info_macro $until_macro] - - if {$j <= $i} { - switch -- [lindex $result end] { - undefined { pass $test_name } - timeout { fail "$test_name (timeout)" } - default { - maybe_kfail $func "$test_name" - } - } - } elseif {$j > $i} { - if {[llength $result] >= 2 && \ - [string compare [lindex $result end] {}] == 0} { - pass $test_name - } elseif {[string compare $result timeout] == 0} { - fail "$test_name (timeout)" - } else { - maybe_kfail $func "$test_name" - } - } - } + if {$j != $i} { + set func_j_entry [lindex $funcs $j] + set func_j [lindex $func_j_entry 0] + + set before_macro "BEFORE_[string toupper $func_j]" + set test_name \ + "$before_macro defined/undefined when stopped at $func" + set result [info_macro $before_macro] + + if {$j < $i} { + if {[llength $result] >= 2 && \ + [string compare [lindex $result end] {}] == 0} { + pass $test_name + } elseif {[string compare $result timeout] == 0} { + fail "$test_name (timeout)" + } else { + maybe_kfail $func "$test_name" + } + } elseif {$j > $i} { + switch -- [lindex $result end] { + undefined { pass $test_name } + timeout { fail "$test_name (timeout)" } + default { + maybe_kfail $func "$test_name" + } + } + } + + set until_macro "UNTIL_[string toupper $func_j]" + set test_name \ + "$until_macro defined/undefined when stopped at $func" + set result [info_macro $until_macro] + + if {$j <= $i} { + switch -- [lindex $result end] { + undefined { pass $test_name } + timeout { fail "$test_name (timeout)" } + default { + maybe_kfail $func "$test_name" + } + } + } elseif {$j > $i} { + if {[llength $result] >= 2 && \ + [string compare [lindex $result end] {}] == 0} { + pass $test_name + } elseif {[string compare $result timeout] == 0} { + fail "$test_name (timeout)" + } else { + maybe_kfail $func "$test_name" + } + } + } } } diff --git a/gdb/testsuite/gdb.base/main-c.exp b/gdb/testsuite/gdb.base/main-c.exp index 2c79f0e..413b64b 100644 --- a/gdb/testsuite/gdb.base/main-c.exp +++ b/gdb/testsuite/gdb.base/main-c.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/main-psymtab.exp b/gdb/testsuite/gdb.base/main-psymtab.exp index cc0ca65..24227b0 100644 --- a/gdb/testsuite/gdb.base/main-psymtab.exp +++ b/gdb/testsuite/gdb.base/main-psymtab.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/main.c b/gdb/testsuite/gdb.base/main.c index 7b7b92a..a8d19f2 100644 --- a/gdb/testsuite/gdb.base/main.c +++ b/gdb/testsuite/gdb.base/main.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.c b/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.c index 2551c40..f324d86 100644 --- a/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.c +++ b/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.exp b/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.exp index 446d7a9..aaf3a8b 100644 --- a/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.exp +++ b/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.h b/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.h index 957b6a4..763e51e 100644 --- a/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.h +++ b/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.h @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.c b/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.c index 35b2064..f0034ef 100644 --- a/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.c +++ b/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp b/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp index 97e5d99..5d45caf 100644 --- a/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp +++ b/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2024 Free Software Foundation, Inc. +# Copyright (C) 2024-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 @@ -201,7 +201,7 @@ gdb_test "maint info blocks" [make_blocks_result normal_func \ inline_func_a inline_func_b] \ "maint info blocks using stored \$pc, inferior still running" -clean_restart $binfile +clean_restart $testfile # Use the recorded $pc value to check inline frames when the inferior # is not executing. diff --git a/gdb/testsuite/gdb.base/maint-info-sections.exp b/gdb/testsuite/gdb.base/maint-info-sections.exp index da9cdd8..8b2a558 100644 --- a/gdb/testsuite/gdb.base/maint-info-sections.exp +++ b/gdb/testsuite/gdb.base/maint-info-sections.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 diff --git a/gdb/testsuite/gdb.base/maint-print-frame-id.c b/gdb/testsuite/gdb.base/maint-print-frame-id.c index 63970ec..82891f1 100644 --- a/gdb/testsuite/gdb.base/maint-print-frame-id.c +++ b/gdb/testsuite/gdb.base/maint-print-frame-id.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/maint-print-frame-id.exp b/gdb/testsuite/gdb.base/maint-print-frame-id.exp index 257a164..6d94c72 100644 --- a/gdb/testsuite/gdb.base/maint-print-frame-id.exp +++ b/gdb/testsuite/gdb.base/maint-print-frame-id.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/maint-target-async-off.c b/gdb/testsuite/gdb.base/maint-target-async-off.c index fb4ffc2..f2b8dba 100644 --- a/gdb/testsuite/gdb.base/maint-target-async-off.c +++ b/gdb/testsuite/gdb.base/maint-target-async-off.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/maint-target-async-off.exp b/gdb/testsuite/gdb.base/maint-target-async-off.exp index 87c7116..a86a21b 100644 --- a/gdb/testsuite/gdb.base/maint-target-async-off.exp +++ b/gdb/testsuite/gdb.base/maint-target-async-off.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/maint-test-remote-args.exp b/gdb/testsuite/gdb.base/maint-test-remote-args.exp new file mode 100644 index 0000000..6cd3006 --- /dev/null +++ b/gdb/testsuite/gdb.base/maint-test-remote-args.exp @@ -0,0 +1,40 @@ +# Copyright 2024-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 'maint test-remote-args' command. +# +# We do minimal testing in here. If you are thinking of adding a new +# test here then you are most likely adding the test in the wrong +# place. Remote argument testing is checked in the following test +# scripts: gdb.base/args.exp, gdb.base/inferior-args.exp, +# gdb.base/startup-with-shell.exp, and gdb.python/py-inferior.exp. +# The test gdb.gdb/unittest.exp also runs 'maint selftest +# remote-args', which are the remote argument self tests. +# +# If you have a new test for an argument that was being passed +# incorrectly, then add the test to one of those scripts. +# +# This file is ONLY for validating that the 'maint test-remote-args' +# command itself is working. + +gdb_start + +gdb_test "maint test-remote-args a b c" \ + [multi_line \ + "Input \\(a b c\\)" \ + " \\(a\\)" \ + " \\(b\\)" \ + " \\(c\\)" \ + "Output \\(a b c\\)"] diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp index c77612d..404eeab 100644 --- a/gdb/testsuite/gdb.base/maint.exp +++ b/gdb/testsuite/gdb.base/maint.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -52,6 +52,40 @@ if {[prepare_for_testing "failed to prepare" $testfile \ return -1 } +# Check "maint set per-command" warnings. We do this early so that +# the following tests don't need to expect them, as GDB only warns +# once. + +with_test_prefix "warnings" { + # Potential warning given by "maint set per-command time". + set maybe_per_command_warning \ + "(?:warning: per-thread run time information not available on this platform)?" + + # This one should not issue the "per-command time" warning. + with_test_prefix "per-command space" { + gdb_test_no_output "mt set per-command space on" + gdb_test_no_output "mt set per-command space off" + } + + # These might warn. "per-command on" enables all sub commands, so + # might trigger the "per-command time" warning. + foreach cmd {"per-command" "per-command time"} { + with_test_prefix $cmd { + # GDB only warns once, so restart between commands. + clean_restart $testfile + gdb_test "mt set $cmd on" "$maybe_per_command_warning" + gdb_test "mt set $cmd off" "command started" + gdb_test_no_output "mt set $cmd on" \ + "mt set $cmd on, again" + gdb_test "mt set $cmd off" "command started" \ + "mt set $cmd off, again" + } + } + + # We've already warned once above, so the following tests don't + # need to expect the warning. +} + set readnow_p [readnow] # The commands we test here produce many lines of output; disable "press @@ -75,14 +109,14 @@ gdb_test_multiple $test $test { exp_continue } -re "\[0-9\]+\[^\r\n\]+\[0-9\]+\[^\r\n\]+\[0-9\]+\[^\r\n\]+\[0-9\]+\[^\r\n\]+\r\n" { - set saw_registers 1 - exp_continue + set saw_registers 1 + exp_continue } -re "^\\*\[0-9\]+\[^\r\n\]+\r\n" { - exp_continue + exp_continue } -re "$gdb_prompt $" { - gdb_assert { $saw_registers && $saw_headers } $test + gdb_assert { $saw_registers && $saw_headers } $test } } @@ -144,7 +178,7 @@ if { $index_cache_misses == 0 && $using_index_cache } { set have_gdb_index 1 } -set have_psyms [expr ! ( $have_gdb_index || $readnow_p )] +set have_psyms [expr {! ( $have_gdb_index || $readnow_p )}] # # this command does not produce any output @@ -188,9 +222,9 @@ gdb_test "maint set per-command off" \ # The timeout value is raised, because printing all the symbols and # statistical information about Cygwin and Windows libraries takes a lot # of time. -if [istarget "*-*-cygwin*"] { +if {[istarget "*-*-cygwin*"]} { set oldtimeout $timeout - set timeout [expr $timeout + 500] + set timeout [expr {$timeout + 500}] } set re \ @@ -205,8 +239,8 @@ set re \ "( Number of \"partial\" symbols read: $decimal" \ ")?( Number of psym tables \\(not yet expanded\\): $decimal" \ ")?( Total memory used for psymbol cache: $decimal" \ - ")?( Number of read CUs: $decimal" \ - " Number of unread CUs: $decimal" \ + ")?( Number of read units: $decimal" \ + " Number of unread units: $decimal" \ ")? Total memory used for objfile obstack: $decimal" \ " Total memory used for BFD obstack: $decimal" \ " Total memory used for string cache: $decimal" \ @@ -253,7 +287,7 @@ gdb_test_multiple "$cmd $re" "$cmd" -lbl { } proc maint_pass_if {val name} { - if $val { pass $name } else { fail $name } + if {$val} { pass $name } else { fail $name } } maint_pass_if $header "maint print objfiles: header" @@ -339,24 +373,24 @@ foreach { test_name command } $test_list { set msg "maint print type" gdb_test_multiple "maint print type argc" $msg { -re "type node $hex\r\nname .int. \\($hex\\)\r\ncode $hex \\(TYPE_CODE_INT\\)\r\nlength \[24\]\r\nobjfile $hex\r\ntarget_type $hex\r\npointer_type $hex\r\nreference_type $hex\r\ntype_chain $hex\r\ninstance_flags $hex\r\nflags\r\nnfields 0 $hex\r\n$gdb_prompt $" { - pass $msg + pass $msg } } -if [istarget "hppa*-*-11*"] { +if {[istarget "hppa*-*-11*"]} { setup_xfail hppa*-*-*11* CLLbs14860 gdb_test_multiple "maint print unwind &main" "maint print unwind" { - -re ".*unwind_table_entry \\($hex\\):\r\n\tregion_start = $hex <main>\r\n\tregion_end = $hex <main\\+\[0-9\]*>\r\n\tflags = Args_stored Save_RP\r\n\tRegion_description = $hex\r\n\tEntry_FR = $hex\r\n\tEntry_GR = $hex\r\n\tTotal_frame_size = $hex\r\n$gdb_prompt $" { + -re ".*unwind_table_entry \\($hex\\):\r\n\tregion_start = $hex <main>\r\n\tregion_end = $hex <main\\+\[0-9\]*>\r\n\tflags = Args_stored Save_RP\r\n\tRegion_description = $hex\r\n\tEntry_FR = $hex\r\n\tEntry_GR = $hex\r\n\tTotal_frame_size = $hex\r\n$gdb_prompt $" { pass "maint print unwind" } - -re ".*unwind_table_entry \\($hex\\):\r\n\tregion_start = $hex <main>\r\n\tregion_end = $hex <main\\+\[0-9\]*>\r\n\tflags = Args_stored Save_RP\r\n\tFLD = $hex\r\n\tFLD = $hex\r\n\tFLD = $hex\r\n\tFLD = $hex\r\n$gdb_prompt $" { + -re ".*unwind_table_entry \\($hex\\):\r\n\tregion_start = $hex <main>\r\n\tregion_end = $hex <main\\+\[0-9\]*>\r\n\tflags = Args_stored Save_RP\r\n\tFLD = $hex\r\n\tFLD = $hex\r\n\tFLD = $hex\r\n\tFLD = $hex\r\n$gdb_prompt $" { xfail "maint print unwind" } } } set oldtimeout $timeout -set timeout [expr $timeout + 300] +set timeout [expr {$timeout + 300}] set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] @@ -371,7 +405,7 @@ gdb_test_multiple "maint info breakpoints" "maint info breakpoints" { gdb_test "maint print" \ "List.*unambiguous\\..*" \ - "maint print w/o args" + "maint print w/o args" gdb_test "maint info" \ "List.*unambiguous\\..*" \ @@ -471,7 +505,7 @@ test_prefix_command_help {"maint" "maintenance"} { } #set oldtimeout $timeout -#set timeout [expr $timeout + 300] +#set timeout [expr {$timeout + 300}] gdb_test_multiple "maint dump-me" "maint dump-me" { -re "Should GDB dump core.*\\(y or n\\) $" { @@ -487,7 +521,7 @@ send_gdb "maint internal-error\n" gdb_expect { -re "A problem internal to GDB has been detected" { pass "maint internal-error" - if [gdb_internal_error_resync] { + if {[gdb_internal_error_resync]} { pass "internal-error resync" } else { fail "internal-error resync" @@ -513,4 +547,9 @@ gdb_test_no_output "maint print symbols" gdb_test_no_output "maint print msymbols" gdb_test_no_output "maint print psymbols" +gdb_test "maint canonicalize int short" "canonical = short" +gdb_test "maint canonicalize fn<ty<int>>" \ + "canonical = fn<ty<int> >" +gdb_test "maint canonical unsigned int" "No change\\." + gdb_exit diff --git a/gdb/testsuite/gdb.base/many-completions.exp b/gdb/testsuite/gdb.base/many-completions.exp index c6215ed..340e38c 100644 --- a/gdb/testsuite/gdb.base/many-completions.exp +++ b/gdb/testsuite/gdb.base/many-completions.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/many-headers.c b/gdb/testsuite/gdb.base/many-headers.c index 25d21ae..5214abf 100644 --- a/gdb/testsuite/gdb.base/many-headers.c +++ b/gdb/testsuite/gdb.base/many-headers.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/many-headers.exp b/gdb/testsuite/gdb.base/many-headers.exp index 349b47f..5e022da 100644 --- a/gdb/testsuite/gdb.base/many-headers.exp +++ b/gdb/testsuite/gdb.base/many-headers.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -33,6 +33,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} { # Generate core file. set corefile [core_find $binfile] if {$corefile == ""} { + untested "unable to create or find corefile" return 0 } diff --git a/gdb/testsuite/gdb.base/max-depth-c++.exp b/gdb/testsuite/gdb.base/max-depth-c++.exp index 4b31bce..2891f7f 100644 --- a/gdb/testsuite/gdb.base/max-depth-c++.exp +++ b/gdb/testsuite/gdb.base/max-depth-c++.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/max-depth-c.exp b/gdb/testsuite/gdb.base/max-depth-c.exp index d9018b3..36353e3 100644 --- a/gdb/testsuite/gdb.base/max-depth-c.exp +++ b/gdb/testsuite/gdb.base/max-depth-c.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/max-depth.c b/gdb/testsuite/gdb.base/max-depth.c index 7e46b13..38fc305 100644 --- a/gdb/testsuite/gdb.base/max-depth.c +++ b/gdb/testsuite/gdb.base/max-depth.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 @@ -143,8 +143,8 @@ struct s9 int a; struct { - int b; - int c; + int b; + int c; }; } d1; }; @@ -174,8 +174,8 @@ struct s10 int a; struct { - int b[10]; - int c; + int b[10]; + int c; }; } d1; }; diff --git a/gdb/testsuite/gdb.base/max-depth.exp.tcl b/gdb/testsuite/gdb.base/max-depth.exp.tcl index 9c6fc61..22bf180 100644 --- a/gdb/testsuite/gdb.base/max-depth.exp.tcl +++ b/gdb/testsuite/gdb.base/max-depth.exp.tcl @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -30,12 +30,12 @@ proc compile_and_run_tests { lang } { lappend flags "additional_flags=-std=c++11" } - if { [prepare_for_testing "failed to prepare" "${binfile}" "${srcfile}" "${flags}"] } { + if { [prepare_for_testing "failed to prepare" $testfile $srcfile $flags] } { return 0 } # Advance to main. - if { ![runto_main] } then { + if { ![runto_main] } { return 0 } diff --git a/gdb/testsuite/gdb.base/max-value-size.c b/gdb/testsuite/gdb.base/max-value-size.c index a831aca..f351de7 100644 --- a/gdb/testsuite/gdb.base/max-value-size.c +++ b/gdb/testsuite/gdb.base/max-value-size.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2016-2024 Free Software Foundation, Inc. + Copyright (C) 2016-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 diff --git a/gdb/testsuite/gdb.base/max-value-size.exp b/gdb/testsuite/gdb.base/max-value-size.exp index e513983..09591b3 100644 --- a/gdb/testsuite/gdb.base/max-value-size.exp +++ b/gdb/testsuite/gdb.base/max-value-size.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2024 Free Software Foundation, Inc. +# Copyright (C) 2016-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 diff --git a/gdb/testsuite/gdb.base/memattr.c b/gdb/testsuite/gdb.base/memattr.c index 0084ce9..49774f3 100644 --- a/gdb/testsuite/gdb.base/memattr.c +++ b/gdb/testsuite/gdb.base/memattr.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/memattr.exp b/gdb/testsuite/gdb.base/memattr.exp index bba00cc..b6afb4f 100644 --- a/gdb/testsuite/gdb.base/memattr.exp +++ b/gdb/testsuite/gdb.base/memattr.exp @@ -1,4 +1,4 @@ -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/memops-watchpoint.c b/gdb/testsuite/gdb.base/memops-watchpoint.c index 0255cfb..3a40293 100644 --- a/gdb/testsuite/gdb.base/memops-watchpoint.c +++ b/gdb/testsuite/gdb.base/memops-watchpoint.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/memops-watchpoint.exp b/gdb/testsuite/gdb.base/memops-watchpoint.exp index cee2d79..09500b3 100644 --- a/gdb/testsuite/gdb.base/memops-watchpoint.exp +++ b/gdb/testsuite/gdb.base/memops-watchpoint.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 @@ -25,7 +25,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ } set linespec ${srcfile}:[gdb_get_line_number "Break here"] -if ![runto ${linespec}] { +if {![runto ${linespec}]} { return -1 } @@ -44,118 +44,63 @@ gdb_test "watch -location c\[28\]" \ # This is to allow the tests to work if there's a properly named symbol for # the function, even if there's no libc debug info. -set saw_watch_trigger 0 -set saw_function 0 -set is_supported 1 -set message "continue until memset watchpoint hits" -set watch_trigger \ +# ARRAY_RE is the array whose modification is caught by the +# watchpoint. SOURCE_FUNCTION is the function that modifies the +# array, as written in the source of the test program. FUNCTION_RE +# matches the name of the symbol that actually implements +# SOURCE_FUNCTION (e.g., memcpy may be implemented with memmove, so we +# may want to expect both). OLD_VALUE_RE and NEW_VALUE_RE match the +# old/new values when the watchpoint triggers. + +proc continue_to_watchpoint {array_re source_function function_re + old_value_re new_value_re} { + set thread_prefix_re "(?:Thread $::decimal \[^\r\n\]*hit )?" + + set saw_watch_trigger 0 + set saw_function 0 + set is_supported 1 + set watch_trigger_re \ [multi_line \ "Continuing\\." \ "" \ - "(Hardware w|W)atchpoint ${decimal}: -location a\\\[28\\\]" \ + "${thread_prefix_re}(Hardware w|W)atchpoint ${::decimal}: -location ${array_re}\\\[28\\\]" \ "" \ - "Old value = 104 'h'" \ - "New value = 0 '\\\\000'"] -gdb_test_multiple "continue" $message { - -re $watch_trigger { - set saw_watch_trigger 1 - exp_continue - } - -re ".*memset.* \\(\\) at .*:$decimal\r\n" { - set saw_function 1 - exp_continue - } - -re ".*memset.* \\(\\) from .*libc\[^\r\n\]+\r\n" { - set saw_function 1 - exp_continue - } - -re "in \\?\\? \\(\\) from .*libc\[^\r\n\]+\r\n" { - set is_supported 0 - unsupported "symbol for memset not found" - exp_continue - } - -re "$gdb_prompt $" { - if { $is_supported } { - setup_kfail breakpoints/31665 arm*-*-linux* - gdb_assert { $saw_watch_trigger && $saw_function } $message + "Old value = ${old_value_re}" \ + "New value = ${new_value_re}"] + gdb_test_multiple "continue" \ + "continue until $source_function watchpoint hits" { + -re $watch_trigger_re { + set saw_watch_trigger 1 + exp_continue + } + -re "${function_re}.* \\(\\) at \[^\r\n\]+:${::decimal}(?=\r\n)" { + set saw_function 1 + exp_continue + } + -re "${function_re}.* \\(\\) from \[^\r\n\]+(?=\r\n)" { + set saw_function 1 + exp_continue + } + -re "in \\?\\? \\(\\) from \[^\r\n\]+(?=\r\n)" { + set is_supported 0 + unsupported "symbol for ${source_function} not found" + exp_continue + } + -re -wrap "" { + if { $is_supported } { + setup_kfail breakpoints/31665 arm*-*-linux* + gdb_assert { $saw_watch_trigger && $saw_function } \ + $gdb_test_name + } } } } +# Note: Some architectures use memmove for memset. +continue_to_watchpoint "a" "memset" "(memset|memmove)" "104 'h'" "0 '\\\\000'" + # Note: Some architectures use memmove for memcpy. -set saw_watch_trigger 0 -set saw_function 0 -set is_supported 1 -set message "continue until memcpy watchpoint hits" -set watch_trigger \ - [multi_line \ - "Continuing\\." \ - "" \ - "(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \ - "" \ - "Old value = 101 'e'" \ - "New value = 114 'r'"] -gdb_test_multiple "continue" $message { - -re $watch_trigger { - set saw_watch_trigger 1 - exp_continue - } - -re ".*(memcpy|memmove).* \\(\\) at .*:$decimal\r\n" { - set saw_function 1 - exp_continue - } - -re ".*(memcpy|memmove).* \\(\\) from .*libc\[^\r\n\]+\r\n" { - set saw_function 1 - exp_continue - } - -re "in \\?\\? \\(\\) from .*libc\[^\r\n\]+\r\n" { - set is_supported 0 - unsupported "symbol for memcpy not found" - exp_continue - } - -re "$gdb_prompt $" { - if { $is_supported } { - setup_kfail breakpoints/31665 arm*-*-linux* - gdb_assert { $saw_watch_trigger && $saw_function } $message - } - } -} +continue_to_watchpoint "b" "memcpy" "(memcpy|memmove)" "101 'e'" "114 'r'" # Note: Some architectures use memcpy for memmove. -set saw_watch_trigger 0 -set saw_function 0 -set is_supported 1 -set message "continue until memmove watchpoint hits" -set watch_trigger \ - [multi_line \ - "Continuing\\." \ - "" \ - "(Hardware w|W)atchpoint ${decimal}: -location c\\\[28\\\]" \ - "" \ - "Old value = 100 'd'" \ - "New value = 114 'r'"] -gdb_test_multiple "continue" $message { - -re $watch_trigger { - set saw_watch_trigger 1 - exp_continue - } - -re ".*(memcpy|memmove).* \\(\\) at .*:$decimal\r\n" { - set saw_function 1 - exp_continue - } - -re ".*(memcpy|memmove).* \\(\\) from .*libc\[^\r\n\]+\r\n" { - set saw_function 1 - exp_continue - } - -re "in \\?\\? \\(\\) from .*libc\[^\r\n\]+\r\n" { - set is_supported 0 - unsupported "symbol for memmove not found" - exp_continue - } - -re "$gdb_prompt $" { - if { $is_supported } { - setup_kfail breakpoints/31665 arm*-*-linux* - gdb_assert { $saw_watch_trigger && $saw_function } $message - } - } -} +continue_to_watchpoint "c" "memmove" "(memcpy|memmove)" "100 'd'" "114 'r'" diff --git a/gdb/testsuite/gdb.base/memtag.c b/gdb/testsuite/gdb.base/memtag.c index 9c48b17..0e07e8d 100644 --- a/gdb/testsuite/gdb.base/memtag.c +++ b/gdb/testsuite/gdb.base/memtag.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/memtag.exp b/gdb/testsuite/gdb.base/memtag.exp index 11249c6..2951c91 100644 --- a/gdb/testsuite/gdb.base/memtag.exp +++ b/gdb/testsuite/gdb.base/memtag.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 @@ -39,7 +39,7 @@ with_test_prefix "before program execution" { clean_restart $testfile -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/mips_pro.exp b/gdb/testsuite/gdb.base/mips_pro.exp index 105e118..ca46e82 100644 --- a/gdb/testsuite/gdb.base/mips_pro.exp +++ b/gdb/testsuite/gdb.base/mips_pro.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 diff --git a/gdb/testsuite/gdb.base/miscexprs.c b/gdb/testsuite/gdb.base/miscexprs.c index a9930c1..62528dd 100644 --- a/gdb/testsuite/gdb.base/miscexprs.c +++ b/gdb/testsuite/gdb.base/miscexprs.c @@ -1,7 +1,7 @@ void marker1 () { - + } int @@ -38,7 +38,7 @@ main () dbig.d[202] = 9.99999999; sbig.s[90] = 255; lbig.l[333] = 999999999; - + marker1 (); return 0; } diff --git a/gdb/testsuite/gdb.base/miscexprs.exp b/gdb/testsuite/gdb.base/miscexprs.exp index 6dbfebe..4f2af50 100644 --- a/gdb/testsuite/gdb.base/miscexprs.exp +++ b/gdb/testsuite/gdb.base/miscexprs.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -20,14 +20,14 @@ # # tests for expressions with struct/array elements and mixed operator types # with elementary types -# +# # By default, the datastructures are allocated on the stack. For targets # with very small stack, that will not work. In that case, just set # storage to `-DSTORAGE=static' which changes the datastructures to be # allocated in data segment. set storage "-DSTORAGE=" -if [target_info exists gdb,small_stack_section] { +if {[target_info exists gdb,small_stack_section]} { set storage "-DSTORAGE=static" } @@ -39,14 +39,11 @@ set additional_flags "additional_flags=${storage}" standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags} nowarnings]] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile \ + [list debug ${additional_flags} nowarnings]] != 0 } { + return } -clean_restart ${binfile} - - # # set it up at a breakpoint so we can play with the variable values # @@ -71,10 +68,10 @@ gdb_test "print &ibig.i\[0\]" " = \\(int \\*\\) $hex" gdb_test_multiple "print &cbig.c\[0\]" "" { -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" { - pass $gdb_test_name + pass $gdb_test_name } -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" { - pass $gdb_test_name + pass $gdb_test_name } } @@ -84,19 +81,19 @@ gdb_test "print &dbig.d\[0\]" " = \\(double \\*\\) $hex" gdb_test_multiple "print &sbig.s\[0\]" "" { -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" { - pass $gdb_test_name + pass $gdb_test_name } -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" { - pass $gdb_test_name + pass $gdb_test_name } } gdb_test_multiple "print &lbig.l\[0\]" "" { -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" { - pass $gdb_test_name + pass $gdb_test_name } -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" { - pass $gdb_test_name + pass $gdb_test_name } } @@ -131,4 +128,3 @@ gdb_test "print ibig.i\[100\] << 2" " = 20" gdb_test "print sbig.s\[90\] >> 4" " = 15" gdb_test "print lbig.l\[333\] >> 6" " = 15624999" - diff --git a/gdb/testsuite/gdb.base/morestack.c b/gdb/testsuite/gdb.base/morestack.c index 102c528..45856a7 100644 --- a/gdb/testsuite/gdb.base/morestack.c +++ b/gdb/testsuite/gdb.base/morestack.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 @@ -68,7 +68,7 @@ down (int i) if (i == 500) { if (munmap (reserved, RESERVED_SIZE) != 0) - abort (); + abort (); reserved = NULL; } diff --git a/gdb/testsuite/gdb.base/morestack.exp b/gdb/testsuite/gdb.base/morestack.exp index 06a5aa4..96cc15c 100644 --- a/gdb/testsuite/gdb.base/morestack.exp +++ b/gdb/testsuite/gdb.base/morestack.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2024 Free Software Foundation, Inc. +# Copyright (C) 2011-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 @@ -25,7 +25,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} $srcfile \ return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/moribund-step.exp b/gdb/testsuite/gdb.base/moribund-step.exp index f0d4b37..d28e33f 100644 --- a/gdb/testsuite/gdb.base/moribund-step.exp +++ b/gdb/testsuite/gdb.base/moribund-step.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2010-2024 Free Software Foundation, Inc. +# Copyright (C) 2010-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 @@ -24,7 +24,7 @@ save_vars { GDBFLAGS } { } } -if ![runto_main] { +if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/msym-bp-2.c b/gdb/testsuite/gdb.base/msym-bp-2.c index 4545ff5..9c2ea41 100644 --- a/gdb/testsuite/gdb.base/msym-bp-2.c +++ b/gdb/testsuite/gdb.base/msym-bp-2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/msym-bp-shl-lib.c b/gdb/testsuite/gdb.base/msym-bp-shl-lib.c index 58e7698..66b2a83 100644 --- a/gdb/testsuite/gdb.base/msym-bp-shl-lib.c +++ b/gdb/testsuite/gdb.base/msym-bp-shl-lib.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/msym-bp-shl-main-2.c b/gdb/testsuite/gdb.base/msym-bp-shl-main-2.c index 727735c..f642f85 100644 --- a/gdb/testsuite/gdb.base/msym-bp-shl-main-2.c +++ b/gdb/testsuite/gdb.base/msym-bp-shl-main-2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/msym-bp-shl-main.c b/gdb/testsuite/gdb.base/msym-bp-shl-main.c index add26b2..1da7711 100644 --- a/gdb/testsuite/gdb.base/msym-bp-shl-main.c +++ b/gdb/testsuite/gdb.base/msym-bp-shl-main.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/msym-bp-shl.exp b/gdb/testsuite/gdb.base/msym-bp-shl.exp index 31af1f9..fb0a99d 100644 --- a/gdb/testsuite/gdb.base/msym-bp-shl.exp +++ b/gdb/testsuite/gdb.base/msym-bp-shl.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -55,7 +55,8 @@ proc test {debug} { return } - clean_restart $bin + clean_restart + gdb_load $bin gdb_load_shlib $lib # Should find two locations: the static foo in the @@ -74,7 +75,7 @@ proc test {debug} { } } - if ![runto_main] { + if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/msym-bp.c b/gdb/testsuite/gdb.base/msym-bp.c index 45f2ba3..a01800a 100644 --- a/gdb/testsuite/gdb.base/msym-bp.c +++ b/gdb/testsuite/gdb.base/msym-bp.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/msym-bp.exp b/gdb/testsuite/gdb.base/msym-bp.exp index 84d2902..08da72e 100644 --- a/gdb/testsuite/gdb.base/msym-bp.exp +++ b/gdb/testsuite/gdb.base/msym-bp.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -68,7 +68,7 @@ proc test {debug} { test_break "before run" - if ![runto_main] { + if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/msym-lang-main.c b/gdb/testsuite/gdb.base/msym-lang-main.c index a0a1613..fb9f4ee 100644 --- a/gdb/testsuite/gdb.base/msym-lang-main.c +++ b/gdb/testsuite/gdb.base/msym-lang-main.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/msym-lang.c b/gdb/testsuite/gdb.base/msym-lang.c index 81e5027..0ef7093 100644 --- a/gdb/testsuite/gdb.base/msym-lang.c +++ b/gdb/testsuite/gdb.base/msym-lang.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/msym-lang.exp b/gdb/testsuite/gdb.base/msym-lang.exp index 357fdee..c86d686 100644 --- a/gdb/testsuite/gdb.base/msym-lang.exp +++ b/gdb/testsuite/gdb.base/msym-lang.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2018-2024 Free Software Foundation, Inc. +# Copyright (C) 2018-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 diff --git a/gdb/testsuite/gdb.base/multi-forks.c b/gdb/testsuite/gdb.base/multi-forks.c index 0764a50..4611167 100644 --- a/gdb/testsuite/gdb.base/multi-forks.c +++ b/gdb/testsuite/gdb.base/multi-forks.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2005-2024 Free Software Foundation, Inc. + Copyright 2005-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 diff --git a/gdb/testsuite/gdb.base/multi-forks.exp b/gdb/testsuite/gdb.base/multi-forks.exp index 19b40c4..a9f4ff1 100644 --- a/gdb/testsuite/gdb.base/multi-forks.exp +++ b/gdb/testsuite/gdb.base/multi-forks.exp @@ -1,4 +1,4 @@ -# Copyright 2005-2024 Free Software Foundation, Inc. +# Copyright 2005-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 @@ -13,11 +13,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/>. -# Until "set follow-fork-mode" and "catch fork" are implemented on -# other targets... -# -require {istarget "*-*-linux*"} - +require allow_fork_tests standard_testfile .c @@ -25,17 +21,10 @@ set flags {} lappend flags debug lappend_include_file flags $srcdir/lib/unbuffer_output.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $flags] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile $flags] != 0 } { + return } -# Start with a fresh gdb - -clean_restart ${binfile} - -global gdb_prompt - # This is a test of gdb's ability to follow the parent, child or both # parent and child of multiple Unix fork() system calls. @@ -107,7 +96,7 @@ proc continue_to_exit_bp_loc {} { # parent's branch. foreach mode { "child" "parent" } { - clean_restart ${binfile} + clean_restart $testfile runto_main gdb_test_no_output "set follow-fork $mode" @@ -139,7 +128,7 @@ foreach mode { "child" "parent" } { # Start with a fresh gdb -clean_restart ${binfile} +clean_restart $testfile runto_main gdb_breakpoint $exit_bp_loc @@ -152,7 +141,7 @@ gdb_test "show detach-on-fork" "on." "show detach default on" gdb_test_no_output "set detach off" "set detach off" # -# We will now run every fork up to the exit bp, +# We will now run every fork up to the exit bp, # eventually winding up with 16 inferiors. # @@ -181,9 +170,9 @@ gdb_test "inferior 2" " main .*" "restart final" # Now we should examine all the pids. # -# +# # Test detach inferior -# +# # [assumes we're at #1] gdb_test "detach inferior 2" "Detaching .*" "detach 2" @@ -191,7 +180,7 @@ gdb_test "detach inferior 3" "Detaching .*" "detach 3" gdb_test "detach inferior 4" "Detaching .*" "detach 4" gdb_test "detach inferior 5" "Detaching .*" "detach 5" -# +# # Test kill inferior # diff --git a/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp b/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp index aaff39d..ba3bdb2 100644 --- a/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp +++ b/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2024 Free Software Foundation, Inc. +# Copyright (C) 2014-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 diff --git a/gdb/testsuite/gdb.base/native-target-noproc-tdesc.exp b/gdb/testsuite/gdb.base/native-target-noproc-tdesc.exp index d7d471d..0e2841a 100644 --- a/gdb/testsuite/gdb.base/native-target-noproc-tdesc.exp +++ b/gdb/testsuite/gdb.base/native-target-noproc-tdesc.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/nested-addr.c b/gdb/testsuite/gdb.base/nested-addr.c index e51f350..ce5b1c8 100644 --- a/gdb/testsuite/gdb.base/nested-addr.c +++ b/gdb/testsuite/gdb.base/nested-addr.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/nested-addr.exp b/gdb/testsuite/gdb.base/nested-addr.exp index f0bfe6a..8f19017 100644 --- a/gdb/testsuite/gdb.base/nested-addr.exp +++ b/gdb/testsuite/gdb.base/nested-addr.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -19,7 +19,7 @@ if {[prepare_for_testing "failed to prepare" "${testfile}" "${srcfile}"]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/nested-subp1.c b/gdb/testsuite/gdb.base/nested-subp1.c index 04161ca..f65ea52 100644 --- a/gdb/testsuite/gdb.base/nested-subp1.c +++ b/gdb/testsuite/gdb.base/nested-subp1.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/nested-subp1.exp b/gdb/testsuite/gdb.base/nested-subp1.exp index f9d614d..f1f29e8 100644 --- a/gdb/testsuite/gdb.base/nested-subp1.exp +++ b/gdb/testsuite/gdb.base/nested-subp1.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -24,15 +24,15 @@ standard_testfile set testcase "nested-subp1" -if ![support_nested_function_tests] { +if {![support_nested_function_tests]} { untested "compiler does not support nested functions" return -1 } if { [gdb_compile "${srcdir}/${subdir}/${testcase}.c" \ - [standard_output_file "${testcase}"] \ - executable \ - [list debug "additional_flags=-std=gnu99"]] != "" } { + [standard_output_file "${testcase}"] \ + executable \ + [list debug "additional_flags=-std=gnu99"]] != "" } { return -1 } @@ -40,17 +40,17 @@ if { [gdb_compile "${srcdir}/${subdir}/${testcase}.c" \ # Run until the variables we are interested in are visible. clean_restart "${testcase}" -if ![runto_main] { +if {![runto_main]} { return } set bp_location [gdb_get_line_number "STOP" "${testcase}.c"] gdb_test "break ${testcase}.c:${bp_location}" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \ - "breakpoint to the STOP marker" + "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \ + "breakpoint to the STOP marker" gdb_test "continue" \ - "Breakpoint \[0-9\]+, nested .*" \ - "continue to the STOP marker" + "Breakpoint \[0-9\]+, nested .*" \ + "continue to the STOP marker" # Check we get correct values for both local and non-local variable references. diff --git a/gdb/testsuite/gdb.base/nested-subp2.c b/gdb/testsuite/gdb.base/nested-subp2.c index 01e03e2..c08aeea 100644 --- a/gdb/testsuite/gdb.base/nested-subp2.c +++ b/gdb/testsuite/gdb.base/nested-subp2.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/nested-subp2.exp b/gdb/testsuite/gdb.base/nested-subp2.exp index 10449c9..35b7865 100644 --- a/gdb/testsuite/gdb.base/nested-subp2.exp +++ b/gdb/testsuite/gdb.base/nested-subp2.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -24,7 +24,7 @@ standard_testfile set testcase "nested-subp2" -if ![support_nested_function_tests] { +if {![support_nested_function_tests]} { untested "compiler does not support nested functions" return -1 } @@ -49,14 +49,14 @@ if { [gdb_compile "${srcdir}/${subdir}/${testcase}.c" \ # Run until the variables we are interested in are visible. clean_restart "${testcase}" -if ![runto_main] { +if {![runto_main]} { return } set bp_location [gdb_get_line_number "STOP" "${testcase}.c"] gdb_test "break ${testcase}.c:${bp_location}" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \ - "breakpoint to the STOP marker" + "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \ + "breakpoint to the STOP marker" with_test_prefix "stop at first iteration" { gdb_test "continue" \ diff --git a/gdb/testsuite/gdb.base/nested-subp3.c b/gdb/testsuite/gdb.base/nested-subp3.c index 754c756..28ffcdd 100644 --- a/gdb/testsuite/gdb.base/nested-subp3.c +++ b/gdb/testsuite/gdb.base/nested-subp3.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/nested-subp3.exp b/gdb/testsuite/gdb.base/nested-subp3.exp index 0f75a84..3898b24 100644 --- a/gdb/testsuite/gdb.base/nested-subp3.exp +++ b/gdb/testsuite/gdb.base/nested-subp3.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -24,7 +24,7 @@ standard_testfile set testcase "nested-subp3" -if ![support_nested_function_tests] { +if {![support_nested_function_tests]} { untested "compiler does not support nested functions" return -1 } @@ -49,17 +49,17 @@ if { [gdb_compile "${srcdir}/${subdir}/${testcase}.c" \ # Run until the variables we are interested in are visible. clean_restart "${testcase}" -if ![runto_main] { +if {![runto_main]} { return } set bp_location [gdb_get_line_number "STOP" "${testcase}.c"] gdb_test "break ${testcase}.c:${bp_location}" \ - "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \ - "breakpoint to the STOP marker" + "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \ + "breakpoint to the STOP marker" gdb_test "continue" \ - "Breakpoint \[0-9\]+, child .*" \ - "continue to the STOP marker" + "Breakpoint \[0-9\]+, child .*" \ + "continue to the STOP marker" # Check we get correct values for both local and non-local variable references. diff --git a/gdb/testsuite/gdb.base/new-ui-echo.c b/gdb/testsuite/gdb.base/new-ui-echo.c index 603bd49..6c99997e 100644 --- a/gdb/testsuite/gdb.base/new-ui-echo.c +++ b/gdb/testsuite/gdb.base/new-ui-echo.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/new-ui-echo.exp b/gdb/testsuite/gdb.base/new-ui-echo.exp index 1ee6704..c8d39e8 100644 --- a/gdb/testsuite/gdb.base/new-ui-echo.exp +++ b/gdb/testsuite/gdb.base/new-ui-echo.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/new-ui-pending-input.c b/gdb/testsuite/gdb.base/new-ui-pending-input.c index 5102247..e5cd93e 100644 --- a/gdb/testsuite/gdb.base/new-ui-pending-input.c +++ b/gdb/testsuite/gdb.base/new-ui-pending-input.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/new-ui-pending-input.exp b/gdb/testsuite/gdb.base/new-ui-pending-input.exp index cfb7ca0..dd2f60d 100644 --- a/gdb/testsuite/gdb.base/new-ui-pending-input.exp +++ b/gdb/testsuite/gdb.base/new-ui-pending-input.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/new-ui.c b/gdb/testsuite/gdb.base/new-ui.c index 674ce63..7f9e00a 100644 --- a/gdb/testsuite/gdb.base/new-ui.c +++ b/gdb/testsuite/gdb.base/new-ui.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/new-ui.exp b/gdb/testsuite/gdb.base/new-ui.exp index a56d213..345cd36 100644 --- a/gdb/testsuite/gdb.base/new-ui.exp +++ b/gdb/testsuite/gdb.base/new-ui.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 @@ -81,7 +81,7 @@ proc_with_prefix do_test {} { clean_restart $testfile - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -184,14 +184,14 @@ proc_with_prefix do_test_invalid_args {} { "new-ui with bad interpreter name" # Test that the TUI cannot be used for a new UI. - if [allow_tui_tests] { + if {[allow_tui_tests]} { gdb_test "new-ui tui $extra_tty_name" \ "interpreter 'tui' cannot be used with a new UI" \ "new-ui with tui" } # Test that we can continue working normally. - if ![runto_main] { + if {![runto_main]} { return } } diff --git a/gdb/testsuite/gdb.base/nextoverexit.c b/gdb/testsuite/gdb.base/nextoverexit.c index 36ec6c4..7f1daf4 100644 --- a/gdb/testsuite/gdb.base/nextoverexit.c +++ b/gdb/testsuite/gdb.base/nextoverexit.c @@ -1,4 +1,4 @@ -/* Copyright 2012-2024 Free Software Foundation, Inc. +/* Copyright 2012-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 @@ -13,7 +13,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/>. */ -#include <stdlib.h> +#include <stdlib.h> int main (void) diff --git a/gdb/testsuite/gdb.base/nextoverexit.exp b/gdb/testsuite/gdb.base/nextoverexit.exp index b09fe91..3209079 100644 --- a/gdb/testsuite/gdb.base/nextoverexit.exp +++ b/gdb/testsuite/gdb.base/nextoverexit.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/nodebug.exp b/gdb/testsuite/gdb.base/nodebug.exp index 4c07d2e..b727ca8 100644 --- a/gdb/testsuite/gdb.base/nodebug.exp +++ b/gdb/testsuite/gdb.base/nodebug.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -18,22 +18,22 @@ standard_testfile .c -if [test_compiler_info "xlc-*"] { - # By default, IBM'x xlc compiler doesn't add static variables into the symtab. - # Use "-qstatsym" to do so. - set exec_opts additional_flags=-qstatsym -} else { - set exec_opts "" +set exec_opts {} +if {[have_compile_flag -std=c99]} { + # Gcc 15 defaults to c23, which no longer supports unprototyped functions. + # Use a c dialect that does support this. + lappend exec_opts additional_flags=-std=c99 } -if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } { - untested "failed to compile" - return -1 +if {[test_compiler_info "xlc-*"]} { + # By default, IBM's xlc compiler doesn't add static variables into the symtab. + # Use "-qstatsym" to do so. + lappend exec_opts additional_flags=-qstatsym } -# Start with a fresh gdb. - -clean_restart $binfile +if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } { + return +} # Run to FUNC and unload symbols from system shared libraries, to # avoid conflicts with the minsyms in the program. E.g., @@ -41,7 +41,7 @@ clean_restart $binfile proc nodebug_runto {func} { with_test_prefix $func { - if ![runto $func] { + if {![runto $func]} { return false } gdb_test_no_output "nosharedlibrary" \ @@ -54,7 +54,7 @@ proc nodebug_runto {func} { # require coercion/promotion, both prototyped and unprototyped, both # return-type-cast style, and function-pointer-cast styles. proc test_call_promotion {} { - if [target_info exists gdb,cannot_call_functions] { + if {[target_info exists gdb,cannot_call_functions]} { return } @@ -85,9 +85,9 @@ proc test_call_promotion {} { } if {[nodebug_runto inner]} { - + # Expect to find global/local symbols in each of text/data/bss. - + # The exact format for some of this output is not necessarily # ideal, particularly interpreting "p top" requires a fair bit of # savvy about gdb's workings and the meaning of the "{}" @@ -99,7 +99,7 @@ if {[nodebug_runto inner]} { # to detect that gdb does not know the type, rather than just # being told they are ints or functions returning int like old # versions of gdb used to do. - + # On alpha (and other ecoff systems) the native compilers put # out debugging info for non-aggregate return values of functions # even without -g, which should be accepted. @@ -144,9 +144,9 @@ if {[nodebug_runto inner]} { set whatis_re [lindex $lang_line 2] set ptype_re [lindex $lang_line 3] - set print_re [subst "$print_re"] - set whatis_re [subst "$whatis_re"] - set ptype_re [subst "$ptype_re"] + set print_re [subst_vars "$print_re"] + set whatis_re [subst_vars "$whatis_re"] + set ptype_re [subst_vars "$ptype_re"] with_test_prefix "$lang" { gdb_test_no_output "set language $lang" @@ -204,9 +204,9 @@ if {[nodebug_runto inner]} { } { set exp [lindex $line 0] # Expand variables. - set fmt [subst -nobackslashes [lindex $line 1]] - set print [subst -nobackslashes [lindex $line 2]] - set whatis [subst -nobackslashes [lindex $line 3]] + set fmt [subst_vars [lindex $line 1]] + set print [subst_vars [lindex $line 2]] + set whatis [subst_vars [lindex $line 3]] if {$fmt == ""} { gdb_test "p $exp" $print } else { @@ -219,7 +219,7 @@ if {[nodebug_runto inner]} { # Check that pointer arithmetic works as expected. set addr1 [get_hexadecimal_valueof "&dataglobal" "*UNKNOWN*"] set addr2 [get_hexadecimal_valueof "(int *) &dataglobal + 1" "*UNKNOWN*"] - set offset [expr $addr2 - $addr1] + set offset [expr {$addr2 - $addr1}] set int_size [get_integer_valueof "sizeof (int)" "*UNKNOWN*"] gdb_assert { $offset == $int_size } @@ -270,14 +270,14 @@ if {[nodebug_runto inner]} { # ever, why bother with a weaker test? #gdb_test "backtrace 10" "#0.*inner.*#1.*#2.*top.*#3.*main.*" \ # "backtrace from inner for externals" - + # This test is not as obscure as it might look. `p getenv ("TERM")' # is a real-world example, at least on many systems. foreach cmd {"p/c" "ptype" "whatis"} { gdb_test "$cmd array_index(\"abcdef\",2)" \ "'array_index' has unknown return type; cast the call to its declared return type" } - if [target_info exists gdb,cannot_call_functions] { + if {[target_info exists gdb,cannot_call_functions]} { unsupported "p/c (int) array_index(\"abcdef\",2)" } else { # We need to up this because this can be really slow on some boards. diff --git a/gdb/testsuite/gdb.base/nofield.c b/gdb/testsuite/gdb.base/nofield.c index 9e81510..a949f38 100644 --- a/gdb/testsuite/gdb.base/nofield.c +++ b/gdb/testsuite/gdb.base/nofield.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2007-2024 Free Software Foundation, Inc. + Copyright 2007-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 @@ -36,4 +36,3 @@ main (void) return 0; } - diff --git a/gdb/testsuite/gdb.base/nofield.exp b/gdb/testsuite/gdb.base/nofield.exp index 0113a8c..1fe0c9d 100644 --- a/gdb/testsuite/gdb.base/nofield.exp +++ b/gdb/testsuite/gdb.base/nofield.exp @@ -1,4 +1,4 @@ -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 @@ -15,21 +15,18 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } set eol "\r\n" set sp "\[ \t\]*" -clean_restart ${binfile} - gdb_test "ptype struct not_empty" \ - "type = struct not_empty {$eol${sp}void \\*e;$eol${sp}void \\*u;$eol}" + "type = struct not_empty {$eol${sp}void \\*e;$eol${sp}void \\*u;$eol}" gdb_test "ptype struct empty" \ - "type = struct empty {$eol$sp<no data fields>$eol}" + "type = struct empty {$eol$sp<no data fields>$eol}" gdb_test "ptype union empty_union" \ - "type = union empty_union {$eol$sp<no data fields>$eol}" + "type = union empty_union {$eol$sp<no data fields>$eol}" diff --git a/gdb/testsuite/gdb.base/non-executable.exp b/gdb/testsuite/gdb.base/non-executable.exp index 0f3b81a..fcfaa1f 100644 --- a/gdb/testsuite/gdb.base/non-executable.exp +++ b/gdb/testsuite/gdb.base/non-executable.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/non-lazy-array-index.c b/gdb/testsuite/gdb.base/non-lazy-array-index.c index 8bf99e8..390911f 100644 --- a/gdb/testsuite/gdb.base/non-lazy-array-index.c +++ b/gdb/testsuite/gdb.base/non-lazy-array-index.c @@ -1,4 +1,4 @@ -/* Copyright 2021-2024 Free Software Foundation, Inc. +/* Copyright 2021-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/non-lazy-array-index.exp b/gdb/testsuite/gdb.base/non-lazy-array-index.exp index be7ea06..288f159 100644 --- a/gdb/testsuite/gdb.base/non-lazy-array-index.exp +++ b/gdb/testsuite/gdb.base/non-lazy-array-index.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/noreturn-finish.c b/gdb/testsuite/gdb.base/noreturn-finish.c index cac0fe7..0413c05 100644 --- a/gdb/testsuite/gdb.base/noreturn-finish.c +++ b/gdb/testsuite/gdb.base/noreturn-finish.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/noreturn-finish.exp b/gdb/testsuite/gdb.base/noreturn-finish.exp index 7e17d28..2da0a40 100644 --- a/gdb/testsuite/gdb.base/noreturn-finish.exp +++ b/gdb/testsuite/gdb.base/noreturn-finish.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -15,7 +15,7 @@ standard_testfile -if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug}] { +if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug}]} { return -1 } diff --git a/gdb/testsuite/gdb.base/noreturn-return.c b/gdb/testsuite/gdb.base/noreturn-return.c index cac0fe7..0413c05 100644 --- a/gdb/testsuite/gdb.base/noreturn-return.c +++ b/gdb/testsuite/gdb.base/noreturn-return.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/noreturn-return.exp b/gdb/testsuite/gdb.base/noreturn-return.exp index f034be2..e6f8117 100644 --- a/gdb/testsuite/gdb.base/noreturn-return.exp +++ b/gdb/testsuite/gdb.base/noreturn-return.exp @@ -1,4 +1,4 @@ -# Copyright 2015-2024 Free Software Foundation, Inc. +# Copyright 2015-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 @@ -15,7 +15,7 @@ standard_testfile -if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug}] { +if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug}]} { return -1 } diff --git a/gdb/testsuite/gdb.base/normal.c b/gdb/testsuite/gdb.base/normal.c index 3fab53d..a9a452a 100644 --- a/gdb/testsuite/gdb.base/normal.c +++ b/gdb/testsuite/gdb.base/normal.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/nostdlib.c b/gdb/testsuite/gdb.base/nostdlib.c index 633183a..82feace 100644 --- a/gdb/testsuite/gdb.base/nostdlib.c +++ b/gdb/testsuite/gdb.base/nostdlib.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/nostdlib.exp b/gdb/testsuite/gdb.base/nostdlib.exp index f595bab..8ea0b40 100644 --- a/gdb/testsuite/gdb.base/nostdlib.exp +++ b/gdb/testsuite/gdb.base/nostdlib.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -31,16 +31,19 @@ foreach_with_prefix pie { "nopie" "pie" } { # OPTS and BINFILE are used by the COMPILE string (defined above) # when it is evaluated below. set opts [list debug additional_flags=-nostdlib $pie] - set binfile [standard_output_file $testfile-$pie] + set filename $testfile-$pie + set binfile [standard_output_file $filename] set board [target_info name] - if [board_info $board exists mathlib] { + if {[board_info $board exists mathlib]} { set mathlib [board_info $dest mathlib] set_board_info mathlib "" + # tclint-disable-next-line command-args set err [eval $compile] set_board_info mathlib $mathlib } else { set_board_info mathlib "" + # tclint-disable-next-line command-args set err [eval $compile] unset_board_info mathlib } @@ -49,7 +52,7 @@ foreach_with_prefix pie { "nopie" "pie" } { return -1 } - clean_restart $binfile + clean_restart $filename gdb_breakpoint "*marker" diff --git a/gdb/testsuite/gdb.base/offsets.c b/gdb/testsuite/gdb.base/offsets.c index e9532bd..a46a072 100644 --- a/gdb/testsuite/gdb.base/offsets.c +++ b/gdb/testsuite/gdb.base/offsets.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/offsets.exp b/gdb/testsuite/gdb.base/offsets.exp index bf9a78c..3193ed9 100644 --- a/gdb/testsuite/gdb.base/offsets.exp +++ b/gdb/testsuite/gdb.base/offsets.exp @@ -1,6 +1,6 @@ # Test big offsets -# Copyright (c) 2014-2024 Free Software Foundation, Inc. +# Copyright (c) 2014-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 @@ -35,7 +35,7 @@ gdb_test_multiple "print &big_struct.second" "$test" { -re "\\$\[0-9\]* = .* (0x\[0-9a-fA-F\]*) .*\[\r\n\]*$gdb_prompt $" { set addr2 $expect_out(1,string) - if {[expr $addr2 - $addr1] == [expr 0x10000000 + 16]} { + if {[expr {$addr2 - $addr1}] == [expr {0x10000000 + 16}]} { pass "big offsets" } else { fail "big offsets" diff --git a/gdb/testsuite/gdb.base/opaque.exp b/gdb/testsuite/gdb.base/opaque.exp index d803714..49d505c 100644 --- a/gdb/testsuite/gdb.base/opaque.exp +++ b/gdb/testsuite/gdb.base/opaque.exp @@ -1,4 +1,4 @@ -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -52,7 +52,7 @@ proc setup_xfail_on_opaque_pointer {} { setup_xfail "vax-*-*" "i*86-sequent-bsd*" if {!$gcc_compiled} { - setup_xfail "alpha-*-*" + setup_xfail "alpha-*-*" } } @@ -110,7 +110,7 @@ gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} # Run to main, where struct foo is incomplete. -if ![runto_main] { +if {![runto_main]} { return } @@ -160,7 +160,7 @@ gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} # Run to getfoo, where struct foo is complete. -if ![runto getfoo] { +if {![runto getfoo]} { perror "cannot run to breakpoint at getfoo" } diff --git a/gdb/testsuite/gdb.base/options.c b/gdb/testsuite/gdb.base/options.c index e2442af..81c8b89 100644 --- a/gdb/testsuite/gdb.base/options.c +++ b/gdb/testsuite/gdb.base/options.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/options.exp b/gdb/testsuite/gdb.base/options.exp index a1ca39e..f9b8657 100644 --- a/gdb/testsuite/gdb.base/options.exp +++ b/gdb/testsuite/gdb.base/options.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -62,8 +62,7 @@ proc check_completion_result {expected test} { # just checking whether GDB recognizes the option and auto-appends a # space. proc test_completer_recognizes {res input_line} { - set expected_re [string_to_regexp $input_line] - test_gdb_complete_unique $input_line $expected_re + test_gdb_complete_unique $input_line $input_line check_completion_result $res $input_line } @@ -99,21 +98,21 @@ proc make_cmd {variant} { # operand. proc expect_none {operand} { return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\ - -string '' -filename '' -- $operand" + -string '' -filename '' -color magenta -- $operand" } # Return a string for the expected result of running "maint # test-options xxx", with -flag set. OPERAND is the expected operand. proc expect_flag {operand} { return "-flag 1 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\ - -string '' -filename '' -- $operand" + -string '' -filename '' -color magenta -- $operand" } # Return a string for the expected result of running "maint # test-options xxx", with -bool set. OPERAND is the expected operand. proc expect_bool {operand} { return "-flag 0 -xx1 0 -xx2 0 -bool 1 -enum xxx -uint-unl 0 -pint-unl 0\ - -string '' -filename '' -- $operand" + -string '' -filename '' -color magenta -- $operand" } # Return a string for the expected result of running "maint @@ -123,10 +122,10 @@ proc expect_bool {operand} { proc expect_integer {option val operand} { if {$option == "uinteger-unlimited"} { return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl $val\ - -pint-unl 0 -string '' -filename '' -- $operand" + -pint-unl 0 -string '' -filename '' -color magenta -- $operand" } elseif {$option == "pinteger-unlimited"} { return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0\ - -pint-unl $val -string '' -filename '' -- $operand" + -pint-unl $val -string '' -filename '' -color magenta -- $operand" } else { error "unsupported option: $option" } @@ -144,7 +143,7 @@ proc expect_string {str operand} { set str [string range $str 1 end-1] } return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\ - -string '$str' -filename '' -- $operand" + -string '$str' -filename '' -color magenta -- $operand" } # Return a string for the expected result of running "maint @@ -159,11 +158,12 @@ proc expect_filename {str operand} { set str [string range $str 1 end-1] } return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\ - -string '' -filename '$str' -- $operand" + -string '' -filename '$str' -color magenta -- $operand" } set all_options { "-bool" + "-color" "-enum" "-filename" "-flag" @@ -204,10 +204,9 @@ proc_with_prefix test-print {{prefix ""}} { "-vtbl" } - global binfile - clean_restart $binfile + clean_restart $::testfile - if ![runto_main] { + if {![runto_main]} { return } @@ -316,10 +315,9 @@ proc_with_prefix test-backtrace {} { "backtrace no-fil" \ "backtrace no-filters" - global binfile - clean_restart $binfile + clean_restart $::testfile - if ![runto_main] { + if {![runto_main]} { return } @@ -508,12 +506,26 @@ proc_with_prefix test-thread-apply {} { proc_with_prefix test-info-threads {} { test_gdb_complete_multiple "info threads " "" "" { "-gid" + "-running" + "-stopped" "ID" } + test_gdb_complete_multiple "info threads " "-" "" { + "-gid" + "-running" + "-stopped" + } + test_gdb_complete_unique \ - "info threads -" \ + "info threads -g" \ "info threads -gid" + test_gdb_complete_unique \ + "info threads -r" \ + "info threads -running" + test_gdb_complete_unique \ + "info threads -s" \ + "info threads -stopped" # "ID" isn't really something the user can type. test_gdb_complete_none "info threads I" @@ -628,7 +640,7 @@ proc_with_prefix test-flag {variant} { # Extract twice the same flag, separated by one space. gdb_test "$cmd -xx1 -xx2 -xx1 -xx2 -xx1 -- non flags args" \ "-flag 0 -xx1 1 -xx2 1 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\ - -string '' -filename '' -- non flags args" + -string '' -filename '' -color magenta -- non flags args" # Extract 2 known flags in front of unknown flags. gdb_test "$cmd -xx1 -xx2 -a -b -c -xx1 --" \ @@ -1147,7 +1159,7 @@ foreach prefix { # Same for "compile print". Not really a wrapper prefix command like # "frame apply", but similar enough that we test pretty much the same # things. -if ![skip_compile_feature_tests] { +if {![skip_compile_feature_tests]} { test-print "compile " } diff --git a/gdb/testsuite/gdb.base/osabi.exp b/gdb/testsuite/gdb.base/osabi.exp index 4fd267b..ba99835 100644 --- a/gdb/testsuite/gdb.base/osabi.exp +++ b/gdb/testsuite/gdb.base/osabi.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2018-2024 Free Software Foundation, Inc. +# Copyright (C) 2018-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 diff --git a/gdb/testsuite/gdb.base/overlays.c b/gdb/testsuite/gdb.base/overlays.c index e9dc9a0..cc967ef 100644 --- a/gdb/testsuite/gdb.base/overlays.c +++ b/gdb/testsuite/gdb.base/overlays.c @@ -31,4 +31,3 @@ int main () + 'g' + 'r' + 'b' + 'x')); } - diff --git a/gdb/testsuite/gdb.base/overlays.exp b/gdb/testsuite/gdb.base/overlays.exp index c8730ec..1ab1cdc 100644 --- a/gdb/testsuite/gdb.base/overlays.exp +++ b/gdb/testsuite/gdb.base/overlays.exp @@ -1,5 +1,5 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. -# +# Copyright 1997-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 @@ -64,7 +64,7 @@ proc get_func_address { func func_sym msg } { global hexx set func_addr 0 - send_gdb "print $func\n" + send_gdb "print $func\n" gdb_expect { -re "\\$\[0-9\]+ = $fptrcast (${hexx}) <$func_sym>.*$gdb_prompt $" { set func_addr $expect_out(1,string) @@ -99,39 +99,39 @@ if {$data_overlays} { # map each overlay successively, and # capture the VMA addresses of [foo bar baz grbx foox barx bazx grbxx] -gdb_test "overlay map .ovly0" "" +gdb_test "overlay map .ovly0" "" gdb_test "overlay list" "Section .ovly0, loaded at.*, mapped at.*" "list ovly0" set foo_vma [get_func_address "foo" "foo" "foo runtime address"] -gdb_test "overlay map .ovly1" "" +gdb_test "overlay map .ovly1" "" gdb_test "overlay list" "Section .ovly1, loaded at.*, mapped at.*" "list ovly1" set bar_vma [get_func_address "bar" "bar" "bar runtime address"] -gdb_test "overlay map .ovly2" "" +gdb_test "overlay map .ovly2" "" gdb_test "overlay list" "Section .ovly2, loaded at.*, mapped at.*" "list ovly2" set baz_vma [get_func_address "baz" "baz" "baz runtime address"] -gdb_test "overlay map .ovly3" "" +gdb_test "overlay map .ovly3" "" gdb_test "overlay list" "Section .ovly3, loaded at.*, mapped at.*" "list ovly3" set grbx_vma [get_func_address "grbx" "grbx" "grbx runtime address"] if {$data_overlays} { - gdb_test "overlay map .data00" "" + gdb_test "overlay map .data00" "" gdb_test "overlay list" "Section .data00, loaded .*, mapped .*" "list data00" gdb_test "print \$foox_vma = &foox" \ ".* $iptrcast 0x.*" "foox runtime addr" - gdb_test "overlay map .data01" "" + gdb_test "overlay map .data01" "" gdb_test "overlay list" "Section .data01, loaded .*, mapped .*" "list data01" gdb_test "print \$barx_vma = &barx" \ ".* $iptrcast 0x.*" "barx runtime addr" - gdb_test "overlay map .data02" "" + gdb_test "overlay map .data02" "" gdb_test "overlay list" "Section .data02, loaded .*, mapped .*" "list data02" gdb_test "print \$bazx_vma = &bazx" \ ".* $iptrcast 0x.*" "bazx runtime addr" - gdb_test "overlay map .data03" "" + gdb_test "overlay map .data03" "" gdb_test "overlay list" "Section .data03, loaded .*, mapped .*" "list data03" gdb_test "print \$grbxx_vma = &grbxx" \ ".* $iptrcast 0x.*" "grbxx runtime addr" @@ -149,7 +149,7 @@ if {$data_overlays} { gdb_test "print \$grbxx_lma != \$grbxx_vma" ".* = 1" "grbxx's LMA != VMA" } -# Verify that early-mapped overlays have been bumped out +# Verify that early-mapped overlays have been bumped out # by later-mapped overlays laid over in the same VMA range. send_gdb "overlay list\n" @@ -175,16 +175,16 @@ proc simultaneous_pair { sec1 sec2 } { send_gdb "overlay list\n" gdb_expect { - -re ".*[string_to_regexp $sec1], " { set seen_sec1 1; exp_continue } - -re ".*[string_to_regexp $sec2], " { set seen_sec2 1; exp_continue } - -re ".*$gdb_prompt $" { - if {$seen_sec1 && $seen_sec2} { - pass "$pairname" - } else { - fail "$pairname" - } - } - timeout { fail "(timeout) $pairname" } + -re ".*[string_to_regexp $sec1], " { set seen_sec1 1; exp_continue } + -re ".*[string_to_regexp $sec2], " { set seen_sec2 1; exp_continue } + -re ".*$gdb_prompt $" { + if {$seen_sec1 && $seen_sec2} { + pass "$pairname" + } else { + fail "$pairname" + } + } + timeout { fail "(timeout) $pairname" } } } @@ -265,4 +265,3 @@ gdb_expect { -re ".*$gdb_prompt $" { fail "BT grbx" } timeout { fail "(timeout) BT grbx" } } - diff --git a/gdb/testsuite/gdb.base/ovlymgr.c b/gdb/testsuite/gdb.base/ovlymgr.c index 262c2a6..8867a80 100644 --- a/gdb/testsuite/gdb.base/ovlymgr.c +++ b/gdb/testsuite/gdb.base/ovlymgr.c @@ -22,7 +22,7 @@ static void ovly_copy (unsigned long dst, unsigned long src, long size); since libgloss is the one intended to handle low level system issues. I would suggest something like _flush_cache to avoid the user's namespace but not be completely obscure as other things may need this facility. */ - + static void FlushCache (void) { @@ -33,7 +33,7 @@ FlushCache (void) } /* _ovly_debug_event: - * Debuggers may set a breakpoint here, to be notified + * Debuggers may set a breakpoint here, to be notified * when the overlay table has been modified. */ static void @@ -63,8 +63,8 @@ OverlayLoad (unsigned long ovlyno) else if (_ovly_table[i][VMA] == _ovly_table[ovlyno][VMA]) _ovly_table[i][MAPPED] = 0; /* this one now un-mapped */ - ovly_copy (_ovly_table[ovlyno][VMA], - _ovly_table[ovlyno][LMA], + ovly_copy (_ovly_table[ovlyno][VMA], + _ovly_table[ovlyno][LMA], _ovly_table[ovlyno][SIZE]); FlushCache (); @@ -77,17 +77,17 @@ OverlayLoad (unsigned long ovlyno) * Does NOT mark overlay as "unmapped", therefore may be called * more than once for the same mapped overlay. */ - + bool OverlayUnload (unsigned long ovlyno) { if (ovlyno < 0 || ovlyno >= _novlys) exit (-1); /* fail, bad ovly number */ - + if (!_ovly_table[ovlyno][MAPPED]) exit (-1); /* error, can't copy out a segment that's not "in" */ - - ovly_copy (_ovly_table[ovlyno][LMA], + + ovly_copy (_ovly_table[ovlyno][LMA], _ovly_table[ovlyno][VMA], _ovly_table[ovlyno][SIZE]); diff --git a/gdb/testsuite/gdb.base/page-logging.exp b/gdb/testsuite/gdb.base/page-logging.exp index 6cc9770..b07d540 100644 --- a/gdb/testsuite/gdb.base/page-logging.exp +++ b/gdb/testsuite/gdb.base/page-logging.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2021-2024 Free Software Foundation, Inc. +# Copyright (C) 2021-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 diff --git a/gdb/testsuite/gdb.base/page.exp b/gdb/testsuite/gdb.base/page.exp index c95a2bc..c9c9884 100644 --- a/gdb/testsuite/gdb.base/page.exp +++ b/gdb/testsuite/gdb.base/page.exp @@ -1,4 +1,4 @@ -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -26,6 +26,7 @@ gdb_test_sequence "help" "unpaged help" { "aliases -- User-defined aliases of other commands" "breakpoints -- Making program stop at certain points" "data -- Examining data" + "essential -- GDB essential commands" "files -- Specifying and examining files" "internals -- Maintenance commands" "obscure -- Obscure features" @@ -53,10 +54,10 @@ gdb_expect_list "paged help" \ "aliases -- User-defined aliases of other commands" "breakpoints -- Making program stop at certain points" "data -- Examining data" + "essential -- GDB essential commands" "files -- Specifying and examining files" "internals -- Maintenance commands" "obscure -- Obscure features" - "running -- Running the program" } gdb_test "q" diff --git a/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.c b/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.c index 726fffe..7e8a5ef 100644 --- a/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.c +++ b/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp b/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp index 1fc7043..8d2929f 100644 --- a/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp +++ b/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2024 Free Software Foundation, Inc. +# Copyright (C) 2014-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 @@ -25,13 +25,13 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} { # does not cause a pagination prompt. proc test_ctrlc_while_target_running_does_not_paginate {} { - global binfile srcfile + global srcfile global gdb_prompt set testline [gdb_get_line_number "after sleep"] with_test_prefix "ctrlc target running" { - clean_restart $binfile + clean_restart $::testfile if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/paginate-bg-execution.c b/gdb/testsuite/gdb.base/paginate-bg-execution.c index 54e0aec..d3a4659 100644 --- a/gdb/testsuite/gdb.base/paginate-bg-execution.c +++ b/gdb/testsuite/gdb.base/paginate-bg-execution.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/paginate-bg-execution.exp b/gdb/testsuite/gdb.base/paginate-bg-execution.exp index 1906e58..6bb49d3 100644 --- a/gdb/testsuite/gdb.base/paginate-bg-execution.exp +++ b/gdb/testsuite/gdb.base/paginate-bg-execution.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2024 Free Software Foundation, Inc. +# Copyright (C) 2014-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 @@ -26,11 +26,10 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} { # command without getting caught in pagination. proc test_bg_execution_pagination_return {} { - global binfile global decimal with_test_prefix "paginate" { - clean_restart $binfile + clean_restart $::testfile if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/paginate-execution-startup.c b/gdb/testsuite/gdb.base/paginate-execution-startup.c index 54e0aec..d3a4659 100644 --- a/gdb/testsuite/gdb.base/paginate-execution-startup.c +++ b/gdb/testsuite/gdb.base/paginate-execution-startup.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/paginate-execution-startup.exp b/gdb/testsuite/gdb.base/paginate-execution-startup.exp index 134cf64..8f971c8 100644 --- a/gdb/testsuite/gdb.base/paginate-execution-startup.exp +++ b/gdb/testsuite/gdb.base/paginate-execution-startup.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2024 Free Software Foundation, Inc. +# Copyright (C) 2014-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 @@ -23,7 +23,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} { } set file_arg $binfile -if [is_remote host] { +if {[is_remote host]} { set file_arg [remote_download host $file_arg] } @@ -176,7 +176,7 @@ save_vars { INTERNAL_GDBFLAGS } { if {[probe_can_run_cmdline] > 0} { test_fg_execution_pagination_return - if ![target_info exists gdb,nointerrupts] { + if {![target_info exists gdb,nointerrupts]} { test_fg_execution_pagination_cancel "ctrl-c" } test_fg_execution_pagination_cancel "quit" diff --git a/gdb/testsuite/gdb.base/paginate-inferior-exit.c b/gdb/testsuite/gdb.base/paginate-inferior-exit.c index 54e0aec..d3a4659 100644 --- a/gdb/testsuite/gdb.base/paginate-inferior-exit.c +++ b/gdb/testsuite/gdb.base/paginate-inferior-exit.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/paginate-inferior-exit.exp b/gdb/testsuite/gdb.base/paginate-inferior-exit.exp index 3d99a5f..aecb357 100644 --- a/gdb/testsuite/gdb.base/paginate-inferior-exit.exp +++ b/gdb/testsuite/gdb.base/paginate-inferior-exit.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2024 Free Software Foundation, Inc. +# Copyright (C) 2014-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 @@ -24,12 +24,11 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} { # Test paginating while printing about the inferior having exited. # proc test_paginate_inferior_exited {} { - global binfile global gdb_prompt pagination_prompt global inferior_exited_re with_test_prefix "paginate" { - clean_restart $binfile + clean_restart $::testfile if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/parse_number.exp b/gdb/testsuite/gdb.base/parse_number.exp index 64ce14c..7f6e37f 100644 --- a/gdb/testsuite/gdb.base/parse_number.exp +++ b/gdb/testsuite/gdb.base/parse_number.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -48,21 +48,21 @@ proc fits_in_type { n type_bits type_signedness } { if { $n < 0} { set n_sign -1 - set n [expr -$n] + set n [expr {-$n}] } else { set n_sign 1 } - set smax [expr 1 << ($type_bits - 1)]; + set smax [expr {1 << ($type_bits - 1)}]; if { $n_sign == -1 } { # Negative number, signed type. - return [expr ($n <= $smax)] + return [expr {($n <= $smax)}] } elseif { $n_sign == 1 && $type_signed_p } { # Positive number, signed type. - return [expr ($n < $smax)] + return [expr {($n < $smax)}] } elseif { $n_sign == 1 && !$type_signed_p } { # Positive number, unsigned type. - return [expr ($n >> $type_bits) == 0] + return [expr {($n >> $type_bits) == 0}] } else { error "unreachable" } @@ -99,9 +99,9 @@ proc parse_number { lang n } { } global sizeof_long_long sizeof_long sizeof_int - set long_long_bits [expr $sizeof_long_long * 8] - set long_bits [expr $sizeof_long * 8] - set int_bits [expr $sizeof_int * 8] + set long_long_bits [expr {$sizeof_long_long * 8}] + set long_bits [expr {$sizeof_long * 8}] + set int_bits [expr {$sizeof_int * 8}] if { $lang == "rust" } { if { [fits_in_type $n 32 s] } { @@ -303,7 +303,7 @@ proc test_parse_numbers {arch} { foreach_with_prefix prefix $prefixes { foreach baseval $basevals { foreach offset { -2 -1 0 1 2 } { - set dec_val [expr $baseval + $offset] + set dec_val [expr {$baseval + $offset}] set hex_val [format "0x%llx" $dec_val] if { $dec_val < 0 } { continue diff --git a/gdb/testsuite/gdb.base/paste-newline.exp b/gdb/testsuite/gdb.base/paste-newline.exp index dabceac..77e278e 100644 --- a/gdb/testsuite/gdb.base/paste-newline.exp +++ b/gdb/testsuite/gdb.base/paste-newline.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2024 Free Software Foundation, Inc. +# Copyright (C) 2024-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 diff --git a/gdb/testsuite/gdb.base/patch.c b/gdb/testsuite/gdb.base/patch.c index 583116c..44abbd6 100644 --- a/gdb/testsuite/gdb.base/patch.c +++ b/gdb/testsuite/gdb.base/patch.c @@ -1,4 +1,4 @@ -/* Copyright 2022-2024 Free Software Foundation, Inc. +/* Copyright 2022-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/patch.exp b/gdb/testsuite/gdb.base/patch.exp index 628ad56..05743e6 100644 --- a/gdb/testsuite/gdb.base/patch.exp +++ b/gdb/testsuite/gdb.base/patch.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -34,7 +34,7 @@ with_test_prefix "exec" { gdb_test "p extern_global = 2" " = 2" "modify value" gdb_test "p extern_global" " = 2" "value modified" - clean_restart $binfile + clean_restart $testfile gdb_test "p extern_global" " = 2" "value modified persisted" } @@ -43,7 +43,7 @@ with_test_prefix "exec" { # Generate a core file. with_test_prefix "gcore" { - clean_restart $binfile + clean_restart $testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/pc-fp.exp b/gdb/testsuite/gdb.base/pc-fp.exp index 667bc45..8e3d80c 100644 --- a/gdb/testsuite/gdb.base/pc-fp.exp +++ b/gdb/testsuite/gdb.base/pc-fp.exp @@ -1,4 +1,4 @@ -# Copyright 2002-2024 Free Software Foundation, Inc. +# Copyright 2002-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 diff --git a/gdb/testsuite/gdb.base/pc-not-saved.c b/gdb/testsuite/gdb.base/pc-not-saved.c index bc6632a..f482c36 100644 --- a/gdb/testsuite/gdb.base/pc-not-saved.c +++ b/gdb/testsuite/gdb.base/pc-not-saved.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/pc-not-saved.exp b/gdb/testsuite/gdb.base/pc-not-saved.exp index 5f22568..98b7505 100644 --- a/gdb/testsuite/gdb.base/pc-not-saved.exp +++ b/gdb/testsuite/gdb.base/pc-not-saved.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 @@ -60,7 +60,7 @@ gdb_assert { ![string equal $pc unknown] } \ "check we read the frame's PC" # Restart and load the Python unwinder script. -clean_restart $binfile +clean_restart $testfile gdb_test_no_output "source ${remote_python_file}" "load python file" # Tell the Python unwinder to use the frame-id we cached above. diff --git a/gdb/testsuite/gdb.base/pc-not-saved.py b/gdb/testsuite/gdb.base/pc-not-saved.py index 8090858..4aa633f 100644 --- a/gdb/testsuite/gdb.base/pc-not-saved.py +++ b/gdb/testsuite/gdb.base/pc-not-saved.py @@ -1,4 +1,4 @@ -# Copyright (C) 2024 Free Software Foundation, Inc. +# Copyright (C) 2024-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 @@ -52,15 +52,14 @@ class break_unwinding(Unwinder): return None block = gdb.block_for_pc(pc) - if block == None: + if block is None: return None func = block.function - if func == None: + if func is None: return None if str(func) != "break_bt_here": return None - global break_bt_here_frame_id if break_bt_here_frame_id is None: return None diff --git a/gdb/testsuite/gdb.base/pending.c b/gdb/testsuite/gdb.base/pending.c index 45b38e9..3ec15b5 100644 --- a/gdb/testsuite/gdb.base/pending.c +++ b/gdb/testsuite/gdb.base/pending.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp index 833e084..fc1820a 100644 --- a/gdb/testsuite/gdb.base/pending.exp +++ b/gdb/testsuite/gdb.base/pending.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 @@ -103,8 +103,8 @@ gdb_test "info break" \ "pending plus real breakpoint info" -# -# Test not setting a pending breakpoint +# +# Test not setting a pending breakpoint # gdb_test "break pendfunc2" \ "" \ @@ -113,7 +113,7 @@ gdb_test "break pendfunc2" \ "n" # -# Add condition to pending breakpoint +# Add condition to pending breakpoint # gdb_test_no_output "condition 1 k == 1" diff --git a/gdb/testsuite/gdb.base/pendshr.c b/gdb/testsuite/gdb.base/pendshr.c index c56f125..fc0c066 100644 --- a/gdb/testsuite/gdb.base/pendshr.c +++ b/gdb/testsuite/gdb.base/pendshr.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/permissions.exp b/gdb/testsuite/gdb.base/permissions.exp index 6c3cecb..edfe5a0 100644 --- a/gdb/testsuite/gdb.base/permissions.exp +++ b/gdb/testsuite/gdb.base/permissions.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/persistent-lang.cc b/gdb/testsuite/gdb.base/persistent-lang.cc index 27a14b7..65b18bc 100644 --- a/gdb/testsuite/gdb.base/persistent-lang.cc +++ b/gdb/testsuite/gdb.base/persistent-lang.cc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/persistent-lang.exp b/gdb/testsuite/gdb.base/persistent-lang.exp index d3bedae..3528998 100644 --- a/gdb/testsuite/gdb.base/persistent-lang.exp +++ b/gdb/testsuite/gdb.base/persistent-lang.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/pie-execl.c b/gdb/testsuite/gdb.base/pie-execl.c index d468d85..e53290e 100644 --- a/gdb/testsuite/gdb.base/pie-execl.c +++ b/gdb/testsuite/gdb.base/pie-execl.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/pie-execl.exp b/gdb/testsuite/gdb.base/pie-execl.exp index cbcb3ac..aa4f2c3 100644 --- a/gdb/testsuite/gdb.base/pie-execl.exp +++ b/gdb/testsuite/gdb.base/pie-execl.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -49,7 +49,7 @@ clean_restart ${executable1} gdb_test_no_output "set args ${binfile2}" "set args ${binfile2_test_msg}" -if ![runto_main] { +if {![runto_main]} { return -1 } @@ -80,7 +80,7 @@ gdb_test_multiple $test $test { } -i "$inferior_spawn_id" -re "pie-execl: re-exec" { # output from inferior - incr matches_found + incr matches_found if { $matches_found == 2 } { pass $test } else { @@ -90,7 +90,7 @@ gdb_test_multiple $test $test { -i "$gdb_spawn_id" -re "executing new program.*\r\nBreakpoint \[0-9\]+,\[^\r\n\]* pie_execl_marker .*\r\n$gdb_prompt $" { # output from gdb - incr matches_found + incr matches_found if { $matches_found == 2 } { pass $test } else { @@ -113,7 +113,7 @@ verbose -log "addr2 is $addr2" # Ensure we cannot get a false PASS and the inferior has really changed. set test "pie_execl_marker address has changed" -if [string equal $addr1 $addr2] { +if {[string equal $addr1 $addr2]} { fail $test } else { pass $test diff --git a/gdb/testsuite/gdb.base/pie-fork.c b/gdb/testsuite/gdb.base/pie-fork.c index 716cf36..54473f9 100644 --- a/gdb/testsuite/gdb.base/pie-fork.c +++ b/gdb/testsuite/gdb.base/pie-fork.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/pie-fork.exp b/gdb/testsuite/gdb.base/pie-fork.exp index 16aba1f..eeddb14 100644 --- a/gdb/testsuite/gdb.base/pie-fork.exp +++ b/gdb/testsuite/gdb.base/pie-fork.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -16,20 +16,20 @@ # Test that we can follow forks properly when the executable is # position-independent. +require allow_fork_tests + standard_testfile set opts [list debug pie] -if [build_executable "failed to prepare" $testfile $srcfile $opts] { +if {[build_executable "failed to prepare" $testfile $srcfile $opts]} { return } proc setup_test {detach_on_fork {follow_fork_mode "parent"}} { - global binfile - - clean_restart ${binfile} + clean_restart $::testfile - if ![runto_main] { + if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/pointers.c b/gdb/testsuite/gdb.base/pointers.c index 96f2b52..cd4e722 100644 --- a/gdb/testsuite/gdb.base/pointers.c +++ b/gdb/testsuite/gdb.base/pointers.c @@ -90,7 +90,7 @@ int main () { void dummy(); int more_code(); - + dummy(); more_code (); @@ -100,29 +100,29 @@ int main () usevar (&y); return 0; - + } void dummy() { - - + + v_char = 0; v_signed_char = 1; v_unsigned_char = 2; v_short = 3; v_signed_short = 4; - v_unsigned_short = 5; + v_unsigned_short = 5; v_int = 6; v_signed_int = 7; - v_unsigned_int = 8; + v_unsigned_int = 8; v_long = 9; v_signed_long = 10; - v_unsigned_long = 11; - + v_unsigned_long = 11; + v_float = 100.0; v_double = 200.0; @@ -148,8 +148,8 @@ void dummy() v_double_pointer = &v_double; ptr_to_ptr_to_float = &v_float_pointer; - - + + v_char_array[0] = v_char; v_signed_char_array[0] = v_signed_char; v_unsigned_char_array[0] = v_unsigned_char; @@ -160,7 +160,7 @@ void dummy() v_int_array[0] = v_int; v_int_array[1] = v_int * 3; - + v_signed_int_array[0] = v_signed_int; v_unsigned_int_array[0] = v_unsigned_int; @@ -215,7 +215,7 @@ int more_code() pUL = &UL; pF = &F; pD = &D; - + marker1(); return 0; } diff --git a/gdb/testsuite/gdb.base/pointers.exp b/gdb/testsuite/gdb.base/pointers.exp index 0bf88be..7292976 100644 --- a/gdb/testsuite/gdb.base/pointers.exp +++ b/gdb/testsuite/gdb.base/pointers.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -19,7 +19,7 @@ # # tests for pointer arithmetic and pointer dereferencing # with integer type variables and pointers to integers -# +# # # test running programs @@ -27,13 +27,9 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { - untested "failed to compile" - return -1 - } - -clean_restart ${binfile} - +if { [prepare_for_testing "prepare" $testfile $srcfile {debug nowarnings}] != 0 } { + return +} # # set it up at a breakpoint so we can play with the variable values @@ -64,7 +60,7 @@ gdb_test "next " "more_code.*;" "continuing after dummy()" # pass "illegal pointer assignment rejected" # } # -re ".*$gdb_prompt $" { fail "illegal pointer assignment rejected" } -# timeout { fail "(timeout) illegal pointer assignment rejected" } +# timeout { fail "(timeout) illegal pointer assignment rejected" } # } @@ -74,7 +70,7 @@ gdb_test "next " "more_code.*;" "continuing after dummy()" # pass "illegal pointer assignment rejected" # } # -re ".*$gdb_prompt $" { fail "illegal pointer assignment rejected" } -# timeout { fail "(timeout) ilegal pointer assignment rejected" } +# timeout { fail "(timeout) ilegal pointer assignment rejected" } # } #send_gdb "print v_unsigned_int_pointer == v_double_pointer\n" @@ -83,7 +79,7 @@ gdb_test "next " "more_code.*;" "continuing after dummy()" # pass "illegal pointer operation (+) rejected" # } # -re ".*$gdb_prompt $" { fail "illegal pointer operation (+) rejected" } -# timeout { fail "(timeout) illegal pointer operation (+) rejected" } +# timeout { fail "(timeout) illegal pointer operation (+) rejected" } # } @@ -93,7 +89,7 @@ gdb_test "next " "more_code.*;" "continuing after dummy()" # pass "illegal pointer operation (*) rejected" # } # -re ".*$gdb_prompt $" { fail "illegal pointer operation (*) rejected" } -# timeout { fail "(timeout) illegal pointer operation (*) rejected" } +# timeout { fail "(timeout) illegal pointer operation (*) rejected" } # } @@ -103,7 +99,7 @@ gdb_test "next " "more_code.*;" "continuing after dummy()" # pass "ilegal pointer assignment rejected" # } # -re ".*$gdb_prompt $" { fail "illegal pointer assignment rejected" } -# timeout { fail "(timeout) illegal pointer assignment rejected" } +# timeout { fail "(timeout) illegal pointer assignment rejected" } # } @@ -113,7 +109,7 @@ gdb_test "next " "more_code.*;" "continuing after dummy()" # pass "illegal pointer assignment rejected" # } # -re ".*$gdb_prompt $" { fail "illegal pointer assignment rejected" } -# timeout { fail "(timeout) illegal pointer assignment rejected" } +# timeout { fail "(timeout) illegal pointer assignment rejected" } # } gdb_test_no_output "set variable v_int_pointer=&v_int_array\[0\]" \ @@ -202,9 +198,9 @@ gdb_test "print *( *(matrix+1) +2)" " = 5" \ gdb_test "print **ptr_to_ptr_to_float" " = 100" \ "print through ptr to ptr" -# tests for pointers +# tests for pointers # with elementary type variables and pointers. -# +# gdb_test "break marker1" ".*" "" gdb_test "cont" "Break.* marker1 \\(\\) at .*:$decimal.*" \ @@ -220,7 +216,7 @@ gdb_test "print *pS" " = -14" "print value of *pS" gdb_test_multiple "ptype pS" "ptype pS" { -re "type = short \\*.*$gdb_prompt $" { pass "ptype pS" } -re "type = short int \\*.*$gdb_prompt $" { pass "ptype pS" } -} +} gdb_test "print *pUS" " = 7" "print value of *pUS" diff --git a/gdb/testsuite/gdb.base/pr10179.exp b/gdb/testsuite/gdb.base/pr10179.exp index efe77aa..a6d8a83 100644 --- a/gdb/testsuite/gdb.base/pr10179.exp +++ b/gdb/testsuite/gdb.base/pr10179.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -22,7 +22,7 @@ if {[build_executable ${testname}.exp $testname $sources {debug}] == -1} { clean_restart ${testname} -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/pr11022.c b/gdb/testsuite/gdb.base/pr11022.c index 1600f2a..81688ad 100644 --- a/gdb/testsuite/gdb.base/pr11022.c +++ b/gdb/testsuite/gdb.base/pr11022.c @@ -1,6 +1,6 @@ /* This test is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/pr11022.exp b/gdb/testsuite/gdb.base/pr11022.exp index 59f8eff..887b8c2 100644 --- a/gdb/testsuite/gdb.base/pr11022.exp +++ b/gdb/testsuite/gdb.base/pr11022.exp @@ -1,4 +1,4 @@ -# Copyright 2009-2024 Free Software Foundation, Inc. +# Copyright 2009-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 @@ -17,15 +17,10 @@ require allow_hw_watchpoint_tests standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -# Start with a fresh gdb. - -clean_restart ${binfile} - if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.base/prelink-lib.c b/gdb/testsuite/gdb.base/prelink-lib.c index 3eac0cf..0f55968 100644 --- a/gdb/testsuite/gdb.base/prelink-lib.c +++ b/gdb/testsuite/gdb.base/prelink-lib.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2006-2024 Free Software Foundation, Inc. + Copyright 2006-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 diff --git a/gdb/testsuite/gdb.base/prelink.c b/gdb/testsuite/gdb.base/prelink.c index 6bc417b..23610db 100644 --- a/gdb/testsuite/gdb.base/prelink.c +++ b/gdb/testsuite/gdb.base/prelink.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2006-2024 Free Software Foundation, Inc. + Copyright 2006-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 diff --git a/gdb/testsuite/gdb.base/prelink.exp b/gdb/testsuite/gdb.base/prelink.exp index 6b4790e..adb9261 100644 --- a/gdb/testsuite/gdb.base/prelink.exp +++ b/gdb/testsuite/gdb.base/prelink.exp @@ -1,4 +1,4 @@ -# Copyright 2006-2024 Free Software Foundation, Inc. +# Copyright 2006-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 @@ -43,13 +43,13 @@ if {$prelink_args == ""} { } set test "split debug of executable" -if [gdb_gnu_strip_debug $binfile] { +if {[gdb_gnu_strip_debug $binfile]} { fail $test } else { pass $test } -if ![prelink_yes $prelink_args] { +if {![prelink_yes $prelink_args]} { # Maybe we don't have prelink. return -1 } @@ -57,10 +57,10 @@ if ![prelink_yes $prelink_args] { set found 0 set coredir "[standard_output_file coredir.[getpid]]" file mkdir $coredir -catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\"" +catch {system "(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1"} foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" { - if [remote_file build exists $i] { + if {[remote_file build exists $i]} { remote_exec build "mv $i [standard_output_file prelink.core]" set found 1 } @@ -69,9 +69,9 @@ foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" { if { $found == 0 } { set names [glob -nocomplain -directory $coredir core.*] if {[llength $names] == 1} { - set corefile [file join $coredir [lindex $names 0]] - remote_exec build "mv $corefile [standard_output_file prelink.core]" - set found 1 + set corefile [file join $coredir [lindex $names 0]] + remote_exec build "mv $corefile [standard_output_file prelink.core]" + set found 1 } } @@ -85,7 +85,7 @@ if { $found == 0 } { } # Relink $libfile to a different address. -if ![prelink_yes $prelink_args] { +if {![prelink_yes $prelink_args]} { return -1 } diff --git a/gdb/testsuite/gdb.base/premature-dummy-frame-removal.c b/gdb/testsuite/gdb.base/premature-dummy-frame-removal.c index 1e78769..bc9e92e 100644 --- a/gdb/testsuite/gdb.base/premature-dummy-frame-removal.c +++ b/gdb/testsuite/gdb.base/premature-dummy-frame-removal.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp b/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp index c813fbe..27e8410 100644 --- a/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp +++ b/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/premature-dummy-frame-removal.py b/gdb/testsuite/gdb.base/premature-dummy-frame-removal.py index 2c3567d..a89e279 100644 --- a/gdb/testsuite/gdb.base/premature-dummy-frame-removal.py +++ b/gdb/testsuite/gdb.base/premature-dummy-frame-removal.py @@ -1,4 +1,4 @@ -# Copyright (C) 2021-2024 Free Software Foundation, Inc. +# Copyright (C) 2021-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 diff --git a/gdb/testsuite/gdb.base/pretty-array.c b/gdb/testsuite/gdb.base/pretty-array.c index d474126..585921d 100644 --- a/gdb/testsuite/gdb.base/pretty-array.c +++ b/gdb/testsuite/gdb.base/pretty-array.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/pretty-array.exp b/gdb/testsuite/gdb.base/pretty-array.exp index 80d515c..1e93ea7 100644 --- a/gdb/testsuite/gdb.base/pretty-array.exp +++ b/gdb/testsuite/gdb.base/pretty-array.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -22,7 +22,7 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/pretty-print.c b/gdb/testsuite/gdb.base/pretty-print.c index 9a93f94..b2cd518 100644 --- a/gdb/testsuite/gdb.base/pretty-print.c +++ b/gdb/testsuite/gdb.base/pretty-print.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/pretty-print.exp b/gdb/testsuite/gdb.base/pretty-print.exp index a36f8fc..8533481 100644 --- a/gdb/testsuite/gdb.base/pretty-print.exp +++ b/gdb/testsuite/gdb.base/pretty-print.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -22,7 +22,7 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/print-file-var-lib1.c b/gdb/testsuite/gdb.base/print-file-var-lib1.c index 7561b64..0a73ba6 100644 --- a/gdb/testsuite/gdb.base/print-file-var-lib1.c +++ b/gdb/testsuite/gdb.base/print-file-var-lib1.c @@ -1,5 +1,5 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/print-file-var-lib2.c b/gdb/testsuite/gdb.base/print-file-var-lib2.c index 4c53c16..97d65ea 100644 --- a/gdb/testsuite/gdb.base/print-file-var-lib2.c +++ b/gdb/testsuite/gdb.base/print-file-var-lib2.c @@ -1,5 +1,5 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/print-file-var-main.c b/gdb/testsuite/gdb.base/print-file-var-main.c index d8475c7..6c67255 100644 --- a/gdb/testsuite/gdb.base/print-file-var-main.c +++ b/gdb/testsuite/gdb.base/print-file-var-main.c @@ -1,5 +1,5 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/print-file-var.exp b/gdb/testsuite/gdb.base/print-file-var.exp index 70e454d..d4866ad 100644 --- a/gdb/testsuite/gdb.base/print-file-var.exp +++ b/gdb/testsuite/gdb.base/print-file-var.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -81,7 +81,7 @@ proc test {hidden dlopen version_id_main lang} { gdb_load_shlib $libobj1 gdb_locate_shlib $libobj2 - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -129,7 +129,7 @@ proc test {hidden dlopen version_id_main lang} { } } - if $version_id_main { + if {$version_id_main} { compare "'print-file-var-main.c'::this_version_id" "vm" compare "this_version_id" "vm" } diff --git a/gdb/testsuite/gdb.base/print-file-var.h b/gdb/testsuite/gdb.base/print-file-var.h index bfcd8cac..7c6de34 100644 --- a/gdb/testsuite/gdb.base/print-file-var.h +++ b/gdb/testsuite/gdb.base/print-file-var.h @@ -1,5 +1,5 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/print-internal-string.c b/gdb/testsuite/gdb.base/print-internal-string.c index 8ede883..b521482 100644 --- a/gdb/testsuite/gdb.base/print-internal-string.c +++ b/gdb/testsuite/gdb.base/print-internal-string.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2023-2024 Free Software Foundation, Inc. + Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/print-internal-string.exp b/gdb/testsuite/gdb.base/print-internal-string.exp index 21605f0..ddfaaef 100644 --- a/gdb/testsuite/gdb.base/print-internal-string.exp +++ b/gdb/testsuite/gdb.base/print-internal-string.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 @@ -27,7 +27,7 @@ if {![runto_main]} { return 0 } -if [allow_python_tests] { +if {[allow_python_tests]} { # The $_as_string convenience function is implemented in Python. gdb_test {printf "%s\n", $_as_string("aabbcc")} "\"aabbcc\"" diff --git a/gdb/testsuite/gdb.base/print-symbol-loading-lib.c b/gdb/testsuite/gdb.base/print-symbol-loading-lib.c index 92d6f60..31ac8dc 100644 --- a/gdb/testsuite/gdb.base/print-symbol-loading-lib.c +++ b/gdb/testsuite/gdb.base/print-symbol-loading-lib.c @@ -1,4 +1,4 @@ -/* Copyright 2010-2024 Free Software Foundation, Inc. +/* Copyright 2010-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/print-symbol-loading-main.c b/gdb/testsuite/gdb.base/print-symbol-loading-main.c index 99bbfd6..359f304 100644 --- a/gdb/testsuite/gdb.base/print-symbol-loading-main.c +++ b/gdb/testsuite/gdb.base/print-symbol-loading-main.c @@ -1,4 +1,4 @@ -/* Copyright 2010-2024 Free Software Foundation, Inc. +/* Copyright 2010-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/print-symbol-loading.exp b/gdb/testsuite/gdb.base/print-symbol-loading.exp index b3520f1..0fdc800 100644 --- a/gdb/testsuite/gdb.base/print-symbol-loading.exp +++ b/gdb/testsuite/gdb.base/print-symbol-loading.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -15,7 +15,7 @@ # Test the "print symbol-loading" option. -require allow_shlib_tests +require allow_shlib_tests gcore_cmd_available standard_testfile print-symbol-loading-main.c set libfile print-symbol-loading-lib @@ -35,10 +35,10 @@ if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } { return -1 } -clean_restart ${binfile} +clean_restart $testfile gdb_load_shlib ${binfile_lib} -if ![runto lib] { +if {![runto lib]} { return -1 } @@ -91,11 +91,11 @@ test_load_core full # Now test the sharedlibrary command. proc test_load_shlib { print_symbol_loading } { - global binfile global gdb_prompt with_test_prefix "shlib ${print_symbol_loading}" { - clean_restart ${binfile} - if ![runto_main] { + clean_restart $::testfile + + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp index 40176c6..2baa339 100644 --- a/gdb/testsuite/gdb.base/printcmds.exp +++ b/gdb/testsuite/gdb.base/printcmds.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -96,18 +96,18 @@ proc test_integer_literals_rejected {} { # Test various octal values. - test_print_reject "p 09" - test_print_reject "p 079" + test_print_reject "p 09" + test_print_reject "p 079" # Test various hexadecimal values. - test_print_reject "p 0xG" - test_print_reject "p 0xAG" + test_print_reject "p 0xG" + test_print_reject "p 0xAG" # Test various binary values. - test_print_reject "p 0b2" - test_print_reject "p 0b12" + test_print_reject "p 0b2" + test_print_reject "p 0b12" } proc test_float_accepted {} { @@ -458,14 +458,14 @@ proc test_print_repeats_10_one { setting } { for { set x 1 } { $x <= 16 } { incr x } { gdb_test_no_output "set print $setting $x" "$setting $x repeats" for { set e 1 } { $e <= 16 } {incr e } { - set v [expr $e - 1] + set v [expr {$e - 1}] set command "p &ctable2\[${v}*16\]" if { $x < $e } { set aval $x } else { set aval $e } - set xval [expr $x - $e] + set xval [expr {$x - $e}] if { $xval < 0 } { set xval 0 } @@ -703,7 +703,7 @@ proc test_artificial_arrays {} { # for the test because that character isn't recognized as an # escape character. set ctrlv "\026" - if [ishost *-*-mingw*] { + if {[ishost *-*-mingw*]} { set ctrlv "" } gdb_test_escape_braces "p int1dim\[0\]${ctrlv}@2" " = {0, 1}" {p int1dim[0]@2} @@ -711,7 +711,7 @@ proc test_artificial_arrays {} { "({{0, 1}, {2, 3}, {4, 5}}|\[Cc\]annot.*)" \ {p int1dim[0]@2@3} gdb_test_escape_braces "p int1dim\[0\]${ctrlv}@FE_TWO" " = {0, 1}" \ - {p int1dim[0]@TWO} + {p int1dim[0]@TWO} gdb_test_escape_braces "p int1dim\[0\]${ctrlv}@FE_TWO${ctrlv}@three" \ "({{0, 1}, {2, 3}, {4, 5}}|\[Cc\]annot.*)" \ {p int1dim[0]@TWO@three} @@ -744,6 +744,12 @@ proc test_print_char_arrays {} { gdb_test_no_output "set print address off" "address off char arrays" } +proc test_print_arrays_negative {} { + # Check whether correct error messages are printed + gdb_test "p 1 == { }" "size of the array element must not be zero" + gdb_test "p 1 == { 1, 'a' }" "array elements must all be the same size" +} + proc test_print_nibbles {} { gdb_test_no_output "set print nibbles on" foreach lang_line { @@ -791,7 +797,7 @@ proc test_print_string_constants {} { gdb_test_no_output "set print elements 50" - if [target_info exists gdb,cannot_call_functions] { + if {[target_info exists gdb,cannot_call_functions]} { unsupported "this target can not call functions" return } @@ -815,7 +821,7 @@ proc test_print_string_constants {} { proc test_print_array_constants {} { global hex - if [target_info exists gdb,cannot_call_functions] { + if {[target_info exists gdb,cannot_call_functions]} { unsupported "this target can not call functions" return } @@ -1022,7 +1028,7 @@ proc test_print_symbol {} { gdb_test_no_output "set print symbol off" } -# Escape a left curly brace to prevent it from being interpreted as +# Escape a left curly brace to prevent it from being interpreted as # the beginning of a bound proc gdb_test_escape_braces { args } { @@ -1235,6 +1241,7 @@ test_print_int_arrays test_print_typedef_arrays test_artificial_arrays test_print_char_arrays +test_print_arrays_negative test_print_nibbles # We used to do the runto main here. test_print_string_constants diff --git a/gdb/testsuite/gdb.base/printf-wchar_t.c b/gdb/testsuite/gdb.base/printf-wchar_t.c index 00b6001..7263f87 100644 --- a/gdb/testsuite/gdb.base/printf-wchar_t.c +++ b/gdb/testsuite/gdb.base/printf-wchar_t.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2023-2024 Free Software Foundation, Inc. + Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/printf-wchar_t.exp b/gdb/testsuite/gdb.base/printf-wchar_t.exp index f4903f7..ea9d37a 100644 --- a/gdb/testsuite/gdb.base/printf-wchar_t.exp +++ b/gdb/testsuite/gdb.base/printf-wchar_t.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/prologue-include.c b/gdb/testsuite/gdb.base/prologue-include.c index b8dd39e..8ca40f8 100644 --- a/gdb/testsuite/gdb.base/prologue-include.c +++ b/gdb/testsuite/gdb.base/prologue-include.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 @@ -22,4 +22,3 @@ main (void) #include "prologue-include.h" return 0; } - diff --git a/gdb/testsuite/gdb.base/prologue-include.exp b/gdb/testsuite/gdb.base/prologue-include.exp index cf748df..d57a471 100644 --- a/gdb/testsuite/gdb.base/prologue-include.exp +++ b/gdb/testsuite/gdb.base/prologue-include.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2024 Free Software Foundation, Inc. +# Copyright (C) 2013-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 diff --git a/gdb/testsuite/gdb.base/prologue-include.h b/gdb/testsuite/gdb.base/prologue-include.h index acdd8c0..1854502 100644 --- a/gdb/testsuite/gdb.base/prologue-include.h +++ b/gdb/testsuite/gdb.base/prologue-include.h @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/prologue.c b/gdb/testsuite/gdb.base/prologue.c index 100e3db..f60c778 100644 --- a/gdb/testsuite/gdb.base/prologue.c +++ b/gdb/testsuite/gdb.base/prologue.c @@ -1,6 +1,6 @@ /* This test is part of GDB, the GNU debugger. - Copyright 2007-2024 Free Software Foundation, Inc. + Copyright 2007-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 diff --git a/gdb/testsuite/gdb.base/prologue.exp b/gdb/testsuite/gdb.base/prologue.exp index a925e4f..e046910 100644 --- a/gdb/testsuite/gdb.base/prologue.exp +++ b/gdb/testsuite/gdb.base/prologue.exp @@ -1,5 +1,5 @@ # Test for prologue skipping in minimal symbols with line info. -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 @@ -18,13 +18,10 @@ require allow_cplus_tests standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart ${binfile} - if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/psym-external-decl-2.c b/gdb/testsuite/gdb.base/psym-external-decl-2.c index 57291f0..a30fa2b 100644 --- a/gdb/testsuite/gdb.base/psym-external-decl-2.c +++ b/gdb/testsuite/gdb.base/psym-external-decl-2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/psym-external-decl.c b/gdb/testsuite/gdb.base/psym-external-decl.c index f651626..e8d3b4a 100644 --- a/gdb/testsuite/gdb.base/psym-external-decl.c +++ b/gdb/testsuite/gdb.base/psym-external-decl.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 @@ -22,4 +22,3 @@ main (void) { return aaa; } - diff --git a/gdb/testsuite/gdb.base/psym-external-decl.exp b/gdb/testsuite/gdb.base/psym-external-decl.exp index 1e2a1d7..9798535 100644 --- a/gdb/testsuite/gdb.base/psym-external-decl.exp +++ b/gdb/testsuite/gdb.base/psym-external-decl.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/psymtab.exp b/gdb/testsuite/gdb.base/psymtab.exp index 8e792b5..bc80740 100644 --- a/gdb/testsuite/gdb.base/psymtab.exp +++ b/gdb/testsuite/gdb.base/psymtab.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 diff --git a/gdb/testsuite/gdb.base/ptr-typedef.c b/gdb/testsuite/gdb.base/ptr-typedef.c index a28e24f..ccde9fb 100644 --- a/gdb/testsuite/gdb.base/ptr-typedef.c +++ b/gdb/testsuite/gdb.base/ptr-typedef.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2005-2024 Free Software Foundation, Inc. + Copyright 2005-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 diff --git a/gdb/testsuite/gdb.base/ptr-typedef.exp b/gdb/testsuite/gdb.base/ptr-typedef.exp index eb70a8a..ce8a599 100644 --- a/gdb/testsuite/gdb.base/ptr-typedef.exp +++ b/gdb/testsuite/gdb.base/ptr-typedef.exp @@ -1,4 +1,4 @@ -# Copyright 2005-2024 Free Software Foundation, Inc. +# Copyright 2005-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 @@ -15,16 +15,11 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -# Get things started. - -clean_restart ${binfile} - -if ![runto marker1] { +if {![runto marker1]} { untested "couldn't run to marker1" } diff --git a/gdb/testsuite/gdb.base/ptype-offsets.cc b/gdb/testsuite/gdb.base/ptype-offsets.cc index 6b1baa8..c657bec 100644 --- a/gdb/testsuite/gdb.base/ptype-offsets.cc +++ b/gdb/testsuite/gdb.base/ptype-offsets.cc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/ptype-offsets.exp b/gdb/testsuite/gdb.base/ptype-offsets.exp index 68748da..a8e9cd7 100644 --- a/gdb/testsuite/gdb.base/ptype-offsets.exp +++ b/gdb/testsuite/gdb.base/ptype-offsets.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -411,7 +411,7 @@ with_test_prefix "with_hex_default" { # Test setting default display to hex gdb_test_no_output "set print type hex on" gdb_test "show print type hex" \ - "Display of struct members offsets and sizes in hexadecimal is on" + "Display of struct members offsets and sizes in hexadecimal is on" # test "ptype /o" is now equivalent to "ptype /ox" gdb_test "ptype /o struct abc" \ diff --git a/gdb/testsuite/gdb.base/ptype.c b/gdb/testsuite/gdb.base/ptype.c index 6d12c2a..92bd624 100644 --- a/gdb/testsuite/gdb.base/ptype.c +++ b/gdb/testsuite/gdb.base/ptype.c @@ -210,7 +210,7 @@ struct highest /**** Enumerations *******/ -enum +enum /* Work around the bug for compilers which don't put out the right stabs. */ #if __GNUC__ < 2 && !defined (_AIX) primary1_tag diff --git a/gdb/testsuite/gdb.base/ptype.exp b/gdb/testsuite/gdb.base/ptype.exp index bdec993..ae52d1b 100644 --- a/gdb/testsuite/gdb.base/ptype.exp +++ b/gdb/testsuite/gdb.base/ptype.exp @@ -1,4 +1,4 @@ -# Copyright 1988-2024 Free Software Foundation, Inc. +# Copyright 1988-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 @@ -51,7 +51,7 @@ gdb_test_multiple "ptype red1" "ptype unnamed enumeration member" { # Here and elsewhere, we accept # "long", "long int", or "int" for long variables (whatis.exp already # has an XFAIL for "int" (Sun cc bug), so no need to fail it here). -gdb_test "ptype struct t_struct" "type = struct t_struct \{.*\[\r\n\] (unsigned |)char v_char_member;.*\[\r\n\] (short|short int) v_short_member;.*\[\r\n\] int v_int_member;.*\[\r\n\] (long|long int|int) v_long_member;.*\[\r\n\] float v_float_member;.*\[\r\n\] double v_double_member;.*\[\r\n\]\}.*" "ptype structure" +gdb_test "ptype struct t_struct" "type = struct t_struct \{.*\[\r\n\] (unsigned |)char v_char_member;.*\[\r\n\] (short|short int) v_short_member;.*\[\r\n\] int v_int_member;.*\[\r\n\] (long|long int|int) v_long_member;.*\[\r\n\] float v_float_member;.*\[\r\n\] double v_double_member;.*\[\r\n\]\}.*" "ptype structure" # Test the equivalence between '.' and '->' for struct member references. @@ -73,30 +73,30 @@ if {[gdb_test "ptype v_t_struct_p->v_float_member" "type = float"] < 0} { # IBM's xlc puts out bogus stabs--the stuff field is type 42, # which isn't defined. -gdb_test "ptype struct link" "type = struct link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.1..2..3.;\[\r\n\]+\}.*" "ptype linked list structure" +gdb_test "ptype struct link" "type = struct link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.1..2..3.;\[\r\n\]+\}.*" "ptype linked list structure" # # test ptype command with unions # -gdb_test "ptype union t_union" "type = union t_union \{.*\[\r\n\] (unsigned |)char v_char_member;.*\[\r\n\] (short|short int) v_short_member;.*\[\r\n\] int v_int_member;.*\[\r\n\] (long|long int|int) v_long_member;.*\[\r\n\] float v_float_member;.*\[\r\n\] double v_double_member;.*\[\r\n\]\}.*" "ptype union" +gdb_test "ptype union t_union" "type = union t_union \{.*\[\r\n\] (unsigned |)char v_char_member;.*\[\r\n\] (short|short int) v_short_member;.*\[\r\n\] int v_int_member;.*\[\r\n\] (long|long int|int) v_long_member;.*\[\r\n\] float v_float_member;.*\[\r\n\] double v_double_member;.*\[\r\n\]\}.*" "ptype union" # IBM's xlc puts out bogus stabs--the stuff field is type 42, # which isn't defined. -gdb_test "ptype union tu_link" "type = union tu_link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.1..2..3.;\[\r\n\]+\}.*" "ptype linked list union" +gdb_test "ptype union tu_link" "type = union tu_link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.1..2..3.;\[\r\n\]+\}.*" "ptype linked list union" # # test ptype command with enums # -gdb_test "ptype primary" "type = enum .red, green, blue.*" "ptype unnamed enumeration" +gdb_test "ptype primary" "type = enum .red, green, blue.*" "ptype unnamed enumeration" -gdb_test "ptype enum colors" "type = enum colors \{yellow, purple, pink\}.*" "ptype named enumeration" +gdb_test "ptype enum colors" "type = enum colors \{yellow, purple, pink\}.*" "ptype named enumeration" # # test ptype command with enums as typedef # -gdb_test "ptype boolean" "type = enum (boolean |)\{FALSE, TRUE\}.*" "ptype unnamed typedef'd enumeration" +gdb_test "ptype boolean" "type = enum (boolean |)\{FALSE, TRUE\}.*" "ptype unnamed typedef'd enumeration" # And check that whatis shows the name, not "enum {...}". # This probably fails for all DWARF 1 cases, so assume so for now. -fnf @@ -132,20 +132,20 @@ gdb_test "ptype enum bvals" "type = enum bvals \{my_false, my_true\}.*" "ptype n # # test ptype command with out-of-order enum values # -gdb_test "ptype enum misordered" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype misordered enumeration" +gdb_test "ptype enum misordered" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype misordered enumeration" # # test ptype command with a named enum's value # -gdb_test "ptype three" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype named enumeration member" +gdb_test "ptype three" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype named enumeration member" -gdb_test "ptype red" "type = enum \{red, green, blue\}.*" "ptype unnamed enumeration member #2" +gdb_test "ptype red" "type = enum \{red, green, blue\}.*" "ptype unnamed enumeration member #2" # # test ptype command with basic C types # # I've commented most of this out because it duplicates tests in whatis.exp. -# I've just left in a token test or 2 which is designed to test that ptype +# I've just left in a token test or 2 which is designed to test that ptype # acts like whatis for basic types. If it is thought to be necessary to # test both whatis and ptype for all the types, the tests should be # merged into whatis.exp, or else maintenance will be a royal pain -kingdon @@ -174,7 +174,7 @@ gdb_test "ptype red" "type = enum \{red, green, blue\}.*" "ptype unnamed enumera # timeout { fail "(timeout) ptype unsigned char" } #} -gdb_test "ptype v_short" "type = short(| int).*" "ptype short" +gdb_test "ptype v_short" "type = short(| int).*" "ptype short" #send "ptype v_signed_short\n" #gdb_expect { @@ -192,7 +192,7 @@ gdb_test "ptype v_short" "type = short(| int).*" "ptype short" #} -gdb_test "ptype v_int" "type = int.*" "ptype int" +gdb_test "ptype v_int" "type = int.*" "ptype int" #send "ptype v_signed_int\n" #gdb_expect { @@ -306,7 +306,7 @@ gdb_test "ptype v_int" "type = int.*" "ptype int" # #send "ptype v_long_array\n" #gdb_expect { -# -re "type = (long|int|long int) .2..*$gdb_prompt $" { +# -re "type = (long|int|long int) .2..*$gdb_prompt $" { # pass "ptype long array" } # -re ".*$gdb_prompt $" { fail "ptype long array" } # timeout { fail "(timeout) ptype long array" } @@ -315,7 +315,7 @@ gdb_test "ptype v_int" "type = int.*" "ptype int" # #send "ptype v_signed_long_array\n" #gdb_expect { -# -re "type = (long|int|long int) .2..*$gdb_prompt $" { +# -re "type = (long|int|long int) .2..*$gdb_prompt $" { # pass "ptype signed long array" } # -re ".*$gdb_prompt $" { fail "ptype signed long array" } # timeout { fail "(timeout) ptype signed long array" } @@ -497,16 +497,16 @@ gdb_test "ptype nested_su.inner_union_instance" "type = union inner_union \{.*\[ # correctly printed (at nesting level 1 and 2). gdb_test "ptype the_highest" \ - "type = struct highest \{.*\[\r\n\] *int a;.*\[\r\n\] *struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{\.\.\.\} anonymous_level_2;.*\[\r\n\] *\} anonymous_level_1;.*\[\r\n\]}.*" + "type = struct highest \{.*\[\r\n\] *int a;.*\[\r\n\] *struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{\.\.\.\} anonymous_level_2;.*\[\r\n\] *\} anonymous_level_1;.*\[\r\n\]}.*" -# Print the type descrption for one of the fields of variable the_highest. +# Print the type description for one of the fields of variable the_highest. # The purpose is to verify that the type of a field that was printed above # as "struct {...}" is now printed in a more descriptive way (because the # nesting level is now one level less). gdb_test "ptype the_highest.anonymous_level_1" \ - "type = struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{.*\[\r\n\] *int c;.*\[\r\n\] *\} anonymous_level_2;.*\[\r\n\]}.*" \ - "ptype the_highest.anonymous_level_1" + "type = struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{.*\[\r\n\] *int c;.*\[\r\n\] *\} anonymous_level_2;.*\[\r\n\]}.*" \ + "ptype the_highest.anonymous_level_1" get_debug_format @@ -528,45 +528,44 @@ proc ptype_maybe_prototyped { id prototyped plain { overprototyped "NO-MATCH" } # Turn the arguments, which are literal strings, into # regular expressions by quoting any special characters they contain. foreach var { prototyped plain overprototyped } { - eval "set val \$$var" - regsub -all "\[\]\[*()\]" $val "\\\\&" val + set val [string_to_regexp [set $var]] regsub -all "short int" $val "short( int)?" val regsub -all "long int" $val "long( int)?" val - eval "set $var \$val" + set $var $val } gdb_test_multiple "ptype $id" "ptype $id" { - -re "type = $prototyped\[\r\n\]+$gdb_prompt $" { - pass "ptype $id" - } - -re "type = $plain\[\r\n\]+$gdb_prompt $" { - if {$gcc_compiled} { setup_xfail_format "stabs" } - fail "ptype $id (compiler doesn't emit prototyped types)" - } - -re "type = $overprototyped\[\r\n\]+$gdb_prompt $" { - if { [test_compiler_info "armcc-*"] } { - setup_xfail "*-*-*" - } - fail "ptype $id (compiler doesn't emit unprototyped types)" - } + -re "type = $prototyped\[\r\n\]+$gdb_prompt $" { + pass "ptype $id" + } + -re "type = $plain\[\r\n\]+$gdb_prompt $" { + if {$gcc_compiled} { setup_xfail_format "stabs" } + fail "ptype $id (compiler doesn't emit prototyped types)" + } + -re "type = $overprototyped\[\r\n\]+$gdb_prompt $" { + # C23 no longer supports non-prototype function declaration, in which + # case the overprototyped regexp is the expected one. Simply pass + # in all cases. + pass "ptype $id (overprototyped)" + } } } ptype_maybe_prototyped "func_type" "int (*)(int (*)(int, float), float)" \ - "int (*)()" + "int (*)()" ptype_maybe_prototyped "old_fptr" "double (*)()" "double (*)()" \ - "double (*)(void)" + "double (*)(void)" ptype_maybe_prototyped "new_fptr" "double (*)(void)" "double (*)()" ptype_maybe_prototyped "fptr" "int (*)(int, float)" "int (*)()" ptype_maybe_prototyped "fptr2" "int *(*)(int (*)(int, float), float)" \ - "int *(*)()" + "int *(*)()" ptype_maybe_prototyped "xptr" "int (*)(int (*)(), int (*)(void), int)" \ - "int (*)()" \ - "int (*)(int (*)(void), int (*)(void), int)" + "int (*)()" \ + "int (*)(int (*)(void), int (*)(void), int)" ptype_maybe_prototyped "ffptr" "int (*(*)(char))(short int)" \ - "int (*(*)())()" + "int (*(*)())()" ptype_maybe_prototyped "fffptr" "int (*(*(*)(char))(short int))(long int)" \ - "int (*(*(*)())())()" + "int (*(*(*)())())()" # Test printing type of typedefs in different scopes, with same name # but different type. @@ -586,7 +585,7 @@ gdb_test "ptype foo" "type = char" "ptype foo typedef after second list of charf if {[runto_main]} { - if [target_info exists gdb,cannot_call_functions] { + if {[target_info exists gdb,cannot_call_functions]} { unsupported "this target can not call functions" return } diff --git a/gdb/testsuite/gdb.base/quit-live.c b/gdb/testsuite/gdb.base/quit-live.c index 3d2e741..5bfaf23 100644 --- a/gdb/testsuite/gdb.base/quit-live.c +++ b/gdb/testsuite/gdb.base/quit-live.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/quit-live.exp b/gdb/testsuite/gdb.base/quit-live.exp index 3199d5f..1ec13b8 100644 --- a/gdb/testsuite/gdb.base/quit-live.exp +++ b/gdb/testsuite/gdb.base/quit-live.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2024 Free Software Foundation, Inc. +# Copyright (C) 2017-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 @@ -95,7 +95,7 @@ proc quit_with_live_inferior {appear_how extra_inferior quit_how} { set test_spawn_id "" if {$appear_how != "attach-nofile"} { - clean_restart $binfile + clean_restart $testfile } else { clean_restart } @@ -119,8 +119,13 @@ proc quit_with_live_inferior {appear_how extra_inferior quit_how} { } if {$extra_inferior} { - gdb_test "add-inferior" "Added inferior 2 on connection .*" \ - "add empty inferior 2" + if {[target_info gdb_protocol] ne "remote"} { + gdb_test "add-inferior" "Added inferior 2 on connection .*" \ + "add empty inferior 2" + } else { + gdb_test "add-inferior -no-connection" "Added inferior 2" \ + "add empty inferior 2" + } gdb_test "inferior 2" "Switching to inferior 2.*" \ "switch to inferior 2" } diff --git a/gdb/testsuite/gdb.base/quit.exp b/gdb/testsuite/gdb.base/quit.exp index b9a80f8..682ce4a 100644 --- a/gdb/testsuite/gdb.base/quit.exp +++ b/gdb/testsuite/gdb.base/quit.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2024 Free Software Foundation, Inc. +# Copyright (C) 2016-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 diff --git a/gdb/testsuite/gdb.base/radix.exp b/gdb/testsuite/gdb.base/radix.exp index 37eb849..eeeb9bb 100644 --- a/gdb/testsuite/gdb.base/radix.exp +++ b/gdb/testsuite/gdb.base/radix.exp @@ -1,5 +1,5 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 1993-2024 Free Software Foundation, Inc. +# Copyright 1993-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 @@ -59,20 +59,20 @@ proc test_input_radix { iradix iradixhex iradixoctal } { test_one_input $iradix "-1" "-1" # test simple two-digit constants - test_one_input $iradix "10" [expr $iradix] - test_one_input $iradix "11" [expr $iradix + 1] - test_one_input $iradix "-10" [expr 0 - $iradix] - test_one_input $iradix "-11" [expr 0 - $iradix - 1] + test_one_input $iradix "10" [expr {$iradix}] + test_one_input $iradix "11" [expr {$iradix + 1}] + test_one_input $iradix "-10" [expr {0 - $iradix}] + test_one_input $iradix "-11" [expr {0 - $iradix - 1}] # test simple three-digit constants - test_one_input $iradix "100" [expr $iradix * $iradix] - test_one_input $iradix "101" [expr $iradix * $iradix + 1] - test_one_input $iradix "-100" [expr 0 - $iradix * $iradix] - test_one_input $iradix "-101" [expr 0 - $iradix * $iradix - 1] + test_one_input $iradix "100" [expr {$iradix * $iradix}] + test_one_input $iradix "101" [expr {$iradix * $iradix + 1}] + test_one_input $iradix "-100" [expr {0 - $iradix * $iradix}] + test_one_input $iradix "-101" [expr {0 - $iradix * $iradix - 1}] # test a five-digit constant test_one_input $iradix "10101" \ - [expr $iradix * $iradix * $iradix * $iradix + $iradix * $iradix + 1] + [expr {$iradix * $iradix * $iradix * $iradix + $iradix * $iradix + 1}] } test_input_radix 2 "2" "2" diff --git a/gdb/testsuite/gdb.base/random-signal.c b/gdb/testsuite/gdb.base/random-signal.c index 4b6d896..127a149 100644 --- a/gdb/testsuite/gdb.base/random-signal.c +++ b/gdb/testsuite/gdb.base/random-signal.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/random-signal.exp b/gdb/testsuite/gdb.base/random-signal.exp index a02d036..afbf58e 100644 --- a/gdb/testsuite/gdb.base/random-signal.exp +++ b/gdb/testsuite/gdb.base/random-signal.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 @@ -49,7 +49,7 @@ proc do_test {} { # while gdb is processing the internal software watchtpoint # single-step. With remote debugging, the ctrl-c reaches GDB first. with_test_prefix "run" { - clean_restart $binfile + clean_restart $testfile if {![runto_main]} { return -1 @@ -62,7 +62,7 @@ with_test_prefix "run" { # reaches GDB first. Test that as well. with_test_prefix "attach" { if {[can_spawn_for_attach]} { - clean_restart $binfile + clean_restart $testfile set test_spawn_id [spawn_wait_for_attach $binfile] set testpid [spawn_id_get_pid $test_spawn_id] diff --git a/gdb/testsuite/gdb.base/randomize.c b/gdb/testsuite/gdb.base/randomize.c index 199440f..193506d 100644 --- a/gdb/testsuite/gdb.base/randomize.c +++ b/gdb/testsuite/gdb.base/randomize.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/randomize.exp b/gdb/testsuite/gdb.base/randomize.exp index 37bf99d..f820267 100644 --- a/gdb/testsuite/gdb.base/randomize.exp +++ b/gdb/testsuite/gdb.base/randomize.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -54,13 +54,13 @@ gdb_test_multiple "${test}" "${test}" { } } gdb_test "show disable-randomization" \ - "Disabling randomization .* is off." \ - "show disable-randomization off" + "Disabling randomization .* is off." \ + "show disable-randomization off" set addr1 [address_get "randomized first address"] set addr2 [address_get "randomized second address"] set test "randomized addresses should not match" -if [string equal $addr1 $addr2] { +if {[string equal $addr1 $addr2]} { untested "no randomization detected on this system" return -1 } else { @@ -69,13 +69,13 @@ if [string equal $addr1 $addr2] { gdb_test_no_output "set disable-randomization on" gdb_test "show disable-randomization" \ - "Disabling randomization .* is on." \ - "show disable-randomization on" + "Disabling randomization .* is on." \ + "show disable-randomization on" set addr1 [address_get "fixed first address"] set addr2 [address_get "fixed second address"] set test "fixed addresses should match" -if [string equal $addr1 $addr2] { +if {[string equal $addr1 $addr2]} { pass $test } else { fail $test diff --git a/gdb/testsuite/gdb.base/range-stepping.c b/gdb/testsuite/gdb.base/range-stepping.c index cd3ba0f..04d56cb 100644 --- a/gdb/testsuite/gdb.base/range-stepping.c +++ b/gdb/testsuite/gdb.base/range-stepping.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/range-stepping.exp b/gdb/testsuite/gdb.base/range-stepping.exp index bdcd598..d1131c8 100644 --- a/gdb/testsuite/gdb.base/range-stepping.exp +++ b/gdb/testsuite/gdb.base/range-stepping.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 @@ -22,11 +22,11 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } -if ![gdb_range_stepping_enabled] { +if {![gdb_range_stepping_enabled]} { unsupported "range stepping not supported by the target" return -1 } @@ -171,7 +171,7 @@ with_test_prefix "loop 2" { # Check that range stepping works well even when it is interrupted by # ctrl-c. -if ![target_info exists gdb,nointerrupts] { +if {![target_info exists gdb,nointerrupts]} { with_test_prefix "interrupt" { gdb_test_no_output "set debug remote 1" diff --git a/gdb/testsuite/gdb.base/readline-ask.c b/gdb/testsuite/gdb.base/readline-ask.c index 247d357..e1b3f2c 100644 --- a/gdb/testsuite/gdb.base/readline-ask.c +++ b/gdb/testsuite/gdb.base/readline-ask.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/readline-ask.exp b/gdb/testsuite/gdb.base/readline-ask.exp index 60a11e0..acf334f 100644 --- a/gdb/testsuite/gdb.base/readline-ask.exp +++ b/gdb/testsuite/gdb.base/readline-ask.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2024 Free Software Foundation, Inc. +# Copyright (C) 2011-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 @@ -13,6 +13,8 @@ # 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 {!is_remote host} + standard_testfile .c set inputrc ${srcdir}/${subdir}/${testfile}.inputrc @@ -25,7 +27,7 @@ setenv TERM dumb # INPUTRC gets reset for the next testfile. setenv INPUTRC $inputrc -clean_restart ${binfile} +clean_restart $testfile if { ![readline_is_used] } { unsupported "completion doesn't work when readline isn't used." diff --git a/gdb/testsuite/gdb.base/readline-ask.inputrc b/gdb/testsuite/gdb.base/readline-ask.inputrc index 072f1a7..6ba06f4 100644 --- a/gdb/testsuite/gdb.base/readline-ask.inputrc +++ b/gdb/testsuite/gdb.base/readline-ask.inputrc @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2024 Free Software Foundation, Inc. +# Copyright (C) 2011-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 diff --git a/gdb/testsuite/gdb.base/readline-commands-eof.c b/gdb/testsuite/gdb.base/readline-commands-eof.c index 4061e6a..60003a6 100644 --- a/gdb/testsuite/gdb.base/readline-commands-eof.c +++ b/gdb/testsuite/gdb.base/readline-commands-eof.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/readline-commands-eof.exp b/gdb/testsuite/gdb.base/readline-commands-eof.exp index c823118..e5dcdd1 100644 --- a/gdb/testsuite/gdb.base/readline-commands-eof.exp +++ b/gdb/testsuite/gdb.base/readline-commands-eof.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 @@ -43,7 +43,7 @@ if { ![readline_supports_eof_flag] } { # arrived. If it is then GDB will start displaying extra blank lines # after each line of input. proc run_test {} { - clean_restart $::binfile + clean_restart $::testfile gdb_breakpoint main @@ -125,4 +125,3 @@ save_vars { env(TERM) } { } } } - diff --git a/gdb/testsuite/gdb.base/readline.exp b/gdb/testsuite/gdb.base/readline.exp index 4e613d6..9b87790 100644 --- a/gdb/testsuite/gdb.base/readline.exp +++ b/gdb/testsuite/gdb.base/readline.exp @@ -1,4 +1,4 @@ -# Copyright 2002-2024 Free Software Foundation, Inc. +# Copyright 2002-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 @@ -21,6 +21,8 @@ # Tests for readline operations. # +require {!is_remote host} + # This function is used to test operate-and-get-next. # NAME is the name of the test. # ARGS is a list of alternating commands and expected results. diff --git a/gdb/testsuite/gdb.base/readnever.c b/gdb/testsuite/gdb.base/readnever.c index e7f755d..5028ae5 100644 --- a/gdb/testsuite/gdb.base/readnever.c +++ b/gdb/testsuite/gdb.base/readnever.c @@ -1,4 +1,4 @@ -/* Copyright 2016-2024 Free Software Foundation, Inc. +/* Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/readnever.exp b/gdb/testsuite/gdb.base/readnever.exp index 6788441..1db5831 100644 --- a/gdb/testsuite/gdb.base/readnever.exp +++ b/gdb/testsuite/gdb.base/readnever.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 @@ -26,7 +26,7 @@ if { [build_executable "failed to build" $testfile $srcfile { debug }] == -1 } { save_vars { GDBFLAGS } { append GDBFLAGS " --readnever" - if { [clean_restart ${binfile}] == -1 } { + if { [clean_restart $testfile] == -1 } { return -1 } } @@ -36,16 +36,16 @@ if {![runto_main]} { } gdb_test "break fun_three" \ - "Breakpoint $decimal at $hex" + "Breakpoint $decimal at $hex" gdb_test "continue" \ - "Breakpoint $decimal, $hex in fun_three \\(\\)" + "Breakpoint $decimal, $hex in fun_three \\(\\)" gdb_test "backtrace" \ - [multi_line "#0 $hex in fun_three \\(\\)" \ - "#1 $hex in fun_two \\(\\)" \ - "#2 $hex in fun_one \\(\\)" \ - "#3 $hex in main \\(\\)" ] + [multi_line "#0 $hex in fun_three \\(\\)" \ + "#1 $hex in fun_two \\(\\)" \ + "#2 $hex in fun_one \\(\\)" \ + "#3 $hex in main \\(\\)" ] gdb_test_no_output "maint info symtabs" \ "maint info symtabs no output for --readnever" diff --git a/gdb/testsuite/gdb.base/realname-expand-real.c b/gdb/testsuite/gdb.base/realname-expand-real.c index 9024f60..c07b72c 100644 --- a/gdb/testsuite/gdb.base/realname-expand-real.c +++ b/gdb/testsuite/gdb.base/realname-expand-real.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/realname-expand.c b/gdb/testsuite/gdb.base/realname-expand.c index 781951f..614f06a 100644 --- a/gdb/testsuite/gdb.base/realname-expand.c +++ b/gdb/testsuite/gdb.base/realname-expand.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/realname-expand.exp b/gdb/testsuite/gdb.base/realname-expand.exp index e62a4db..8753b32 100644 --- a/gdb/testsuite/gdb.base/realname-expand.exp +++ b/gdb/testsuite/gdb.base/realname-expand.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2024 Free Software Foundation, Inc. +# Copyright (C) 2013-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 diff --git a/gdb/testsuite/gdb.base/record-full-error.exp b/gdb/testsuite/gdb.base/record-full-error.exp index 0ec2dab..70d858b 100644 --- a/gdb/testsuite/gdb.base/record-full-error.exp +++ b/gdb/testsuite/gdb.base/record-full-error.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. # -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/recpar.c b/gdb/testsuite/gdb.base/recpar.c index 87746a0..8206f2d 100644 --- a/gdb/testsuite/gdb.base/recpar.c +++ b/gdb/testsuite/gdb.base/recpar.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/recpar.exp b/gdb/testsuite/gdb.base/recpar.exp index b62b6aa..59935c2 100644 --- a/gdb/testsuite/gdb.base/recpar.exp +++ b/gdb/testsuite/gdb.base/recpar.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2024 Free Software Foundation, Inc. +# Copyright (C) 2012-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 @@ -19,23 +19,23 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } gdb_test "break $srcfile:[gdb_get_line_number BREAK $srcfile] if n == 3" \ - "Breakpoint $decimal at $hex: file .*recpar\\.c, line $decimal\\." + "Breakpoint $decimal at $hex: file .*recpar\\.c, line $decimal\\." gdb_test "continue" \ - "Breakpoint .* foo \\(n=3\\) at .*$srcfile:$decimal.*" + "Breakpoint .* foo \\(n=3\\) at .*$srcfile:$decimal.*" gdb_test "backtrace" \ - "#0 +foo \\(n=3\\).*\r\n#1.* foo \\(n=4\\).*\r\n#2.* foo \\(n=5\\).*#3.* main \\(\\).*" + "#0 +foo \\(n=3\\).*\r\n#1.* foo \\(n=4\\).*\r\n#2.* foo \\(n=5\\).*#3.* main \\(\\).*" gdb_test "frame 2" \ - "#2 .* foo \\(n=5\\) .*" + "#2 .* foo \\(n=5\\) .*" # In the currently selected frame, n=5, and thus foo::val should be 5 # as well. gdb_test "print foo::val" \ - " = 5" + " = 5" diff --git a/gdb/testsuite/gdb.base/recurse.c b/gdb/testsuite/gdb.base/recurse.c index 821c2de..cd93310 100644 --- a/gdb/testsuite/gdb.base/recurse.c +++ b/gdb/testsuite/gdb.base/recurse.c @@ -1,4 +1,4 @@ -/* Trivial code used to test watchpoints in recursive code and +/* Trivial code used to test watchpoints in recursive code and auto-deletion of watchpoints as they go out of scope. */ static int diff --git a/gdb/testsuite/gdb.base/recurse.exp b/gdb/testsuite/gdb.base/recurse.exp index 01ba55a..a8ad98a 100644 --- a/gdb/testsuite/gdb.base/recurse.exp +++ b/gdb/testsuite/gdb.base/recurse.exp @@ -1,4 +1,4 @@ -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -108,10 +108,10 @@ proc recurse_tests {} { # The former version expected the test to return to main(). # Now it expects the test to return to main or to stop in the # function's epilogue. - # + # # The problem is that gdb needs to (but doesn't) understand # function epilogues in the same way as for prologues. - # + # # If there is no hardware watchpoint (such as a x86 debug register), # then watchpoints are done "the hard way" by single-stepping the # target until the value of the watched variable changes. If you @@ -119,7 +119,7 @@ proc recurse_tests {} { # When you do that, the "top" stack frame may become partially # deconstructed (as when you pop the frame pointer, for instance), # and from that point on, GDB can no longer make sense of the stack. - # + # # A test which stops in the epilogue is trying to determine when GDB # leaves the stack frame in which the watchpoint was created. It does # this basically by watching for the frame pointer to change. When @@ -134,7 +134,7 @@ proc recurse_tests {} { # Preserve the old timeout, and set a new one that should be # sufficient to avoid timing out during this test. set oldtimeout $timeout -set timeout [expr "$timeout + 60"] +set timeout [expr {$timeout + 60}] verbose "Timeout is now $timeout seconds" 2 recurse_tests @@ -142,4 +142,3 @@ recurse_tests # Restore the preserved old timeout value. set timeout $oldtimeout verbose "Timeout is now $timeout seconds" 2 - diff --git a/gdb/testsuite/gdb.base/reggroups.c b/gdb/testsuite/gdb.base/reggroups.c index cd4a9b2..7d13022 100644 --- a/gdb/testsuite/gdb.base/reggroups.c +++ b/gdb/testsuite/gdb.base/reggroups.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/reggroups.exp b/gdb/testsuite/gdb.base/reggroups.exp index 638601b..0d333af 100644 --- a/gdb/testsuite/gdb.base/reggroups.exp +++ b/gdb/testsuite/gdb.base/reggroups.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -114,7 +114,7 @@ set reggroups [fetch_reggroups "fetch reggroups"] set regcount 0 foreach reggroup $reggroups { set regs [fetch_reggroup_regs $reggroup "fetch reggroup regs $reggroup"] - set regcount [expr $regcount + [llength $regs]] + set regcount [expr {$regcount + [llength $regs]}] } gdb_assert "[llength $regcount] != 0" "system has reggroup registers" diff --git a/gdb/testsuite/gdb.base/relational.exp b/gdb/testsuite/gdb.base/relational.exp index 76352fd..864e3e6 100644 --- a/gdb/testsuite/gdb.base/relational.exp +++ b/gdb/testsuite/gdb.base/relational.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -19,7 +19,7 @@ # # tests for correctenss of relational operators, associativity and precedence # with integer type variables -# +# # # test running programs @@ -203,4 +203,3 @@ with_test_prefix "with parenthesis" { # 1 3 4 gdb_test "print (x == y) < z" "$true" "print value of (x==y)<z" } - diff --git a/gdb/testsuite/gdb.base/relativedebug.c b/gdb/testsuite/gdb.base/relativedebug.c index c696cce..f6b1614 100644 --- a/gdb/testsuite/gdb.base/relativedebug.c +++ b/gdb/testsuite/gdb.base/relativedebug.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2007-2024 Free Software Foundation, Inc. + Copyright 2007-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 diff --git a/gdb/testsuite/gdb.base/relativedebug.exp b/gdb/testsuite/gdb.base/relativedebug.exp index f882a5c..44d774d 100644 --- a/gdb/testsuite/gdb.base/relativedebug.exp +++ b/gdb/testsuite/gdb.base/relativedebug.exp @@ -1,4 +1,4 @@ -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 @@ -17,15 +17,10 @@ require {!target_info exists gdb,nosignals} libc_has_debug_info standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -# Get things started. - -clean_restart ${binfile} - runto_main # pause () -> SIGALRM -> handler () -> abort () @@ -60,5 +55,5 @@ gdb_test "continue" "Program received signal SIGABRT.*" # (gdb) gdb_test "bt" \ - ".*\[^a-zA-Z\]pause\[^a-zA-Z\].*" \ - "pause found in backtrace" + ".*\[^a-zA-Z\]pause\[^a-zA-Z\].*" \ + "pause found in backtrace" diff --git a/gdb/testsuite/gdb.base/relocate.c b/gdb/testsuite/gdb.base/relocate.c index 0b65036..6cd946f 100644 --- a/gdb/testsuite/gdb.base/relocate.c +++ b/gdb/testsuite/gdb.base/relocate.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2002-2024 Free Software Foundation, Inc. + Copyright 2002-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 diff --git a/gdb/testsuite/gdb.base/relocate.exp b/gdb/testsuite/gdb.base/relocate.exp index e3a6a03..db42885 100644 --- a/gdb/testsuite/gdb.base/relocate.exp +++ b/gdb/testsuite/gdb.base/relocate.exp @@ -1,4 +1,4 @@ -# Copyright 2002-2024 Free Software Foundation, Inc. +# Copyright 2002-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 @@ -29,7 +29,7 @@ clean_restart #Check that invalid options are rejected. foreach x {"-raednow" "readnow" "foo" "-readnow s"} { - set word [lindex $x [expr [llength $x]-1]] + set word [lindex $x [expr {[llength $x]-1}]] gdb_test "add-symbol-file ${binfile} 0 $x" \ "Unrecognized argument \"$word\"" \ "add-symbol-file: unknown option $word" @@ -278,7 +278,7 @@ with_test_prefix "functions, 2nd" { # Re-load the object giving an explicit address for .text -set text [ format "0x%x" [expr ${function_foo_addr} + 0x20000] ] +set text [ format "0x%x" [expr {${function_foo_addr} + 0x20000}] ] clean_restart gdb_test "add-symbol-file $binfile -o $offset $text" \ "Reading symbols from ${binfile}\.\.\.(\r\n$readnow_re)?" \ @@ -295,7 +295,7 @@ with_test_prefix "functions, 3rd" { # Re-load the object giving an explicit address for .data -set data [ format "0x%x" [expr ${global_foo_addr} + 0x20000] ] +set data [ format "0x%x" [expr {${global_foo_addr} + 0x20000}] ] clean_restart gdb_test "add-symbol-file $binfile -o $offset -s .data $data" \ "Reading symbols from ${binfile}\.\.\.(\r\n$readnow_re)?" \ diff --git a/gdb/testsuite/gdb.base/remote-exec-file.exp b/gdb/testsuite/gdb.base/remote-exec-file.exp index 2ef23f0..baaf039 100644 --- a/gdb/testsuite/gdb.base/remote-exec-file.exp +++ b/gdb/testsuite/gdb.base/remote-exec-file.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -37,10 +37,13 @@ with_test_prefix "set inf 2" { with_test_prefix "show inf 1" { gdb_test "inferior 1" "Switching to inferior 1.*" - gdb_test "show remote exec-file" "prog1" + gdb_test "show remote exec-file" \ + "The remote exec-file is \"prog1\"\\." + } with_test_prefix "show inf 2" { gdb_test "inferior 2" "Switching to inferior 2.*" - gdb_test "show remote exec-file" "prog2" + gdb_test "show remote exec-file" \ + "The remote exec-file is \"prog2\"\\." } diff --git a/gdb/testsuite/gdb.base/remote.c b/gdb/testsuite/gdb.base/remote.c index a43c40b..66f00db 100644 --- a/gdb/testsuite/gdb.base/remote.c +++ b/gdb/testsuite/gdb.base/remote.c @@ -1,14 +1,14 @@ #include <stdio.h> #include <stdlib.h> -/************************************************************************** +/************************************************************************** * TESTS : * -- downloading of a rather large executable - ***************************************************************************/ + ***************************************************************************/ /* A large array in .data. If RLE compression becomes available during - downloads, this would have to become a bunch of real random data. + downloads, this would have to become a bunch of real random data. Here's a quick way of generating such a bunch: awk < /dev/null ' @@ -6187,7 +6187,7 @@ unsigned char random_data[RANDOM_DATA_SIZE] = { }; int -main() +main() { long size = sizeof (random_data) / sizeof (random_data[0]); printf ("%d\n", random_data [size - 1]); diff --git a/gdb/testsuite/gdb.base/remote.exp b/gdb/testsuite/gdb.base/remote.exp index 52c4d27..9faea30 100644 --- a/gdb/testsuite/gdb.base/remote.exp +++ b/gdb/testsuite/gdb.base/remote.exp @@ -1,4 +1,4 @@ -# Copyright 1999-2024 Free Software Foundation, Inc. +# Copyright 1999-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 @@ -136,7 +136,7 @@ proc gdb_load_timed {executable class writesize} { fail "$test - loading executable" return } - verbose "$test - time [expr ($load_end_time - $load_begin_time) / 1000] ms" + verbose "$test - time [expr {($load_end_time - $load_begin_time) / 1000}] ms" pass $test } @@ -164,7 +164,7 @@ gdb_load_timed $binfile "limit" 0 # Get the size of random_data table (defaults to 48K). set sizeof_random_data [get_sizeof "random_data" 48*1024] -clean_restart $binfile +clean_restart $testfile # # Part THREE: Check the upload behavior. diff --git a/gdb/testsuite/gdb.base/remotetimeout.exp b/gdb/testsuite/gdb.base/remotetimeout.exp index b7d8c90..0f1e167 100644 --- a/gdb/testsuite/gdb.base/remotetimeout.exp +++ b/gdb/testsuite/gdb.base/remotetimeout.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/reread-readsym.c b/gdb/testsuite/gdb.base/reread-readsym.c index 0c151af..145a3b4 100644 --- a/gdb/testsuite/gdb.base/reread-readsym.c +++ b/gdb/testsuite/gdb.base/reread-readsym.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/reread-readsym.exp b/gdb/testsuite/gdb.base/reread-readsym.exp index 8c06ff6..698662d 100644 --- a/gdb/testsuite/gdb.base/reread-readsym.exp +++ b/gdb/testsuite/gdb.base/reread-readsym.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/reread.exp b/gdb/testsuite/gdb.base/reread.exp index 481409b..e2eb516 100644 --- a/gdb/testsuite/gdb.base/reread.exp +++ b/gdb/testsuite/gdb.base/reread.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -86,7 +86,7 @@ foreach_with_prefix opts { "" "pie" } { # Should see "Breakpoint 1, foo () at reread2.c:9" set test "run to foo() second time" - if [is_remote target] { + if {[is_remote target]} { unsupported $test } else { gdb_run_cmd @@ -97,7 +97,7 @@ foreach_with_prefix opts { "" "pie" } { ### Second pass: verify that GDB checks the executable file's ### timestamp when the program is *restarted*, not just when it exits. - if [is_remote target] { + if {[is_remote target]} { unsupported "second pass: GDB should check for changes before running" } else { @@ -106,7 +106,7 @@ foreach_with_prefix opts { "" "pie" } { gdb_rename_execfile ${binfile1} ${binfile} # Restart GDB entirely. - clean_restart ${binfile} + clean_restart $testfile # Set a breakpoint on foo and run to it. gdb_test "break foo" \ diff --git a/gdb/testsuite/gdb.base/reset-catchpoint-cond-lib.c b/gdb/testsuite/gdb.base/reset-catchpoint-cond-lib.c index 06f3c3d..1df2260 100644 --- a/gdb/testsuite/gdb.base/reset-catchpoint-cond-lib.c +++ b/gdb/testsuite/gdb.base/reset-catchpoint-cond-lib.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/reset-catchpoint-cond.c b/gdb/testsuite/gdb.base/reset-catchpoint-cond.c index 0c1d5ea..11bd74d 100644 --- a/gdb/testsuite/gdb.base/reset-catchpoint-cond.c +++ b/gdb/testsuite/gdb.base/reset-catchpoint-cond.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/reset-catchpoint-cond.exp b/gdb/testsuite/gdb.base/reset-catchpoint-cond.exp index d953938..852576a 100644 --- a/gdb/testsuite/gdb.base/reset-catchpoint-cond.exp +++ b/gdb/testsuite/gdb.base/reset-catchpoint-cond.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 @@ -75,7 +75,8 @@ proc run_test { mode } { return } - clean_restart $exec_name + clean_restart + gdb_load $exec_name gdb_load_shlib $::libfile if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/reset-catchpoint-cond.py b/gdb/testsuite/gdb.base/reset-catchpoint-cond.py index bf90ec8..d7a4e8d 100644 --- a/gdb/testsuite/gdb.base/reset-catchpoint-cond.py +++ b/gdb/testsuite/gdb.base/reset-catchpoint-cond.py @@ -1,4 +1,4 @@ -# Copyright (C) 2024 Free Software Foundation, Inc. +# Copyright (C) 2024-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 @@ -13,6 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import gdb + bp_modified_list = [] diff --git a/gdb/testsuite/gdb.base/restore.c b/gdb/testsuite/gdb.base/restore.c index 7b7882b..7225937 100644 --- a/gdb/testsuite/gdb.base/restore.c +++ b/gdb/testsuite/gdb.base/restore.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1998-2024 Free Software Foundation, Inc. + Copyright 1998-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 @@ -25,7 +25,7 @@ in this file. If people modify the functions manually, instead of changing this expression and re-running it, then evaluating this expression could wipe out their work, so you probably shouldn't - re-run it. But I leave it here for reference. + re-run it. But I leave it here for reference. (defun callee (n) (format "callee%d" n)) (defun caller (n) (format "caller%d" n)) @@ -33,19 +33,19 @@ (defun local-sum (n) (if (zerop n) (insert "0") (let ((j 1)) - (while (<= j n) - (insert (local j)) - (if (< j n) (insert "+")) - (setq j (1+ j)))))) + (while (<= j n) + (insert (local j)) + (if (< j n) (insert "+")) + (setq j (1+ j)))))) (defun local-chain (n previous first-end) (let ((j 1)) (while (<= j n) (insert " register int " (local j) - " = increment (" previous ");") - (if first-end + " = increment (" previous ");") + (if first-end (progn - (insert " /" "* " first-end " prologue *" "/") - (setq first-end nil))) + (insert " /" "* " first-end " prologue *" "/") + (setq first-end nil))) (insert "\n") (setq previous (local j)) (setq j (1+ j)))) @@ -64,8 +64,8 @@ ;; Generate callee functions. (let ((i 0)) (while (<= i limit) - (insert (format "/%s Returns n * %d + %d %s/\n" - "*" i (/ (+ i (* i i)) 2) "*")) + (insert (format "/%s Returns n * %d + %d %s/\n" + "*" i (/ (+ i (* i i)) 2) "*")) (insert "int\n") (insert (callee i) " (int n)\n") (insert "{\n") @@ -86,13 +86,13 @@ (insert " register int n;\n") (let ((j 0)) (while (<= j limit) - (insert " n = " (callee j) " (" - (if (> j 0) "n + " "") - last ");\n") - (setq j (1+ j))))) + (insert " n = " (callee j) " (" + (if (> j 0) "n + " "") + last ");\n") + (setq j (1+ j))))) (insert " return n+") (local-sum i) - (insert ";\n") + (insert ";\n") (insert "}\n\n") (setq i (1+ i)))) diff --git a/gdb/testsuite/gdb.base/restore.exp b/gdb/testsuite/gdb.base/restore.exp index 2d50fb1..167086b 100644 --- a/gdb/testsuite/gdb.base/restore.exp +++ b/gdb/testsuite/gdb.base/restore.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -44,22 +44,22 @@ proc restore_tests { } { for {set c 1} {$c <= $limit} {incr c} { - # Set a breakpoint at the next caller function. - gdb_test "tbreak caller$c" "Temporary breakpoint.*\[0-9\]*\\." + # Set a breakpoint at the next caller function. + gdb_test "tbreak caller$c" "Temporary breakpoint.*\[0-9\]*\\." # Continue to the next caller function. gdb_test "continue" " caller$c prologue .*" "run to caller$c" # Do each callee function. - for {set e 1} {$e <= $limit} {incr e} { + for {set e 1} {$e <= $limit} {incr e} { - gdb_test "tbreak callee$e" "Temporary breakpoint.*\[0-9\]*\\." \ + gdb_test "tbreak callee$e" "Temporary breakpoint.*\[0-9\]*\\." \ "caller$c calls callee$e; tbreak callee" - - gdb_test "continue" " callee$e prologue .*/" \ + + gdb_test "continue" " callee$e prologue .*/" \ "caller$c calls callee$e; continue to callee" - - # Do a forced return from the callee. + + # Do a forced return from the callee. set test "caller$c calls callee$e; return callee now" gdb_test "return 0" \ @@ -68,14 +68,14 @@ proc restore_tests { } { "Make .* return now.*y or n. $" \ "y" - # Check that the values of the local variables are what + # Check that the values of the local variables are what # they should be. - for {set var 1} {$var <= $c} {incr var} { - set expected [expr 0x7eeb + $var] + for {set var 1} {$var <= $c} {incr var} { + set expected [expr {0x7eeb + $var}] set test "caller$c calls callee$e; return restored l$var to $expected" set pass_pattern " = $expected" set unsupported_pattern " = <optimized out>" - gdb_test_multiple "print l$var" $test { + gdb_test_multiple "print l$var" $test { -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { pass $test } @@ -83,8 +83,8 @@ proc restore_tests { } { unsupported $test } } - } - } + } + } } gdb_continue_to_end "" continue 1 @@ -96,7 +96,7 @@ restore_tests set timeout $prev_timeout # Test PR cli/23785 -clean_restart $binfile +clean_restart $testfile if { ![runto_main] } { return -1 } diff --git a/gdb/testsuite/gdb.base/return-nodebug.c b/gdb/testsuite/gdb.base/return-nodebug.c index d8e08ed..d0724f7 100644 --- a/gdb/testsuite/gdb.base/return-nodebug.c +++ b/gdb/testsuite/gdb.base/return-nodebug.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/return-nodebug.exp b/gdb/testsuite/gdb.base/return-nodebug.exp index d44967b..32b31c6 100644 --- a/gdb/testsuite/gdb.base/return-nodebug.exp +++ b/gdb/testsuite/gdb.base/return-nodebug.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# Copyright (C) 2009-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 diff --git a/gdb/testsuite/gdb.base/return-nodebug1.c b/gdb/testsuite/gdb.base/return-nodebug1.c index d733d06..c129b44 100644 --- a/gdb/testsuite/gdb.base/return-nodebug1.c +++ b/gdb/testsuite/gdb.base/return-nodebug1.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/return.c b/gdb/testsuite/gdb.base/return.c index 6520663..c17470d 100644 --- a/gdb/testsuite/gdb.base/return.c +++ b/gdb/testsuite/gdb.base/return.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1992-2024 Free Software Foundation, Inc. + Copyright 1992-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 diff --git a/gdb/testsuite/gdb.base/return.exp b/gdb/testsuite/gdb.base/return.exp index 23016f8..2d8665f 100644 --- a/gdb/testsuite/gdb.base/return.exp +++ b/gdb/testsuite/gdb.base/return.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1992-2024 Free Software Foundation, Inc. +# Copyright (C) 1992-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 @@ -36,8 +36,8 @@ proc return_tests { } { send_gdb "step\n" exp_continue } - -re ".*in main after func1.*$gdb_prompt $" { - pass "simple return" + -re ".*in main after func1.*$gdb_prompt $" { + pass "simple return" } } diff --git a/gdb/testsuite/gdb.base/return2.c b/gdb/testsuite/gdb.base/return2.c index 58d85ec..bdbe96a 100644 --- a/gdb/testsuite/gdb.base/return2.c +++ b/gdb/testsuite/gdb.base/return2.c @@ -73,7 +73,7 @@ int main (int argc, char **argv) double double_resultval; int i; - /* A "test load" that will insure that the function really returns + /* A "test load" that will insure that the function really returns a ${type} (as opposed to just a truncated or part of a ${type}). */ for (i = 0; i < sizeof (testval.ffff); i++) testval.ffff[i] = 0xff; @@ -102,9 +102,9 @@ int main (int argc, char **argv) throughout the value, so we'll still detect truncated values. */ testval.float_testval = 2.7182818284590452354;/* long_long_checkpoint */ - float_resultval = float_func (); + float_resultval = float_func (); testval.double_testval = 3.14159265358979323846; /* float_checkpoint */ - double_resultval = double_func (); + double_resultval = double_func (); main_test = 1; /* double_checkpoint */ return 0; } diff --git a/gdb/testsuite/gdb.base/return2.exp b/gdb/testsuite/gdb.base/return2.exp index a9b0b98..1840218 100644 --- a/gdb/testsuite/gdb.base/return2.exp +++ b/gdb/testsuite/gdb.base/return2.exp @@ -1,4 +1,4 @@ -# Copyright 2000-2024 Free Software Foundation, Inc. +# Copyright 2000-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 @@ -91,7 +91,7 @@ proc return2_tests { } { return_1 "int" return_1 "long" if {![istarget "m6811-*-*"] && ![istarget "h8300*-*"]} { - return_1 "long_long" + return_1 "long_long" } if {$allow_float_test} { return_1 "float" @@ -103,7 +103,7 @@ proc return2_tests { } { # Start with a fresh gdb. -clean_restart ${binfile} +clean_restart $testfile set timeout 30 return2_tests diff --git a/gdb/testsuite/gdb.base/retval-large-struct.c b/gdb/testsuite/gdb.base/retval-large-struct.c index 52ac178..839b1fb 100644 --- a/gdb/testsuite/gdb.base/retval-large-struct.c +++ b/gdb/testsuite/gdb.base/retval-large-struct.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/retval-large-struct.exp b/gdb/testsuite/gdb.base/retval-large-struct.exp index a8f6ff6..4414f6f 100644 --- a/gdb/testsuite/gdb.base/retval-large-struct.exp +++ b/gdb/testsuite/gdb.base/retval-large-struct.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/reverse-init-functions.exp b/gdb/testsuite/gdb.base/reverse-init-functions.exp index 5558d28..74201e9 100644 --- a/gdb/testsuite/gdb.base/reverse-init-functions.exp +++ b/gdb/testsuite/gdb.base/reverse-init-functions.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/rtld-step-main.c b/gdb/testsuite/gdb.base/rtld-step-main.c index 5677680..91b7727 100644 --- a/gdb/testsuite/gdb.base/rtld-step-main.c +++ b/gdb/testsuite/gdb.base/rtld-step-main.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/rtld-step-nodebugsym.c b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.c index 029a504..4e3f807 100644 --- a/gdb/testsuite/gdb.base/rtld-step-nodebugsym.c +++ b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp index b64c8fe..7c617f2 100644 --- a/gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp +++ b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/rtld-step-rtld.c b/gdb/testsuite/gdb.base/rtld-step-rtld.c index 8d88a5a..31d008f 100644 --- a/gdb/testsuite/gdb.base/rtld-step-rtld.c +++ b/gdb/testsuite/gdb.base/rtld-step-rtld.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/rtld-step.exp b/gdb/testsuite/gdb.base/rtld-step.exp index 1985428..a2086a1 100644 --- a/gdb/testsuite/gdb.base/rtld-step.exp +++ b/gdb/testsuite/gdb.base/rtld-step.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -53,7 +53,7 @@ set binfile_rtld [standard_output_file ${rtld_basename}] # the flags -static-pie -fPIE were needed for Fedora 35 through Fedora # 38. The source file rtld-step-rtld.c didn't need the _start() # function either. And, better still, it was possible to call -# printf() to output progress messages in the pretend/fake RTLD. +# printf() to output progress messages in the pretend/fake RTLD. # Sadly, these output statements had to be removed in order to obtain # code which would work on other Linux distributions / releases. # @@ -114,7 +114,8 @@ if { [gdb_compile ${srcfile_main} ${binfile_main} executable $main_flags] != "" return -1 } -clean_restart ${binfile_main} +clean_restart +gdb_load $binfile_main if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/run-after-attach.c b/gdb/testsuite/gdb.base/run-after-attach.c index 3aa16f5..78b0e7b 100644 --- a/gdb/testsuite/gdb.base/run-after-attach.c +++ b/gdb/testsuite/gdb.base/run-after-attach.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/run-after-attach.exp b/gdb/testsuite/gdb.base/run-after-attach.exp index 7e9211b..2b8b4d0 100644 --- a/gdb/testsuite/gdb.base/run-after-attach.exp +++ b/gdb/testsuite/gdb.base/run-after-attach.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2024 Free Software Foundation, Inc. +# Copyright (C) 2015-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 @@ -21,7 +21,7 @@ require can_spawn_for_attach standard_testfile set executable $testfile -if [prepare_for_testing "failed to prepare" $executable] { +if {[prepare_for_testing "failed to prepare" $executable]} { return -1 } diff --git a/gdb/testsuite/gdb.base/run-attach-while-running.c b/gdb/testsuite/gdb.base/run-attach-while-running.c index a736c7e..35b5df3 100644 --- a/gdb/testsuite/gdb.base/run-attach-while-running.c +++ b/gdb/testsuite/gdb.base/run-attach-while-running.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/run-attach-while-running.exp b/gdb/testsuite/gdb.base/run-attach-while-running.exp index 7bf73fdb..a79a759 100644 --- a/gdb/testsuite/gdb.base/run-attach-while-running.exp +++ b/gdb/testsuite/gdb.base/run-attach-while-running.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 @@ -22,9 +22,10 @@ standard_testfile -set binfile_threads ${binfile}-threads -set binfile_nothreads ${binfile}-nothreads +set testfile_threads ${testfile}-threads +set testfile_nothreads ${testfile}-nothreads unset binfile +unset testfile # Valid parameter / axis values: # @@ -60,7 +61,7 @@ proc_with_prefix test { non-stop threaded run-or-attach } { set ::GDBFLAGS "$::GDBFLAGS -ex \"maint set target-non-stop on\"" } - clean_restart $::binfile + clean_restart $::testfile } if { ![runto_main] } { @@ -89,7 +90,8 @@ proc_with_prefix test { non-stop threaded run-or-attach } { gdb_run_cmd gdb_test "" "Breakpoint $::decimal, .*main.*" "hit main breakpoint after re-run" } elseif { ${run-or-attach} == "attach" } { - set test_spawn_id [spawn_wait_for_attach $::binfile] + set binfile [standard_output_file $::testfile] + set test_spawn_id [spawn_wait_for_attach $binfile] set test_pid [spawn_id_get_pid $test_spawn_id] gdb_test_multiple "attach $test_pid" "attach to process" { @@ -109,12 +111,12 @@ foreach_with_prefix threaded {0 1} { set options [list debug additional_flags=-DWITH_THREADS=$threaded \ additional_flags=-std=gnu99] if { $threaded } { - set binfile $binfile_threads + set testfile $testfile_threads lappend options pthreads } else { - set binfile $binfile_nothreads + set testfile $testfile_nothreads } - if { [build_executable "failed to prepare" ${binfile} ${srcfile} $options] } { + if { [build_executable "failed to prepare" ${testfile} ${srcfile} $options] } { continue } diff --git a/gdb/testsuite/gdb.base/run-control-while-bg-execution.c b/gdb/testsuite/gdb.base/run-control-while-bg-execution.c index 1fd36ee..329b0b1 100644 --- a/gdb/testsuite/gdb.base/run-control-while-bg-execution.c +++ b/gdb/testsuite/gdb.base/run-control-while-bg-execution.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp index 380047a..e5d31e8 100644 --- a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp +++ b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -49,9 +49,14 @@ if {[build_executable "failed to prepare" $testfile $srcfile]} { # - run: use the run command # - attach: start a process outside of GDB and attach it proc do_test { action1 action2 } { + + if {$action1 == "add" && ![allow_multi_inferior_tests]} { + return + } + save_vars { ::GDBFLAGS } { append ::GDBFLAGS " -ex \"maintenance set target-non-stop on\"" - clean_restart $::binfile + clean_restart $::testfile } # Ensure we are at least after the getpid call, should we need it. diff --git a/gdb/testsuite/gdb.base/run-fail-twice.c b/gdb/testsuite/gdb.base/run-fail-twice.c index fddf841..2bbb585 100644 --- a/gdb/testsuite/gdb.base/run-fail-twice.c +++ b/gdb/testsuite/gdb.base/run-fail-twice.c @@ -1,4 +1,4 @@ -/* Copyright 2024 Free Software Foundation, Inc. +/* Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/run-fail-twice.exp b/gdb/testsuite/gdb.base/run-fail-twice.exp index 676fc48..97788c7 100644 --- a/gdb/testsuite/gdb.base/run-fail-twice.exp +++ b/gdb/testsuite/gdb.base/run-fail-twice.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 @@ -43,7 +43,7 @@ proc test_run {testname} { proc_with_prefix test {} { global gdb_prompt binfile - clean_restart $binfile + clean_restart $::testfile gdb_test_no_output "set confirm off" diff --git a/gdb/testsuite/gdb.base/run.c b/gdb/testsuite/gdb.base/run.c index d0e631a..b297821 100644 --- a/gdb/testsuite/gdb.base/run.c +++ b/gdb/testsuite/gdb.base/run.c @@ -17,7 +17,7 @@ main (int argc, char **argv, char **envp) #ifdef FAKEARGV printf ("%d\n", factorial (1)); /* commands.exp: hw local_var out of scope */ -#else +#else if (argc != 2) { printf ("usage: factorial <number>\n"); return 1; diff --git a/gdb/testsuite/gdb.base/save-bp.c b/gdb/testsuite/gdb.base/save-bp.c index 8936894..177741f 100644 --- a/gdb/testsuite/gdb.base/save-bp.c +++ b/gdb/testsuite/gdb.base/save-bp.c @@ -1,4 +1,4 @@ -/* Copyright 2011-2024 Free Software Foundation, Inc. +/* Copyright 2011-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -33,4 +33,3 @@ main (void) break_me (); /* Finally, try a breakpoint with commands. */ return 0; /* Return line. */ } - diff --git a/gdb/testsuite/gdb.base/save-bp.exp b/gdb/testsuite/gdb.base/save-bp.exp index 2872d7b..00b216a 100644 --- a/gdb/testsuite/gdb.base/save-bp.exp +++ b/gdb/testsuite/gdb.base/save-bp.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2024 Free Software Foundation, Inc. +# Copyright (C) 2011-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 @@ -19,7 +19,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} $srcfile] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } # Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that @@ -61,7 +61,7 @@ gdb_test "save breakpoint $bps" "" "save breakpoint bps" # Now start a new debugger session... clean_restart $testfile -if ![runto_main] { +if {![runto_main]} { return -1 } # Delete all breakpoints, watchpoints, tracepoints, and catchpoints so that diff --git a/gdb/testsuite/gdb.base/savedregs.c b/gdb/testsuite/gdb.base/savedregs.c index dffdc87..a916cab 100644 --- a/gdb/testsuite/gdb.base/savedregs.c +++ b/gdb/testsuite/gdb.base/savedregs.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/savedregs.exp b/gdb/testsuite/gdb.base/savedregs.exp index f20fd7c..60a8eec 100644 --- a/gdb/testsuite/gdb.base/savedregs.exp +++ b/gdb/testsuite/gdb.base/savedregs.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 @@ -29,14 +29,10 @@ require {!target_info exists gdb,nosignals} standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -# get things started -clean_restart ${binfile} - # Advance to main if {![runto_main]} { return 0 @@ -95,7 +91,7 @@ proc process_saved_regs { current inner outer } { } incr level } - + # Now iterate through the list of OUTER frames checking that the # "info frame" output from each still matches what was captured # during an early query. To avoid cascading failures, checking is @@ -108,7 +104,7 @@ proc process_saved_regs { current inner outer } { foreach func $outer { set test [concat "Check $func info frame; stack contains" \ $current $inner $outer] - if $ok { + if {$ok} { set ok 0 set pat [string_to_regexp "$saved_regs($func)"] gdb_test_multiple "info frame $level" "$test" { diff --git a/gdb/testsuite/gdb.base/scope-hw-watch-disable.c b/gdb/testsuite/gdb.base/scope-hw-watch-disable.c index df5baad..6453766 100644 --- a/gdb/testsuite/gdb.base/scope-hw-watch-disable.c +++ b/gdb/testsuite/gdb.base/scope-hw-watch-disable.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2023-2024 Free Software Foundation, Inc. + Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/scope-hw-watch-disable.exp b/gdb/testsuite/gdb.base/scope-hw-watch-disable.exp index 29eb682..6ddb2f6 100644 --- a/gdb/testsuite/gdb.base/scope-hw-watch-disable.exp +++ b/gdb/testsuite/gdb.base/scope-hw-watch-disable.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/scope.exp b/gdb/testsuite/gdb.base/scope.exp index a3b11f6..38ab6ca 100644 --- a/gdb/testsuite/gdb.base/scope.exp +++ b/gdb/testsuite/gdb.base/scope.exp @@ -1,4 +1,4 @@ -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -263,7 +263,7 @@ proc_with_prefix test_at_autovars {} { set count 0 while {$count < 100} { gdb_test "print i$count" ".* = $count" "" - set count [expr $count+1] + set count [expr {$count+1}] } clear_xfail "*-*-*" pass "$count auto variables correctly initialized" @@ -327,7 +327,7 @@ clean_restart gdb_file_cmd $binfile # Test that variables in various segments print out correctly before -# the program is run. +# the program is run. # AIX--sections get mapped to the same address so we can't get the right one. setup_xfail "rs6000-*-*" diff --git a/gdb/testsuite/gdb.base/scope1.c b/gdb/testsuite/gdb.base/scope1.c index e4a7ed2..54019d1 100644 --- a/gdb/testsuite/gdb.base/scope1.c +++ b/gdb/testsuite/gdb.base/scope1.c @@ -9,7 +9,7 @@ void foo () { void bar (); - + static int funclocal = 3; /* In Data section */ static int funclocal_bss; /* In BSS section */ static const int funclocal_ro = 203; /* RO Data */ @@ -37,7 +37,7 @@ void init1 () void usestatics1 () { void useit1 (const int *val); - + useit1 (&filelocal); useit1 (&filelocal_bss); useit1 (&filelocal_ro); diff --git a/gdb/testsuite/gdb.base/sect-cmd.exp b/gdb/testsuite/gdb.base/sect-cmd.exp index 49a94cd..e8d1404 100644 --- a/gdb/testsuite/gdb.base/sect-cmd.exp +++ b/gdb/testsuite/gdb.base/sect-cmd.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 diff --git a/gdb/testsuite/gdb.base/segv.c b/gdb/testsuite/gdb.base/segv.c index 53aef97..b730e7a 100644 --- a/gdb/testsuite/gdb.base/segv.c +++ b/gdb/testsuite/gdb.base/segv.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/sep-proc.c b/gdb/testsuite/gdb.base/sep-proc.c index 8466e2e..a72c7d2 100644 --- a/gdb/testsuite/gdb.base/sep-proc.c +++ b/gdb/testsuite/gdb.base/sep-proc.c @@ -1,6 +1,6 @@ /* This file is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/sep.c b/gdb/testsuite/gdb.base/sep.c index 0df02e8..cce3441 100644 --- a/gdb/testsuite/gdb.base/sep.c +++ b/gdb/testsuite/gdb.base/sep.c @@ -1,6 +1,6 @@ /* This file is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 @@ -28,4 +28,3 @@ main (void) say_hello (); return 0; } - diff --git a/gdb/testsuite/gdb.base/sep.exp b/gdb/testsuite/gdb.base/sep.exp index eb36dd0..3a3af32 100644 --- a/gdb/testsuite/gdb.base/sep.exp +++ b/gdb/testsuite/gdb.base/sep.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 @@ -19,14 +19,11 @@ if { [is_remote host] } { standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { - untested "failed to compile" - return -1 -} - set location [gdb_get_line_number "say_hello" "sep-proc.c"] -clean_restart ${binfile} +if { [prepare_for_testing "prepare" $testfile $srcfile {debug nowarnings}] != 0 } { + return +} # Try to display the source code inside a file which is included by # another source file. The purpose of this test is to verify that @@ -39,21 +36,20 @@ clean_restart ${binfile} # decides later to reformat sep-proc.c. gdb_test "list sep-proc.c:$location" \ - "void.*say_hello.*" \ - "list using location inside included file" + "void.*say_hello.*" \ + "list using location inside included file" # Try the same, but this time with a breakpoint. We need to exit # GDB to make sure that we havn't loaded the full symbols yet when # we test the breakpoint insertion. -clean_restart $binfile +clean_restart $testfile set test "breakpoint inside included file" gdb_test_multiple "break sep-proc.c:$location" "$test" { -re "Breakpoint.*at.* file .*sep-proc.c, line .*" { - pass "$test" + pass "$test" } -re "No source file named sep-proc.c.*" { - fail "$test" + fail "$test" } } - diff --git a/gdb/testsuite/gdb.base/sepdebug.c b/gdb/testsuite/gdb.base/sepdebug.c index d6ecadd..47111cb 100644 --- a/gdb/testsuite/gdb.base/sepdebug.c +++ b/gdb/testsuite/gdb.base/sepdebug.c @@ -1,4 +1,4 @@ -/* Copyright 1994-2024 Free Software Foundation, Inc. +/* Copyright 1994-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 diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp index eb3515b..0235cbe 100644 --- a/gdb/testsuite/gdb.base/sepdebug.exp +++ b/gdb/testsuite/gdb.base/sepdebug.exp @@ -1,4 +1,4 @@ -# Copyright 1988-2024 Free Software Foundation, Inc. +# Copyright 1988-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 @@ -42,7 +42,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb # the name of a debuginfo only file. This file will be stored in the # gdb.base/ subdirectory. -if [gdb_gnu_strip_debug $binfile$EXEEXT] { +if {[gdb_gnu_strip_debug $binfile$EXEEXT]} { # check that you have a recent version of strip and objcopy installed unsupported "cannot produce separate debug info files" return -1 @@ -461,7 +461,7 @@ gdb_test "finish 123" \ # Verify that GDB responds gracefully to a request to "finish" from # the outermost frame. On a stub that never exits, this will just -# run to the stubs routine, so we don't get this error... Thus the +# run to the stubs routine, so we don't get this error... Thus the # second condition. # @@ -478,7 +478,7 @@ gdb_test_multiple "finish" "finish from outermost frame disallowed" { # Test "next" over recursive function call. # -proc test_next_with_recursion {} { +proc test_next_with_recursion {} { global gdb_prompt global decimal global binfile @@ -520,7 +520,7 @@ proc test_next_with_recursion {} { delete_breakpoints - if [istarget "mips*tx39-*"] { + if {[istarget "mips*tx39-*"]} { set timeout 60 } # We used to set timeout here for all other targets as well. This @@ -610,7 +610,7 @@ proc test_different_dir {type test_different_dir xfail} { # # Add a second pass pattern. The behavior differs here between stabs # and dwarf for one-line functions. Stabs preserves two line symbols - # (one before the prologue and one after) with the same line number, + # (one before the prologue and one after) with the same line number, # but dwarf regards these as duplicates and discards one of them. # Therefore the address after the prologue (where the breakpoint is) # has no exactly matching line symbol, and GDB reports the breakpoint diff --git a/gdb/testsuite/gdb.base/sepdebug2.c b/gdb/testsuite/gdb.base/sepdebug2.c index e816f41..490b4d8 100644 --- a/gdb/testsuite/gdb.base/sepdebug2.c +++ b/gdb/testsuite/gdb.base/sepdebug2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/sepsymtab.c b/gdb/testsuite/gdb.base/sepsymtab.c index 995d195..1876b5c 100644 --- a/gdb/testsuite/gdb.base/sepsymtab.c +++ b/gdb/testsuite/gdb.base/sepsymtab.c @@ -1,4 +1,4 @@ -/* Copyright 2006-2024 Free Software Foundation, Inc. +/* Copyright 2006-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 diff --git a/gdb/testsuite/gdb.base/sepsymtab.exp b/gdb/testsuite/gdb.base/sepsymtab.exp index c94ca9f..749031c 100644 --- a/gdb/testsuite/gdb.base/sepsymtab.exp +++ b/gdb/testsuite/gdb.base/sepsymtab.exp @@ -1,4 +1,4 @@ -# Copyright 2006-2024 Free Software Foundation, Inc. +# Copyright 2006-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 @@ -25,13 +25,13 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ return -1 } -if [gdb_gnu_strip_debug $binfile no-main] { +if {[gdb_gnu_strip_debug $binfile no-main]} { # check that you have a recent version of strip and objcopy installed unsupported "cannot produce separate debug info files" return -1 } -clean_restart ${binfile} +clean_restart $testfile set command "info sym main" set command_regex [string_to_regexp $command] diff --git a/gdb/testsuite/gdb.base/server-del-break.c b/gdb/testsuite/gdb.base/server-del-break.c index 0c151af..145a3b4 100644 --- a/gdb/testsuite/gdb.base/server-del-break.c +++ b/gdb/testsuite/gdb.base/server-del-break.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/server-del-break.exp b/gdb/testsuite/gdb.base/server-del-break.exp index db59878..9cd1d5b 100644 --- a/gdb/testsuite/gdb.base/server-del-break.exp +++ b/gdb/testsuite/gdb.base/server-del-break.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -25,7 +25,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { } gdb_test "break -q main" \ - "Breakpoint.*at.* file .*$srcfile, line .*" + "Breakpoint.*at.* file .*$srcfile, line .*" # Try deleting all breakpoints, using the "server" command prefix. # Prefixing the "delete breakpoints" with "server" should turn diff --git a/gdb/testsuite/gdb.base/set-cwd.c b/gdb/testsuite/gdb.base/set-cwd.c index f27e398..eaf8a9b 100644 --- a/gdb/testsuite/gdb.base/set-cwd.c +++ b/gdb/testsuite/gdb.base/set-cwd.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/set-cwd.exp b/gdb/testsuite/gdb.base/set-cwd.exp index 41446f8..81b1ec1 100644 --- a/gdb/testsuite/gdb.base/set-cwd.exp +++ b/gdb/testsuite/gdb.base/set-cwd.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -184,7 +184,7 @@ proc_with_prefix test_cwd_reset { } { } test_cd_into_dir -clean_restart $binfile +clean_restart $testfile test_tilde_expansion -clean_restart $binfile +clean_restart $testfile test_cwd_reset diff --git a/gdb/testsuite/gdb.base/set-inferior-tty.c b/gdb/testsuite/gdb.base/set-inferior-tty.c index 26a4197..3207aa9 100644 --- a/gdb/testsuite/gdb.base/set-inferior-tty.c +++ b/gdb/testsuite/gdb.base/set-inferior-tty.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/set-inferior-tty.exp b/gdb/testsuite/gdb.base/set-inferior-tty.exp index 47a1f4d..d24cc99 100644 --- a/gdb/testsuite/gdb.base/set-inferior-tty.exp +++ b/gdb/testsuite/gdb.base/set-inferior-tty.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 @@ -22,9 +22,7 @@ if {[build_executable $testfile.exp $testfile ${srcfile} ${compile_options}] == } proc test_set_inferior_tty { command } { - global binfile - - clean_restart ${binfile} + clean_restart $::testfile gdb_test_no_output "$command hello" "set inferior-tty to hello" gdb_test "show inferior-tty" \ diff --git a/gdb/testsuite/gdb.base/set-lang-auto.exp b/gdb/testsuite/gdb.base/set-lang-auto.exp index 9958e43..947762c 100644 --- a/gdb/testsuite/gdb.base/set-lang-auto.exp +++ b/gdb/testsuite/gdb.base/set-lang-auto.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -26,28 +26,26 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { # Check the language after the binary has been loaded. It should be # "auto; currently c". gdb_test "show lang" \ - "The current source language is \"auto; currently c\"\\." \ - "show lang after loading binary" + "The current source language is \"auto; currently c\"\\." \ + "show lang after loading binary" # Now, switch the language to a specific language, instead of leaving it # on auto. gdb_test_no_output "set lang ada" \ - "forcing the language to ada" + "forcing the language to ada" # Verify that the language is now "ada". gdb_test "show lang" \ - "The current source language is \"ada\"\\." \ - "show lang after switching language to ada" + "The current source language is \"ada\"\\." \ + "show lang after switching language to ada" # Then, switch back to auto... gdb_test_no_output "set lang auto" \ - "switching the language back to auto" + "switching the language back to auto" # ... And verify that the language mode is back to auto *and* that # the selected language is C. gdb_test "show lang" \ - "The current source language is \"auto; currently c\"\\." \ - "show lang after having switched back to auto" - - + "The current source language is \"auto; currently c\"\\." \ + "show lang after having switched back to auto" diff --git a/gdb/testsuite/gdb.base/set-noassign.exp b/gdb/testsuite/gdb.base/set-noassign.exp index f59860d..be0c2bc 100644 --- a/gdb/testsuite/gdb.base/set-noassign.exp +++ b/gdb/testsuite/gdb.base/set-noassign.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp index 9380331..516b387 100644 --- a/gdb/testsuite/gdb.base/setshow.exp +++ b/gdb/testsuite/gdb.base/setshow.exp @@ -1,4 +1,4 @@ -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -29,7 +29,7 @@ if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable {debug}] proc_with_prefix test_setshow_annotate {} { # Start with a fresh gdb - clean_restart $::binfile + clean_restart $::testfile if {![runto_main]} { return @@ -78,7 +78,7 @@ proc_with_prefix test_setshow_annotate {} { } proc_with_prefix test_setshow_args {} { - clean_restart $::binfile + clean_restart $::testfile if {![runto_main]} { return @@ -409,7 +409,7 @@ proc_with_prefix test_setshow_print_characters {} { proc_with_prefix test_setshow_prompt {} { clean_restart - if [board_info target exists gdb_prompt] { + if {[board_info target exists gdb_prompt]} { return } @@ -513,6 +513,70 @@ proc_with_prefix test_argument_preceded_by_space {} { } } +# Some settings are per-inferior instead of global. Verify that we can set +# and show them correctly, including with the $_gdb_setting and +# $_gdb_setting_str convenience functions. + +proc_with_prefix test_per_inferior_settings {} { + clean_restart $::testfile + + # The $_gdb_setting/$_gdb_setting_str tests require running inferiors, + # because they allocate memory in the inferiors for the produced values. + # Since we need two inferiors for this test, we can't run them with stub + # boards (e.g. gdbserver with non-extended remote protocol), since they + # can only run one inferior at a time. We can still run the other tests + # with multiple inferiors, they just won't be running inferiors. + set run [expr {![use_gdb_stub]}] + + # Add a second inferior. + gdb_test "add-inferior -exec $::binfile" "Added inferior 2.*" \ + "add second inferior" + + # Set some settings on each inferior. + foreach_with_prefix inf {1 2} { + gdb_test "inferior ${inf}" "Switching to inferior ${inf}.*" \ + "switch to inferior ${inf} before set" + + if { $run } { + if {![runto_main]} { + fail "could not run to main" + return + } + } + + gdb_test_no_output "set inferior-tty /inf${inf}-tty" + gdb_test_no_output "set cwd /inf${inf}-cwd" + gdb_test_no_output "set args /inf${inf}-args" + gdb_test_no_output "set remote exec-file /inf${inf}-ref" + # Outputs a warning, ignore it. + gdb_test "set tdesc filename /inf${inf}-tf" + } + + foreach_with_prefix inf {1 2} { + gdb_test "inferior ${inf}" "Switching to inferior ${inf}.*" \ + "switch to inferior ${inf} before show" + + gdb_test "show inferior-tty" "Terminal for future runs of program being debugged is \"/inf${inf}-tty\"." + gdb_test "show cwd" "Current working directory that will be used when starting the inferior is \"/inf${inf}-cwd\"." + gdb_test "show args" "Argument list to give program being debugged when it is started is \"/inf${inf}-args\"." + gdb_test "show remote exec-file" "The remote exec-file is \"/inf${inf}-ref\"." + gdb_test "show tdesc filename" "The target description will be read from \"/inf${inf}-tf\"." + + if { $run } { + gdb_test "print \$_gdb_setting(\"inferior-tty\")" " = \"/inf${inf}-tty\"" + gdb_test "print \$_gdb_setting_str(\"inferior-tty\")" " = \"/inf${inf}-tty\"" + gdb_test "print \$_gdb_setting(\"cwd\")" " = \"/inf${inf}-cwd\"" + gdb_test "print \$_gdb_setting_str(\"cwd\")" " = \"/inf${inf}-cwd\"" + gdb_test "print \$_gdb_setting(\"args\")" " = \"/inf${inf}-args\"" + gdb_test "print \$_gdb_setting_str(\"args\")" " = \"/inf${inf}-args\"" + gdb_test "print \$_gdb_setting(\"remote exec-file\")" " = \"/inf${inf}-ref\"" + gdb_test "print \$_gdb_setting_str(\"remote exec-file\")" " = \"/inf${inf}-ref\"" + gdb_test "print \$_gdb_setting(\"tdesc filename\")" " = \"/inf${inf}-tf\"" + gdb_test "print \$_gdb_setting_str(\"tdesc filename\")" " = \"/inf${inf}-tf\"" + } + } +} + test_setshow_annotate test_setshow_args test_setshow_check @@ -533,3 +597,4 @@ test_setshow_write test_show_user test_setshow_verbose test_argument_preceded_by_space +test_per_inferior_settings diff --git a/gdb/testsuite/gdb.base/settings.c b/gdb/testsuite/gdb.base/settings.c index b6a97f1..5333d9d 100644 --- a/gdb/testsuite/gdb.base/settings.c +++ b/gdb/testsuite/gdb.base/settings.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp index 3dafbae..a5eab25 100644 --- a/gdb/testsuite/gdb.base/settings.exp +++ b/gdb/testsuite/gdb.base/settings.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -114,7 +114,7 @@ proc check_type {setting expected} { # "No type information for GDB functions" # Test 'type int', so as to make it fail if ptype is changed. gdb_test "ptype \$_gdb_maint_setting(\"$setting\")" \ - "type = int" + "type = int" } } @@ -528,10 +528,10 @@ proc_with_prefix test-enum {} { # string settings tests. proc test-string {variant} { global gdb_prompt - global srcfile binfile + global srcfile # Load symbols for the completion test below. - clean_restart $binfile + clean_restart $::testfile # Use these variables to make sure we don't call the wrong command # by mistake. diff --git a/gdb/testsuite/gdb.base/setvar.c b/gdb/testsuite/gdb.base/setvar.c index 415eb6f..eccb69b 100644 --- a/gdb/testsuite/gdb.base/setvar.c +++ b/gdb/testsuite/gdb.base/setvar.c @@ -207,16 +207,16 @@ dummy () v_short = 3; v_signed_short = 4; - v_unsigned_short = 5; + v_unsigned_short = 5; v_int = 6; v_signed_int = 7; - v_unsigned_int = 8; + v_unsigned_int = 8; v_long = 9; v_signed_long = 10; - v_unsigned_long = 11; - + v_unsigned_long = 11; + v_float = 100.0; v_double = 200.0; diff --git a/gdb/testsuite/gdb.base/setvar.exp b/gdb/testsuite/gdb.base/setvar.exp index 416dcc6..5335eff 100644 --- a/gdb/testsuite/gdb.base/setvar.exp +++ b/gdb/testsuite/gdb.base/setvar.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 1988-2024 Free Software Foundation, Inc. +# Copyright 1988-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 @@ -33,7 +33,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { # # set it up at a breakpoint so we canplay with the variable values # -gdb_test_no_output "set print sevenbit-strings" +gdb_test_no_output "set print sevenbit-strings" if {![runto_main]} { return @@ -51,22 +51,22 @@ gdb_test_multiple "print sizeof (unsigned long)" "sizeof ulong" { set ulong_minus_1 18446744073709551615 set ulong_minus_456 18446744073709551160 } -} +} proc test_set { args } { global gdb_prompt - set length [expr [llength $args] - 1] + set length [expr {[llength $args] - 1}] set message "[lindex $args $length]" - set final [expr $length - 2] + set final [expr {$length - 2}] set count 1 # Set up the variables. for {set x 0} {$x < $length} {incr x} { if { "[lindex $args $x]" != "" } { set arg [lindex $args $x] - if { ($x == $final) || ([string first ".*" [lindex $args [expr $x + 1]]] >= 0) } { - set match [lindex $args [expr $x + 1]] + if { ($x == $final) || ([string first ".*" [lindex $args [expr {$x + 1}]]] >= 0) } { + set match [lindex $args [expr {$x + 1}]] set mess "$message -- $match" if { $count != 1 } { append mess " (#$count)" @@ -78,7 +78,7 @@ proc test_set { args } { set mess "$message -- $match" } verbose "doing $arg $match" - if [gdb_test -nopass "$arg" "$match" "$mess"] { + if {[gdb_test -nopass "$arg" "$match" "$mess"]} { return 1 } } @@ -91,27 +91,27 @@ proc test_set { args } { # # Because bare char types can be either signed or unsigned, we just test the # range of values that are common to both (0-127). -# +# -test_set "set variable v_char=0" "print v_char" ".\[0-9\]* = 0 \'.000\'" "set variable char=0" -test_set "set variable v_char=1" "print v_char" ".\[0-9\]* = 1 \'.001\'" "set variable char=1" -test_set "set variable v_char=7" "print v_char" ".\[0-9\]* = 7 \'.a\'" "set variable char=7 (Bel)" -test_set "set variable v_char=32" "print v_char" ".\[0-9\]* = 32 \' \'" "set variable char=32 (SPC)" -test_set "set variable v_char=65" "print v_char" ".\[0-9\]* = 65 \'A\'" "set variable char=65 ('A')" -test_set "set variable v_char=97" "print v_char" ".\[0-9\]* = 97 \'a\'" "set variable char=97 ('a')" -test_set "set variable v_char=126" "print v_char" ".\[0-9\]* = 126 \'~\'" "set variable char=126 ('~')" -test_set "set variable v_char=127" "print v_char" ".\[0-9\]* = 127 \'.177\'" "set variable char=127 (8-bit)" +test_set "set variable v_char=0" "print v_char" ".\[0-9\]* = 0 \'.000\'" "set variable char=0" +test_set "set variable v_char=1" "print v_char" ".\[0-9\]* = 1 \'.001\'" "set variable char=1" +test_set "set variable v_char=7" "print v_char" ".\[0-9\]* = 7 \'.a\'" "set variable char=7 (Bel)" +test_set "set variable v_char=32" "print v_char" ".\[0-9\]* = 32 \' \'" "set variable char=32 (SPC)" +test_set "set variable v_char=65" "print v_char" ".\[0-9\]* = 65 \'A\'" "set variable char=65 ('A')" +test_set "set variable v_char=97" "print v_char" ".\[0-9\]* = 97 \'a\'" "set variable char=97 ('a')" +test_set "set variable v_char=126" "print v_char" ".\[0-9\]* = 126 \'~\'" "set variable char=126 ('~')" +test_set "set variable v_char=127" "print v_char" ".\[0-9\]* = 127 \'.177\'" "set variable char=127 (8-bit)" # # test "set variable" for type "signed char" -# -test_set "set variable v_char=0" "print v_signed_char" ".\[0-9\]* = 0 \'.000\'" "set variable signed char=0" -test_set "set variable v_signed_char=1" "print v_signed_char" ".\[0-9\]* = 1 \'.001\'" "set variable signed char=1" -test_set "set variable v_signed_char=7" "print v_signed_char" ".\[0-9\]* = 7 \'.a\'" "set variable signed char=7 (Bel)" -test_set "set variable v_signed_char=32" "print v_signed_char" ".\[0-9\]* = 32 \' \'" "set variable signed char=32 (SPC)" -test_set "set variable v_signed_char=65" "print v_signed_char" ".\[0-9\]* = 65 \'A\'" "set variable signed char=65 ('A')" -test_set "set variable v_signed_char=97" "print v_signed_char" ".\[0-9\]* = 97 \'a\'" "set variable signed char=97 ('a')" -test_set "set variable v_signed_char=126" "print v_signed_char" ".\[0-9\]* = 126 \'~\'" "set variable signed char=126 ('~')" -test_set "set variable v_signed_char=127" "print v_signed_char" ".\[0-9\]* = 127 \'.177\'" "set variable signed char=127 (8-bit)" +# +test_set "set variable v_char=0" "print v_signed_char" ".\[0-9\]* = 0 \'.000\'" "set variable signed char=0" +test_set "set variable v_signed_char=1" "print v_signed_char" ".\[0-9\]* = 1 \'.001\'" "set variable signed char=1" +test_set "set variable v_signed_char=7" "print v_signed_char" ".\[0-9\]* = 7 \'.a\'" "set variable signed char=7 (Bel)" +test_set "set variable v_signed_char=32" "print v_signed_char" ".\[0-9\]* = 32 \' \'" "set variable signed char=32 (SPC)" +test_set "set variable v_signed_char=65" "print v_signed_char" ".\[0-9\]* = 65 \'A\'" "set variable signed char=65 ('A')" +test_set "set variable v_signed_char=97" "print v_signed_char" ".\[0-9\]* = 97 \'a\'" "set variable signed char=97 ('a')" +test_set "set variable v_signed_char=126" "print v_signed_char" ".\[0-9\]* = 126 \'~\'" "set variable signed char=126 ('~')" +test_set "set variable v_signed_char=127" "print v_signed_char" ".\[0-9\]* = 127 \'.177\'" "set variable signed char=127 (8-bit)" gdb_test_no_output "set variable v_signed_char=-1" with_target_charset "ASCII" { @@ -129,156 +129,156 @@ with_target_charset "ASCII" { # # test "set variable" for type "unsigned char" # -test_set "set variable v_unsigned_char=0" "print v_unsigned_char" ".\[0-9\]* = 0 \'.000\'" "set variable unsigned char=0" -test_set "set variable v_unsigned_char=1" "print v_unsigned_char" ".\[0-9\]* = 1 \'.001\'" "set variable unsigned char=1" -test_set "set variable v_unsigned_char=7" "print v_unsigned_char" ".\[0-9\]* = 7 \'.a\'" "set variable unsigned char=7 (Bel)" -test_set "set variable v_unsigned_char=32" "print v_unsigned_char" ".\[0-9\]* = 32 \' \'" "set variable unsigned char=32 (SPC)" -test_set "set variable v_unsigned_char=65" "print v_unsigned_char" ".\[0-9\]* = 65 \'A\'" "set variable unsigned char=65 ('A')" -test_set "set variable v_unsigned_char=97" "print v_unsigned_char" ".\[0-9\]* = 97 \'a\'" "set variable unsigned char=97 ('a')" -test_set "set variable v_unsigned_char=126" "print v_unsigned_char" ".\[0-9\]* = 126 \'~\'" "set variable unsigned char=126 ('~')" +test_set "set variable v_unsigned_char=0" "print v_unsigned_char" ".\[0-9\]* = 0 \'.000\'" "set variable unsigned char=0" +test_set "set variable v_unsigned_char=1" "print v_unsigned_char" ".\[0-9\]* = 1 \'.001\'" "set variable unsigned char=1" +test_set "set variable v_unsigned_char=7" "print v_unsigned_char" ".\[0-9\]* = 7 \'.a\'" "set variable unsigned char=7 (Bel)" +test_set "set variable v_unsigned_char=32" "print v_unsigned_char" ".\[0-9\]* = 32 \' \'" "set variable unsigned char=32 (SPC)" +test_set "set variable v_unsigned_char=65" "print v_unsigned_char" ".\[0-9\]* = 65 \'A\'" "set variable unsigned char=65 ('A')" +test_set "set variable v_unsigned_char=97" "print v_unsigned_char" ".\[0-9\]* = 97 \'a\'" "set variable unsigned char=97 ('a')" +test_set "set variable v_unsigned_char=126" "print v_unsigned_char" ".\[0-9\]* = 126 \'~\'" "set variable unsigned char=126 ('~')" with_target_charset "ASCII" { - test_set "set variable v_unsigned_char=~0" "print v_unsigned_char" ".\[0-9\]* = 255 \'.377\'" "set variable unsigned char=255 (8-bit)" + test_set "set variable v_unsigned_char=~0" "print v_unsigned_char" ".\[0-9\]* = 255 \'.377\'" "set variable unsigned char=255 (8-bit)" } # # test "set variable" for type "short" # -test_set "set variable v_short=0" "print v_short" ".\[0-9\]* = 0" "set variable short=0" -test_set "set variable v_short=1" "print v_short" ".\[0-9\]* = 1" "set variable short=1" -test_set "set variable v_short=-1" "print v_short" ".\[0-9\]* = -1" "set variable short=-1 (minus)" +test_set "set variable v_short=0" "print v_short" ".\[0-9\]* = 0" "set variable short=0" +test_set "set variable v_short=1" "print v_short" ".\[0-9\]* = 1" "set variable short=1" +test_set "set variable v_short=-1" "print v_short" ".\[0-9\]* = -1" "set variable short=-1 (minus)" # # test "set variable" for type "signed short" # -test_set "set variable v_signed_short=0" "print v_signed_short" ".\[0-9\]* = 0" "set variable signed short=0" -test_set "set variable v_signed_short=1" "print v_signed_short" ".\[0-9\]* = 1" "set variable signed short=1" -test_set "set variable v_signed_short=-1" "print v_signed_short" ".\[0-9\]* = -1" "set variable signed short=-1 (minus)" +test_set "set variable v_signed_short=0" "print v_signed_short" ".\[0-9\]* = 0" "set variable signed short=0" +test_set "set variable v_signed_short=1" "print v_signed_short" ".\[0-9\]* = 1" "set variable signed short=1" +test_set "set variable v_signed_short=-1" "print v_signed_short" ".\[0-9\]* = -1" "set variable signed short=-1 (minus)" # # test "set variable" for type "unsigned short" # -test_set "set variable v_unsigned_short=0" "print v_unsigned_short" ".\[0-9\]* = 0" "set variable unsigned short=0" -test_set "set variable v_unsigned_short=1" "print v_unsigned_short" ".\[0-9\]* = 1" "set variable unsigned short=1" -test_set "set variable v_unsigned_short=~0" "print v_unsigned_short" ".\[0-9\]* = 65535" "set variable unsigned short=~0 (minus)" +test_set "set variable v_unsigned_short=0" "print v_unsigned_short" ".\[0-9\]* = 0" "set variable unsigned short=0" +test_set "set variable v_unsigned_short=1" "print v_unsigned_short" ".\[0-9\]* = 1" "set variable unsigned short=1" +test_set "set variable v_unsigned_short=~0" "print v_unsigned_short" ".\[0-9\]* = 65535" "set variable unsigned short=~0 (minus)" # # test "set variable" for type "int" # -test_set "set variable v_int=0" "print v_int" ".\[0-9\]* = 0" "set variable int=0" -test_set "set variable v_int=1" "print v_int" ".\[0-9\]* = 1" "set variable int=1" -test_set "set variable v_int=-1" "print v_int" ".\[0-9\]* = -1" "set variable int=-1 (minus)" +test_set "set variable v_int=0" "print v_int" ".\[0-9\]* = 0" "set variable int=0" +test_set "set variable v_int=1" "print v_int" ".\[0-9\]* = 1" "set variable int=1" +test_set "set variable v_int=-1" "print v_int" ".\[0-9\]* = -1" "set variable int=-1 (minus)" # # test "set variable" for type "signed int" # -test_set "set variable v_signed_int=0" "print v_signed_int" ".\[0-9\]* = 0" "set variable signed int=0" -test_set "set variable v_signed_int=1" "print v_signed_int" ".\[0-9\]* = 1" "set variable signed int=1" -test_set "set variable v_signed_int=-1" "print v_signed_int" ".\[0-9\]* = -1" "set variable signed int=-1 (minus)" +test_set "set variable v_signed_int=0" "print v_signed_int" ".\[0-9\]* = 0" "set variable signed int=0" +test_set "set variable v_signed_int=1" "print v_signed_int" ".\[0-9\]* = 1" "set variable signed int=1" +test_set "set variable v_signed_int=-1" "print v_signed_int" ".\[0-9\]* = -1" "set variable signed int=-1 (minus)" # # test "set variable" for type "unsigned int" # -test_set "set variable v_unsigned_int=0" "print v_unsigned_int" ".\[0-9\]* = 0" "set variable unsigned int=0" -test_set "set variable v_unsigned_int=1" "print v_unsigned_int" ".\[0-9\]* = 1" "set variable unsigned int=1" -test_set "set variable v_unsigned_int=~0" "print v_unsigned_int" ".\[0-9\]* = (4294967295|65535)" "set variable unsigned int=~0 (minus)" -#test_set ".\[0-9\]* = 65535" "set variable unsigned int=~0 (minus)" +test_set "set variable v_unsigned_int=0" "print v_unsigned_int" ".\[0-9\]* = 0" "set variable unsigned int=0" +test_set "set variable v_unsigned_int=1" "print v_unsigned_int" ".\[0-9\]* = 1" "set variable unsigned int=1" +test_set "set variable v_unsigned_int=~0" "print v_unsigned_int" ".\[0-9\]* = (4294967295|65535)" "set variable unsigned int=~0 (minus)" +#test_set ".\[0-9\]* = 65535" "set variable unsigned int=~0 (minus)" # # test "set variable" for type "long" # -test_set "set variable v_long=0" "print v_long" ".\[0-9\]* = 0" "set variable long=0" -test_set "set variable v_long=1" "print v_long" ".\[0-9\]* = 1" "set variable long=1" -test_set "set variable v_long=-1" "print v_long" ".\[0-9\]* = -1" "set variable long=-1 (minus)" +test_set "set variable v_long=0" "print v_long" ".\[0-9\]* = 0" "set variable long=0" +test_set "set variable v_long=1" "print v_long" ".\[0-9\]* = 1" "set variable long=1" +test_set "set variable v_long=-1" "print v_long" ".\[0-9\]* = -1" "set variable long=-1 (minus)" # # test "set variable" for type "signed long" # -test_set "set variable v_signed_long=0" "print v_signed_long" ".\[0-9\]* = 0" "set variable signed long=0" -test_set "set variable v_signed_long=1" "print v_signed_long" ".\[0-9\]* = 1" "set variable signed long=1" -test_set "set variable v_signed_long=-1" "print v_signed_long" ".\[0-9\]* = -1" "set variable signed long=-1 (minus)" +test_set "set variable v_signed_long=0" "print v_signed_long" ".\[0-9\]* = 0" "set variable signed long=0" +test_set "set variable v_signed_long=1" "print v_signed_long" ".\[0-9\]* = 1" "set variable signed long=1" +test_set "set variable v_signed_long=-1" "print v_signed_long" ".\[0-9\]* = -1" "set variable signed long=-1 (minus)" # # test "set variable" for type "unsigned long" # -test_set "set variable v_unsigned_long=0" "print v_unsigned_long" ".\[0-9\]* = 0" "set variable unsigned long=0" -test_set "set variable v_unsigned_long=1" "print v_unsigned_long" ".\[0-9\]* = 1" "set variable unsigned long=1" -test_set "set variable v_unsigned_long=~0" "print v_unsigned_long" ".\[0-9\]* = $ulong_minus_1" "set variable unsigned long=~0 (minus)" +test_set "set variable v_unsigned_long=0" "print v_unsigned_long" ".\[0-9\]* = 0" "set variable unsigned long=0" +test_set "set variable v_unsigned_long=1" "print v_unsigned_long" ".\[0-9\]* = 1" "set variable unsigned long=1" +test_set "set variable v_unsigned_long=~0" "print v_unsigned_long" ".\[0-9\]* = $ulong_minus_1" "set variable unsigned long=~0 (minus)" # # test "set variable" for type "float" # -test_set "set variable v_float=0.0" "print v_float" ".\[0-9\]* = 0" "set variable float=0" -test_set "set variable v_float=1.0" "print v_float" ".\[0-9\]* = 1" "set variable float=1" -test_set "set variable v_float=-1.0" "print v_float" ".\[0-9\]* = -1" "set variable float=-1 (minus)" +test_set "set variable v_float=0.0" "print v_float" ".\[0-9\]* = 0" "set variable float=0" +test_set "set variable v_float=1.0" "print v_float" ".\[0-9\]* = 1" "set variable float=1" +test_set "set variable v_float=-1.0" "print v_float" ".\[0-9\]* = -1" "set variable float=-1 (minus)" # # test "set variable" for type "double" # -test_set "set variable v_double=0.0" "print v_double" ".\[0-9\]* = 0" "set variable double=0" -test_set "set variable v_double=1.0" "print v_double" ".\[0-9\]* = 1" "set variable double=1" -test_set "set variable v_double=-1.0" "print v_double" ".*.\[0-9\]* = -1" "set variable double=-1 (minus)" +test_set "set variable v_double=0.0" "print v_double" ".\[0-9\]* = 0" "set variable double=0" +test_set "set variable v_double=1.0" "print v_double" ".\[0-9\]* = 1" "set variable double=1" +test_set "set variable v_double=-1.0" "print v_double" ".*.\[0-9\]* = -1" "set variable double=-1 (minus)" # # test "set variable" for "char array[2]" # -test_set "set variable v_char_array\[0\]='h'" "set variable v_char_array\[1\]='i'" "print v_char_array" ".*.\[0-9\]* =.*\"hi\"" "set variable char array=\"hi\" (string)" +test_set "set variable v_char_array\[0\]='h'" "set variable v_char_array\[1\]='i'" "print v_char_array" ".*.\[0-9\]* =.*\"hi\"" "set variable char array=\"hi\" (string)" # # test "set variable" for "signed char array[2]" # -test_set "set variable v_signed_char_array\[0\]='h'" "set variable v_signed_char_array\[1\]='i'" "print v_signed_char_array" ".*.\[0-9\]* =.*\"hi\"" "set variable signed char array=\"hi\" (string)" +test_set "set variable v_signed_char_array\[0\]='h'" "set variable v_signed_char_array\[1\]='i'" "print v_signed_char_array" ".*.\[0-9\]* =.*\"hi\"" "set variable signed char array=\"hi\" (string)" # # test "set variable" for "unsigned char array[2]" # -test_set "set variable v_unsigned_char_array\[0\]='h'" "set variable v_unsigned_char_array\[1\]='i'" "print v_unsigned_char_array" ".*.\[0-9\]* =.*\"hi\"" "set variable unsigned char array=\"hi\" (string)" +test_set "set variable v_unsigned_char_array\[0\]='h'" "set variable v_unsigned_char_array\[1\]='i'" "print v_unsigned_char_array" ".*.\[0-9\]* =.*\"hi\"" "set variable unsigned char array=\"hi\" (string)" # # test "set variable" for "short array[2]" # -test_set "set variable v_short_array\[0\]=123" "set variable v_short_array\[1\]=-456" "print v_short_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable short array" +test_set "set variable v_short_array\[0\]=123" "set variable v_short_array\[1\]=-456" "print v_short_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable short array" # # test "set variable" for "signed short array[2]" # -test_set "set variable v_signed_short_array\[0\]=123" "set variable v_signed_short_array\[1\]=-456" "print v_signed_short_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable signed short array" +test_set "set variable v_signed_short_array\[0\]=123" "set variable v_signed_short_array\[1\]=-456" "print v_signed_short_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable signed short array" # # test "set variable" for "unsigned short array[2]" # -test_set "set variable v_unsigned_short_array\[0\]=123" "set variable v_unsigned_short_array\[1\]=-456" "print v_unsigned_short_array" ".*.\[0-9\]* =.*\\{123,.*65080\\}" "set variable unsigned short array" +test_set "set variable v_unsigned_short_array\[0\]=123" "set variable v_unsigned_short_array\[1\]=-456" "print v_unsigned_short_array" ".*.\[0-9\]* =.*\\{123,.*65080\\}" "set variable unsigned short array" # # test "set variable" for "int array[2]" # -test_set "set variable v_int_array\[0\]=123" "set variable v_int_array\[1\]=-456" "print v_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable int array" +test_set "set variable v_int_array\[0\]=123" "set variable v_int_array\[1\]=-456" "print v_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable int array" # # test "set variable" for "signed int array[2]" # -test_set "set variable v_signed_int_array\[0\]=123" "set variable v_signed_int_array\[1\]=-456" "print v_signed_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable signed int array" +test_set "set variable v_signed_int_array\[0\]=123" "set variable v_signed_int_array\[1\]=-456" "print v_signed_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable signed int array" # # test "set variable" for "unsigned int array[2]" # -test_set "set variable v_unsigned_int_array\[0\]=123" "set variable v_unsigned_int_array\[1\]=-456" "print v_unsigned_int_array" ".*.\[0-9\]* =.*\\{123,.*(4294966840|65080)\\}" "set variable unsigned int array" +test_set "set variable v_unsigned_int_array\[0\]=123" "set variable v_unsigned_int_array\[1\]=-456" "print v_unsigned_int_array" ".*.\[0-9\]* =.*\\{123,.*(4294966840|65080)\\}" "set variable unsigned int array" # # test "set variable" for "long array[2]" # -test_set "set variable v_long_array\[0\]=123" "set variable v_long_array\[1\]=-456" "print v_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable long array" +test_set "set variable v_long_array\[0\]=123" "set variable v_long_array\[1\]=-456" "print v_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable long array" # # test "set variable" for "signed long array[2]" # -test_set "set variable v_signed_long_array\[0\]=123" "set variable v_signed_long_array\[1\]=-456" "print v_signed_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable signed long array" +test_set "set variable v_signed_long_array\[0\]=123" "set variable v_signed_long_array\[1\]=-456" "print v_signed_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable signed long array" # # test "set variable" for "unsigned long array[2]" # -test_set "set variable v_unsigned_long_array\[0\]=123" "set variable v_unsigned_long_array\[1\]=-456" "print v_unsigned_long_array" ".*.\[0-9\]* =.*\\{123,.*$ulong_minus_456\\}" "set variable unsigned long array" +test_set "set variable v_unsigned_long_array\[0\]=123" "set variable v_unsigned_long_array\[1\]=-456" "print v_unsigned_long_array" ".*.\[0-9\]* =.*\\{123,.*$ulong_minus_456\\}" "set variable unsigned long array" # # test "set variable" for "float array[2]" # -test_set "set variable v_float_array\[0\]=123.0" "set variable v_float_array\[1\]=-456.0" "print v_float_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable float array" +test_set "set variable v_float_array\[0\]=123.0" "set variable v_float_array\[1\]=-456.0" "print v_float_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable float array" # # test "set variable" for "double array[2]" # -test_set "set variable v_double_array\[0\]=123.0" "set variable v_double_array\[1\]=-456.0" "print v_double_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable double array" +test_set "set variable v_double_array\[0\]=123.0" "set variable v_double_array\[1\]=-456.0" "print v_double_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable double array" # # test "set variable" for type "char *" # -test_set "set v_char_pointer=v_char_array" "set variable *(v_char_pointer)='h'" "set variable *(v_char_pointer+1)='i'" "print v_char_array" ".*.\[0-9\]* =.*\"hi\"" "print *(v_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'" "set variable char pointer=\"hi\" (string)" +test_set "set v_char_pointer=v_char_array" "set variable *(v_char_pointer)='h'" "set variable *(v_char_pointer+1)='i'" "print v_char_array" ".*.\[0-9\]* =.*\"hi\"" "print *(v_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'" "set variable char pointer=\"hi\" (string)" # # test "set variable" for type "signed char *" # -test_set "set v_signed_char_pointer=v_signed_char_array" "set variable *(v_signed_char_pointer)='h'" "set variable *(v_signed_char_pointer+1)='i'" "print v_signed_char_array" ".*.\[0-9\]* =.*\"hi\"" "print *(v_signed_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'" "set variable signed char pointer=\"hi\" (string)" +test_set "set v_signed_char_pointer=v_signed_char_array" "set variable *(v_signed_char_pointer)='h'" "set variable *(v_signed_char_pointer+1)='i'" "print v_signed_char_array" ".*.\[0-9\]* =.*\"hi\"" "print *(v_signed_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'" "set variable signed char pointer=\"hi\" (string)" # # test "set variable" for type "unsigned char *" # -test_set "set v_unsigned_char_pointer=v_unsigned_char_array" "set variable *(v_unsigned_char_pointer)='h'" "set variable *(v_unsigned_char_pointer+1)='i'" "print v_unsigned_char_array" ".*.\[0-9\]* =.*\"hi\"" "print *(v_unsigned_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'" "set variable unsigned char pointer=\"hi\" (string)" +test_set "set v_unsigned_char_pointer=v_unsigned_char_array" "set variable *(v_unsigned_char_pointer)='h'" "set variable *(v_unsigned_char_pointer+1)='i'" "print v_unsigned_char_array" ".*.\[0-9\]* =.*\"hi\"" "print *(v_unsigned_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'" "set variable unsigned char pointer=\"hi\" (string)" # # test "set variable" for type "short *" # -test_set "set v_short_pointer=v_short_array" "set variable *(v_short_pointer)=123" "set variable *(v_short_pointer+1)=-456" "print v_short_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_short_pointer+1)" ".*.\[0-9\]* = -456" "set variable short pointer" +test_set "set v_short_pointer=v_short_array" "set variable *(v_short_pointer)=123" "set variable *(v_short_pointer+1)=-456" "print v_short_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_short_pointer+1)" ".*.\[0-9\]* = -456" "set variable short pointer" # # test "set variable" for type "signed short *" # @@ -300,11 +300,11 @@ gdb_test "print *(v_unsigned_short_pointer+1)" ".\[0-9\]* = 65080" # # test "set variable" for type "int *" # -test_set "set v_int_pointer=v_int_array" "set variable *(v_int_pointer)=123" "set variable *(v_int_pointer+1)=-456" "print v_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_int_pointer+1)" ".*.\[0-9\]* = -456" "set variable int pointer" +test_set "set v_int_pointer=v_int_array" "set variable *(v_int_pointer)=123" "set variable *(v_int_pointer+1)=-456" "print v_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_int_pointer+1)" ".*.\[0-9\]* = -456" "set variable int pointer" # # test "set variable" for type "signed int *" # -test_set "set v_signed_int_pointer=v_signed_int_array" "set variable *(v_signed_int_pointer)=123" "set variable *(v_signed_int_pointer+1)=-456" "print v_signed_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_signed_int_pointer+1)" ".*.\[0-9\]* = -456" "set variable signed int pointer" +test_set "set v_signed_int_pointer=v_signed_int_array" "set variable *(v_signed_int_pointer)=123" "set variable *(v_signed_int_pointer+1)=-456" "print v_signed_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_signed_int_pointer+1)" ".*.\[0-9\]* = -456" "set variable signed int pointer" # # test "set variable" for type "unsigned int *" # @@ -313,32 +313,32 @@ test_set "" "print *(v_unsigned_int_pointer+1)" ".*.\[0-9\]* = (4294966840|65080 # # test "set variable" for type "long *" # -test_set "set v_long_pointer=v_long_array" "set variable *(v_long_pointer)=123" "set variable *(v_long_pointer+1)=-456" "print v_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_long_pointer+1)" ".*.\[0-9\]* = -456" "set variable long pointer" +test_set "set v_long_pointer=v_long_array" "set variable *(v_long_pointer)=123" "set variable *(v_long_pointer+1)=-456" "print v_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_long_pointer+1)" ".*.\[0-9\]* = -456" "set variable long pointer" # # test "set variable" for type "signed long *" # -test_set "set v_signed_long_pointer=v_signed_long_array" "set variable *(v_signed_long_pointer)=123" "set variable *(v_signed_long_pointer+1)=-456" "print v_signed_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_signed_long_pointer+1)" ".*.\[0-9\]* = -456" "set variable signed long pointer" +test_set "set v_signed_long_pointer=v_signed_long_array" "set variable *(v_signed_long_pointer)=123" "set variable *(v_signed_long_pointer+1)=-456" "print v_signed_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_signed_long_pointer+1)" ".*.\[0-9\]* = -456" "set variable signed long pointer" # # test "set variable" for type "unsigned long *" # -test_set "set v_unsigned_long_pointer=v_unsigned_long_array" "set variable *(v_unsigned_long_pointer)=123" "set variable *(v_unsigned_long_pointer+1)=-456" "print v_unsigned_long_array" ".*.\[0-9\]* =.*\\{123,.*$ulong_minus_456\\}" "print *(v_unsigned_long_pointer+1)" ".*.\[0-9\]* = $ulong_minus_456" "set variable unsigned long pointer" +test_set "set v_unsigned_long_pointer=v_unsigned_long_array" "set variable *(v_unsigned_long_pointer)=123" "set variable *(v_unsigned_long_pointer+1)=-456" "print v_unsigned_long_array" ".*.\[0-9\]* =.*\\{123,.*$ulong_minus_456\\}" "print *(v_unsigned_long_pointer+1)" ".*.\[0-9\]* = $ulong_minus_456" "set variable unsigned long pointer" # # test "set variable" for type "float *" # -test_set "set v_float_pointer=v_float_array" "set variable *(v_float_pointer)=123.0" "set variable *(v_float_pointer+1)=-456.0" "print v_float_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_float_pointer+1)" ".*.\[0-9\]* = -456" "set variable float pointer" +test_set "set v_float_pointer=v_float_array" "set variable *(v_float_pointer)=123.0" "set variable *(v_float_pointer+1)=-456.0" "print v_float_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_float_pointer+1)" ".*.\[0-9\]* = -456" "set variable float pointer" # # test "set variable" for type "double *" # -test_set "set v_double_pointer=v_double_array" "set variable *(v_double_pointer)=123.0" "set variable *(v_double_pointer+1)=-456.0" "print v_double_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_double_pointer+1)" ".*.\[0-9\]* = -456" "set variable double pointer" +test_set "set v_double_pointer=v_double_array" "set variable *(v_double_pointer)=123.0" "set variable *(v_double_pointer+1)=-456.0" "print v_double_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_double_pointer+1)" ".*.\[0-9\]* = -456" "set variable double pointer" # # test "set variable" for struct members # -test_set "set variable v_struct1.v_char_member='h'" "print v_struct1.v_char_member" ".*.\[0-9\]* = 104 \'h\'" "set variable structure char member" -test_set "set variable v_struct1.v_short_member=1" "print v_struct1.v_short_member" ".*.\[0-9\]* = 1" "set variable structure short member" -test_set "set variable v_struct1.v_int_member=2" "print v_struct1.v_int_member" ".*.\[0-9\]* = 2" "set variable structure int member" -test_set "set variable v_struct1.v_long_member=3" "print v_struct1.v_long_member" ".*.\[0-9\]* = 3" "set variable structure long member" -test_set "set variable v_struct1.v_float_member=4.0" "print v_struct1.v_float_member" ".*.\[0-9\]* = 4" "set variable structure float member" -test_set "set variable v_struct1.v_double_member=5.0" "print v_struct1.v_double_member" ".*.\[0-9\]* = 5" "set variable structure double member" +test_set "set variable v_struct1.v_char_member='h'" "print v_struct1.v_char_member" ".*.\[0-9\]* = 104 \'h\'" "set variable structure char member" +test_set "set variable v_struct1.v_short_member=1" "print v_struct1.v_short_member" ".*.\[0-9\]* = 1" "set variable structure short member" +test_set "set variable v_struct1.v_int_member=2" "print v_struct1.v_int_member" ".*.\[0-9\]* = 2" "set variable structure int member" +test_set "set variable v_struct1.v_long_member=3" "print v_struct1.v_long_member" ".*.\[0-9\]* = 3" "set variable structure long member" +test_set "set variable v_struct1.v_float_member=4.0" "print v_struct1.v_float_member" ".*.\[0-9\]* = 4" "set variable structure float member" +test_set "set variable v_struct1.v_double_member=5.0" "print v_struct1.v_double_member" ".*.\[0-9\]* = 5" "set variable structure double member" gdb_test "print v_struct1" \ ".*.\[0-9\]* = \{.*v_char_member = 104 \'h\',.*v_short_member = 1,\ diff --git a/gdb/testsuite/gdb.base/share-env-with-gdbserver.c b/gdb/testsuite/gdb.base/share-env-with-gdbserver.c index cdb86d6..3183c33 100644 --- a/gdb/testsuite/gdb.base/share-env-with-gdbserver.c +++ b/gdb/testsuite/gdb.base/share-env-with-gdbserver.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp b/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp index 79cee83..abf347d 100644 --- a/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp +++ b/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -89,9 +89,9 @@ proc do_prepare_inferior { } { # VAR_NAME_MATCH. If empty, defaults, to $var_value. proc do_test { var_value { var_name "" } { var_name_match "" } { var_value_match "" } } { - global binfile test_var_name + global test_var_name - clean_restart $binfile + clean_restart $::testfile if { $var_name == "" } { set var_name $test_var_name @@ -144,9 +144,7 @@ with_test_prefix "strange named var" { # fashions. proc test_set_unset_vars { } { - global binfile - - clean_restart $binfile + clean_restart $::testfile with_test_prefix "set 3 environment variables" { # Set some environment variables @@ -203,9 +201,9 @@ with_test_prefix "test set/unset of vars" { # Test that unsetting works. proc test_unset { } { - global hex decimal binfile gdb_prompt + global hex decimal gdb_prompt - clean_restart $binfile + clean_restart $::testfile do_prepare_inferior @@ -234,7 +232,7 @@ proc test_unset { } { } with_test_prefix "set-then-unset" { - clean_restart $binfile + clean_restart $::testfile # Test if setting and then unsetting $HOME works. gdb_test_no_output "set environment HOME = test" "set HOME as test" diff --git a/gdb/testsuite/gdb.base/share-psymtabs-bt-2.c b/gdb/testsuite/gdb.base/share-psymtabs-bt-2.c index afdf84b..c1d7d2e 100644 --- a/gdb/testsuite/gdb.base/share-psymtabs-bt-2.c +++ b/gdb/testsuite/gdb.base/share-psymtabs-bt-2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/share-psymtabs-bt.c b/gdb/testsuite/gdb.base/share-psymtabs-bt.c index 406ad54..78c24ed 100644 --- a/gdb/testsuite/gdb.base/share-psymtabs-bt.c +++ b/gdb/testsuite/gdb.base/share-psymtabs-bt.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/share-psymtabs-bt.exp b/gdb/testsuite/gdb.base/share-psymtabs-bt.exp index 6c13e5e..3f8b8db 100644 --- a/gdb/testsuite/gdb.base/share-psymtabs-bt.exp +++ b/gdb/testsuite/gdb.base/share-psymtabs-bt.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -28,7 +28,7 @@ standard_testfile .c share-psymtabs-bt-2.c if { [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" \ - {debug}] } { + {debug}] } { untested "failed to compile" return -1 } diff --git a/gdb/testsuite/gdb.base/shell.exp b/gdb/testsuite/gdb.base/shell.exp index e92270c..62052a1 100644 --- a/gdb/testsuite/gdb.base/shell.exp +++ b/gdb/testsuite/gdb.base/shell.exp @@ -1,4 +1,4 @@ -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/shlib-call.exp b/gdb/testsuite/gdb.base/shlib-call.exp index 4a963ed..adba0bd 100644 --- a/gdb/testsuite/gdb.base/shlib-call.exp +++ b/gdb/testsuite/gdb.base/shlib-call.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -42,7 +42,7 @@ set lib2src ${srcdir}/${subdir}/${srcfile3} set lib1 [standard_output_file shr1.sl] set lib2 [standard_output_file shr2.sl] -set lib_opts "debug" +set lib_opts {debug shlib} set exec_opts {} lappend exec_opts debug @@ -50,16 +50,18 @@ lappend exec_opts shlib=$lib1 lappend exec_opts shlib=$lib2 lappend_include_file exec_opts $srcdir/lib/unbuffer_output.c -if { [gdb_compile_shlib ${lib1src} ${lib1} $lib_opts] != "" - || [gdb_compile_shlib ${lib2src} ${lib2} $lib_opts] != "" - || [gdb_compile ${srcfile} ${binfile} executable $exec_opts] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build shlib 1" $lib1 $lib1src $lib_opts] != 0 } { + return } -# Start with a fresh gdb. +if { [build_executable "build shlib 2" $lib2 $lib2src $lib_opts] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } { + return +} -clean_restart ${binfile} gdb_load_shlib $lib1 gdb_load_shlib $lib2 @@ -78,7 +80,7 @@ gdb_test "next 2" "g = shr1\\(g\\);" "next to shr1" gdb_test "print g" "\[0-9\]* = 1" #step -over -if ![gdb_skip_stdio_test "next over shr1"] { +if {![gdb_skip_stdio_test "next over shr1"]} { gdb_test_stdio "next" \ "address of sgs is $hex" \ "g = shr2\\(g\\);" \ @@ -92,7 +94,7 @@ if ![gdb_skip_stdio_test "next over shr1"] { gdb_test "print g" "\[0-9\]* = 2" "print g two" #print shr1(1) -if ![gdb_skip_stdio_test "print shr1(1)"] { +if {![gdb_skip_stdio_test "print shr1(1)"]} { gdb_test_stdio "print shr1(1)" \ "address of sgs is $hex" \ "\[0-9\]* = 2" \ @@ -100,7 +102,7 @@ if ![gdb_skip_stdio_test "print shr1(1)"] { } #print shr1(g) -if ![gdb_skip_stdio_test "print shr1(g)"] { +if {![gdb_skip_stdio_test "print shr1(g)"]} { gdb_test_stdio "print shr1(g)" \ "address of sgs is $hex" \ "\[0-9\]* = 4" \ @@ -119,7 +121,7 @@ gdb_test "continue" \ #print shr1(1) -if ![gdb_skip_stdio_test "print shr1(1) 2nd time"] { +if {![gdb_skip_stdio_test "print shr1(1) 2nd time"]} { gdb_test_stdio "print shr1(1)" \ "address of sgs is $hex" \ "\[0-9\]* = 2" \ @@ -161,7 +163,7 @@ gdb_test "step" "mainshr1 \\(g=4\\) at.*return 2.g;" \ # Start with a fresh gdb. -clean_restart $binfile +clean_restart $testfile # PR's 16495, 18213 # test that we can re-set breakpoints in shared libraries diff --git a/gdb/testsuite/gdb.base/shlib-unload.exp b/gdb/testsuite/gdb.base/shlib-unload.exp index f3e8cce..1eb5f74 100644 --- a/gdb/testsuite/gdb.base/shlib-unload.exp +++ b/gdb/testsuite/gdb.base/shlib-unload.exp @@ -57,7 +57,7 @@ set bp_disabled_re "warning: Temporarily disabling breakpoints for unloaded shar # assuming that GDB has disabled some breakpoints. set stop_after_bp_re [multi_line \ "^$::bp_disabled_re" \ - "[expr $::bp_line + 1]\\s+assert \\(res == 0\\);"] + "[expr {$::bp_line + 1}]\\s+assert \\(res == 0\\);"] # Checking that a breakpoint with multiple locations in a shared # library only triggers a single breakpoint modified event from @@ -69,7 +69,7 @@ proc_with_prefix test_bp_modified_events {} { return } - clean_restart $::binfile + clean_restart $::testfile if {![runto_main]} { return @@ -114,7 +114,7 @@ proc_with_prefix test_bp_modified_events {} { # Check that GDB disables dprintf breakpoints within a shared library # when the shared library is unloaded. proc_with_prefix test_dprintf_after_unload {} { - clean_restart $::binfile + clean_restart $::testfile if {![runto_main]} { return @@ -143,7 +143,7 @@ proc_with_prefix test_dprintf_after_unload {} { # inferior. We should not get an error about re-setting the dprintf # breakpoint. proc_with_prefix test_dprintf_with_rerun {} { - clean_restart $::binfile + clean_restart $::testfile if {![runto_main]} { return @@ -225,6 +225,75 @@ proc_with_prefix test_dprintf_with_rerun {} { "dprintf is non-pending after restart" } +# Check that we see breakpoint modified events (where appropriate) +# when the 'nosharedlibrary' command is used to unload all shared +# libraries. +# +# Also check that the 'nosharedlibrary' doesn't trigger a warning +# about shared library breakpoints being disabled. +proc_with_prefix test_silent_nosharedlib {} { + if { ![allow_python_tests] } { + unsupported "python support needed" + return + } + + foreach_with_prefix type { breakpoint dprintf } { + clean_restart $::testfile + + if {![runto_main]} { + return + } + + gdb_breakpoint $::srcfile:$::bp_line + gdb_continue_to_breakpoint "stop before dlclose" + + # Setup a dprintf or breakpoint in the shared library. + if { $type eq "breakpoint" } { + gdb_test "break foo" + } else { + gdb_test "dprintf foo,\"In foo\"" + } + + # Record the number of the b/p (or dprintf) we just inserted. + set bp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*" \ + "get b/p number"] + + # Load Python library to track b/p modifications. + gdb_test_no_output "source $::pyfile" "import python scripts" + + # Initialise the b/p modified hash. Currently dprintf style + # breakpoints are not visible from Python, so the modification + # count will remain unchanged in that case. + gdb_test_no_output "python bp_modified_counts\[$bp_num\] = 0" + + # Discard symbols from all loaded shared libraries. + gdb_test_no_output "nosharedlibrary" + + # Check that our b/p is now showing as disabled. + if { $type eq "breakpoint" } { + set re \ + [list "$bp_num\\s+breakpoint\\s+keep\\s+y\\s+<PENDING>\\s+foo"] + set count 1 + } else { + set re \ + [list \ + "$bp_num\\s+dprintf\\s+keep\\s+y\\s+<PENDING>\\s+foo" \ + "\\s+printf \"In foo\""] + set count 0 + } + + gdb_test "info breakpoints $bp_num" \ + [multi_line "^Num\\s+Type\\s+Disp\\s+Enb\\s+Address\\s+What" \ + {*}$re] + + # Check we've seen the expected number of breakpoint modified + # events. Currently dprintf breakpoints are not visible from + # Python, so we will not see an event in that case. + gdb_test "python print(bp_modified_counts\[$bp_num\])" "^$count" + } +} + test_bp_modified_events test_dprintf_after_unload test_dprintf_with_rerun +test_silent_nosharedlib diff --git a/gdb/testsuite/gdb.base/shlib-unload.py b/gdb/testsuite/gdb.base/shlib-unload.py index ec62caf..464852b 100644 --- a/gdb/testsuite/gdb.base/shlib-unload.py +++ b/gdb/testsuite/gdb.base/shlib-unload.py @@ -13,6 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import gdb + # Breakpoint modification events will be recorded in this dictionary. # The keys are the b/p numbers, and the values are the number of # modification events seen. @@ -22,7 +24,6 @@ bp_modified_counts = {} # Record breakpoint modification events into the global # bp_modified_counts dictionary. def bp_modified(bp): - global bp_modified_counts if bp.number not in bp_modified_counts: bp_modified_counts[bp.number] = 1 else: diff --git a/gdb/testsuite/gdb.base/shmain.c b/gdb/testsuite/gdb.base/shmain.c index 853352e..f9da71f 100644 --- a/gdb/testsuite/gdb.base/shmain.c +++ b/gdb/testsuite/gdb.base/shmain.c @@ -14,7 +14,7 @@ extern float sg; int eglob; struct { - int a; + int a; int b; } s; diff --git a/gdb/testsuite/gdb.base/show-user-completion.exp b/gdb/testsuite/gdb.base/show-user-completion.exp index 8194915..88f6122 100644 --- a/gdb/testsuite/gdb.base/show-user-completion.exp +++ b/gdb/testsuite/gdb.base/show-user-completion.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/shr1.c b/gdb/testsuite/gdb.base/shr1.c index da7bffa..9d428c6 100644 --- a/gdb/testsuite/gdb.base/shr1.c +++ b/gdb/testsuite/gdb.base/shr1.c @@ -38,6 +38,3 @@ int pstructarg(struct s *x) { return x->a; } - - - diff --git a/gdb/testsuite/gdb.base/shreloc.exp b/gdb/testsuite/gdb.base/shreloc.exp index 82e6ec6..d7c2cc9 100644 --- a/gdb/testsuite/gdb.base/shreloc.exp +++ b/gdb/testsuite/gdb.base/shreloc.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2003-2024 Free Software Foundation, Inc. +# Copyright (C) 2003-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 @@ -35,37 +35,35 @@ set binfile [standard_output_file $testfile] set lib1_sl [standard_output_file shreloc1.sl] set lib2_sl [standard_output_file shreloc2.sl] -set lib_opts "debug" +set lib_opts {debug shlib} set exec_opts [list debug shlib=$lib1_sl shlib=$lib2_sl] if {([istarget "*pc-cygwin"] || [istarget "*pc-mingw32"]) } { lappend lib_opts "ldflags=-Wl,--image-base,0x04000000" } -if [test_compiler_info "xlc-*"] { +if {[test_compiler_info "xlc-*"]} { - # IBM's xlc compiler does not add static variables to the ELF symbol - # table by default. We need this option to make the variables show - # up in "maint print msymbols". + # IBM's xlc compiler does not add static variables to the ELF symbol + # table by default. We need this option to make the variables show + # up in "maint print msymbols". lappend lib_opts "additional_flags=-qstatsym" } -if { [gdb_compile_shlib $lib1src $lib1_sl $lib_opts] != ""} { - untested "could not build $lib1_sl." - return -1 -} elseif { [gdb_compile_shlib $lib2src $lib2_sl $lib_opts] != ""} { - untested "could not build $lib1_s2." - return -1 -} elseif { [gdb_compile $srcfile $binfile executable $exec_opts] != ""} { - untested "could not build $binfile." - return -1 +if { [build_executable "build shlib 1" $lib1_sl $lib1src $lib_opts] != 0} { + return } -# Start with a fresh gdb. +if { [build_executable "build shlib " $lib2_sl $lib2src $lib_opts] != 0} { + return +} + +if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0} { + return +} -clean_restart $binfile gdb_load_shlib $lib1_sl gdb_load_shlib $lib2_sl @@ -193,13 +191,13 @@ proc check_different {var msymfile} { return 1 } -if [is_remote host] { +if {[is_remote host]} { set msymfile shreloc.txt } else { set msymfile [standard_output_file shreloc.txt] } -if [send_gdb_discard "maint print msymbols ${msymfile}"] { +if {[send_gdb_discard "maint print msymbols ${msymfile}"]} { if {[check_different "static_var_\[12\]" "${msymfile}"]} { pass "(msymbol) relocated static vars have different addresses" } else { diff --git a/gdb/testsuite/gdb.base/sigall.c b/gdb/testsuite/gdb.base/sigall.c index 81f3b08..05fdc1d 100644 --- a/gdb/testsuite/gdb.base/sigall.c +++ b/gdb/testsuite/gdb.base/sigall.c @@ -380,7 +380,7 @@ gen_ABRT () { kill (getpid (), SIGABRT); return 0; -} +} int x; @@ -429,7 +429,7 @@ gen_HUP () handle_HUP (0); #endif return 0; -} +} int gen_QUIT () @@ -660,7 +660,7 @@ gen_USR2 () handle_USR2 (0); #endif return 0; -} +} int gen_PWR () diff --git a/gdb/testsuite/gdb.base/sigall.exp b/gdb/testsuite/gdb.base/sigall.exp index 94d58ae..500ccd9 100644 --- a/gdb/testsuite/gdb.base/sigall.exp +++ b/gdb/testsuite/gdb.base/sigall.exp @@ -1,4 +1,4 @@ -# Copyright 1995-2024 Free Software Foundation, Inc. +# Copyright 1995-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 @@ -41,13 +41,14 @@ proc test_one_sig {nextsig} { setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu" } # On Linux SPARC64 systems SIGLOST==SIGPWR and gdb identifies - # the raised signal as PWR. - if {$thissig == "LOST" && [istarget "sparc64-*-linux*"]} { + # the raised signal as PWR. Same for Cygwin. + if {$thissig == "LOST" + && ([istarget "sparc64-*-linux*"] || [istarget "*-*-cygwin*"])} { set esig "PWR" } gdb_test "continue" \ - "Continuing.*Program received signal SIG$esig.*" \ + "Continuing.* received signal SIG$esig.*" \ "get signal $esig" } @@ -55,7 +56,7 @@ proc test_one_sig {nextsig} { if { $thissig == "URG" } { setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu" } - # Either Lynx or GDB screws up on SIGPRIO + # Either Lynx or GDB screws up on SIGPRIO if { $thissig == "PRIO" } { setup_xfail "*-*-*lynx*" } @@ -73,14 +74,14 @@ proc test_one_sig {nextsig} { if {$missed_handler == "0"} { gdb_test_multiple "signal 0" "advance to $nextsig" { -re "Breakpoint.*gen_$nextsig.*\r\n\[0-9\]+\[ \t\]+kill \\(.*\r\n$gdb_prompt $" { - pass "advance to $nextsig" - set sig_supported 1 + pass "advance to $nextsig" + set sig_supported 1 } -re "Breakpoint.*gen_$nextsig.*\r\n\[0-9\]+\[ \t\]+handle_.*\r\n$gdb_prompt $" { - pass "advance to $nextsig" - set sig_supported 0 + pass "advance to $nextsig" + set sig_supported 0 } - } + } } set thissig $nextsig } @@ -177,7 +178,7 @@ gdb_test "handle SIGTERM stop print" \ "SIGTERM\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*" gdb_test "b handle_TERM" "Breakpoint \[0-9\]+ .*" gdb_test "continue" \ - "Continuing.*Program received signal SIGTERM.*" \ + "Continuing.* received signal SIGTERM.*" \ "get signal TERM" gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM" gdb_continue_to_end "continue to sigall exit" diff --git a/gdb/testsuite/gdb.base/sigaltstack.c b/gdb/testsuite/gdb.base/sigaltstack.c index 24bb4a7..4515745 100644 --- a/gdb/testsuite/gdb.base/sigaltstack.c +++ b/gdb/testsuite/gdb.base/sigaltstack.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/sigaltstack.exp b/gdb/testsuite/gdb.base/sigaltstack.exp index fea4e7c..72c9df0 100644 --- a/gdb/testsuite/gdb.base/sigaltstack.exp +++ b/gdb/testsuite/gdb.base/sigaltstack.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 @@ -27,14 +27,10 @@ require {!target_info exists gdb,nosignals} standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -# get things started -clean_restart ${binfile} - # Pass all the alarms straight through (but verbosely) gdb_test "handle SIGALRM print pass nostop" gdb_test "handle SIGVTALRM print pass nostop" diff --git a/gdb/testsuite/gdb.base/sigbpt.c b/gdb/testsuite/gdb.base/sigbpt.c index 8660d8b..66238eb 100644 --- a/gdb/testsuite/gdb.base/sigbpt.c +++ b/gdb/testsuite/gdb.base/sigbpt.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/sigbpt.exp b/gdb/testsuite/gdb.base/sigbpt.exp index 6808db2..c003baf 100644 --- a/gdb/testsuite/gdb.base/sigbpt.exp +++ b/gdb/testsuite/gdb.base/sigbpt.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 @@ -236,7 +236,7 @@ proc cont_out { name args } { # Now single step the faulted instrction at that breakpoint. gdb_test "stepi" \ "Program received signal ${signame}.*pc(\r\n| *)=> [at_segv] .*" \ - "${name}; stepi fault" + "${name}; stepi fault" # Clear any breakpoints for {set i 0} {$i < [llength $args]} {incr i} { diff --git a/gdb/testsuite/gdb.base/sigchld.c b/gdb/testsuite/gdb.base/sigchld.c index d5d9d7b..b642f33 100644 --- a/gdb/testsuite/gdb.base/sigchld.c +++ b/gdb/testsuite/gdb.base/sigchld.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/sigchld.exp b/gdb/testsuite/gdb.base/sigchld.exp index b69b8f8..844d6c8 100644 --- a/gdb/testsuite/gdb.base/sigchld.exp +++ b/gdb/testsuite/gdb.base/sigchld.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2008-2024 Free Software Foundation, Inc. +# Copyright (C) 2008-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 @@ -20,18 +20,16 @@ require {!target_info exists gdb,nosignals} standard_testfile .c -if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart ${binfile} - runto_main gdb_test "b [gdb_get_line_number "good, not blocked"]" \ - ".*Breakpoint .*sigchld.*" "set breakpoint at success exit" + ".*Breakpoint .*sigchld.*" "set breakpoint at success exit" gdb_test "b [gdb_get_line_number "bad, blocked"]" \ - ".*Breakpoint .*sigchld.*" "set breakpoint at failure exit" + ".*Breakpoint .*sigchld.*" "set breakpoint at failure exit" gdb_test "continue" ".*good, not blocked.*" "SIGCHLD blocked in inferior" diff --git a/gdb/testsuite/gdb.base/siginfo-addr.c b/gdb/testsuite/gdb.base/siginfo-addr.c index a7bf13c..7cba3e3 100644 --- a/gdb/testsuite/gdb.base/siginfo-addr.c +++ b/gdb/testsuite/gdb.base/siginfo-addr.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/siginfo-addr.exp b/gdb/testsuite/gdb.base/siginfo-addr.exp index 81b319f..4352503 100644 --- a/gdb/testsuite/gdb.base/siginfo-addr.exp +++ b/gdb/testsuite/gdb.base/siginfo-addr.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/siginfo-infcall.c b/gdb/testsuite/gdb.base/siginfo-infcall.c index ea0ca9e..372ff0a 100644 --- a/gdb/testsuite/gdb.base/siginfo-infcall.c +++ b/gdb/testsuite/gdb.base/siginfo-infcall.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/siginfo-infcall.exp b/gdb/testsuite/gdb.base/siginfo-infcall.exp index 731c3b7..46d67cc 100644 --- a/gdb/testsuite/gdb.base/siginfo-infcall.exp +++ b/gdb/testsuite/gdb.base/siginfo-infcall.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/siginfo-obj.c b/gdb/testsuite/gdb.base/siginfo-obj.c index c06b5a1..3aa7d48 100644 --- a/gdb/testsuite/gdb.base/siginfo-obj.c +++ b/gdb/testsuite/gdb.base/siginfo-obj.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/siginfo-obj.exp b/gdb/testsuite/gdb.base/siginfo-obj.exp index 38065c0..58b5a0a 100644 --- a/gdb/testsuite/gdb.base/siginfo-obj.exp +++ b/gdb/testsuite/gdb.base/siginfo-obj.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 @@ -118,7 +118,7 @@ with_test_prefix "validate modified siginfo fields" { # Test siginfo preservation in core files. if {$gcore_created} { - clean_restart $binfile + clean_restart $testfile gdb_test "core $gcorefile" "Core was generated by.*" \ "core [file tail $gcorefile]" diff --git a/gdb/testsuite/gdb.base/siginfo-thread.c b/gdb/testsuite/gdb.base/siginfo-thread.c index bb9cff6..7ca527c 100644 --- a/gdb/testsuite/gdb.base/siginfo-thread.c +++ b/gdb/testsuite/gdb.base/siginfo-thread.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/siginfo-thread.exp b/gdb/testsuite/gdb.base/siginfo-thread.exp index 384eb8b..09ef242 100644 --- a/gdb/testsuite/gdb.base/siginfo-thread.exp +++ b/gdb/testsuite/gdb.base/siginfo-thread.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 @@ -22,13 +22,10 @@ require supports_get_siginfo_type standard_testfile .c -if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" \ - "${binfile}" executable {debug}] != "" } { - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile {debug pthreads}] != 0 } { + return } -clean_restart $binfile - # Advance to main if {![runto_main]} { return 0 @@ -92,7 +89,7 @@ gdb_test "p \$_siginfo.si_signo == $ssi_signo" " = 0" \ # Test siginfo preservation in core files. if {$gcore_created} { - clean_restart $binfile + clean_restart $testfile gdb_test "core $gcorefile" "Core was generated by.*" \ "core [file tail $gcorefile]" diff --git a/gdb/testsuite/gdb.base/siginfo.c b/gdb/testsuite/gdb.base/siginfo.c index 39e15ba..77d94da 100644 --- a/gdb/testsuite/gdb.base/siginfo.c +++ b/gdb/testsuite/gdb.base/siginfo.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/siginfo.exp b/gdb/testsuite/gdb.base/siginfo.exp index d703250..a8571b9 100644 --- a/gdb/testsuite/gdb.base/siginfo.exp +++ b/gdb/testsuite/gdb.base/siginfo.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/signals-state-child.c b/gdb/testsuite/gdb.base/signals-state-child.c index 31d40e9..69267ed 100644 --- a/gdb/testsuite/gdb.base/signals-state-child.c +++ b/gdb/testsuite/gdb.base/signals-state-child.c @@ -1,4 +1,4 @@ -/* Copyright 2016-2024 Free Software Foundation, Inc. +/* Copyright 2016-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/signals-state-child.exp b/gdb/testsuite/gdb.base/signals-state-child.exp index 8c5965b..ed8b572 100644 --- a/gdb/testsuite/gdb.base/signals-state-child.exp +++ b/gdb/testsuite/gdb.base/signals-state-child.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 @@ -90,14 +90,14 @@ if { $res < 0 || $res == "" } { } set wait_status [remote_wait target 60] -set have_standalone [expr [lindex $wait_status 0] == 0] +set have_standalone [expr {[lindex $wait_status 0] == 0}] gdb_assert { $have_standalone } "collect standalone signals state" remote_close target # Now run the program through gdb, and dump its initial signal actions # and mask in "gdb.txt". -clean_restart $binfile +clean_restart $testfile if {![runto_main]} { return -1 diff --git a/gdb/testsuite/gdb.base/signals.exp b/gdb/testsuite/gdb.base/signals.exp index e6bd35a..6e4b9cb 100644 --- a/gdb/testsuite/gdb.base/signals.exp +++ b/gdb/testsuite/gdb.base/signals.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -35,11 +35,11 @@ proc test_handle_all_print {} { # Increase timeout and expect input buffer for large output from gdb. # Allow blank or TAB as whitespace characters. set oldtimeout $timeout - set timeout [expr "$timeout + 60"] + set timeout [expr {$timeout + 60}] verbose "Timeout is now $timeout seconds" 2 if { ![istarget "*-*-linux*"] - && ( [istarget "*-*-gnu*"] - || [istarget "*-*-mach*"] ) } { + && ( [istarget "*-*-gnu*"] + || [istarget "*-*-mach*"] ) } { gdb_test_sequence "handle all print" "" \ { "Signal\[ \]+Stop\[ \]+Print\[ \]+Pass to program\[ \]+Description\r\nSIGHUP\[ \]+Yes\[ \]+Yes\[ \]+Yes\[ \]+Hangup" @@ -58,7 +58,7 @@ proc test_handle_all_print {} { } test_handle_all_print -clean_restart $binfile +clean_restart $testfile if {[runto_main]} { @@ -257,7 +257,7 @@ The program being debugged stopped while in a function called from GDB.*" \ gdb_test "signal" \ "Argument required .signal number..*" \ "signal without arguments disallowed" - + # Verify that we can successfully send a signal other than 0 to # the inferior. (This probably causes the inferior to run away. # Be prepared to rerun to main for further testing.) diff --git a/gdb/testsuite/gdb.base/signed-builtin-types-lib.c b/gdb/testsuite/gdb.base/signed-builtin-types-lib.c index 26b28aa..3b78dad 100644 --- a/gdb/testsuite/gdb.base/signed-builtin-types-lib.c +++ b/gdb/testsuite/gdb.base/signed-builtin-types-lib.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/signed-builtin-types.c b/gdb/testsuite/gdb.base/signed-builtin-types.c index 4eec62f..460e048 100644 --- a/gdb/testsuite/gdb.base/signed-builtin-types.c +++ b/gdb/testsuite/gdb.base/signed-builtin-types.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/signed-builtin-types.exp b/gdb/testsuite/gdb.base/signed-builtin-types.exp index 4cc324b..7750d98 100644 --- a/gdb/testsuite/gdb.base/signed-builtin-types.exp +++ b/gdb/testsuite/gdb.base/signed-builtin-types.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/signest.c b/gdb/testsuite/gdb.base/signest.c index 37bb8b9..54245f8 100644 --- a/gdb/testsuite/gdb.base/signest.c +++ b/gdb/testsuite/gdb.base/signest.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/signest.exp b/gdb/testsuite/gdb.base/signest.exp index b66f066..67f2f0c 100644 --- a/gdb/testsuite/gdb.base/signest.exp +++ b/gdb/testsuite/gdb.base/signest.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 @@ -19,7 +19,7 @@ standard_testfile require {!target_info exists gdb,nosignals} -if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug}] { +if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug}]} { return -1 } @@ -41,7 +41,7 @@ if { [is_address_zero_readable] } { # Run until we hit the SIGSEGV (or SIGBUS on some platforms). gdb_test "continue" \ ".*Program received signal (SIGBUS|SIGSEGV).*bowler.*" \ - "continue to fault" + "continue to fault" # Insert conditional breakpoint at faulting instruction gdb_test "break if 0" ".*" "set conditional breakpoint" @@ -52,6 +52,5 @@ gdb_test "handle SIGBUS nostop print pass" ".*" "pass SIGBUS" # Step off the faulting instruction into the handler, triggering nested faults gdb_test "continue" \ - ".*Program received signal (SIGBUS|SIGSEGV).*Program received signal (SIGBUS|SIGSEGV).*exited normally.*" \ + ".*Program received signal (SIGBUS|SIGSEGV).*Program received signal (SIGBUS|SIGSEGV).*exited normally.*" \ "run through nested faults" - diff --git a/gdb/testsuite/gdb.base/signull.c b/gdb/testsuite/gdb.base/signull.c index 17529b4..d93d884 100644 --- a/gdb/testsuite/gdb.base/signull.c +++ b/gdb/testsuite/gdb.base/signull.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1996-2024 Free Software Foundation, Inc. + Copyright 1996-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 diff --git a/gdb/testsuite/gdb.base/signull.exp b/gdb/testsuite/gdb.base/signull.exp index 6d72cd5..5cb0ea6 100644 --- a/gdb/testsuite/gdb.base/signull.exp +++ b/gdb/testsuite/gdb.base/signull.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 @@ -32,13 +32,10 @@ require {!target_info exists gdb,nosignals} standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart ${binfile} - # # Run to `main' where we begin our tests. # diff --git a/gdb/testsuite/gdb.base/sigrepeat.c b/gdb/testsuite/gdb.base/sigrepeat.c index 79fe648..c65f07f 100644 --- a/gdb/testsuite/gdb.base/sigrepeat.c +++ b/gdb/testsuite/gdb.base/sigrepeat.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/sigrepeat.exp b/gdb/testsuite/gdb.base/sigrepeat.exp index dd65d92..a01cdb8 100644 --- a/gdb/testsuite/gdb.base/sigrepeat.exp +++ b/gdb/testsuite/gdb.base/sigrepeat.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 @@ -24,14 +24,10 @@ require {!target_info exists gdb,nosignals} standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -# get things started -clean_restart ${binfile} - # Advance to main if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/sigstep.c b/gdb/testsuite/gdb.base/sigstep.c index 6e96ad2..e0f4604 100644 --- a/gdb/testsuite/gdb.base/sigstep.c +++ b/gdb/testsuite/gdb.base/sigstep.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/sigstep.exp b/gdb/testsuite/gdb.base/sigstep.exp index d08a34e..b691173 100644 --- a/gdb/testsuite/gdb.base/sigstep.exp +++ b/gdb/testsuite/gdb.base/sigstep.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 @@ -38,9 +38,7 @@ set other_handler_location [gdb_get_line_number "other handler location"] # Restart GDB, set a display showing $PC, and run to main. proc restart {} { - global binfile - - clean_restart $binfile + clean_restart $::testfile gdb_test "display/i \$pc" diff --git a/gdb/testsuite/gdb.base/sigwinch-notty.exp b/gdb/testsuite/gdb.base/sigwinch-notty.exp index cef21c0..0459ce9 100644 --- a/gdb/testsuite/gdb.base/sigwinch-notty.exp +++ b/gdb/testsuite/gdb.base/sigwinch-notty.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/sizeof.exp b/gdb/testsuite/gdb.base/sizeof.exp index 5706a6f..3c81b77 100644 --- a/gdb/testsuite/gdb.base/sizeof.exp +++ b/gdb/testsuite/gdb.base/sizeof.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2000-2024 Free Software Foundation, Inc. +# Copyright 2000-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 @@ -127,7 +127,7 @@ while { $ok } { gdb_expect { -re ".*dump" { #pass "maint print arch $ok" - #set ok [expr $ok + 1] + #set ok [expr {$ok + 1}] } -re "$gdb_prompt $" { pass "maint print arch" diff --git a/gdb/testsuite/gdb.base/skip-inline.c b/gdb/testsuite/gdb.base/skip-inline.c index 207e8d6..4ac203b 100644 --- a/gdb/testsuite/gdb.base/skip-inline.c +++ b/gdb/testsuite/gdb.base/skip-inline.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/skip-inline.exp b/gdb/testsuite/gdb.base/skip-inline.exp index 3c01234..e3bc108 100644 --- a/gdb/testsuite/gdb.base/skip-inline.exp +++ b/gdb/testsuite/gdb.base/skip-inline.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -27,7 +27,7 @@ set srcfile skip-inline.c set srcfile1 skip1.c proc_with_prefix single_step { } { - if ![runto_main] { + if {![runto_main]} { return } @@ -43,7 +43,7 @@ proc_with_prefix single_step { } { } proc_with_prefix double_step { } { - if ![runto_main] { + if {![runto_main]} { return } @@ -61,7 +61,7 @@ proc_with_prefix double_step { } { } proc_with_prefix triple_step { } { - if ![runto_main] { + if {![runto_main]} { return } @@ -75,7 +75,7 @@ proc_with_prefix triple_step { } { } proc_with_prefix skip_current_frame { } { - if ![runto_main] { + if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/skip-solib.exp b/gdb/testsuite/gdb.base/skip-solib.exp index 9df0983..e152023 100644 --- a/gdb/testsuite/gdb.base/skip-solib.exp +++ b/gdb/testsuite/gdb.base/skip-solib.exp @@ -1,4 +1,4 @@ -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 @@ -72,7 +72,7 @@ with_test_prefix "ignoring solib file" { "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s*" \ "1\\s+y\\s+n\\s+${srcfile_lib}\\s+n\\s+<none>\\s*"] - if ![runto_main] { + if {![runto_main]} { return } @@ -94,7 +94,7 @@ with_test_prefix "ignoring solib function" { "Function multiply will be skipped when stepping\\." \ "skip function" - if ![runto_main] { + if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/skip.c b/gdb/testsuite/gdb.base/skip.c index 138b087..fc6319c 100644 --- a/gdb/testsuite/gdb.base/skip.c +++ b/gdb/testsuite/gdb.base/skip.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/skip.exp b/gdb/testsuite/gdb.base/skip.exp index ccc7ca3..c6fa26b 100644 --- a/gdb/testsuite/gdb.base/skip.exp +++ b/gdb/testsuite/gdb.base/skip.exp @@ -1,4 +1,4 @@ -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 @@ -49,7 +49,7 @@ gdb_test "skip -rfunction" "Missing value for -rfunction option." gdb_test "skip -x" "Invalid skip option: -x" gdb_test "skip -rfu foo.* xyzzy" "Invalid argument: xyzzy" -if ![runto_main] { +if {![runto_main]} { return } @@ -93,7 +93,7 @@ gdb_test "info skip" \ # files, so when we step into the first line in main(), we should step # right over it and go to the second line of main(). -if ![runto_main] { +if {![runto_main]} { return } @@ -121,7 +121,7 @@ with_test_prefix "step after deleting 1" { "4\\s+y\\s+n\\s+<none>\\s+n\\s+baz"] \ "info skip (delete 1)" - if ![runto_main] { + if {![runto_main]} { return } @@ -164,7 +164,7 @@ with_test_prefix "step after disabling 3" { "3\\s+n\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*" \ "info skip shows entry as disabled" - if ![runto_main] { + if {![runto_main]} { return } @@ -180,7 +180,7 @@ with_test_prefix "step after enable 3" { "3\\s+y\\s+n\\s+$srcfile1\\s+n\\s+<none>\\s*" \ "info skip shows entry as enabled" - if ![runto_main] { + if {![runto_main]} { return } @@ -247,7 +247,7 @@ gdb_test "skip -fu baz" "Function baz will be skipped when stepping\." gdb_test "skip -rfu ^b.z$" "Function\\(s\\) \\^b\\.z\\$ will be skipped when stepping." with_test_prefix "step using -fi" { - if ![runto_main] { + if {![runto_main]} { return } @@ -257,7 +257,7 @@ with_test_prefix "step using -fi" { } with_test_prefix "step using -gfi" { - if ![runto_main] { + if {![runto_main]} { return } @@ -267,7 +267,7 @@ with_test_prefix "step using -gfi" { } with_test_prefix "step using -fu for baz" { - if ![runto_main] { + if {![runto_main]} { return } @@ -278,7 +278,7 @@ with_test_prefix "step using -fu for baz" { } with_test_prefix "step using -rfu for baz" { - if ![runto_main] { + if {![runto_main]} { return } @@ -293,7 +293,7 @@ with_test_prefix "step using -rfu for baz" { with_test_prefix "step using -fi + -fu" { gdb_test_no_output "skip delete" - if ![runto test_skip_file_and_function] { + if {![runto test_skip_file_and_function]} { return } @@ -308,9 +308,9 @@ with_test_prefix "step using -fi + -fu" { } with_test_prefix "skip delete completion" { - global binfile - clean_restart "${binfile}" - if ![runto_main] { + clean_restart $::testfile + + if {![runto_main]} { return } @@ -336,4 +336,3 @@ with_test_prefix "skip delete completion" { test_gdb_complete_none "skip delete a1" test_gdb_complete_none "skip delete 2-33" } - diff --git a/gdb/testsuite/gdb.base/skip1.c b/gdb/testsuite/gdb.base/skip1.c index a68b96b..3888ac0 100644 --- a/gdb/testsuite/gdb.base/skip1.c +++ b/gdb/testsuite/gdb.base/skip1.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/skipcxx.cc b/gdb/testsuite/gdb.base/skipcxx.cc index 677d8d8..65ba99a 100644 --- a/gdb/testsuite/gdb.base/skipcxx.cc +++ b/gdb/testsuite/gdb.base/skipcxx.cc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/skipcxx.exp b/gdb/testsuite/gdb.base/skipcxx.exp index 73beed8..29f9254 100644 --- a/gdb/testsuite/gdb.base/skipcxx.exp +++ b/gdb/testsuite/gdb.base/skipcxx.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -23,7 +23,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/so-disc-shr.c b/gdb/testsuite/gdb.base/so-disc-shr.c index d6cf36c..ab2f0b5 100644 --- a/gdb/testsuite/gdb.base/so-disc-shr.c +++ b/gdb/testsuite/gdb.base/so-disc-shr.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2007-2024 Free Software Foundation, Inc. + Copyright 2007-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 diff --git a/gdb/testsuite/gdb.base/so-impl-ld.exp b/gdb/testsuite/gdb.base/so-impl-ld.exp index 04d4e47..2315397 100644 --- a/gdb/testsuite/gdb.base/so-impl-ld.exp +++ b/gdb/testsuite/gdb.base/so-impl-ld.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -21,19 +21,17 @@ set libfile "solib1" set libsrc $srcdir/$subdir/$libfile.c set lib_sl [standard_output_file $libfile.sl] -set lib_opts debug +set lib_opts {debug shlib} set exec_opts [list debug shlib=$lib_sl] -if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != "" - || [gdb_compile $srcdir/$subdir/$srcfile $binfile \ - executable $exec_opts] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build shlib" $lib_sl $libsrc $lib_opts] != 0 } { + return } -# Start with a fresh gdb +if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } { + return +} -clean_restart ${binfile} gdb_load_shlib $lib_sl # This program implicitly loads SOM shared libraries. diff --git a/gdb/testsuite/gdb.base/solib-abort-lib.c b/gdb/testsuite/gdb.base/solib-abort-lib.c index 39797ab..a224b26 100644 --- a/gdb/testsuite/gdb.base/solib-abort-lib.c +++ b/gdb/testsuite/gdb.base/solib-abort-lib.c @@ -1,4 +1,4 @@ -/* Copyright 2023-2024 Free Software Foundation, Inc. +/* Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/solib-abort.c b/gdb/testsuite/gdb.base/solib-abort.c index 1e2d78f..7b09561 100644 --- a/gdb/testsuite/gdb.base/solib-abort.c +++ b/gdb/testsuite/gdb.base/solib-abort.c @@ -1,4 +1,4 @@ -/* Copyright 2023-2024 Free Software Foundation, Inc. +/* Copyright 2023-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 @@ -22,4 +22,3 @@ main () callee (); return 0; } - diff --git a/gdb/testsuite/gdb.base/solib-abort.exp b/gdb/testsuite/gdb.base/solib-abort.exp index c0cfef0..6970229 100644 --- a/gdb/testsuite/gdb.base/solib-abort.exp +++ b/gdb/testsuite/gdb.base/solib-abort.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 @@ -24,7 +24,7 @@ set srcfile_lib ${srcdir}/${subdir}/${libname}.c set binfile_lib [standard_output_file ${libname}.so] # Note: no debugging info here, since this will assure that the solib # name is printed in the stack trace. -set lib_flags {} +set lib_flags {shlib} # Binary file. set testfile "solib-abort" @@ -32,13 +32,14 @@ set srcfile ${srcdir}/${subdir}/${testfile}.c set binfile [standard_output_file ${testfile}] set bin_flags [list debug shlib=${binfile_lib}] -if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != "" - || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } { - untested "failed to compile" - return -1 +if { [build_executable "build solib" $binfile_lib $srcfile_lib \ + $lib_flags] != 0 } { + return } -clean_restart $binfile +if { [prepare_for_testing "prepare" $testfile $srcfile $bin_flags] != 0 } { + return +} if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/solib-corrupted.exp b/gdb/testsuite/gdb.base/solib-corrupted.exp index aff8b85..9b5556d 100644 --- a/gdb/testsuite/gdb.base/solib-corrupted.exp +++ b/gdb/testsuite/gdb.base/solib-corrupted.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -30,7 +30,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { # corruption cannot be tested. Disable the probes interface. gdb_test "maint ignore-probes rtld" -if ![runto_main] { +if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/solib-disc.c b/gdb/testsuite/gdb.base/solib-disc.c index 9894174..f97fae1 100644 --- a/gdb/testsuite/gdb.base/solib-disc.c +++ b/gdb/testsuite/gdb.base/solib-disc.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2007-2024 Free Software Foundation, Inc. + Copyright 2007-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 diff --git a/gdb/testsuite/gdb.base/solib-disc.exp b/gdb/testsuite/gdb.base/solib-disc.exp index 280e8de..221a1fa 100644 --- a/gdb/testsuite/gdb.base/solib-disc.exp +++ b/gdb/testsuite/gdb.base/solib-disc.exp @@ -1,4 +1,4 @@ -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 @@ -39,12 +39,14 @@ remote_exec build "rm -f ${binfile}" set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME=\"${lib_dlopen}\"] -if { [gdb_compile_shlib $libsrc $libobj {debug}] != "" - || [gdb_compile $execsrc ${binfile} executable $exec_opts] != "" } { - return -1 +if { [build_executable "build solib" $libobj $libsrc {debug shlib}] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $execsrc $exec_opts] != 0 } { + return } -clean_restart $binfile gdb_load_shlib $libobj if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/solib-display-lib.c b/gdb/testsuite/gdb.base/solib-display-lib.c index e43a88c..4e025b8 100644 --- a/gdb/testsuite/gdb.base/solib-display-lib.c +++ b/gdb/testsuite/gdb.base/solib-display-lib.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/solib-display-main.c b/gdb/testsuite/gdb.base/solib-display-main.c index d9ac66b..593ee33 100644 --- a/gdb/testsuite/gdb.base/solib-display-main.c +++ b/gdb/testsuite/gdb.base/solib-display-main.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/solib-display.exp b/gdb/testsuite/gdb.base/solib-display.exp index c9c66f6..f79ed54 100644 --- a/gdb/testsuite/gdb.base/solib-display.exp +++ b/gdb/testsuite/gdb.base/solib-display.exp @@ -1,4 +1,4 @@ -# Copyright 2009-2024 Free Software Foundation, Inc. +# Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/solib-nodir.exp b/gdb/testsuite/gdb.base/solib-nodir.exp index fe34396..249f494 100644 --- a/gdb/testsuite/gdb.base/solib-nodir.exp +++ b/gdb/testsuite/gdb.base/solib-nodir.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -53,7 +53,7 @@ gdb_test_no_output "set cwd ${binlibfiledir}" \ "set cwd OBJDIR/${subdir}" set test "library loaded" -if [runto_main] { +if {[runto_main]} { pass $test } else { fail $test diff --git a/gdb/testsuite/gdb.base/solib-overlap-lib.c b/gdb/testsuite/gdb.base/solib-overlap-lib.c index 47eedda..dc2a7aa 100644 --- a/gdb/testsuite/gdb.base/solib-overlap-lib.c +++ b/gdb/testsuite/gdb.base/solib-overlap-lib.c @@ -1,4 +1,4 @@ -/* Copyright 2009-2024 Free Software Foundation, Inc. +/* Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/solib-overlap-main.c b/gdb/testsuite/gdb.base/solib-overlap-main.c index dfa2c03..0fa9ea1 100644 --- a/gdb/testsuite/gdb.base/solib-overlap-main.c +++ b/gdb/testsuite/gdb.base/solib-overlap-main.c @@ -1,4 +1,4 @@ -/* Copyright 2009-2024 Free Software Foundation, Inc. +/* Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/solib-overlap.exp b/gdb/testsuite/gdb.base/solib-overlap.exp index 593f51d..893deb6 100644 --- a/gdb/testsuite/gdb.base/solib-overlap.exp +++ b/gdb/testsuite/gdb.base/solib-overlap.exp @@ -1,4 +1,4 @@ -# Copyright 2009-2024 Free Software Foundation, Inc. +# Copyright 2009-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 @@ -42,7 +42,7 @@ set srcfile ${srcdir}/${subdir}/${testfile}.c # Prelink first lib1 at 0x40000000 and lib2 at 0x41000000. # During second pass try lib1 at 0x50000000 and lib2 at 0x51000000. foreach prelink_lib1 {0x40000000 0x50000000} { with_test_prefix "$prelink_lib1" { - set prelink_lib2 [format "0x%x" [expr $prelink_lib1 + 0x01000000]] + set prelink_lib2 [format "0x%x" [expr {$prelink_lib1 + 0x01000000}]] # Library file. set binfile_lib1 [standard_output_file ${libname}1-${prelink_lib1}.so] @@ -64,8 +64,8 @@ foreach prelink_lib1 {0x40000000 0x50000000} { with_test_prefix "$prelink_lib1" return -1 } - if {[catch "exec prelink -N -r ${prelink_lib1} ${binfile_lib1}" output] != 0 - || [catch "exec prelink -N -r ${prelink_lib2} ${binfile_lib2}" output] != 0} { + if {[catch {exec prelink -N -r ${prelink_lib1} ${binfile_lib1}} output] != 0 + || [catch {exec prelink -N -r ${prelink_lib2} ${binfile_lib2}} output] != 0} { # Maybe we don't have prelink. verbose -log "prelink failed: $output" untested "could not prelink ${binfile_lib1_test_msg} or ${binfile_lib2_test_msg}." diff --git a/gdb/testsuite/gdb.base/solib-probes-nosharedlibrary.c b/gdb/testsuite/gdb.base/solib-probes-nosharedlibrary.c index e6a98eb..e851b7e 100644 --- a/gdb/testsuite/gdb.base/solib-probes-nosharedlibrary.c +++ b/gdb/testsuite/gdb.base/solib-probes-nosharedlibrary.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/solib-probes-nosharedlibrary.exp b/gdb/testsuite/gdb.base/solib-probes-nosharedlibrary.exp index d66d68a..1fe909c 100644 --- a/gdb/testsuite/gdb.base/solib-probes-nosharedlibrary.exp +++ b/gdb/testsuite/gdb.base/solib-probes-nosharedlibrary.exp @@ -1,4 +1,4 @@ -# Copyright 2005-2024 Free Software Foundation, Inc. +# Copyright 2005-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 diff --git a/gdb/testsuite/gdb.base/solib-search-lib1.c b/gdb/testsuite/gdb.base/solib-search-lib1.c index 535cfce..44062a8 100644 --- a/gdb/testsuite/gdb.base/solib-search-lib1.c +++ b/gdb/testsuite/gdb.base/solib-search-lib1.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/solib-search-lib2.c b/gdb/testsuite/gdb.base/solib-search-lib2.c index 4bb467d..d9322dc 100644 --- a/gdb/testsuite/gdb.base/solib-search-lib2.c +++ b/gdb/testsuite/gdb.base/solib-search-lib2.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/solib-search.c b/gdb/testsuite/gdb.base/solib-search.c index 775bf21..d8426c6 100644 --- a/gdb/testsuite/gdb.base/solib-search.c +++ b/gdb/testsuite/gdb.base/solib-search.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/solib-search.exp b/gdb/testsuite/gdb.base/solib-search.exp index bf021c8..48b0267 100644 --- a/gdb/testsuite/gdb.base/solib-search.exp +++ b/gdb/testsuite/gdb.base/solib-search.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 @@ -16,7 +16,7 @@ # Test solib-search-path, and in the case of solib-svr4.c whether l_addr_p # is properly reset when the path is changed. -require allow_shlib_tests +require allow_shlib_tests gcore_cmd_available require {!is_remote target} # Build "wrong" and "right" versions of the libraries in separate directories. @@ -180,4 +180,3 @@ gdb_test "set solib-search-path [standard_output_file ${right_lib_subdir}]" \ test_backtrace 0 gdb_test "p lib1_size" " = 8192" gdb_test "p lib2_size" " = 8192" - diff --git a/gdb/testsuite/gdb.base/solib-search.h b/gdb/testsuite/gdb.base/solib-search.h index 89f385c..f917e88 100644 --- a/gdb/testsuite/gdb.base/solib-search.h +++ b/gdb/testsuite/gdb.base/solib-search.h @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2013-2024 Free Software Foundation, Inc. + Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/solib-symbol-lib.c b/gdb/testsuite/gdb.base/solib-symbol-lib.c index 9f1e6b4..49fb67b 100644 --- a/gdb/testsuite/gdb.base/solib-symbol-lib.c +++ b/gdb/testsuite/gdb.base/solib-symbol-lib.c @@ -1,4 +1,4 @@ -/* Copyright 2007-2024 Free Software Foundation, Inc. +/* Copyright 2007-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 diff --git a/gdb/testsuite/gdb.base/solib-symbol-main.c b/gdb/testsuite/gdb.base/solib-symbol-main.c index a6186cd..61af4af 100644 --- a/gdb/testsuite/gdb.base/solib-symbol-main.c +++ b/gdb/testsuite/gdb.base/solib-symbol-main.c @@ -1,4 +1,4 @@ -/* Copyright 2007-2024 Free Software Foundation, Inc. +/* Copyright 2007-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 @@ -39,4 +39,3 @@ void foo2() printf ("foo2 in main\n"); return; } - diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/solib-symbol.exp index 1ec3867..2990aaf 100644 --- a/gdb/testsuite/gdb.base/solib-symbol.exp +++ b/gdb/testsuite/gdb.base/solib-symbol.exp @@ -1,4 +1,4 @@ -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 @@ -21,20 +21,22 @@ require allow_shlib_tests set libname "solib-symbol-lib" set srcfile_lib ${srcdir}/${subdir}/${libname}.c set binfile_lib [standard_output_file ${libname}.so] -set lib_flags [list debug ldflags=-Wl,-Bsymbolic] +set lib_flags [list debug shlib ldflags=-Wl,-Bsymbolic] # Binary file. set testfile "solib-symbol-main" set srcfile ${srcdir}/${subdir}/${testfile}.c set binfile [standard_output_file ${testfile}] set bin_flags [list debug shlib=${binfile_lib}] -if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != "" - || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } { - untested "failed to compile" - return -1 +if { [build_executable "build solib" $binfile_lib $srcfile_lib \ + $lib_flags] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $srcfile $bin_flags] != 0 } { + return } -clean_restart $binfile gdb_load_shlib $binfile_lib # Set a breakpoint in the binary. diff --git a/gdb/testsuite/gdb.base/solib-vanish-lib1.c b/gdb/testsuite/gdb.base/solib-vanish-lib1.c index f15b4dc..565e651 100644 --- a/gdb/testsuite/gdb.base/solib-vanish-lib1.c +++ b/gdb/testsuite/gdb.base/solib-vanish-lib1.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/solib-vanish-lib2.c b/gdb/testsuite/gdb.base/solib-vanish-lib2.c index ba673e6..e3d94ed 100644 --- a/gdb/testsuite/gdb.base/solib-vanish-lib2.c +++ b/gdb/testsuite/gdb.base/solib-vanish-lib2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/solib-vanish-main.c b/gdb/testsuite/gdb.base/solib-vanish-main.c index 4ef78dc..5615854 100644 --- a/gdb/testsuite/gdb.base/solib-vanish-main.c +++ b/gdb/testsuite/gdb.base/solib-vanish-main.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/solib-vanish.exp b/gdb/testsuite/gdb.base/solib-vanish.exp index 9c7c372..f594873 100644 --- a/gdb/testsuite/gdb.base/solib-vanish.exp +++ b/gdb/testsuite/gdb.base/solib-vanish.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -114,4 +114,3 @@ gdb_continue_to_breakpoint "bar" \ gdb_test "next" \ "" \ "next succeeds" - diff --git a/gdb/testsuite/gdb.base/solib-weak.c b/gdb/testsuite/gdb.base/solib-weak.c index 4199721..413787a 100644 --- a/gdb/testsuite/gdb.base/solib-weak.c +++ b/gdb/testsuite/gdb.base/solib-weak.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2006-2024 Free Software Foundation, Inc. + Copyright 2006-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 @@ -22,4 +22,4 @@ main() { foo (); return 0; -} +} diff --git a/gdb/testsuite/gdb.base/solib-weak.exp b/gdb/testsuite/gdb.base/solib-weak.exp index 1ed552c..343eba4 100644 --- a/gdb/testsuite/gdb.base/solib-weak.exp +++ b/gdb/testsuite/gdb.base/solib-weak.exp @@ -1,4 +1,4 @@ -# Copyright 2006-2024 Free Software Foundation, Inc. +# Copyright 2006-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 @@ -69,7 +69,7 @@ proc do_test { lib1opts lib2opts lib1first } { set lib1 [standard_output_file ${libfile1}.sl] set lib2 [standard_output_file ${libfile2}.sl] - if $lib1first { + if {$lib1first} { set exec_opts [list debug shlib=${lib1} shlib=${lib2}] set expected_file ${libfile1} } else { @@ -84,7 +84,7 @@ proc do_test { lib1opts lib2opts lib1first } { } with_test_prefix $testopts { - clean_restart $binfile + clean_restart $testfile gdb_load_shlib $lib1 gdb_load_shlib $lib2 diff --git a/gdb/testsuite/gdb.base/source-dir.c b/gdb/testsuite/gdb.base/source-dir.c index e6a98eb..e851b7e 100644 --- a/gdb/testsuite/gdb.base/source-dir.c +++ b/gdb/testsuite/gdb.base/source-dir.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/source-dir.exp b/gdb/testsuite/gdb.base/source-dir.exp index 96b6446..2fb351f 100644 --- a/gdb/testsuite/gdb.base/source-dir.exp +++ b/gdb/testsuite/gdb.base/source-dir.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -62,7 +62,7 @@ proc test_truncated_comp_dir {} { # /some/path/to/gdb/build/testsuite/ # We are going to copy the source file out of the source tree into # a location like this: - # /some/path/to/gdb/build/testsuite/output/gdb.base/soure-dir/ + # /some/path/to/gdb/build/testsuite/output/gdb.base/source-dir/ # # We will then switch to this directory and compile the source # file, however, we will ask GCC to remove this prefix from the @@ -83,15 +83,16 @@ proc test_truncated_comp_dir {} { # All of these pathname and directory manipulations assume # host == build, so do not attempt this set of tests on remote host. - if [is_remote host] { - return + if {[is_remote host]} { + return } - set working_dir [standard_output_file ""] + set working_dir [build_standard_output_file ""] with_cwd $working_dir { - set strip_dir [file normalize "${working_dir}/../.."] + set strip_dir [build_file_normalize "${working_dir}/../.."] + set h_strip_dir [host_file_normalize $strip_dir] - set new_srcfile [standard_output_file ${srcfile}] + set new_srcfile [build_standard_output_file ${srcfile}] set fd [open "$new_srcfile" w] puts $fd "int main () @@ -100,8 +101,17 @@ proc test_truncated_comp_dir {} { }" close $fd + # We ask GCC to remove both the build and host views of the + # path, because we don't know which one GCC uses. E.g., we're + # testing on MSYS2 with an MSYS2 cross-compiler that targets + # MinGW, then the path GCC uses is a Unix path. If OTOH we're + # testing on MSYS2 with a native Windows compiler, then the + # path GCC uses is a Windows path. set options \ - "debug additional_flags=-fdebug-prefix-map=${strip_dir}=" + [list \ + "debug" \ + "additional_flags=-fdebug-prefix-map=${strip_dir}=" \ + "additional_flags=-fdebug-prefix-map=${h_strip_dir}="] if { [gdb_compile "${srcfile}" "${binfile}" \ executable ${options}] != "" } { untested "failed to compile" @@ -109,10 +119,10 @@ proc test_truncated_comp_dir {} { } } - clean_restart ${binfile} + clean_restart $::testfile if { [ishost *-*-mingw*] } { - gdb_test_no_output "set directories \$cdir;\$cwd" + gdb_test_no_output "set directories \$cdir;\$cwd" } else { gdb_test_no_output "set directories \$cdir:\$cwd" } @@ -133,9 +143,9 @@ proc test_truncated_comp_dir {} { "Does not include preprocessor macro info." ] \ "info source before setting directory search list" - gdb_test "dir $strip_dir" \ + gdb_test "dir $h_strip_dir" \ [search_dir_list [list \ - "$strip_dir" \ + "$h_strip_dir" \ "\\\$cdir" \ "\\\$cwd"]] \ "setup source path search directory" @@ -146,17 +156,23 @@ proc test_truncated_comp_dir {} { "4\[ \t\]+return 0;" \ "5\[ \t\]+\\}" ] - gdb_test "info source" \ - [multi_line \ - "Current source file is ${srcfile}" \ - "Compilation directory is \[^\n\r\]+" \ - "Located in ${new_srcfile}" \ - "Contains 5 lines." \ - "Source language is c." \ - "Producer is \[^\n\r\]+" \ - "\[^\n\r\]+" \ - "\[^\n\r\]+" ] \ - "info source after setting directory search list" + set re [multi_line \ + "Current source file is ${srcfile}" \ + "Compilation directory is \[^\n\r\]+" \ + "Located in (\[^\n\r\]+)" \ + "Contains 5 lines." \ + "Source language is c." \ + "Producer is \[^\n\r\]+" \ + "\[^\n\r\]+" \ + "\[^\n\r\]+"] + set test "info source after setting directory search list" + gdb_test_multiple "info source" $test { + -re -wrap "$re" { + set host_new_srcfile [host_file_normalize $new_srcfile] + set host_location [host_file_sanitize $expect_out(1,string)] + gdb_assert {$host_new_srcfile eq $host_location} $gdb_test_name + } + } } proc test_change_search_directory_with_empty_dirname {} { diff --git a/gdb/testsuite/gdb.base/source-error-1.gdb b/gdb/testsuite/gdb.base/source-error-1.gdb index 8528fd8..05f9029 100644 --- a/gdb/testsuite/gdb.base/source-error-1.gdb +++ b/gdb/testsuite/gdb.base/source-error-1.gdb @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2005-2024 Free Software Foundation, Inc. +# Copyright 2005-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 diff --git a/gdb/testsuite/gdb.base/source-error.gdb b/gdb/testsuite/gdb.base/source-error.gdb index d5b9983..a531253 100644 --- a/gdb/testsuite/gdb.base/source-error.gdb +++ b/gdb/testsuite/gdb.base/source-error.gdb @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/source-execution.c b/gdb/testsuite/gdb.base/source-execution.c index 46d9299..9f64585 100644 --- a/gdb/testsuite/gdb.base/source-execution.c +++ b/gdb/testsuite/gdb.base/source-execution.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/source-execution.exp b/gdb/testsuite/gdb.base/source-execution.exp index 7fc60d5..c0a54f2 100644 --- a/gdb/testsuite/gdb.base/source-execution.exp +++ b/gdb/testsuite/gdb.base/source-execution.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/source-execution.gdb b/gdb/testsuite/gdb.base/source-execution.gdb index 8fb9194c..55d9be8 100644 --- a/gdb/testsuite/gdb.base/source-execution.gdb +++ b/gdb/testsuite/gdb.base/source-execution.gdb @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. # -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/source-nofile.gdb b/gdb/testsuite/gdb.base/source-nofile.gdb index 0255445..f3461b6 100644 --- a/gdb/testsuite/gdb.base/source-nofile.gdb +++ b/gdb/testsuite/gdb.base/source-nofile.gdb @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. # -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/source-open.c b/gdb/testsuite/gdb.base/source-open.c index afaa14e..bd8a16d 100644 --- a/gdb/testsuite/gdb.base/source-open.c +++ b/gdb/testsuite/gdb.base/source-open.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/source-open.exp b/gdb/testsuite/gdb.base/source-open.exp index df9a9f9..016fde4 100644 --- a/gdb/testsuite/gdb.base/source-open.exp +++ b/gdb/testsuite/gdb.base/source-open.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/source-search.c b/gdb/testsuite/gdb.base/source-search.c new file mode 100644 index 0000000..2320c5c --- /dev/null +++ b/gdb/testsuite/gdb.base/source-search.c @@ -0,0 +1,127 @@ +/* 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/>. */ + +int +main (void) +{ + /* Line 21 */ + /* Line 22 */ + /* Line 23 */ + /* Line 24 */ + /* Line 25 */ + /* Line 26 */ + /* Line 27 */ + /* Line 28 */ + /* Line 29 */ + /* Line 30 */ + /* Line 31 */ + /* Line 32 */ + /* Line 33 */ + /* Line 34 */ + /* Line 35 */ + /* Line 36 */ + /* Line 37 */ + /* Line 38 */ + /* Line 39 */ + /* Line 40 */ + /* Line 41 */ + /* Line 42 */ + /* Line 43 */ + /* Line 44 */ + /* Line 45 */ + /* Line 46 */ + /* Line 47 */ + /* Line 48 */ + /* Line 49 */ + /* Line 50 */ + /* Line 51 */ + /* Line 52 */ + /* Line 53 */ + /* Line 54 */ + /* Line 55 */ + /* Line 56 */ + /* Line 57 */ + /* Line 58 */ + /* Line 59 */ + /* Line 60 */ + /* Line 61 */ + /* Line 62 */ + /* Line 63 */ + /* Line 64 */ + /* Line 65 */ + /* Line 66 */ + /* Line 67 */ + /* Line 68 */ + /* Line 69 */ + /* Line 70 */ + /* Line 71 */ + /* Line 72 */ + /* Line 73 */ + /* Line 74 */ + /* Line 75 */ + /* Line 76 */ + /* Line 77 */ + /* Line 78 */ + /* Line 79 */ + /* Line 80 */ + /* Line 81 */ + /* Line 82 */ + /* Line 83 */ + /* Line 84 */ + /* Line 85 */ + /* Line 86 */ + /* Line 87 */ + /* Line 88 */ + /* Line 89 */ + /* Line 90 */ + /* Line 91 */ + /* Line 92 */ + /* Line 93 */ + /* Line 94 */ + /* Line 95 */ + /* Line 96 */ + /* Line 97 */ + /* Line 98 */ + /* Line 99 */ + /* Line 100 */ + /* Line 101 */ + /* Line 102 */ + /* Line 103 */ + /* Line 104 */ + /* Line 105 */ + /* Line 106 */ + /* Line 107 */ + /* Line 108 */ + /* Line 109 */ + /* Line 110 */ + /* Line 111 */ + /* Line 112 */ + /* Line 113 */ + /* Line 114 */ + /* Line 115 */ + /* Line 116 */ + /* Line 117 */ + /* Line 118 */ + /* Line 119 */ + /* Line 120 */ + /* Line 121 */ + /* Line 122 */ + /* Line 123 */ + /* Line 124 */ + /* Line 125 */ + return 0; +} /* Last line. */ diff --git a/gdb/testsuite/gdb.base/source-search.exp b/gdb/testsuite/gdb.base/source-search.exp new file mode 100644 index 0000000..559c500 --- /dev/null +++ b/gdb/testsuite/gdb.base/source-search.exp @@ -0,0 +1,106 @@ +# 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/>. + +# Test 'forward-search' and 'reverse-search' commands. This test +# relies on some hard-coded line numbers relating to the source file. +# We could switch to using gdb_get_line_number, but it doesn't feel +# like that would add much value; just don't change the source file. + +standard_testfile + +if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { + return +} + +gdb_test "forward-search This testcase is part" \ + "1\\s+/\\* This testcase is part of GDB, the GNU debugger\\." \ + "search for first line of the file" + +gdb_test "forward-search This testcase is part" \ + "Expression not found" \ + "repeated search doesn't find the same first line" + +# The 'reverse-search' command starts searching from the line before +# the last line displayed. So in this case, the reverse search starts +# from line 0, i.e. nothing is searched. +gdb_test "reverse-search This testcase is part" \ + "Expression not found" \ + "reverse search doesn't find the first line either" + +# List some source lines, and then perform some forward-searches. The +# searches start from the first line after the last line displayed. +gdb_test "list 20" ".*" \ + "list source code ahead of a forward-search" +gdb_test "forward-search Line 2" \ + "25\\s+/\\* Line 25 \\*/" \ + "first forward-search after a list" +gdb_test "forward-search Line 2" \ + "26\\s+/\\* Line 26 \\*/" \ + "second forward-search after a list" +gdb_test "forward-search Line 2" \ + "27\\s+/\\* Line 27 \\*/" \ + "third forward-search after a list" + +# Now reverse-search from where we got too. +gdb_test "reverse-search Line 2" \ + "26\\s+/\\* Line 26 \\*/" \ + "first reverse-search for 'Line 2'" +gdb_test "reverse-search Line 2" \ + "25\\s+/\\* Line 25 \\*/" \ + "second reverse-search for 'Line 2'" +gdb_test "reverse-search Line 2" \ + "24\\s+/\\* Line 24 \\*/" \ + "third reverse-search for 'Line 2'" + +# List some source lines, and then perform a reverse-search. The +# search starts frm the first line before the last line displayed. +gdb_test "list 20" ".*" \ + "list source code ahead of a reverse-search" +gdb_test "reverse-search Line 2" \ + "23\\s+/\\* Line 23 \\*/" \ + "reverse-search after a list" + +# List the last lines of the file, then reverse search for the last +# line. As reverse-search starts on the line before the last line +# displayed, this will fail to find the last line. +gdb_test "list 127" +gdb_test "reverse-search Last line" \ + "Expression not found" \ + "reverse search for the last line fails" + +# List some lines from the middle of the file. Then try an invalid +# 'list' command. Finally, check searches pick up from the middle of +# the file where the first 'list' successfully completed. +foreach_with_prefix search_direction { forward reverse } { + foreach_with_prefix bad_list { out-of-range backwards } { + gdb_test "list 50" + + if { $bad_list eq "out-of-range" } { + gdb_test "list 1000" \ + "Line number 995 out of range; \[^\r\n\]+ has 127 lines\\." + } else { + gdb_test_no_output "list 60,50" + } + + if { $search_direction eq "forward" } { + set line 55 + } else { + set line 53 + } + + gdb_test "${search_direction}-search Line" \ + "$line\\s+/\\* Line $line \\*/" + } +} diff --git a/gdb/testsuite/gdb.base/source-test.gdb b/gdb/testsuite/gdb.base/source-test.gdb index f23b549..cd1dfcc 100644 --- a/gdb/testsuite/gdb.base/source-test.gdb +++ b/gdb/testsuite/gdb.base/source-test.gdb @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/source.exp b/gdb/testsuite/gdb.base/source.exp index 26e4d26..60b0ebd 100644 --- a/gdb/testsuite/gdb.base/source.exp +++ b/gdb/testsuite/gdb.base/source.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2005-2024 Free Software Foundation, Inc. +# Copyright 2005-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 @@ -57,10 +57,10 @@ gdb_test "source -v -s ./source-test.gdb" \ # comes from the a command entered at the GDB prompt, and when # it comes from a script being sourced. gdb_test "source for-sure-nonexistant-file" \ - "for-sure-nonexistant-file: No such file or directory\." + "for-sure-nonexistant-file: No such file or directory\." gdb_test "source source-nofile.gdb" \ - "warning: for-sure-nonexistant-file: No such file or directory\.\[\r\n\]*source error not fatal" + "warning: for-sure-nonexistant-file: No such file or directory\.\[\r\n\]*source error not fatal" # Test commands that error out in sourced files, including in nested sourced diff --git a/gdb/testsuite/gdb.base/sss-bp-on-user-bp-2.c b/gdb/testsuite/gdb.base/sss-bp-on-user-bp-2.c index d22cf67..4a91280 100644 --- a/gdb/testsuite/gdb.base/sss-bp-on-user-bp-2.c +++ b/gdb/testsuite/gdb.base/sss-bp-on-user-bp-2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/sss-bp-on-user-bp-2.exp b/gdb/testsuite/gdb.base/sss-bp-on-user-bp-2.exp index 226a756..0ded183 100644 --- a/gdb/testsuite/gdb.base/sss-bp-on-user-bp-2.exp +++ b/gdb/testsuite/gdb.base/sss-bp-on-user-bp-2.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2024 Free Software Foundation, Inc. +# Copyright (C) 2014-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 @@ -41,7 +41,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return 0 } @@ -140,7 +140,7 @@ gdb_test_multiple "" $test { set disasm_after [disassemble "after"] set test "before/after disassembly matches" -if ![string compare $disasm_before $disasm_after] { +if {![string compare $disasm_before $disasm_after]} { pass $test } else { fail $test diff --git a/gdb/testsuite/gdb.base/sss-bp-on-user-bp.c b/gdb/testsuite/gdb.base/sss-bp-on-user-bp.c index 5a5a68e..c34e7b7 100644 --- a/gdb/testsuite/gdb.base/sss-bp-on-user-bp.c +++ b/gdb/testsuite/gdb.base/sss-bp-on-user-bp.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/sss-bp-on-user-bp.exp b/gdb/testsuite/gdb.base/sss-bp-on-user-bp.exp index a3cbe1d..4aabe19 100644 --- a/gdb/testsuite/gdb.base/sss-bp-on-user-bp.exp +++ b/gdb/testsuite/gdb.base/sss-bp-on-user-bp.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/stack-checking.c b/gdb/testsuite/gdb.base/stack-checking.c index 2439edc..bec4815 100644 --- a/gdb/testsuite/gdb.base/stack-checking.c +++ b/gdb/testsuite/gdb.base/stack-checking.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/stack-checking.exp b/gdb/testsuite/gdb.base/stack-checking.exp index 41fd7e8..286c12a 100644 --- a/gdb/testsuite/gdb.base/stack-checking.exp +++ b/gdb/testsuite/gdb.base/stack-checking.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -16,13 +16,11 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [concat debug additional_flags=-fstack-check nowarnings]] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile \ + [list debug additional_flags=-fstack-check nowarnings]] != 0 } { + return } -clean_restart ${binfile} - if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.base/stack-protector.c b/gdb/testsuite/gdb.base/stack-protector.c index 3967857..738383f 100644 --- a/gdb/testsuite/gdb.base/stack-protector.c +++ b/gdb/testsuite/gdb.base/stack-protector.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/stack-protector.exp b/gdb/testsuite/gdb.base/stack-protector.exp index 6b6043e..8fe63a8 100644 --- a/gdb/testsuite/gdb.base/stack-protector.exp +++ b/gdb/testsuite/gdb.base/stack-protector.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2019-2024 Free Software Foundation, Inc. +# Copyright (C) 2019-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 @@ -52,7 +52,7 @@ proc simple_func_break_test { protection } { gdb_breakpoint "foo" if { $protection == "-fstack-protector-all" - && [test_compiler_info "gcc-*"] } { + && [test_compiler_info "gcc-*"] } { setup_xfail "gcc/88432" "*-*-linux*" } gdb_continue_to_breakpoint "foo" ".*break here.*" diff --git a/gdb/testsuite/gdb.base/stale-infcall.c b/gdb/testsuite/gdb.base/stale-infcall.c index 07def7f..f66d12d 100644 --- a/gdb/testsuite/gdb.base/stale-infcall.c +++ b/gdb/testsuite/gdb.base/stale-infcall.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/stale-infcall.exp b/gdb/testsuite/gdb.base/stale-infcall.exp index e0c71de..1d2c655 100644 --- a/gdb/testsuite/gdb.base/stale-infcall.exp +++ b/gdb/testsuite/gdb.base/stale-infcall.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2024 Free Software Foundation, Inc. +# Copyright (C) 2012-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 @@ -19,7 +19,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/stap-probe.c b/gdb/testsuite/gdb.base/stap-probe.c index 2bc010d..0162875 100644 --- a/gdb/testsuite/gdb.base/stap-probe.c +++ b/gdb/testsuite/gdb.base/stap-probe.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/stap-probe.exp b/gdb/testsuite/gdb.base/stap-probe.exp index 40e8c5e..540daf3 100644 --- a/gdb/testsuite/gdb.base/stap-probe.exp +++ b/gdb/testsuite/gdb.base/stap-probe.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2024 Free Software Foundation, Inc. +# Copyright (C) 2012-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 @@ -60,8 +60,8 @@ proc gdb_count_probes { type provider name { object "" }} { } } - if { [expr $no_probes_line && $probe_count > 0] \ - || [expr !$no_probes_line && $probe_count == 0] } { + if { ($no_probes_line && $probe_count > 0) \ + || (!$no_probes_line && $probe_count == 0) } { perror "Mismatch between no probes found line, and probes count" return -1 } @@ -74,7 +74,7 @@ proc check_for_usable_xmm0_probe { binfile } { set binfile [standard_output_file $binfile] set command "exec $readelf_program -n $binfile" verbose -log "command is $command" - set result [catch $command output] + set result [catch {{*}$command} output] verbose -log "result is $result" verbose -log "output is $output" @@ -89,7 +89,7 @@ proc check_for_usable_xmm0_probe { binfile } { # First, look for the xmmreg probe, and if we find it, grab the # argument string. - if ![regexp {\n\s+Provider: test\n\s+Name: xmmreg\n[^\n]+\n\s+Arguments: ([^\n]+)\n} $output ignore arguments] { + if {![regexp {\n\s+Provider: test\n\s+Name: xmmreg\n[^\n]+\n\s+Arguments: ([^\n]+)\n} $output ignore arguments]} { verbose -log "APB: Couldn't find probe at all" return false } @@ -98,7 +98,7 @@ proc check_for_usable_xmm0_probe { binfile } { verbose -log "APB: arguments: '$arguments'" # Check the the argument string mentions xmm0. - if ![regexp {@%?xmm0} $arguments] { + if {![regexp {@%?xmm0} $arguments]} { verbose -log "APB: Prove doesn't use xmm0 register" return false } @@ -133,7 +133,7 @@ proc stap_test {exec_name {args ""}} { "get original address of relocation_marker"] } - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -159,7 +159,7 @@ proc stap_test {exec_name {args ""}} { [get_hexadecimal_valueof "&relocation_marker" \ "0" "get revised relocation_marker address"] set relocation_base \ - [expr $updated_semaphore_addr_var - $semaphore_addr_var] + [expr {$updated_semaphore_addr_var - $semaphore_addr_var}] if {$relocation_base != 0} { # Checks that GDB doesn't mistakenly relocate and write to null # semaphore addresses. If it were to relocate a zero-valued @@ -177,8 +177,8 @@ proc stap_test {exec_name {args ""}} { gdb_test "print \$_probe_arg0 == x" " = 1" \ "check \$_probe_arg0 for probe user" gdb_test "print \$_probe_arg1" \ - "Invalid probe argument 1 -- probe has 1 arguments available" \ - "check \$_probe_arg1 for probe user" + "Invalid probe argument 1 -- probe has 1 arguments available" \ + "check \$_probe_arg1 for probe user" # Set a breakpoint with multiple probe locations. gdb_test "break -pstap test:two" \ @@ -219,7 +219,7 @@ proc stap_test {exec_name {args ""}} { "print \$_probe_arg1 for probe ps" # Check the probe is using the xmm0 register. - if [check_for_usable_xmm0_probe $exec_name] { + if {[check_for_usable_xmm0_probe $exec_name]} { delete_breakpoints if {[runto "-pstap test:xmmreg"]} { @@ -267,8 +267,8 @@ proc stap_test_no_debuginfo {exec_name {args ""}} { gdb_test "print \$_probe_arg0 == 23" " = 1" \ "check \$_probe_arg0 for probe user" gdb_test "print \$_probe_arg1" \ - "Invalid probe argument 1 -- probe has 1 arguments available" \ - "check \$_probe_arg1 for probe user" + "Invalid probe argument 1 -- probe has 1 arguments available" \ + "check \$_probe_arg1 for probe user" # Set a breakpoint with multiple probe locations. # In this scenario, we may expect more than 2 locations because of diff --git a/gdb/testsuite/gdb.base/start-cpp.cc b/gdb/testsuite/gdb.base/start-cpp.cc index 6a800d8..1f788ed 100644 --- a/gdb/testsuite/gdb.base/start-cpp.cc +++ b/gdb/testsuite/gdb.base/start-cpp.cc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/start-cpp.exp b/gdb/testsuite/gdb.base/start-cpp.exp index 330c6ea..59a1a59 100644 --- a/gdb/testsuite/gdb.base/start-cpp.exp +++ b/gdb/testsuite/gdb.base/start-cpp.exp @@ -1,4 +1,4 @@ -# Copyright 2005-2024 Free Software Foundation, Inc. +# Copyright 2005-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 @@ -39,5 +39,5 @@ if { [gdb_start_cmd] < 0 } { } gdb_test "" \ - "Temporary breakpoint $decimal at $hex: file.*main \\(\\) at .*start-cpp.cc:.*" \ - "start" + "Temporary breakpoint $decimal at $hex: file.*main \\(\\) at .*start-cpp.cc:.*" \ + "start" diff --git a/gdb/testsuite/gdb.base/start.c b/gdb/testsuite/gdb.base/start.c index 4587679..f06fe58 100644 --- a/gdb/testsuite/gdb.base/start.c +++ b/gdb/testsuite/gdb.base/start.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2005-2024 Free Software Foundation, Inc. + Copyright 2005-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 diff --git a/gdb/testsuite/gdb.base/start.exp b/gdb/testsuite/gdb.base/start.exp index 64b04c2..97be64d 100644 --- a/gdb/testsuite/gdb.base/start.exp +++ b/gdb/testsuite/gdb.base/start.exp @@ -1,4 +1,4 @@ -# Copyright 2005-2024 Free Software Foundation, Inc. +# Copyright 2005-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 @@ -31,5 +31,5 @@ if { [gdb_start_cmd] < 0 } { } gdb_test "" \ - "main \\(\\) at .*start.c.*" \ - "start" + "main \\(\\) at .*start.c.*" \ + "start" diff --git a/gdb/testsuite/gdb.base/starti.c b/gdb/testsuite/gdb.base/starti.c index 35f995c..7e5555f 100644 --- a/gdb/testsuite/gdb.base/starti.c +++ b/gdb/testsuite/gdb.base/starti.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/starti.exp b/gdb/testsuite/gdb.base/starti.exp index 5fe98dc..c123519 100644 --- a/gdb/testsuite/gdb.base/starti.exp +++ b/gdb/testsuite/gdb.base/starti.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/startup-with-shell.c b/gdb/testsuite/gdb.base/startup-with-shell.c index ca7a809..423cd17 100644 --- a/gdb/testsuite/gdb.base/startup-with-shell.c +++ b/gdb/testsuite/gdb.base/startup-with-shell.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/startup-with-shell.exp b/gdb/testsuite/gdb.base/startup-with-shell.exp index e27f17a..0887a5a 100644 --- a/gdb/testsuite/gdb.base/startup-with-shell.exp +++ b/gdb/testsuite/gdb.base/startup-with-shell.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -22,6 +22,8 @@ require !use_gdb_stub # (via dejagnu) yet. require {!is_remote target} +require {expr {[have_startup_shell] != -1}} + standard_testfile if { [build_executable "failed to prepare" $testfile $srcfile debug] } { @@ -38,9 +40,9 @@ run_on_host \ # Initial setup for simple test (wildcard expansion, variable substitution). proc initial_setup_simple { startup_with_shell run_args } { - global hex decimal binfile unique_file + global hex decimal unique_file - clean_restart $binfile + clean_restart $::testfile gdb_test_no_output "set startup-with-shell $startup_with_shell" gdb_test_no_output "set print characters unlimited" @@ -91,73 +93,97 @@ proc run_test_same { args re testname } { run_test $args $re $re $testname } -# The regexp to match a single '\' character. -set bs "\\\\" - -# Are we using 'remote' or 'extended-remote' protocol? -set is_remote_p [gdb_protocol_is_remote] - -## Run the actual tests - -run_test "$unique_file_dir/*.unique-extension" \ - "\"$unique_file\"" \ - "\"$unique_file_dir/\\\*\.unique-extension\"" \ - "arg is glob" \ - $is_remote_p - -run_test_same "$unique_file_dir/\\*.unique-extension" \ - "\"$unique_file_dir/\\\*\.unique-extension\"" \ - "arg is escaped glob" - -save_vars { env(TEST) } { - set env(TEST) "1234" - run_test "\$TEST" \ - "\"1234\"" \ - "\"\\\$TEST\"" \ - "arg is shell variable" \ - $is_remote_p +# Run the actual tests +proc run_all_tests { { is_remote_with_split_args false } } { + # The regexp to match a single '\' character. + set bs "\\\\" + + run_test "$::unique_file_dir/*.unique-extension" \ + "\"$::unique_file\"" \ + "\"$::unique_file_dir/\\\*\.unique-extension\"" \ + "arg is glob" \ + $is_remote_with_split_args + + run_test_same "$::unique_file_dir/\\*.unique-extension" \ + "\"$::unique_file_dir/\\\*\.unique-extension\"" \ + "arg is escaped glob" + + save_vars { ::env(TEST) } { + set ::env(TEST) "1234" + run_test "\$TEST" \ + "\"1234\"" \ + "\"\\\$TEST\"" \ + "arg is shell variable" \ + $is_remote_with_split_args + + run_test_same "\\\$TEST" \ + "\"\\\$TEST\"" \ + "arg is escaped shell variable" + } - run_test_same "\\\$TEST" \ - "\"\\\$TEST\"" \ - "arg is escaped shell variable" + run_test "\$(echo foo)" \ + "\"foo\"" \ + "\"\\\$\\(echo\"" \ + "arg is parameter expansion, command execution" \ + $is_remote_with_split_args + + run_test "\$((2 + 3))" \ + "\"5\"" \ + "\"\\\$\\(\\(2\"" \ + "arg is parameter expansion, expression evaluation" \ + $is_remote_with_split_args + + run_test_same "\"\\a\"" \ + "\"${bs}${bs}a\"" \ + "retain backslash in double quote arg" + + run_test_same "'\\a'" \ + "\"${bs}${bs}a\"" \ + "retain backslash in single quote arg" + + run_test_same "\"\\\$\"" \ + "\"\\\$\"" \ + "'\$' can be escaped in double quote arg" + + run_test_same "'\\\$'" \ + "\"${bs}${bs}\\\$\"" \ + "'\$' is not escaped in single quote arg" + + run_test_same "\"\\`\"" \ + "\"\\`\"" \ + "'`' can be escaped in double quote arg" + + run_test_same "'\\`'" \ + "\"${bs}${bs}`\"" \ + "'`' is not escaped in single quote arg" + + run_test_same "\"\\\"\"" \ + "\"${bs}\"\"" \ + "'\"' can be escaped in double quote arg" + + run_test_same "'\\\"'" \ + "\"${bs}${bs}${bs}\"\"" \ + "'\"' is not escaped in single quote arg" + + run_test_same "\"\\\\\"" \ + "\"${bs}${bs}\"" \ + "'\\' can be escaped in double quote arg" + + run_test_same "'\\\\'" \ + "\"${bs}${bs}${bs}${bs}\"" \ + "'\\' is not escaped in single quote arg" } -run_test_same "\"\\a\"" \ - "\"${bs}${bs}a\"" \ - "retain backslash in double quote arg" - -run_test_same "'\\a'" \ - "\"${bs}${bs}a\"" \ - "retain backslash in single quote arg" - -run_test_same "\"\\\$\"" \ - "\"\\\$\"" \ - "'\$' can be escaped in double quote arg" +run_all_tests -run_test_same "'\\\$'" \ - "\"${bs}${bs}\\\$\"" \ - "'\$' is not escaped in single quote arg" - -run_test_same "\"\\`\"" \ - "\"\\`\"" \ - "'`' can be escaped in double quote arg" - -run_test_same "'\\`'" \ - "\"${bs}${bs}`\"" \ - "'`' is not escaped in single quote arg" - -run_test_same "\"\\\"\"" \ - "\"${bs}\"\"" \ - "'\"' can be escaped in double quote arg" - -run_test_same "'\\\"'" \ - "\"${bs}${bs}${bs}\"\"" \ - "'\"' is not escaped in single quote arg" - -run_test_same "\"\\\\\"" \ - "\"${bs}${bs}\"" \ - "'\\' can be escaped in double quote arg" - -run_test_same "'\\\\'" \ - "\"${bs}${bs}${bs}${bs}\"" \ - "'\\' is not escaped in single quote arg" +# For extended-remote targets, disable the packet which passes +# inferior arguments as a single string. This changes how the vRun +# (extended-remote only) packet works. +if {[target_info gdb_protocol] == "extended-remote"} { + with_test_prefix "single-inferior-arg disabled" { + save_vars { GDBFLAGS } { + append GDBFLAGS " -ex \"set remote single-inferior-argument-feature-packet off\"" + run_all_tests true + } + } +} diff --git a/gdb/testsuite/gdb.base/statistics.exp b/gdb/testsuite/gdb.base/statistics.exp index a333f99..1dacc4d 100644 --- a/gdb/testsuite/gdb.base/statistics.exp +++ b/gdb/testsuite/gdb.base/statistics.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/step-break.c b/gdb/testsuite/gdb.base/step-break.c index 8cd4df7..1934f60 100644 --- a/gdb/testsuite/gdb.base/step-break.c +++ b/gdb/testsuite/gdb.base/step-break.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/step-break.exp b/gdb/testsuite/gdb.base/step-break.exp index 7dc0492..e565185 100644 --- a/gdb/testsuite/gdb.base/step-break.exp +++ b/gdb/testsuite/gdb.base/step-break.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/step-bt.c b/gdb/testsuite/gdb.base/step-bt.c index 9b3c718..49f42ad 100644 --- a/gdb/testsuite/gdb.base/step-bt.c +++ b/gdb/testsuite/gdb.base/step-bt.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2006-2024 Free Software Foundation, Inc. + Copyright 2006-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 diff --git a/gdb/testsuite/gdb.base/step-bt.exp b/gdb/testsuite/gdb.base/step-bt.exp index f872daf..56b082c 100644 --- a/gdb/testsuite/gdb.base/step-bt.exp +++ b/gdb/testsuite/gdb.base/step-bt.exp @@ -1,4 +1,4 @@ -# Copyright 2006-2024 Free Software Foundation, Inc. +# Copyright 2006-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 @@ -24,25 +24,24 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { } gdb_test "break *hello" \ - "Breakpoint.*at.* file .*$srcfile, line .*" \ - "breakpoint at first instruction of hello()" + "Breakpoint.*at.* file .*$srcfile, line .*" \ + "breakpoint at first instruction of hello()" gdb_run_cmd gdb_test "" "Breakpoint.* hello .* at .*$srcfile:.*" "run to hello()" gdb_test "stepi" \ - ".*" \ - "step first instruction" + ".*" \ + "step first instruction" gdb_test "bt" \ - "#0 +(0x\[0-9a-z\]+ in )?hello .*#1 +(0x\[0-9a-z\]* in )?main.*" \ - "backtrace after first instruction step" + "#0 +(0x\[0-9a-z\]+ in )?hello .*#1 +(0x\[0-9a-z\]* in )?main.*" \ + "backtrace after first instruction step" gdb_test "stepi" \ - ".*" \ - "step second instruction" + ".*" \ + "step second instruction" gdb_test "bt" \ - "#0 +(0x\[0-9a-z\]+ in )?hello .*#1 +(0x\[0-9a-z\]* in )?main.*" \ - "backtrace after second instruction step" - + "#0 +(0x\[0-9a-z\]+ in )?hello .*#1 +(0x\[0-9a-z\]* in )?main.*" \ + "backtrace after second instruction step" diff --git a/gdb/testsuite/gdb.base/step-indirect-call-thunk.c b/gdb/testsuite/gdb.base/step-indirect-call-thunk.c index 277653c..3266305 100644 --- a/gdb/testsuite/gdb.base/step-indirect-call-thunk.c +++ b/gdb/testsuite/gdb.base/step-indirect-call-thunk.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/step-indirect-call-thunk.exp b/gdb/testsuite/gdb.base/step-indirect-call-thunk.exp index 36d3933..3a5700a 100644 --- a/gdb/testsuite/gdb.base/step-indirect-call-thunk.exp +++ b/gdb/testsuite/gdb.base/step-indirect-call-thunk.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -23,7 +23,7 @@ if { [gcc_major_version] >= 8 } { append cflags " -fcf-protection=none" } if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ - [list debug "additional_flags=$cflags"]] } { + [list debug "additional_flags=$cflags"]] } { return -1 } @@ -48,18 +48,18 @@ proc stepi_until { current target test } { set count 0 gdb_test_multiple "stepi" "$test" { - -re "$current.*$gdb_prompt $" { - incr count - if { $count < 100 } { - send_gdb "stepi\n" - exp_continue - } else { - fail "$test" - } - } - -re "$target.*$gdb_prompt $" { - pass "$test" - } + -re "$current.*$gdb_prompt $" { + incr count + if { $count < 100 } { + send_gdb "stepi\n" + exp_continue + } else { + fail "$test" + } + } + -re "$target.*$gdb_prompt $" { + pass "$test" + } } } diff --git a/gdb/testsuite/gdb.base/step-into-other-file.c b/gdb/testsuite/gdb.base/step-into-other-file.c index 5ec7c33..5023755 100644 --- a/gdb/testsuite/gdb.base/step-into-other-file.c +++ b/gdb/testsuite/gdb.base/step-into-other-file.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/step-into-other-file.exp b/gdb/testsuite/gdb.base/step-into-other-file.exp index f0e8c3f..80fc55e 100644 --- a/gdb/testsuite/gdb.base/step-into-other-file.exp +++ b/gdb/testsuite/gdb.base/step-into-other-file.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2024 Free Software Foundation, Inc. +# Copyright (C) 2024-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 @@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/step-into-other-file.h b/gdb/testsuite/gdb.base/step-into-other-file.h index 60b4816..0617011 100644 --- a/gdb/testsuite/gdb.base/step-into-other-file.h +++ b/gdb/testsuite/gdb.base/step-into-other-file.h @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2024 Free Software Foundation, Inc. + Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/step-line.c b/gdb/testsuite/gdb.base/step-line.c index 24b8bfb..ac7a7bb 100644 --- a/gdb/testsuite/gdb.base/step-line.c +++ b/gdb/testsuite/gdb.base/step-line.c @@ -1,6 +1,6 @@ /* Test step/next in presence of #line directives. - Copyright (C) 2001-2024 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/step-line.exp b/gdb/testsuite/gdb.base/step-line.exp index 6629eb8..96071d0 100644 --- a/gdb/testsuite/gdb.base/step-line.exp +++ b/gdb/testsuite/gdb.base/step-line.exp @@ -1,4 +1,4 @@ -# Copyright 2001-2024 Free Software Foundation, Inc. +# Copyright 2001-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 @@ -35,47 +35,47 @@ set remote_linefile [gdb_remote_download host ${srcdir}/${subdir}/${linefile}] gdb_test "break f1" ".*Breakpoint 2 at .* file .*step-line.c.*" gdb_test "continue" \ - "Continuing.*Breakpoint 2, f1 \\(i=4\\).*dummy \\(1, i\\);" \ + "Continuing.*Breakpoint 2, f1 \\(i=4\\).*dummy \\(1, i\\);" \ "continue to f1" gdb_test "next" \ - ".*i = f2 \\(i\\);.*" \ + ".*i = f2 \\(i\\);.*" \ "next over dummy 1" gdb_test "next" \ - ".*dummy \\(2, i\\);.*" \ + ".*dummy \\(2, i\\);.*" \ "next to dummy 2" gdb_test "next" \ - ".*i = f2 \\(i\\);.*" \ + ".*i = f2 \\(i\\);.*" \ "next over dummy 2" gdb_test "step" \ - ".*f2 \\(i=4\\).*dummy \\(4, i\\);.*" \ + ".*f2 \\(i=4\\).*dummy \\(4, i\\);.*" \ "step into f2" gdb_test "next" \ - ".*j = i;.*" \ + ".*j = i;.*" \ "next over dummy 4" gdb_test "next" \ - ".*dummy \\(5, i\\);.*" \ + ".*dummy \\(5, i\\);.*" \ "next to dummy 5" gdb_test "next" \ - ".*dummy \\(6, j\\);.*" \ + ".*dummy \\(6, j\\);.*" \ "next to dummy 6" gdb_test "next" \ - ".*j = SUCC \\(j\\);.*" \ + ".*j = SUCC \\(j\\);.*" \ "next over dummy 6" gdb_test "next" \ - ".*dummy \\(7, i\\);.*" \ + ".*dummy \\(7, i\\);.*" \ "next to dummy 7" gdb_test "next" \ - ".*dummy \\(8, j\\);.*" \ + ".*dummy \\(8, j\\);.*" \ "next to dummy 8" gdb_test "next" \ - ".*j = j - i;.*" \ + ".*j = j - i;.*" \ "next over dummy 8" gdb_test "next" \ - ".*dummy \\(9, i\\);.*" \ + ".*dummy \\(9, i\\);.*" \ "next to dummy 9" gdb_test "next" \ - ".*dummy \\(10, j\\);.*" \ + ".*dummy \\(10, j\\);.*" \ "next to dummy 10" gdb_test "next" \ - ".*RETURN \\(j\\);.*" \ + ".*RETURN \\(j\\);.*" \ "next over dummy 10" diff --git a/gdb/testsuite/gdb.base/step-line.inp b/gdb/testsuite/gdb.base/step-line.inp index 744b2f0..5bf49c6 100644 --- a/gdb/testsuite/gdb.base/step-line.inp +++ b/gdb/testsuite/gdb.base/step-line.inp @@ -1,17 +1,17 @@ # Test step/next in presence of #line directives -# Copyright (C) 2001-2024 Free Software Foundation, Inc. +# Copyright (C) 2001-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/>. diff --git a/gdb/testsuite/gdb.base/step-over-clone.c b/gdb/testsuite/gdb.base/step-over-clone.c index 920de86..f254882 100644 --- a/gdb/testsuite/gdb.base/step-over-clone.c +++ b/gdb/testsuite/gdb.base/step-over-clone.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/step-over-exit.c b/gdb/testsuite/gdb.base/step-over-exit.c index 5c34547..6c3db60 100644 --- a/gdb/testsuite/gdb.base/step-over-exit.c +++ b/gdb/testsuite/gdb.base/step-over-exit.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2016-2024 Free Software Foundation, Inc. + Copyright 2016-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 diff --git a/gdb/testsuite/gdb.base/step-over-exit.exp b/gdb/testsuite/gdb.base/step-over-exit.exp index d373b1a..105157d 100644 --- a/gdb/testsuite/gdb.base/step-over-exit.exp +++ b/gdb/testsuite/gdb.base/step-over-exit.exp @@ -1,4 +1,4 @@ -# Copyright 2016-2024 Free Software Foundation, Inc. +# Copyright 2016-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 @@ -13,11 +13,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -standard_testfile - # Test a thread is doing step-over a syscall instruction which is exit, # and GDBserver should cleanup its state of step-over properly. +# The testcase relies on follow-fork-mode child. +require allow_fork_tests + +standard_testfile + set syscall_insn "" # Define the syscall instruction for each target. @@ -35,7 +38,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/step-over-fork.c b/gdb/testsuite/gdb.base/step-over-fork.c index 3b46f44..365e080 100644 --- a/gdb/testsuite/gdb.base/step-over-fork.c +++ b/gdb/testsuite/gdb.base/step-over-fork.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/step-over-no-symbols.exp b/gdb/testsuite/gdb.base/step-over-no-symbols.exp index 98158e1..b5fbfbb 100644 --- a/gdb/testsuite/gdb.base/step-over-no-symbols.exp +++ b/gdb/testsuite/gdb.base/step-over-no-symbols.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2024 Free Software Foundation, Inc. +# Copyright (C) 2015-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 @@ -45,11 +45,10 @@ proc get_pc { msg } { proc test_step_over { displaced } { global hex - global binfile - clean_restart $binfile + clean_restart $::testfile - if ![runto_main] { + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/step-over-syscall.exp b/gdb/testsuite/gdb.base/step-over-syscall.exp index dc73def..e4425a1 100644 --- a/gdb/testsuite/gdb.base/step-over-syscall.exp +++ b/gdb/testsuite/gdb.base/step-over-syscall.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 @@ -227,7 +227,7 @@ proc step_over_syscall { syscall } { lappend options "pthreads" } - if [build_executable ${testfile}.exp ${testfile} ${testfile}.c $options] { + if {[build_executable ${testfile}.exp ${testfile} ${testfile}.c $options]} { untested "failed to compile" return -1 } diff --git a/gdb/testsuite/gdb.base/step-over-vfork.c b/gdb/testsuite/gdb.base/step-over-vfork.c index 0ce8d65..704c0d8 100644 --- a/gdb/testsuite/gdb.base/step-over-vfork.c +++ b/gdb/testsuite/gdb.base/step-over-vfork.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 diff --git a/gdb/testsuite/gdb.base/step-resume-infcall.c b/gdb/testsuite/gdb.base/step-resume-infcall.c index a5baf1a..f2e9047 100644 --- a/gdb/testsuite/gdb.base/step-resume-infcall.c +++ b/gdb/testsuite/gdb.base/step-resume-infcall.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2005-2024 Free Software Foundation, Inc. + Copyright 2005-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 diff --git a/gdb/testsuite/gdb.base/step-resume-infcall.exp b/gdb/testsuite/gdb.base/step-resume-infcall.exp index 5646e7c..f1f8dc2 100644 --- a/gdb/testsuite/gdb.base/step-resume-infcall.exp +++ b/gdb/testsuite/gdb.base/step-resume-infcall.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2010-2024 Free Software Foundation, Inc. +# Copyright (C) 2010-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 @@ -19,7 +19,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} $srcfile] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } @@ -27,7 +27,7 @@ gdb_test "step" " in-func .*" gdb_test "up" " call-func .*" gdb_test_no_output {set $b=$pc} -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.c b/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.c index c4baeac..438ed7a 100644 --- a/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.c +++ b/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.exp b/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.exp index 4577b8f..8e20711 100644 --- a/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.exp +++ b/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -21,7 +21,7 @@ standard_testfile -if [build_executable "failed to build" ${testfile} ${srcfile} {debug}] { +if {[build_executable "failed to build" ${testfile} ${srcfile} {debug}]} { return -1 } @@ -29,20 +29,19 @@ set linenum_for_user_bp [gdb_get_line_number "break for user-bp test here"] set linenum_for_step_resume [gdb_get_line_number "break for step-resume test here"] proc test {non_stop displaced always_inserted} { - global binfile global linenum_for_user_bp global linenum_for_step_resume global GDBFLAGS save_vars { GDBFLAGS } { set GDBFLAGS "$GDBFLAGS -ex \"set non-stop $non_stop\"" - clean_restart $binfile + clean_restart $::testfile } gdb_test_no_output "set displaced-stepping $displaced" gdb_test_no_output "set breakpoint always-inserted $always_inserted" - if ![runto_main] { + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/step-symless.c b/gdb/testsuite/gdb.base/step-symless.c index 19c72f8..e39216e 100644 --- a/gdb/testsuite/gdb.base/step-symless.c +++ b/gdb/testsuite/gdb.base/step-symless.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/step-symless.exp b/gdb/testsuite/gdb.base/step-symless.exp index b01b9f6..47e4682 100644 --- a/gdb/testsuite/gdb.base/step-symless.exp +++ b/gdb/testsuite/gdb.base/step-symless.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2024 Free Software Foundation, Inc. +# Copyright (C) 2012-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 @@ -21,7 +21,7 @@ if {[build_executable ${testfile}.exp ${testfile} ${srcfile} {nodebug}] == -1} { # We need those symbols global to access them from the .S file. set test "strip stub symbols" set objcopy_program [gdb_find_objcopy] -set result [catch "exec $objcopy_program -N symless ${binfile}" output] +set result [catch {exec $objcopy_program -N symless ${binfile}} output] verbose "result is $result" verbose "output is $output" if {$result != 0} { @@ -32,7 +32,7 @@ pass $test clean_restart $testfile -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/step-test.c b/gdb/testsuite/gdb.base/step-test.c index a1e1dc4..a3a5c43 100644 --- a/gdb/testsuite/gdb.base/step-test.c +++ b/gdb/testsuite/gdb.base/step-test.c @@ -43,7 +43,7 @@ int main () { /* Test "stepi" */ a[5] = a[3] - a[4]; callee(); /* STEPI */ - + /* Test "nexti" */ callee(); /* NEXTI */ @@ -58,4 +58,3 @@ int main () { exit (0); } - diff --git a/gdb/testsuite/gdb.base/step-test.exp b/gdb/testsuite/gdb.base/step-test.exp index 6e6f89b..1fb793d 100644 --- a/gdb/testsuite/gdb.base/step-test.exp +++ b/gdb/testsuite/gdb.base/step-test.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -19,12 +19,10 @@ standard_testfile .c remote_exec build "rm -f ${binfile}" -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 -} -clean_restart ${binfile} +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return +} if {![runto_main]} { return 0 @@ -32,7 +30,7 @@ if {![runto_main]} { # Set a breakpoint at line 45, if stepi then finish fails, we would # run to the end of the program, which would mess up the rest of the tests. - + # Vanilla step/next # gdb_test "next" ".*${decimal}.*x = 1;.*" "next 1" @@ -66,10 +64,10 @@ gdb_test "step" ".*${decimal}.*myglob.*" "step into" set test "step out" if { [istarget "ia64-*-*"] || [istarget "mips*-*-*"]} { gdb_test_multiple "finish" "$test" { - -re ".*${decimal}.*a.*5.*= a.*3.*$gdb_prompt $" { + -re ".*${decimal}.*a.*5.*= a.*3.*$gdb_prompt $" { pass "$test" } - -re ".*${decimal}.*callee.*INTO.*$gdb_prompt $" { + -re ".*${decimal}.*callee.*INTO.*$gdb_prompt $" { pass "$test" } } @@ -91,10 +89,10 @@ if { [istarget "ia64-*-*"] || [istarget "mips*-*-*"]} { ### ### The exact regexps used are "$HERE.*$gdb_prompt $" ### and "$THERE.*$gdb_prompt $" -### +### proc test_i {name command here there} { global gdb_prompt - + set i 0 gdb_test_multiple "$command" "$name" { -re "$here.*$gdb_prompt $" { @@ -122,7 +120,7 @@ test_i "stepi to next line" "stepi" \ # if this passes through a (useless) PLT entry. test_i "stepi into function" "stepi" \ "(.*${decimal}.*callee.*STEPI|.* in callee@plt)" \ - ".*callee \\(\\) at .*step-test\\.c" + ".*callee \\(\\) at .*step-test\\.c" # Continue to step until we reach the function's body. This makes it # more likely that we've actually completed the prologue, so "finish" @@ -133,7 +131,7 @@ test_i "stepi into function's first source line" "stepi" \ "(${decimal}.*int callee|$pic_thunk_re)" \ ".*${decimal}.*myglob.*; return 0;" -# Have to be careful here, if the finish does not work, +# Have to be careful here, if the finish does not work, # then we may run to the end of the program, which # will cause erroneous failures in the rest of the tests set test "stepi: finish call" @@ -142,7 +140,7 @@ gdb_test_multiple "finish" "$test" { pass "$test" } -re ".*(Program received|$inferior_exited_re).*$gdb_prompt $" { - # Oops... We ran to the end of the program... Better reset + # Oops... We ran to the end of the program... Better reset if {![runto_main]} { return 0 } @@ -187,7 +185,7 @@ gdb_test \ ".*Breakpoint.* at .*" \ "set breakpoint at call to large_struct_by_value" gdb_test "continue" \ - ".*Breakpoint ${decimal},.*large_struct_by_value.*" \ + ".*Breakpoint ${decimal},.*large_struct_by_value.*" \ "run to pass large struct" set test "large struct by value" gdb_test_multiple "step" "$test" { diff --git a/gdb/testsuite/gdb.base/step-through-epilogue.c b/gdb/testsuite/gdb.base/step-through-epilogue.c index c545cb1..d96f0ae 100644 --- a/gdb/testsuite/gdb.base/step-through-epilogue.c +++ b/gdb/testsuite/gdb.base/step-through-epilogue.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1992-2024 Free Software Foundation, Inc. + Copyright 1992-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 diff --git a/gdb/testsuite/gdb.base/step-through-epilogue.exp b/gdb/testsuite/gdb.base/step-through-epilogue.exp index 8416e13..e024433 100644 --- a/gdb/testsuite/gdb.base/step-through-epilogue.exp +++ b/gdb/testsuite/gdb.base/step-through-epilogue.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/store.c b/gdb/testsuite/gdb.base/store.c index 545515d..82d84f3 100644 --- a/gdb/testsuite/gdb.base/store.c +++ b/gdb/testsuite/gdb.base/store.c @@ -279,13 +279,13 @@ main () wack_struct_2 (); wack_struct_3 (); wack_struct_4 (); - + /* These calls are for up frame. */ wack_struct_1 (); wack_struct_2 (); wack_struct_3 (); wack_struct_4 (); - + wack_field_1 (); wack_field_2 (); wack_field_3 (); diff --git a/gdb/testsuite/gdb.base/store.exp b/gdb/testsuite/gdb.base/store.exp index 2271156..e91ebf4 100644 --- a/gdb/testsuite/gdb.base/store.exp +++ b/gdb/testsuite/gdb.base/store.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2002-2024 Free Software Foundation, Inc. +# Copyright 2002-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 @@ -234,4 +234,3 @@ check_field 4 # WANTED: A fairly portable way of convincing the compiler to split a # value across memory and registers. - diff --git a/gdb/testsuite/gdb.base/structs.c b/gdb/testsuite/gdb.base/structs.c index dd85e5e..c1cc4ef 100644 --- a/gdb/testsuite/gdb.base/structs.c +++ b/gdb/testsuite/gdb.base/structs.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1996-2024 Free Software Foundation, Inc. + Copyright 1996-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 @@ -122,7 +122,7 @@ struct struct18 foo18 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E' struct struct1 fun1() { - return foo1; + return foo1; } struct struct2 fun2() { @@ -158,39 +158,39 @@ struct struct9 fun9() } struct struct10 fun10() { - return foo10; + return foo10; } struct struct11 fun11() { - return foo11; + return foo11; } struct struct12 fun12() { - return foo12; + return foo12; } struct struct13 fun13() { - return foo13; + return foo13; } struct struct14 fun14() { - return foo14; + return foo14; } struct struct15 fun15() { - return foo15; + return foo15; } struct struct16 fun16() { - return foo16; + return foo16; } struct struct17 fun17() { - return foo17; + return foo17; } struct struct18 fun18() { - return foo18; + return foo18; } void Fun1(struct struct1 foo1) @@ -231,39 +231,39 @@ void Fun9(struct struct9 foo9) } void Fun10(struct struct10 foo10) { - L10 = foo10; + L10 = foo10; } void Fun11(struct struct11 foo11) { - L11 = foo11; + L11 = foo11; } void Fun12(struct struct12 foo12) { - L12 = foo12; + L12 = foo12; } void Fun13(struct struct13 foo13) { - L13 = foo13; + L13 = foo13; } void Fun14(struct struct14 foo14) { - L14 = foo14; + L14 = foo14; } void Fun15(struct struct15 foo15) { - L15 = foo15; + L15 = foo15; } void Fun16(struct struct16 foo16) { - L16 = foo16; + L16 = foo16; } void Fun17(struct struct17 foo17) { - L17 = foo17; + L17 = foo17; } void Fun18(struct struct18 foo18) { - L18 = foo18; + L18 = foo18; } void @@ -317,15 +317,15 @@ int main() chartest[i].c = i; chartest[0].c = 0; /* chartest-done */ - Fun1(foo1); - Fun2(foo2); - Fun3(foo3); - Fun4(foo4); - Fun5(foo5); - Fun6(foo6); - Fun7(foo7); - Fun8(foo8); - Fun9(foo9); + Fun1(foo1); + Fun2(foo2); + Fun3(foo3); + Fun4(foo4); + Fun5(foo5); + Fun6(foo6); + Fun7(foo7); + Fun8(foo8); + Fun9(foo9); Fun10(foo10); Fun11(foo11); Fun12(foo12); @@ -346,15 +346,15 @@ int main() for (i = 0; i < 1000000; ++i) { zed (); - L1 = fun1(); - L2 = fun2(); - L3 = fun3(); - L4 = fun4(); - L5 = fun5(); - L6 = fun6(); - L7 = fun7(); - L8 = fun8(); - L9 = fun9(); + L1 = fun1(); + L2 = fun2(); + L3 = fun3(); + L4 = fun4(); + L5 = fun5(); + L6 = fun6(); + L7 = fun7(); + L8 = fun8(); + L9 = fun9(); L10 = fun10(); L11 = fun11(); L12 = fun12(); diff --git a/gdb/testsuite/gdb.base/structs.exp b/gdb/testsuite/gdb.base/structs.exp index 99b6aa9..5f0fae8 100644 --- a/gdb/testsuite/gdb.base/structs.exp +++ b/gdb/testsuite/gdb.base/structs.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 1996-2024 Free Software Foundation, Inc. +# Copyright 1996-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 @@ -56,7 +56,7 @@ proc start_structs_test { types } { } set binfile [standard_output_file ${testfile}] - if { [prepare_for_testing "failed to prepare" $binfile $srcfile $flags] } { + if { [prepare_for_testing "failed to prepare" $testfile $srcfile $flags] } { return -1 } @@ -75,7 +75,7 @@ proc start_structs_test { types } { get_debug_format # Limit the slow $anychar_re{256} matching for better performance. - if $first { + if {$first} { set first 0 # Verify $anychar_re can match all the values of `char' type. @@ -215,7 +215,7 @@ proc test_struct_calls { n } { # Check that GDB can always extract a struct-return value from an # inferior function call. Since GDB always knows the location of an # inferior function call's return value these should never fail - + # Implemented by calling the parameterless function "fun$N" and then # examining the return value printed by GDB. @@ -358,24 +358,24 @@ proc test_struct_returns { n } { set test "value foo<n> returned; ${tests}" gdb_test_multiple "p/c L${n}" "${test}" { -re " = [foo ${n}].*${gdb_prompt} $" { - # This answer is okay regardless of whether GDB claims to - # have set the return value: if it did, then this is what - # we expected; and if it didn't, then any answer is okay. - pass "${test}" + # This answer is okay regardless of whether GDB claims to + # have set the return value: if it did, then this is what + # we expected; and if it didn't, then any answer is okay. + pass "${test}" } -re " = [any $n].*${gdb_prompt} $" { - if $return_value_known { + if {$return_value_known} { # This contradicts the above claim that GDB knew # the location of the return value. fail "${test}" } else { - # We expected L${n} to be set to garbage, so any - # answer is acceptable. + # We expected L${n} to be set to garbage, so any + # answer is acceptable. pass "${test}" } } -re ".*${gdb_prompt} $" { - if $return_value_unimplemented { + if {$return_value_unimplemented} { # What a surprise. The architecture hasn't implemented # return_value, and hence has to fail. kfail "$test" gdb/1444 @@ -383,8 +383,8 @@ proc test_struct_returns { n } { fail "$test" } } - } - + } + # Check that a "finish" works. # This is almost but not quite the same as "call struct funcs". @@ -425,7 +425,7 @@ proc test_struct_returns { n } { set test "value foo<n> finished; ${tests}" gdb_test_multiple "p/c" "${test}" { -re "[foo ${n}]\[\r\n\]+${gdb_prompt} $" { - if $finish_value_known { + if {$finish_value_known} { pass "${test}" } else { # This contradicts the above claim that GDB didn't @@ -435,7 +435,7 @@ proc test_struct_returns { n } { } -re "[zed ${n}]\[\r\n\]+${gdb_prompt} $" { # The value didn't get found. This is "expected". - if $finish_value_known { + if {$finish_value_known} { # This contradicts the above claim that GDB did # know the location of the return-value. fail "${test}" diff --git a/gdb/testsuite/gdb.base/structs2.exp b/gdb/testsuite/gdb.base/structs2.exp index 938d931..f0e8342 100644 --- a/gdb/testsuite/gdb.base/structs2.exp +++ b/gdb/testsuite/gdb.base/structs2.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -15,7 +15,7 @@ standard_testfile .c -if { [prepare_for_testing "failed to prepare" $binfile $srcfile {debug}] } { +if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug}] } { return -1 } @@ -31,14 +31,14 @@ gdb_test "break param_reg" \ "Breakpoint .* at .*" \ "structs2 breakpoint set" -if [test_compiler_info gcc-3-*] { +if {[test_compiler_info gcc-3-*]} { setup_xfail hppa*-* gcc/15860 } gdb_test "continue" \ ".*pr_char=120.*pr_uchar=130.*pr_short=32000.*pr_ushort=33000.*bkpt = 1.*" \ "structs2 continue1" -if [test_compiler_info gcc-3-*] { +if {[test_compiler_info gcc-3-*]} { setup_xfail hppa*-* gcc/15860 } gdb_test "continue" \ diff --git a/gdb/testsuite/gdb.base/structs3.c b/gdb/testsuite/gdb.base/structs3.c index 7b6808f..2fd26d0 100644 --- a/gdb/testsuite/gdb.base/structs3.c +++ b/gdb/testsuite/gdb.base/structs3.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/structs3.exp b/gdb/testsuite/gdb.base/structs3.exp index 15ba8f3..22cda9d 100644 --- a/gdb/testsuite/gdb.base/structs3.exp +++ b/gdb/testsuite/gdb.base/structs3.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" "structs3" "" {debug}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/style-interp-exec-mi.c b/gdb/testsuite/gdb.base/style-interp-exec-mi.c index fb4ffc2..f2b8dba 100644 --- a/gdb/testsuite/gdb.base/style-interp-exec-mi.c +++ b/gdb/testsuite/gdb.base/style-interp-exec-mi.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/style-interp-exec-mi.exp b/gdb/testsuite/gdb.base/style-interp-exec-mi.exp index 6c704ba..3c738c3 100644 --- a/gdb/testsuite/gdb.base/style-interp-exec-mi.exp +++ b/gdb/testsuite/gdb.base/style-interp-exec-mi.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/style-logging.exp b/gdb/testsuite/gdb.base/style-logging.exp index d866d36..10b4636 100644 --- a/gdb/testsuite/gdb.base/style-logging.exp +++ b/gdb/testsuite/gdb.base/style-logging.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/style.c b/gdb/testsuite/gdb.base/style.c index e72c2ee..fb705eb 100644 --- a/gdb/testsuite/gdb.base/style.c +++ b/gdb/testsuite/gdb.base/style.c @@ -2,7 +2,7 @@ /* The leading newlines here are intentional, do not remove. They are used to test that the source highlighter doesn't strip them. */ -/* Copyright 2018-2024 Free Software Foundation, Inc. +/* Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index f63dedc..eff13fa 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -13,6 +13,8 @@ # 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 {!is_remote host} + load_lib gdb-python.exp # Test CLI output styling. @@ -48,7 +50,7 @@ proc clean_restart_and_disable { prefix args } { global currently_disabled_style with_test_prefix "$prefix" { - eval "clean_restart $args" + clean_restart {*}$args if { $currently_disabled_style != "" } { set st $currently_disabled_style @@ -75,7 +77,7 @@ proc run_style_tests { } { # Restart GDB with the correct TERM variable setting, this # means that GDB will enable styling. - clean_restart_and_disable "restart 1" ${binfile} + clean_restart_and_disable "restart 1" $::testfile set readnow [readnow] @@ -161,7 +163,7 @@ proc run_style_tests { } { # - 4 leading spaces # - argv string # - closing parenthesis - set line_len [expr 4 + $argv_len + 1] + set line_len [expr {4 + $argv_len + 1}] if { $argv == "argv=0x0" && $width >= 27 } { # Embedded target with no argv support. @@ -323,12 +325,24 @@ proc run_style_tests { } { gdb_test_no_output "set style version background 255" gdb_test_no_output "set style version foreground #FED210" gdb_test "show style version background" \ - "The \033\\\[38;2;254;210;16;48;5;255;22;27m.*\".*version.*\".*style.*\033\\\[m background color is: 255" \ + "The \033\\\[38;2;254;210;16;48;5;255;22;23;24;27m.*\".*version.*\".*style.*\033\\\[m background color is: 255" \ "Version's 256-color background style" gdb_test "show style version foreground" \ - "The \033\\\[38;2;254;210;16;48;5;255;22;27m.*\".*version.*\".*style.*\033\\\[m foreground color is: #FED210" \ + "The \033\\\[38;2;254;210;16;48;5;255;22;23;24;27m.*\".*version.*\".*style.*\033\\\[m foreground color is: #FED210" \ "Version's TrueColor foreground style" } + + gdb_test_no_output "set host-charset UTF-8" + # Chosen since it will print an error. + gdb_test "maint translate-address" \ + "❌️ requires argument.*" \ + "emoji output" + + gdb_test_no_output "set style error-prefix abcd:" \ + "set the error prefix" + gdb_test "maint translate-address" \ + "abcd:requires argument.*" \ + "error prefix" } } @@ -344,7 +358,7 @@ proc test_disable_disassembler_styling { } { # Restart GDB with the correct TERM variable setting, this # means that GDB will enable styling. - clean_restart_and_disable "restart 3" $::binfile + clean_restart_and_disable "restart 3" $::testfile set styled_hex [limited_style $::hex address] set main [limited_style main function] @@ -459,7 +473,7 @@ proc test_disassembler_error_handling { } { # Restart GDB with the correct TERM variable setting, this # means that GDB will enable styling. - clean_restart_and_disable "restart 4" $::binfile + clean_restart_and_disable "restart 4" $::testfile # Disable use of libopcodes for styling. As this function is # only called when Python Pygments module is available, we @@ -739,10 +753,290 @@ proc test_enable_styling_warning { } { } } +# Run an 'apropos' command. Each line of output starts with a +# non-default style (command style). Ensure that pagination triggers +# during the 'apropos' output such that, at the point pagination kicks +# in, a non-default style is in effect. +# +# Then, at the pagination prompt, quit the command. +# +# Next, run a command which switches to a different style, and then +# back to the current style. +# +# At one point, a bug in the pagination code would leave the +# non-default style from the 'apropos' command recorded as the current +# style, such that the second command would switch back to the earlier +# style. +proc test_pagination_cmd_after_quit_styling {} { + with_ansi_styling_terminal { + clean_restart + } + + # We're going to use 'apropos time'. Check that with a height of + # 12 lines, each line starts with a non-default style, and that we + # do see the pagination prompt. This means that there are more + # than 12 lines for this command. + with_test_prefix "validate apropos output" { + gdb_test_no_output "set height 12" + + set saw_pagination_prompt false + gdb_test_multiple "apropos time" "" { + -re "^apropos time\r\n" { + exp_continue + } + -re "^\033\\\[39;49;1;23;24;27m\[^\r\n\]+\r\n" { + exp_continue + } + -re "^$::pagination_prompt$" { + set saw_pagination_prompt true + send_gdb "q\n" + exp_continue + } + -re "^q\r\n" { + exp_continue + } + -re "^Quit\r\n" { + exp_continue + } + -re "^$::gdb_prompt $" { + gdb_assert { $saw_pagination_prompt } $gdb_test_name + } + -re "^\[^\r\n\]+\r\n" { + exp_continue + } + } + } + + # Now reduce the height to 10 and re-run 'apropos time'. Based on + # the previous check, we know that this is going to present the + # pagination prompt when a non-default style is in use. + gdb_test_no_output "set height 10" + + set saw_pagination_prompt false + gdb_test_multiple "apropos time" "" { + -re "$::pagination_prompt" { + set saw_pagination_prompt true + send_gdb "q\n" + exp_continue + } + -re "\r\n$::gdb_prompt $" { + gdb_assert { $saw_pagination_prompt } $gdb_test_name + } + } + + # The help output for this maintenance command switches to a + # different style, and then back to the default. If the + # pagination bug still exists, then this would switch back to the + # non-default style that was in use when pagination kicked in + # above. + gdb_test "maintenance time" \ + "^\"\033\\\[39;49;1;23;24;27mmaintenance time\033\\\[m\" takes a numeric argument\\." +} + +# Helper for test_pagination_prompt_styling. Return false if STR, a +# line that appears immediately before a pagination prompt, matches +# the pattern for needing a style reset at the end, but does not have +# the style reset. +# +# In all other cases, return true. So lines that don't match the +# known pattern for neededing a style reset will always return true, +# as will lines that match the pattern, and do have the style reset. +proc previous_line_is_ok { str } { + + # Create a copy of STR with all the '\033' characters removed. + # Then compare string lengths to get a count of the '\033' + # charactes present in STR. + regsub -all "\033" $str {} stripped + set count [expr {[string length $str] - [string length $stripped]}] + + # If STR switched styles, then it _must_ switch back again, + # otherwise the pagination prompt will be in the wrong style. + # This means that there _must_ be an even number of '\033' + # characters in STR. If there is not then we switched style, but + # failed to switch back. + if {$count % 2 != 0} { + return false + } + + # For lines that don't match this pattern, we cannot comment on + # where the style reset should occur, so lets just claim the line + # is fine. + if { ![regexp "\\s+$::hex - $::hex is \[^\r\n\]+ in \033" $str] } { + return true + } + + # This line did match the above pattern, so we know that a style + # reset _must_ occur at the end of the line. If it doesn't then + # this line is not OK. + if { ![regexp "\033\\\[m$" $str] } { + return false + } + + # All tests passed, this line looks OK. + return true +} + +# Test that the pagination prompt is displayed unstyled. This is done +# by looking at the 'info files' output and selecting a width that +# will mean we should get a pagination prompt part way through a +# styled filename. +# +# Then, re-run 'info files' and check that for every pagination +# prompt, the previous line disables styling as expected. +proc test_pagination_prompt_styling {} { + with_ansi_styling_terminal { + clean_restart $::testfile + } + + if {![runto_main]} { + return + } + + # Set height so we actually get a pagination prompt. + gdb_test_no_output "set height 3" + + # Scan the 'info files' output and set DESIRED_WIDTH such that it + # will trigger pagination part-way through a styled filename. + set desired_width 0 + gdb_test_multiple "info files" "find good test width" { + -re "^info files\r\n" { + exp_continue + } + + -re "^$::pagination_prompt$" { + send_gdb "\n" + exp_continue + } + + -re "^$::gdb_prompt $" { + } + + -re "^((\\s+$::hex - $::hex is \[^\r\n\]+ in )\[^\r\n\]+)\r\n" { + if { $desired_width == 0 } { + set full_line $expect_out(1,string) + set inner_line $expect_out(2,string) + set desired_width [expr [string length $inner_line] + ([string length $full_line] - [string length $inner_line]) / 2] + } + exp_continue + } + + -re "^\[^\r\n\]*\r\n" { + exp_continue + } + } + + if { $desired_width < [string length $::pagination_prompt_str] + 2 } { + # Avoid readline wrapping after printing the pagination prompt. + return + } + + # Now setup the screen width. + gdb_test_no_output "set width $desired_width" \ + "set width to desired width" + + # Re-run 'info files'. Check that the content before any + # pagination prompt correctly disables styling. + set saw_bad_line false + set prev_line "" + gdb_test_multiple "info files" "check pagination prompt styling" { + -re "^info files\r\n" { + exp_continue + } + + -re "^$::pagination_prompt$" { + if { ![previous_line_is_ok $prev_line] } { + set saw_bad_line true + } + send_gdb "\n" + exp_continue + } + + -re "^(\[^\r\n\]+)$::pagination_prompt$" { + set prev_line $expect_out(1,string) + if { ![previous_line_is_ok $prev_line] } { + set saw_bad_line true + } + send_gdb "\n" + exp_continue + } + + -re "^$::gdb_prompt $" { + gdb_assert { !$saw_bad_line } $gdb_test_name + } + + -re "^(\[^\r\n\]*)\r\n" { + set prev_line $expect_out(1,string) + exp_continue + } + } +} + +# Test that GDB can correctly restore the current style after a +# pagination prompt. +# +# Set the logging file to a garbage string based on LENGTH (is +# actually 2x LENGTH), then 'show logging file'. Press return at the +# pagination prompt, and check that the reset of the filename is +# styled correctly, and that GDB correctly switches back to the +# default style once the logging file has finished. +proc test_pagination_continue_styling_1 { length } { + with_ansi_styling_terminal { + clean_restart $::testfile + } + + set filename [string repeat "ax" $length] + + gdb_test_no_output "set logging file $filename" + + gdb_test_no_output "set height 3" + gdb_test_no_output "set width 80" + + set saw_bad_styling false + gdb_test_multiple "show logging file" "" { + -re "^show logging file\r\n" { + exp_continue + } + + -re "^The current logfile is \"\033\\\[32;49;22;23;24;27m(?:ax)+\033\\\[m" { + exp_continue + } + + -re "^\r\n\033\\\[32;49;22;23;24;27m(?:ax)+\033\\\[m(?=--)" { + exp_continue + } + + -re "^\r\n\033\\\[32;49;22;23;24;27m(?:ax)+(?=--)" { + set saw_bad_styling true + exp_continue + } + + -re "^\r\n\033\\\[32;49;22;23;24;27m(?:ax)+\033\\\[m\"\\.\r\n" { + exp_continue + } + + -re "^$::gdb_prompt $" { + gdb_assert { !$saw_bad_styling } $gdb_test_name + } + + -re "^$::pagination_prompt$$" { + send_gdb "\n" + exp_continue + } + } +} + +# Wrapper around test_pagination_continue_styling_1, calls that +# function with different lengths. +proc test_pagination_continue_styling { } { + foreach_with_prefix length { 80 160 } { + test_pagination_continue_styling_1 $length + } +} + # Check to see if the Python styling of disassembler output is # expected or not, this styling requires Python support in GDB, and # the Python pygments module to be available. -clean_restart ${binfile} +clean_restart $testfile if {[allow_python_tests] && [gdb_py_module_available "pygments"]} { set python_disassembly_styling true } else { @@ -781,3 +1075,6 @@ test_colorsupport_truecolor test_colorsupport_truecolor_only test_enable_styling_warning +test_pagination_cmd_after_quit_styling +test_pagination_prompt_styling +test_pagination_continue_styling diff --git a/gdb/testsuite/gdb.base/subst.exp b/gdb/testsuite/gdb.base/subst.exp index b1e352d..556eef1 100644 --- a/gdb/testsuite/gdb.base/subst.exp +++ b/gdb/testsuite/gdb.base/subst.exp @@ -1,4 +1,4 @@ -# Copyright 2006-2024 Free Software Foundation, Inc. +# Copyright 2006-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 @@ -19,126 +19,124 @@ clean_restart # commands that do not require the presence of an executable. gdb_test_no_output "set confirm off" \ - "deactivate GDB's confirmation interface" + "deactivate GDB's confirmation interface" # Clear any substitution rules that are available by default due # to GDB being configured with --with-relocated-sources. gdb_test_no_output "unset substitute-path" \ - "remove default substitution rules" + "remove default substitution rules" gdb_test "show substitute-path" \ - "List of all source path substitution rules:" \ - "show substitute-path, no rule entered yet" + "List of all source path substitution rules:" \ + "show substitute-path, no rule entered yet" gdb_test "show substitute-path from" \ - "Source path substitution rule matching `from':" \ - "show substitute-path from, no rule entered yet" + "Source path substitution rule matching `from':" \ + "show substitute-path from, no rule entered yet" gdb_test "show substitute-path too many" \ - "Too many arguments in command" \ - "show substitute-path, too many arguments" + "Too many arguments in command" \ + "show substitute-path, too many arguments" gdb_test "unset substitute-path from" \ - "No substitution rule defined for `from'" \ - "unset substitute-path from, no rule entered yet" + "No substitution rule defined for `from'" \ + "unset substitute-path from, no rule entered yet" gdb_test_no_output "unset substitute-path" \ - "unset substitute-path, no rule entered yet" + "unset substitute-path, no rule entered yet" gdb_test "unset substitute-path from" \ - "No substitution rule defined for `from'" \ - "unset substitute-path from, after unset substitute-path" + "No substitution rule defined for `from'" \ + "unset substitute-path from, after unset substitute-path" gdb_test "unset substitute-path from to" \ - "Incorrect usage, too many arguments in command" \ - "unset substitute-path, too many arguments" + "Incorrect usage, too many arguments in command" \ + "unset substitute-path, too many arguments" gdb_test "set substitute-path too many arguments" \ - "Incorrect usage, too many arguments in command" \ - "set substitute-path, too many arguments" + "Incorrect usage, too many arguments in command" \ + "set substitute-path, too many arguments" gdb_test "set substitute-path missing" \ - "Incorrect usage, too few arguments in command" \ - "set substitute-path, too few arguments" + "Incorrect usage, too few arguments in command" \ + "set substitute-path, too few arguments" gdb_test "set substitute-path '' to" \ - "First argument must be at least one character long" \ - "set substitute-path, first argument is empty string" + "First argument must be at least one character long" \ + "set substitute-path, first argument is empty string" gdb_test_no_output "set substitute-path from to" \ - "add from -> to substitution rule" + "add from -> to substitution rule" gdb_test_no_output "set substitute-path from1 to1/" \ - "add from1 -> to1 substitution rule" + "add from1 -> to1 substitution rule" gdb_test_no_output "set substitute-path source destination" \ - "add source -> destination substitution rule" + "add source -> destination substitution rule" gdb_test_no_output "set substitute-path depuis/ vers" \ - "add depuis -> vers substitution rule" + "add depuis -> vers substitution rule" gdb_test_no_output "set substitute-path empty ''" \ - "add substitution rule to empty string" + "add substitution rule to empty string" gdb_test "show substitute-path" \ - "List of all source path substitution rules:\r\n +`from' -> `to'.\r\n +`from1' -> `to1'.\r\n +`source' -> `destination'.\r\n\ +`depuis' -> `vers'.\r\n +`empty' -> `'." \ - "show substitute-path after all paths added" + "List of all source path substitution rules:\r\n +`from' -> `to'.\r\n +`from1' -> `to1'.\r\n +`source' -> `destination'.\r\n\ +`depuis' -> `vers'.\r\n +`empty' -> `'." \ + "show substitute-path after all paths added" gdb_test "show substitute-path from" \ - "Source path substitution rule matching `from':\r\n +`from' -> `to'." \ - "show substitute-path from, after all paths added" + "Source path substitution rule matching `from':\r\n +`from' -> `to'." \ + "show substitute-path from, after all paths added" gdb_test "show substitute-path depuis" \ - "Source path substitution rule matching `depuis':\r\n +`depuis' -> `vers'." \ - "show substitute-path depuis, after all paths added" + "Source path substitution rule matching `depuis':\r\n +`depuis' -> `vers'." \ + "show substitute-path depuis, after all paths added" gdb_test "show substitute-path from/path" \ - "Source path substitution rule matching `from/path':\r\n +`from' -> `to'." \ - "show substitute-path from/path, after all paths added" + "Source path substitution rule matching `from/path':\r\n +`from' -> `to'." \ + "show substitute-path from/path, after all paths added" gdb_test "show substitute-path from_a_bad_path" \ - "Source path substitution rule matching `from_a_bad_path':" \ - "show substitute-path from_a_bad_path, after all paths added" + "Source path substitution rule matching `from_a_bad_path':" \ + "show substitute-path from_a_bad_path, after all paths added" gdb_test "show substitute-path garbage" \ - "Source path substitution rule matching `garbage':" \ - "show substitute-path garbage, after all paths added" + "Source path substitution rule matching `garbage':" \ + "show substitute-path garbage, after all paths added" gdb_test_no_output "unset substitute-path from" \ - "unset substitute-path from" + "unset substitute-path from" gdb_test "show substitute-path from" \ - "Source path substitution rule matching `from':" \ - "show substitute-path from, after unsetting it" + "Source path substitution rule matching `from':" \ + "show substitute-path from, after unsetting it" gdb_test "show substitute-path" \ - "List of all source path substitution rules:\r\n +`from1' -> `to1'.\r\n +`source' -> `destination'.\r\n\ +`depuis' -> `vers'.\r\n +`empty' -> `'." \ - "show substitute-path after from rule removed" + "List of all source path substitution rules:\r\n +`from1' -> `to1'.\r\n +`source' -> `destination'.\r\n\ +`depuis' -> `vers'.\r\n +`empty' -> `'." \ + "show substitute-path after from rule removed" gdb_test "unset substitute-path from" \ - "No substitution rule defined for `from'" \ - "unset substitute-path from after the rule was removed" + "No substitution rule defined for `from'" \ + "unset substitute-path from after the rule was removed" gdb_test_no_output "unset substitute-path depuis" \ - "unset substitute-path depuis (middle of list)" + "unset substitute-path depuis (middle of list)" gdb_test "show substitute-path" \ - "List of all source path substitution rules:\r\n +`from1' -> `to1'.\r\n +`source' -> `destination'.\r\n\ +`empty' -> `'." \ - "show substitute-path after depuis rule removed" + "List of all source path substitution rules:\r\n +`from1' -> `to1'.\r\n +`source' -> `destination'.\r\n\ +`empty' -> `'." \ + "show substitute-path after depuis rule removed" gdb_test_no_output "unset substitute-path empty" \ - "unset substitute-path empty (end of list)" + "unset substitute-path empty (end of list)" gdb_test "show substitute-path" \ - "List of all source path substitution rules:\r\n +`from1' -> `to1'.\r\n +`source' -> `destination'." \ - "show substitute-path after empty rule removed" + "List of all source path substitution rules:\r\n +`from1' -> `to1'.\r\n +`source' -> `destination'." \ + "show substitute-path after empty rule removed" gdb_test_no_output "unset substitute-path" \ - "remove all remaining substitution rules" + "remove all remaining substitution rules" gdb_test "show substitute-path" \ - "List of all source path substitution rules:" \ - "show substitute-path after all remaining rules removed" - - + "List of all source path substitution rules:" \ + "show substitute-path after all remaining rules removed" diff --git a/gdb/testsuite/gdb.base/sum.c b/gdb/testsuite/gdb.base/sum.c index 3e27fa1..d3e745b 100644 --- a/gdb/testsuite/gdb.base/sum.c +++ b/gdb/testsuite/gdb.base/sum.c @@ -3,8 +3,8 @@ int sum(int *list, int low, int high) { - int i = 0, s = 0; /* stop-in-sum */ - for (i = low; i <= high; i++) - s += list[i]; - return(s); + int i = 0, s = 0; /* stop-in-sum */ + for (i = low; i <= high; i++) + s += list[i]; + return(s); } diff --git a/gdb/testsuite/gdb.base/sym-file-lib.c b/gdb/testsuite/gdb.base/sym-file-lib.c index 9a4af81..c9ae329 100644 --- a/gdb/testsuite/gdb.base/sym-file-lib.c +++ b/gdb/testsuite/gdb.base/sym-file-lib.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2024 Free Software Foundation, Inc. +/* Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/sym-file-loader.c b/gdb/testsuite/gdb.base/sym-file-loader.c index 1c70536..f782a37 100644 --- a/gdb/testsuite/gdb.base/sym-file-loader.c +++ b/gdb/testsuite/gdb.base/sym-file-loader.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2024 Free Software Foundation, Inc. +/* Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/sym-file-loader.h b/gdb/testsuite/gdb.base/sym-file-loader.h index 69c7402..a626899 100644 --- a/gdb/testsuite/gdb.base/sym-file-loader.h +++ b/gdb/testsuite/gdb.base/sym-file-loader.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2024 Free Software Foundation, Inc. +/* Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/sym-file-main.c b/gdb/testsuite/gdb.base/sym-file-main.c index 31b2da1..e941af8 100644 --- a/gdb/testsuite/gdb.base/sym-file-main.c +++ b/gdb/testsuite/gdb.base/sym-file-main.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2024 Free Software Foundation, Inc. +/* Copyright 2013-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 diff --git a/gdb/testsuite/gdb.base/sym-file.exp b/gdb/testsuite/gdb.base/sym-file.exp index 17650cb..0d521c1 100644 --- a/gdb/testsuite/gdb.base/sym-file.exp +++ b/gdb/testsuite/gdb.base/sym-file.exp @@ -1,4 +1,4 @@ -# Copyright 2013-2024 Free Software Foundation, Inc. +# Copyright 2013-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 @@ -61,7 +61,8 @@ if {[gdb_compile_shlib $libsrc $lib_so {debug}] != ""} { return } -if {[prepare_for_testing "failed to prepare" $binfile "$srcfile $srcfile2" $exec_opts]} { +if { [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" \ + $exec_opts] } { return } @@ -70,7 +71,7 @@ gdb_load_shlib ${lib_so} proc do_test { remove_expr } { global lib_basename lib_syms srcfile srcfile3 - clean_restart $::binfile + clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/symbol-alias.c b/gdb/testsuite/gdb.base/symbol-alias.c index 790ba39..8db973f 100644 --- a/gdb/testsuite/gdb.base/symbol-alias.c +++ b/gdb/testsuite/gdb.base/symbol-alias.c @@ -1,6 +1,6 @@ /* This test is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/symbol-alias.exp b/gdb/testsuite/gdb.base/symbol-alias.exp index 30599c7..84ba82d 100644 --- a/gdb/testsuite/gdb.base/symbol-alias.exp +++ b/gdb/testsuite/gdb.base/symbol-alias.exp @@ -1,5 +1,5 @@ # Test for printing alias symbols. -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -16,8 +16,8 @@ standard_testfile symbol-alias.c symbol-alias2.c # Clang versions prior to v15 do not emit debug info for aliases. -set old_clang [expr [test_compiler_info {clang-1[0-4]-*-*}] \ - || [test_compiler_info {clang-[1-9]-*}]] +set old_clang [expr {[test_compiler_info {clang-1[0-4]-*-*}] \ + || [test_compiler_info {clang-[1-9]-*}]}] if { [prepare_for_testing "failed to prepare" ${testfile} [list $srcfile $srcfile2]] } { return -1 diff --git a/gdb/testsuite/gdb.base/symbol-alias2.c b/gdb/testsuite/gdb.base/symbol-alias2.c index 09e2660..0da57dd 100644 --- a/gdb/testsuite/gdb.base/symbol-alias2.c +++ b/gdb/testsuite/gdb.base/symbol-alias2.c @@ -1,6 +1,6 @@ /* This test is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/symbol-without-target_section.c b/gdb/testsuite/gdb.base/symbol-without-target_section.c index e99cc78..64e7e3e 100644 --- a/gdb/testsuite/gdb.base/symbol-without-target_section.c +++ b/gdb/testsuite/gdb.base/symbol-without-target_section.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/symbol-without-target_section.exp b/gdb/testsuite/gdb.base/symbol-without-target_section.exp index 56cbd18..cf4d262 100644 --- a/gdb/testsuite/gdb.base/symbol-without-target_section.exp +++ b/gdb/testsuite/gdb.base/symbol-without-target_section.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/symfile-warn.c b/gdb/testsuite/gdb.base/symfile-warn.c index aa148a9..ddcee2b 100644 --- a/gdb/testsuite/gdb.base/symfile-warn.c +++ b/gdb/testsuite/gdb.base/symfile-warn.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/symfile-warn.exp b/gdb/testsuite/gdb.base/symfile-warn.exp index b34de70..485c449 100644 --- a/gdb/testsuite/gdb.base/symfile-warn.exp +++ b/gdb/testsuite/gdb.base/symfile-warn.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/symlink-sourcefile.c b/gdb/testsuite/gdb.base/symlink-sourcefile.c index 55df002..0f46d42 100644 --- a/gdb/testsuite/gdb.base/symlink-sourcefile.c +++ b/gdb/testsuite/gdb.base/symlink-sourcefile.c @@ -1,4 +1,4 @@ -/* Copyright 2019-2024 Free Software Foundation, Inc. +/* Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/symlink-sourcefile.exp b/gdb/testsuite/gdb.base/symlink-sourcefile.exp index 1a02eec..cf1e9a8 100644 --- a/gdb/testsuite/gdb.base/symlink-sourcefile.exp +++ b/gdb/testsuite/gdb.base/symlink-sourcefile.exp @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/symtab-search-order-1.c b/gdb/testsuite/gdb.base/symtab-search-order-1.c index fa0c4cf..2fc201f 100644 --- a/gdb/testsuite/gdb.base/symtab-search-order-1.c +++ b/gdb/testsuite/gdb.base/symtab-search-order-1.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/symtab-search-order-shlib-1.c b/gdb/testsuite/gdb.base/symtab-search-order-shlib-1.c index 5f6ece5..955004a 100644 --- a/gdb/testsuite/gdb.base/symtab-search-order-shlib-1.c +++ b/gdb/testsuite/gdb.base/symtab-search-order-shlib-1.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/symtab-search-order.c b/gdb/testsuite/gdb.base/symtab-search-order.c index 64f742b..96cb94a 100644 --- a/gdb/testsuite/gdb.base/symtab-search-order.c +++ b/gdb/testsuite/gdb.base/symtab-search-order.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/symtab-search-order.exp b/gdb/testsuite/gdb.base/symtab-search-order.exp index d34b0af..70db420 100644 --- a/gdb/testsuite/gdb.base/symtab-search-order.exp +++ b/gdb/testsuite/gdb.base/symtab-search-order.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -21,22 +21,21 @@ set srcfile2 $srcdir/$subdir/$srcfile2 set lib1src $srcdir/$subdir/$srcfile3 set lib1 [standard_output_file symtab-search-order-1.sl] -set lib_opts "debug" +set lib_opts {debug shlib} set exec_opts [list debug shlib=$lib1] -if { [gdb_compile_shlib $lib1src $lib1 $lib_opts] != "" - || [gdb_compile [list $srcfile $srcfile2] $binfile executable \ - $exec_opts] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build shlib" $lib1 $lib1src $lib_opts] != 0 } { + return } -# Start with a fresh gdb. +if { [prepare_for_testing "prepare" $testfile [list $srcfile $srcfile2] \ + $exec_opts] != 0 } { + return +} -clean_restart $binfile gdb_load_shlib $lib1 -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/sysroot-debug-lookup.exp b/gdb/testsuite/gdb.base/sysroot-debug-lookup.exp index 80cad95..74c1708 100644 --- a/gdb/testsuite/gdb.base/sysroot-debug-lookup.exp +++ b/gdb/testsuite/gdb.base/sysroot-debug-lookup.exp @@ -1,4 +1,4 @@ -# Copyright 2024 Free Software Foundation, Inc. +# Copyright 2024-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 diff --git a/gdb/testsuite/gdb.base/template.c b/gdb/testsuite/gdb.base/template.c index 002dcb8..371e20b 100644 --- a/gdb/testsuite/gdb.base/template.c +++ b/gdb/testsuite/gdb.base/template.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/template.exp b/gdb/testsuite/gdb.base/template.exp index 8a68a2f..09c3e3d 100644 --- a/gdb/testsuite/gdb.base/template.exp +++ b/gdb/testsuite/gdb.base/template.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/term.c b/gdb/testsuite/gdb.base/term.c index fd667d8..6f45b2d 100644 --- a/gdb/testsuite/gdb.base/term.c +++ b/gdb/testsuite/gdb.base/term.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/term.exp b/gdb/testsuite/gdb.base/term.exp index d113cee..545d4bc 100644 --- a/gdb/testsuite/gdb.base/term.exp +++ b/gdb/testsuite/gdb.base/term.exp @@ -1,4 +1,4 @@ -# Copyright 1988-2024 Free Software Foundation, Inc. +# Copyright 1988-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 @@ -49,18 +49,18 @@ proc compare_gdb_and_inferior_settings { t } { gdb_test "info terminal" \ [multi_line "Inferior's terminal status .currently saved by GDB.:" \ - "File descriptor flags = .*" \ - "Process group = $decimal" \ - "c_iflag = ${termios(c_iflag)}, c_oflag = ${termios(c_oflag)}," \ - "c_cflag = ${termios(c_cflag)}, c_lflag = ${termios(c_lflag)}.*" ] + "File descriptor flags = .*" \ + "Process group = $decimal" \ + "c_iflag = ${termios(c_iflag)}, c_oflag = ${termios(c_oflag)}," \ + "c_cflag = ${termios(c_cflag)}, c_lflag = ${termios(c_lflag)}.*" ] } if {[target_info gdb_protocol] == ""} { # Record the initial terminal settings. Verify that GDB's version of the # inferior's terminal settings is right. with_test_prefix "initial" { - array set termios1 [read_term_settings_from_inferior] - compare_gdb_and_inferior_settings [array get termios1] + array set termios1 [read_term_settings_from_inferior] + compare_gdb_and_inferior_settings [array get termios1] } # Continue until after the inferior removes ECHO from its terminal settings. @@ -69,12 +69,12 @@ if {[target_info gdb_protocol] == ""} { # After the inferior has changed its terminal settings, check that GDB's # saved version reflects the new settings correctly. with_test_prefix "post tcsetattr" { - array set termios2 [read_term_settings_from_inferior] - compare_gdb_and_inferior_settings [array get termios2] + array set termios2 [read_term_settings_from_inferior] + compare_gdb_and_inferior_settings [array get termios2] - # Make sure that the current settings are different than the initial - # settings... otherwise this test is meaningless. - gdb_assert {${termios1(c_lflag)} != ${termios2(c_lflag)}} + # Make sure that the current settings are different than the initial + # settings... otherwise this test is meaningless. + gdb_assert {${termios1(c_lflag)} != ${termios2(c_lflag)}} } # Continue again... @@ -83,12 +83,12 @@ if {[target_info gdb_protocol] == ""} { # ... and verify again, to validate that when resuming, GDB restored the # inferior's terminal settings correctly. with_test_prefix "after last resume" { - array set termios3 [read_term_settings_from_inferior] - compare_gdb_and_inferior_settings [array get termios3] - gdb_assert {${termios2(c_iflag)} == ${termios3(c_iflag)}} - gdb_assert {${termios2(c_oflag)} == ${termios3(c_oflag)}} - gdb_assert {${termios2(c_cflag)} == ${termios3(c_cflag)}} - gdb_assert {${termios2(c_lflag)} == ${termios3(c_lflag)}} + array set termios3 [read_term_settings_from_inferior] + compare_gdb_and_inferior_settings [array get termios3] + gdb_assert {${termios2(c_iflag)} == ${termios3(c_iflag)}} + gdb_assert {${termios2(c_oflag)} == ${termios3(c_oflag)}} + gdb_assert {${termios2(c_cflag)} == ${termios3(c_cflag)}} + gdb_assert {${termios2(c_lflag)} == ${termios3(c_lflag)}} } } else { # While only native targets save terminal status, we still test diff --git a/gdb/testsuite/gdb.base/testenv.c b/gdb/testsuite/gdb.base/testenv.c index 5a98cba..8e57070 100644 --- a/gdb/testsuite/gdb.base/testenv.c +++ b/gdb/testsuite/gdb.base/testenv.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 @@ -41,4 +41,3 @@ int main (int argc, char **argv, char **envp) printf ("Program found %d variables starting with TEST_GDB\n", j); return 0; /* set breakpoint here. */ } - diff --git a/gdb/testsuite/gdb.base/testenv.exp b/gdb/testsuite/gdb.base/testenv.exp index 908918a..a8fb320 100644 --- a/gdb/testsuite/gdb.base/testenv.exp +++ b/gdb/testsuite/gdb.base/testenv.exp @@ -1,4 +1,4 @@ -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 @@ -27,7 +27,7 @@ standard_testfile .c # Compile binary # and start with a fresh gdb -if { [prepare_for_testing "failed to prepare" ${binfile} ${srcfile}] } { +if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { return -1 } @@ -75,7 +75,7 @@ proc find_env {varname} { } if {[string match "$varname=*" $var]} { - set from [expr [string first "=" $var] + 1] + set from [expr {[string first "=" $var] + 1}] set to [string length $var] return [string range $var $from $to] } @@ -88,13 +88,11 @@ proc find_env {varname} { # starting with TEST_GDB. proc_with_prefix test_set_unset_env {} { - global binfile - - clean_restart $binfile + clean_restart $::testfile # First test with no TEST_GDB_VAR. with_test_prefix "test1" { - if ![run_and_count_vars] { + if {![run_and_count_vars]} { return } test_num_test_vars 0 "no TEST_GDB vars" @@ -105,7 +103,7 @@ proc_with_prefix test_set_unset_env {} { gdb_test_no_output "set env TEST_GDB_VAR1 test1" \ "set TEST_GDB_VAR1" - if ![run_and_count_vars] { + if {![run_and_count_vars]} { return } test_num_test_vars 1 "one TEST_GDB var" @@ -116,7 +114,7 @@ proc_with_prefix test_set_unset_env {} { gdb_test_no_output "set env TEST_GDB_VAR2 test2" \ "set TEST_GDB_VAR2" - if ![run_and_count_vars] { + if {![run_and_count_vars]} { return } @@ -129,7 +127,7 @@ proc_with_prefix test_set_unset_env {} { gdb_test_no_output "unset env TEST_GDB_VAR1" \ "unset TEST_GDB_VAR1" - if ![run_and_count_vars] { + if {![run_and_count_vars]} { return } @@ -138,26 +136,25 @@ proc_with_prefix test_set_unset_env {} { } proc_with_prefix test_inherit_env_var {} { - global binfile global bp_line global env # This test assumes that the build's environ (where dejagnu runs) # is the same as the host's (where gdb runs) environ. - if [is_remote host] { + if {[is_remote host]} { return } save_vars {env(TEST_GDB_GLOBAL)} { set env(TEST_GDB_GLOBAL) "Global environment value" - clean_restart $binfile + clean_restart $::testfile gdb_breakpoint $bp_line # First test with only inherited TEST_GDB_GLOBAL. with_test_prefix "test1" { - if ![run_and_count_vars] { + if {![run_and_count_vars]} { return } @@ -177,7 +174,7 @@ proc_with_prefix test_inherit_env_var {} { gdb_test_no_output "unset env TEST_GDB_GLOBAL" \ "unset TEST_GDB_GLOBAL" - if ![run_and_count_vars] { + if {![run_and_count_vars]} { return } diff --git a/gdb/testsuite/gdb.base/thread-bp-multi-loc.c b/gdb/testsuite/gdb.base/thread-bp-multi-loc.c index 5950b0f..881ff85 100644 --- a/gdb/testsuite/gdb.base/thread-bp-multi-loc.c +++ b/gdb/testsuite/gdb.base/thread-bp-multi-loc.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/thread-bp-multi-loc.exp b/gdb/testsuite/gdb.base/thread-bp-multi-loc.exp index bdb51bf..1f0b2a7 100644 --- a/gdb/testsuite/gdb.base/thread-bp-multi-loc.exp +++ b/gdb/testsuite/gdb.base/thread-bp-multi-loc.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/timestamp.exp b/gdb/testsuite/gdb.base/timestamp.exp index 4bcdcad..80ea66e 100644 --- a/gdb/testsuite/gdb.base/timestamp.exp +++ b/gdb/testsuite/gdb.base/timestamp.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/tls-common.exp.tcl b/gdb/testsuite/gdb.base/tls-common.exp.tcl new file mode 100644 index 0000000..a17409f --- /dev/null +++ b/gdb/testsuite/gdb.base/tls-common.exp.tcl @@ -0,0 +1,50 @@ +# Copyright 2024-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. + +# Require statement, variables and procs used by tls-nothreads.exp, +# tls-multiobj.exp, and tls-dlobj.exp. + +# The tests listed above are known to work for the targets listed on +# the 'require' line, below. +# +# At the moment, only the Linux target is listed, but, ideally, these +# tests should be run on other targets too. E.g, testing on FreeBSD +# shows many failures which should be addressed in some fashion before +# enabling it for that target. + +require {is_any_target "*-*-linux*"} + +# These are the targets which have support for internal TLS lookup: + +set internal_tls_linux_targets {"x86_64-*-linux*" "aarch64-*-linux*" + "riscv*-*-linux*" "powerpc64*-*-linux*" + "s390x*-*-linux*"} + +# The "maint set force-internal-tls-address-lookup" command is only +# available for certain Linux architectures. Don't attempt to force +# use of internal TLS support for architectures which don't support +# it. + +if {[is_any_target {*}$internal_tls_linux_targets]} { + set internal_tls_iters { false true } +} else { + set internal_tls_iters { false } +} + +# Set up a kfail with message KFAIL_MSG when KFAIL_COND holds, then +# issue gdb_test with command CMD and regular expression RE. + +proc gdb_test_with_kfail {cmd re kfail_cond kfail_msg} { + if {[uplevel 1 [list expr $kfail_cond]]} { + setup_kfail $kfail_msg *-*-* + } + gdb_test $cmd $re +} diff --git a/gdb/testsuite/gdb.base/tls-dlobj-lib.c b/gdb/testsuite/gdb.base/tls-dlobj-lib.c new file mode 100644 index 0000000..e82a064 --- /dev/null +++ b/gdb/testsuite/gdb.base/tls-dlobj-lib.c @@ -0,0 +1,87 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2024-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/>. */ + +/* This program needs to be compiled with preprocessor symbol set to + a small integer, e.g. "gcc -DN=1 ..." With N defined, the CONCAT2 + and CONCAT3 macros will construct suitable names for the global + variables and functions. */ + +#define CONCAT2(a,b) CONCAT2_(a,b) +#define CONCAT2_(a,b) a ## b + +#define CONCAT3(a,b,c) CONCAT3_(a,b,c) +#define CONCAT3_(a,b,c) a ## b ## c + +/* For N=1, this ends up being... + __thread int tls_lib1_tbss_1; + __thread int tls_lib1_tbss_2; + __thread int tls_lib1_tdata_1 = 196; + __thread int tls_lib1_tdata_2 = 197; */ + +__thread int CONCAT3(tls_lib, N, _tbss_1); +__thread int CONCAT3(tls_lib, N, _tbss_2); +__thread int CONCAT3(tls_lib, N, _tdata_1) = CONCAT2(N, 96); +__thread int CONCAT3(tls_lib, N, _tdata_2) = CONCAT2(N, 97); + +/* Substituting for N, define function: + + int get_tls_libN_var (int which) . */ + +int +CONCAT3(get_tls_lib, N, _var) (int which) +{ + switch (which) + { + case 0: + return -1; + case 1: + return CONCAT3(tls_lib, N, _tbss_1); + case 2: + return CONCAT3(tls_lib, N, _tbss_2); + case 3: + return CONCAT3(tls_lib, N, _tdata_1); + case 4: + return CONCAT3(tls_lib, N, _tdata_2); + } + return -1; +} + +/* Substituting for N, define function: + + void set_tls_libN_var (int which, int val) . */ + +void +CONCAT3(set_tls_lib, N, _var) (int which, int val) +{ + switch (which) + { + case 0: + break; + case 1: + CONCAT3(tls_lib, N, _tbss_1) = val; + break; + case 2: + CONCAT3(tls_lib, N, _tbss_2) = val; + break; + case 3: + CONCAT3(tls_lib, N, _tdata_1) = val; + break; + case 4: + CONCAT3(tls_lib, N, _tdata_2) = val; + break; + } +} diff --git a/gdb/testsuite/gdb.base/tls-dlobj.c b/gdb/testsuite/gdb.base/tls-dlobj.c new file mode 100644 index 0000000..a93f4a7 --- /dev/null +++ b/gdb/testsuite/gdb.base/tls-dlobj.c @@ -0,0 +1,311 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2024-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/>. */ + +#include <dlfcn.h> +#include <assert.h> +#include <stdlib.h> +#include <stdio.h> + +typedef void (*setter_ftype) (int which, int val); + +__thread int tls_main_tbss_1; +__thread int tls_main_tbss_2; +__thread int tls_main_tdata_1 = 96; +__thread int tls_main_tdata_2 = 97; + +extern void set_tls_lib10_var (int which, int val); +extern void set_tls_lib11_var (int which, int val); + +volatile int data; + +static void +set_tls_main_var (int which, int val) +{ + switch (which) + { + case 1: + tls_main_tbss_1 = val; + break; + case 2: + tls_main_tbss_2 = val; + break; + case 3: + tls_main_tdata_1 = val; + break; + case 4: + tls_main_tdata_2 = val; + break; + } +} + +void +use_it (int a) +{ + data = a; +} + +static void * +load_dso (char *dso_name, int n, setter_ftype *setterp) +{ + char buf[80]; + void *sym; + void *handle = dlopen (dso_name, RTLD_NOW | RTLD_GLOBAL); + if (handle == NULL) + { + fprintf (stderr, "dlopen of DSO '%s' failed: %s\n", dso_name, dlerror ()); + exit (1); + } + sprintf (buf, "set_tls_lib%d_var", n); + sym = dlsym (handle, buf); + assert (sym != NULL); + *setterp = sym; + + /* Some libc implementations (for some architectures) refuse to + initialize TLS data structures (specifically, the DTV) without + first calling dlsym on one of the TLS symbols. */ + sprintf (buf, "tls_lib%d_tdata_1", n); + assert (dlsym (handle, buf) != NULL); + + return handle; +} + +int +main (int argc, char **argv) +{ + int i, status; + setter_ftype s0, s1, s2, s3, s4, s10, s11; + void *h1 = load_dso (OBJ1, 1, &s1); + void *h2 = load_dso (OBJ2, 2, &s2); + void *h3 = load_dso (OBJ3, 3, &s3); + void *h4 = load_dso (OBJ4, 4, &s4); + s0 = set_tls_main_var; + s10 = set_tls_lib10_var; + s11 = set_tls_lib11_var; + + use_it (0); /* main-breakpoint-1 */ + + /* Set TLS variables in main program and all libraries. */ + for (i = 1; i <= 4; i++) + s0 (i, 10 + i); + for (i = 1; i <= 4; i++) + s1 (i, 110 + i); + for (i = 1; i <= 4; i++) + s2 (i, 210 + i); + for (i = 1; i <= 4; i++) + s3 (i, 310 + i); + for (i = 1; i <= 4; i++) + s4 (i, 410 + i); + for (i = 1; i <= 4; i++) + s10 (i, 1010 + i); + for (i = 1; i <= 4; i++) + s11 (i, 1110 + i); + + use_it (0); /* main-breakpoint-2 */ + + /* Unload lib2 and lib3. */ + status = dlclose (h2); + assert (status == 0); + status = dlclose (h3); + assert (status == 0); + + /* Set TLS variables in main program and in libraries which are still + loaded. */ + for (i = 1; i <= 4; i++) + s0 (i, 20 + i); + for (i = 1; i <= 4; i++) + s1 (i, 120 + i); + for (i = 1; i <= 4; i++) + s4 (i, 420 + i); + for (i = 1; i <= 4; i++) + s10 (i, 1020 + i); + for (i = 1; i <= 4; i++) + s11 (i, 1120 + i); + + use_it (0); /* main-breakpoint-3 */ + + /* Load lib3. */ + h3 = load_dso (OBJ3, 3, &s3); + + /* Set TLS vars again; currently, only lib2 is not loaded. */ + for (i = 1; i <= 4; i++) + s0 (i, 30 + i); + for (i = 1; i <= 4; i++) + s1 (i, 130 + i); + for (i = 1; i <= 4; i++) + s3 (i, 330 + i); + for (i = 1; i <= 4; i++) + s4 (i, 430 + i); + for (i = 1; i <= 4; i++) + s10 (i, 1030 + i); + for (i = 1; i <= 4; i++) + s11 (i, 1130 + i); + + use_it (0); /* main-breakpoint-4 */ + + /* Unload lib1 and lib4; load lib2. */ + status = dlclose (h1); + assert (status == 0); + status = dlclose (h4); + assert (status == 0); + h2 = load_dso (OBJ2, 2, &s2); + + /* Set TLS vars; currently, lib2 and lib3 are loaded, + lib1 and lib4 are not. */ + for (i = 1; i <= 4; i++) + s0 (i, 40 + i); + for (i = 1; i <= 4; i++) + s2 (i, 240 + i); + for (i = 1; i <= 4; i++) + s3 (i, 340 + i); + for (i = 1; i <= 4; i++) + s10 (i, 1040 + i); + for (i = 1; i <= 4; i++) + s11 (i, 1140 + i); + + use_it (0); /* main-breakpoint-5 */ + + /* Load lib4 and lib1. Unload lib2. */ + h4 = load_dso (OBJ4, 4, &s4); + h1 = load_dso (OBJ1, 1, &s1); + status = dlclose (h2); + assert (status == 0); + + /* Set TLS vars; currently, lib1, lib3, and lib4 are loaded; + lib2 is not loaded. */ + for (i = 1; i <= 4; i++) + s0 (i, 50 + i); + for (i = 1; i <= 4; i++) + s1 (i, 150 + i); + for (i = 1; i <= 4; i++) + s3 (i, 350 + i); + for (i = 1; i <= 4; i++) + s4 (i, 450 + i); + for (i = 1; i <= 4; i++) + s10 (i, 1050 + i); + for (i = 1; i <= 4; i++) + s11 (i, 1150 + i); + + use_it (0); /* main-breakpoint-6 */ + + /* Load lib2, unload lib1, lib3, and lib4; then load lib3 again. */ + h2 = load_dso (OBJ2, 2, &s2); + status = dlclose (h1); + assert (status == 0); + status = dlclose (h3); + assert (status == 0); + status = dlclose (h4); + assert (status == 0); + h3 = load_dso (OBJ3, 3, &s3); + + /* Set TLS vars; currently, lib2 and lib3 are loaded; + lib1 and lib4 are not loaded. */ + for (i = 1; i <= 4; i++) + s0 (i, 60 + i); + for (i = 1; i <= 4; i++) + s2 (i, 260 + i); + for (i = 1; i <= 4; i++) + s3 (i, 360 + i); + for (i = 1; i <= 4; i++) + s10 (i, 1060 + i); + for (i = 1; i <= 4; i++) + s11 (i, 1160 + i); + + use_it (0); /* main-breakpoint-7 */ + + /* Unload lib3 and lib2, then (re)load lib4, lib3, lib2, and lib1, + in that order. */ + status = dlclose (h3); + assert (status == 0); + status = dlclose (h2); + assert (status == 0); + h4 = load_dso (OBJ4, 4, &s4); + h3 = load_dso (OBJ3, 3, &s3); + h2 = load_dso (OBJ2, 2, &s2); + h1 = load_dso (OBJ1, 1, &s1); + + /* Set TLS vars; currently, lib1, lib2, lib3, and lib4 are all + loaded. */ + for (i = 1; i <= 4; i++) + s0 (i, 70 + i); + for (i = 1; i <= 4; i++) + s1 (i, 170 + i); + for (i = 1; i <= 4; i++) + s2 (i, 270 + i); + for (i = 1; i <= 4; i++) + s3 (i, 370 + i); + for (i = 1; i <= 4; i++) + s4 (i, 470 + i); + for (i = 1; i <= 4; i++) + s10 (i, 1070 + i); + for (i = 1; i <= 4; i++) + s11 (i, 1170 + i); + + use_it (0); /* main-breakpoint-8 */ + + /* Unload lib3, lib1, and lib4. */ + status = dlclose (h3); + assert (status == 0); + status = dlclose (h1); + assert (status == 0); + status = dlclose (h4); + assert (status == 0); + + /* Set TLS vars; currently, lib2 is loaded; lib1, lib3, and lib4 are + not. */ + for (i = 1; i <= 4; i++) + s0 (i, 80 + i); + for (i = 1; i <= 4; i++) + s2 (i, 280 + i); + for (i = 1; i <= 4; i++) + s10 (i, 1080 + i); + for (i = 1; i <= 4; i++) + s11 (i, 1180 + i); + + use_it (0); /* main-breakpoint-9 */ + + /* Load lib3, unload lib2, load lib4. */ + h3 = load_dso (OBJ3, 3, &s3); + status = dlclose (h2); + assert (status == 0); + h4 = load_dso (OBJ4, 4, &s4); + + /* Set TLS vars; currently, lib3 and lib4 are loaded; lib1 and lib2 + are not. */ + for (i = 1; i <= 4; i++) + s0 (i, 90 + i); + for (i = 1; i <= 4; i++) + s3 (i, 390 + i); + for (i = 1; i <= 4; i++) + s4 (i, 490 + i); + for (i = 1; i <= 4; i++) + s10 (i, 1090 + i); + for (i = 1; i <= 4; i++) + s11 (i, 1190 + i); + + use_it (0); /* main-breakpoint-10 */ + + /* Attempt to keep variables in the main program from being optimized + away. */ + use_it (tls_main_tbss_1); + use_it (tls_main_tbss_2); + use_it (tls_main_tdata_1); + use_it (tls_main_tdata_2); + + use_it (100); /* main-breakpoint-last */ + + return 0; +} diff --git a/gdb/testsuite/gdb.base/tls-dlobj.exp b/gdb/testsuite/gdb.base/tls-dlobj.exp new file mode 100644 index 0000000..858cfc7 --- /dev/null +++ b/gdb/testsuite/gdb.base/tls-dlobj.exp @@ -0,0 +1,378 @@ +# Copyright 2024-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. + +# Test that the GDB-internal TLS link map to module id mapping code +# works correctly when debugging a program which is linked against +# shared objects and which also loads and unloads other shared objects +# in different orders. For targets which have GDB-internal TLS +# support, it'll check both GDB-internal TLS support as well as that +# provided by a helper library such as libthread_db. + +source $srcdir/$subdir/tls-common.exp.tcl + +require allow_shlib_tests + +standard_testfile + +set libsrc "${srcdir}/${subdir}/${testfile}-lib.c" + +# These will be dlopen'd: +set lib1obj [standard_output_file "${testfile}1-lib.so"] +set lib2obj [standard_output_file "${testfile}2-lib.so"] +set lib3obj [standard_output_file "${testfile}3-lib.so"] +set lib4obj [standard_output_file "${testfile}4-lib.so"] + +# These will be dynamically linked with the main program: +set lib10obj [standard_output_file "${testfile}10-lib.so"] +set lib11obj [standard_output_file "${testfile}11-lib.so"] + +# Due to problems with some versions of glibc, we expect some tests to +# fail due to TLS storage not being allocated/initialized. Test +# command CMD using regular expression RE, and use XFAIL instead of +# FAIL when the relevant RE is matched and COND is true when evaluated +# in the upper level. + +proc gdb_test_with_xfail { cmd re cond} { + gdb_test_multiple $cmd $cmd { + -re -wrap $re { + pass $gdb_test_name + } + -re -wrap "The inferior has not yet allocated storage for thread-local variables.*" { + if {[ uplevel 1 [list expr $cond]]} { + xfail $gdb_test_name + } else { + fail $gdb_test_name + } + } + } +} + +proc do_tests {force_internal_tls} { + clean_restart $::testfile + if {![runto_main]} { + return + } + + if {$force_internal_tls} { + gdb_test_no_output "maint set force-internal-tls-address-lookup on" + } + + gdb_breakpoint [gdb_get_line_number "main-breakpoint-1"] + gdb_continue_to_breakpoint "main-breakpoint-1" + + with_test_prefix "before assignments" { + gdb_test "print tls_main_tbss_1" ".* = 0" + gdb_test "print tls_main_tbss_2" ".* = 0" + gdb_test "print tls_main_tdata_1" ".* = 96" + gdb_test "print tls_main_tdata_2" ".* = 97" + + # For these tests, where we're attempting to access TLS vars + # in a dlopen'd library, but before assignment to any of the + # vars, so it could happen that storage hasn't been allocated + # yet. But it might also work. (When testing against MUSL, + # things just work; GLIBC ends to produce the TLS error.) So + # accept either the right answer or a TLS error message. + + set tlserr "The inferior has not yet allocated storage for thread-local variables.*" + foreach n {1 2 3 4} { + gdb_test "print tls_lib${n}_tbss_1" \ + "0|${tlserr}" + gdb_test "print tls_lib${n}_tbss_2" \ + "0|${tlserr}" + gdb_test "print tls_lib${n}_tdata_1" \ + "96|${tlserr}" + gdb_test "print tls_lib${n}_tdata_2" \ + "97|${tlserr}" + } + foreach n {10 11} { + gdb_test "print tls_lib${n}_tbss_1" ".* = 0" + gdb_test "print tls_lib${n}_tbss_2" ".* = 0" + gdb_test "print tls_lib${n}_tdata_1" ".* = ${n}96" + gdb_test "print tls_lib${n}_tdata_2" ".* = ${n}97" + } + } + + gdb_breakpoint [gdb_get_line_number "main-breakpoint-2"] + gdb_continue_to_breakpoint "main-breakpoint-2" + + with_test_prefix "at main-breakpoint-2" { + gdb_test "print tls_main_tbss_1" ".* = 11" + gdb_test "print tls_main_tbss_2" ".* = 12" + gdb_test "print tls_main_tdata_1" ".* = 13" + gdb_test "print tls_main_tdata_2" ".* = 14" + + foreach n {1 2 3 4 10 11} { + gdb_test "print tls_lib${n}_tbss_1" ".* = ${n}11" + gdb_test "print tls_lib${n}_tbss_2" ".* = ${n}12" + gdb_test "print tls_lib${n}_tdata_1" ".* = ${n}13" + gdb_test "print tls_lib${n}_tdata_2" ".* = ${n}14" + } + } + + gdb_breakpoint [gdb_get_line_number "main-breakpoint-3"] + gdb_continue_to_breakpoint "main-breakpoint-3" + + # At this point lib2 and lib3 have been unloaded. Also, TLS vars + # in remaining libraries have been changed. + + with_test_prefix "at main-breakpoint-3" { + gdb_test "print tls_main_tbss_1" ".* = 21" + gdb_test "print tls_main_tbss_2" ".* = 22" + gdb_test "print tls_main_tdata_1" ".* = 23" + gdb_test "print tls_main_tdata_2" ".* = 24" + + foreach n {1 4 10 11} { + gdb_test "print tls_lib${n}_tbss_1" ".* = ${n}21" + gdb_test "print tls_lib${n}_tbss_2" ".* = ${n}22" + gdb_test "print tls_lib${n}_tdata_1" ".* = ${n}23" + gdb_test "print tls_lib${n}_tdata_2" ".* = ${n}24" + } + } + + gdb_breakpoint [gdb_get_line_number "main-breakpoint-4"] + gdb_continue_to_breakpoint "main-breakpoint-4" + + # lib3 has been loaded again; lib2 is the only one not loaded. + + with_test_prefix "at main-breakpoint-4" { + gdb_test "print tls_main_tbss_1" ".* = 31" + gdb_test "print tls_main_tbss_2" ".* = 32" + gdb_test "print tls_main_tdata_1" ".* = 33" + gdb_test "print tls_main_tdata_2" ".* = 34" + + set cond { $n == 3 } + foreach n {1 3 4 10 11} { + gdb_test_with_xfail "print tls_lib${n}_tbss_1" ".* = ${n}31" $cond + gdb_test_with_xfail "print tls_lib${n}_tbss_2" ".* = ${n}32" $cond + gdb_test_with_xfail "print tls_lib${n}_tdata_1" ".* = ${n}33" $cond + gdb_test_with_xfail "print tls_lib${n}_tdata_2" ".* = ${n}34" $cond + } + } + + gdb_breakpoint [gdb_get_line_number "main-breakpoint-5"] + gdb_continue_to_breakpoint "main-breakpoint-5" + + # lib2 and lib3 are loaded; lib1 and lib4 are not. + + with_test_prefix "at main-breakpoint-5" { + gdb_test "print tls_main_tbss_1" ".* = 41" + gdb_test "print tls_main_tbss_2" ".* = 42" + gdb_test "print tls_main_tdata_1" ".* = 43" + gdb_test "print tls_main_tdata_2" ".* = 44" + + set cond { $n == 2 || $n == 3 } + foreach n {2 3 10 11} { + gdb_test_with_xfail "print tls_lib${n}_tbss_1" ".* = ${n}41" $cond + gdb_test_with_xfail "print tls_lib${n}_tbss_2" ".* = ${n}42" $cond + gdb_test_with_xfail "print tls_lib${n}_tdata_1" ".* = ${n}43" $cond + gdb_test_with_xfail "print tls_lib${n}_tdata_2" ".* = ${n}44" $cond + } + } + + gdb_breakpoint [gdb_get_line_number "main-breakpoint-6"] + gdb_continue_to_breakpoint "main-breakpoint-6" + + # lib1, lib3 and lib4 are loaded; lib2 is not loaded. + + with_test_prefix "at main-breakpoint-6" { + gdb_test "print tls_main_tbss_1" ".* = 51" + gdb_test "print tls_main_tbss_2" ".* = 52" + gdb_test "print tls_main_tdata_1" ".* = 53" + gdb_test "print tls_main_tdata_2" ".* = 54" + + set cond { $n == 1 || $n == 3 || $n == 4} + foreach n {1 3 4 10 11} { + gdb_test_with_xfail "print tls_lib${n}_tbss_1" ".* = ${n}51" $cond + gdb_test_with_xfail "print tls_lib${n}_tbss_2" ".* = ${n}52" $cond + gdb_test_with_xfail "print tls_lib${n}_tdata_1" ".* = ${n}53" $cond + gdb_test_with_xfail "print tls_lib${n}_tdata_2" ".* = ${n}54" $cond + } + } + + gdb_breakpoint [gdb_get_line_number "main-breakpoint-7"] + gdb_continue_to_breakpoint "main-breakpoint-7" + + # lib2 and lib3 are loaded; lib1 and lib4 are not. + + with_test_prefix "at main-breakpoint-7" { + gdb_test "print tls_main_tbss_1" ".* = 61" + gdb_test "print tls_main_tbss_2" ".* = 62" + gdb_test "print tls_main_tdata_1" ".* = 63" + gdb_test "print tls_main_tdata_2" ".* = 64" + + set cond { $n == 2 || $n == 3 } + foreach n {2 3 10 11} { + gdb_test_with_xfail "print tls_lib${n}_tbss_1" ".* = ${n}61" $cond + gdb_test_with_xfail "print tls_lib${n}_tbss_2" ".* = ${n}62" $cond + gdb_test_with_xfail "print tls_lib${n}_tdata_1" ".* = ${n}63" $cond + gdb_test_with_xfail "print tls_lib${n}_tdata_2" ".* = ${n}64" $cond + } + } + + gdb_breakpoint [gdb_get_line_number "main-breakpoint-8"] + gdb_continue_to_breakpoint "main-breakpoint-8" + + # lib1, lib2, lib3, and lib4 are all loaded. + + with_test_prefix "at main-breakpoint-8" { + gdb_test "print tls_main_tbss_1" ".* = 71" + gdb_test "print tls_main_tbss_2" ".* = 72" + gdb_test "print tls_main_tdata_1" ".* = 73" + gdb_test "print tls_main_tdata_2" ".* = 74" + + foreach n {1 2 3 4 10 11} { + gdb_test "print tls_lib${n}_tbss_1" ".* = ${n}71" + gdb_test "print tls_lib${n}_tbss_2" ".* = ${n}72" + gdb_test "print tls_lib${n}_tdata_1" ".* = ${n}73" + gdb_test "print tls_lib${n}_tdata_2" ".* = ${n}74" + } + } + + gdb_breakpoint [gdb_get_line_number "main-breakpoint-9"] + gdb_continue_to_breakpoint "main-breakpoint-9" + + # lib2 is loaded; lib1, lib3, and lib4 are not. + + with_test_prefix "at main-breakpoint-9" { + gdb_test "print tls_main_tbss_1" ".* = 81" + gdb_test "print tls_main_tbss_2" ".* = 82" + gdb_test "print tls_main_tdata_1" ".* = 83" + gdb_test "print tls_main_tdata_2" ".* = 84" + + foreach n {2 10 11} { + gdb_test "print tls_lib${n}_tbss_1" ".* = ${n}81" + gdb_test "print tls_lib${n}_tbss_2" ".* = ${n}82" + gdb_test "print tls_lib${n}_tdata_1" ".* = ${n}83" + gdb_test "print tls_lib${n}_tdata_2" ".* = ${n}84" + } + } + + gdb_breakpoint [gdb_get_line_number "main-breakpoint-10"] + gdb_continue_to_breakpoint "main-breakpoint-10" + + # lib3 and lib4 are loaded; lib1 and lib2 are not. + + with_test_prefix "at main-breakpoint-10" { + gdb_test "print tls_main_tbss_1" ".* = 91" + gdb_test "print tls_main_tbss_2" ".* = 92" + gdb_test "print tls_main_tdata_1" ".* = 93" + gdb_test "print tls_main_tdata_2" ".* = 94" + + set cond { $n == 3 || $n == 4 } + foreach n {3 4 10 11} { + gdb_test_with_xfail "print tls_lib${n}_tbss_1" ".* = ${n}91" $cond + gdb_test_with_xfail "print tls_lib${n}_tbss_2" ".* = ${n}92" $cond + gdb_test_with_xfail "print tls_lib${n}_tdata_1" ".* = ${n}93" $cond + gdb_test_with_xfail "print tls_lib${n}_tdata_2" ".* = ${n}94" $cond + } + } + + # gdb_interact + + set corefile ${::binfile}.core + set core_supported 0 + if { ![is_remote host] } { + set core_supported [gdb_gcore_cmd $corefile "save corefile"] + } + + # Finish test early if no core file was made. + if {!$core_supported} { + return + } + + clean_restart $::testfile + + set core_loaded [gdb_core_cmd $corefile "load corefile"] + if { $core_loaded == -1 } { + return + } + + with_test_prefix "core file" { + if {$force_internal_tls} { + gdb_test_no_output "maint set force-internal-tls-address-lookup on" + } + + gdb_test "print tls_main_tbss_1" ".* = 91" + gdb_test "print tls_main_tbss_2" ".* = 92" + gdb_test "print tls_main_tdata_1" ".* = 93" + gdb_test "print tls_main_tdata_2" ".* = 94" + + set cond { $n == 3 || $n == 4 } + foreach n {3 4 10 11} { + gdb_test_with_xfail "print tls_lib${n}_tbss_1" ".* = ${n}91" $cond + gdb_test_with_xfail "print tls_lib${n}_tbss_2" ".* = ${n}92" $cond + gdb_test_with_xfail "print tls_lib${n}_tdata_1" ".* = ${n}93" $cond + gdb_test_with_xfail "print tls_lib${n}_tdata_2" ".* = ${n}94" $cond + } + } +} + +# Build shared objects for dlopen: +if { [gdb_compile_shlib $libsrc $lib1obj [list debug additional_flags=-DN=1]] != "" } { + untested "failed to compile shared object" + return -1 +} +if { [gdb_compile_shlib $libsrc $lib2obj [list debug additional_flags=-DN=2]] != "" } { + untested "failed to compile shared object" + return -1 +} +if { [gdb_compile_shlib $libsrc $lib3obj [list debug additional_flags=-DN=3]] != "" } { + untested "failed to compile shared object" + return -1 +} +if { [gdb_compile_shlib $libsrc $lib4obj [list debug additional_flags=-DN=4]] != "" } { + untested "failed to compile shared object" + return -1 +} + +# Build shared objects to link against main program: +if { [gdb_compile_shlib $libsrc $lib10obj [list debug additional_flags=-DN=10]] != "" } { + untested "failed to compile shared object" + return -1 +} +if { [gdb_compile_shlib $libsrc $lib11obj [list debug additional_flags=-DN=11]] != "" } { + untested "failed to compile shared object" + return -1 +} + +# Use gdb_compile_pthreads to build and link the main program for +# testing. It's also possible to run the tests using plain old +# gdb_compile, but this adds complexity with setting up additional +# KFAILs. (When run using GLIBC versions earlier than 2.34, a program +# that's not dynamically linked against libpthread will lack a working +# libthread_db, and, therefore, won't be able to access thread local +# storage without GDB-internal TLS support. Additional complications +# arise from when testing on x86_64 with -m32, which tends to work +# okay on GLIBC 2.34 and newer, but not older versions. It gets messy +# to properly sort out all of these cases.) +# +# This test was originally written to do it both ways, i.e. with both +# both gdb_compile and gdb_compile_pthreads, but the point of this +# test is to check that the link map address to TLS module id mapping +# code works correctly in programs which use lots of dlopen and +# dlclose calls in various orders - and that can be done using just +# gdb_compile_pthreads. + +if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \ + [list debug shlib_load \ + shlib=${lib10obj} \ + shlib=${lib11obj} \ + additional_flags=-DOBJ1=\"${lib1obj}\" \ + additional_flags=-DOBJ2=\"${lib2obj}\" \ + additional_flags=-DOBJ3=\"${lib3obj}\" \ + additional_flags=-DOBJ4=\"${lib4obj}\" \ + ]] != "" } { + untested "failed to compile" +} else { + foreach_with_prefix force_internal_tls $internal_tls_iters { + do_tests $force_internal_tls + } +} diff --git a/gdb/testsuite/gdb.base/tls-multiobj.c b/gdb/testsuite/gdb.base/tls-multiobj.c new file mode 100644 index 0000000..dd4aadb --- /dev/null +++ b/gdb/testsuite/gdb.base/tls-multiobj.c @@ -0,0 +1,89 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2024-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/>. */ + +__thread int tls_main_tbss_1; +__thread int tls_main_tbss_2; +__thread int tls_main_tdata_1 = 96; +__thread int tls_main_tdata_2 = 97; + +extern __thread int tls_lib1_tbss_1; +extern __thread int tls_lib1_tbss_2; +extern __thread int tls_lib1_tdata_1; +extern __thread int tls_lib1_tdata_2; + +extern __thread int tls_lib2_tbss_1; +extern __thread int tls_lib2_tbss_2; +extern __thread int tls_lib2_tdata_1; +extern __thread int tls_lib2_tdata_2; + +extern __thread int tls_lib3_tbss_1; +extern __thread int tls_lib3_tbss_2; +extern __thread int tls_lib3_tdata_1; +extern __thread int tls_lib3_tdata_2; + +extern void lib1_func (); +extern void lib2_func (); +extern void lib3_func (); + +volatile int data; + +void +use_it (int a) +{ + data = a; +} + +int +main (int argc, char **argv) +{ + use_it (-1); + + tls_main_tbss_1 = 51; /* main-breakpoint-1 */ + tls_main_tbss_2 = 52; + tls_main_tdata_1 = 53; + tls_main_tdata_2 = 54; + + tls_lib1_tbss_1 = 151; + tls_lib1_tbss_2 = 152; + tls_lib1_tdata_1 = 153; + tls_lib1_tdata_2 = 154; + + tls_lib2_tbss_1 = 251; + tls_lib2_tbss_2 = 252; + tls_lib2_tdata_1 = 253; + tls_lib2_tdata_2 = 254; + + tls_lib3_tbss_1 = 351; + tls_lib3_tbss_2 = 352; + tls_lib3_tdata_1 = 353; + tls_lib3_tdata_2 = 354; + + lib1_func (); + lib2_func (); + lib3_func (); + + /* Attempt to keep variables in the main program from being optimized + away. */ + use_it (tls_main_tbss_1); + use_it (tls_main_tbss_2); + use_it (tls_main_tdata_1); + use_it (tls_main_tdata_2); + + use_it (100); /* main-breakpoint-2 */ + + return 0; +} diff --git a/gdb/testsuite/gdb.base/tls-multiobj.exp b/gdb/testsuite/gdb.base/tls-multiobj.exp new file mode 100644 index 0000000..87aac16 --- /dev/null +++ b/gdb/testsuite/gdb.base/tls-multiobj.exp @@ -0,0 +1,233 @@ +# Copyright 2024-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. + +# Using different compilation/linking scenarios, attempt to access +# thread-local variables in a non-threaded program using multiple +# shared objects. + +source $srcdir/$subdir/tls-common.exp.tcl + +standard_testfile + +set lib1src "${srcdir}/${subdir}/${testfile}1.c" +set lib2src "${srcdir}/${subdir}/${testfile}2.c" +set lib3src "${srcdir}/${subdir}/${testfile}3.c" + +set lib1obj [standard_output_file "${testfile}1-lib.so"] +set lib2obj [standard_output_file "${testfile}2-lib.so"] +set lib3obj [standard_output_file "${testfile}3-lib.so"] + +proc do_tests {force_internal_tls {do_kfail_tls_access 0}} { + set filename [file tail $::binfile] + + clean_restart $filename + + if {![runto_main]} { + return + } + + if {$force_internal_tls} { + gdb_test_no_output "maint set force-internal-tls-address-lookup on" + } + + if { $do_kfail_tls_access && [istarget "*-*-linux*"] } { + # Turn off do_kfail_tls_access when libthread_db is loaded. + # This can happen for the default case when testing x86_64 + # w/ -m32 using glibc versions 2.34 or newer. + gdb_test_multiple "maint check libthread-db" "Check for loaded libthread_db" { + -re -wrap "libthread_db integrity checks passed." { + set do_kfail_tls_access 0 + pass $gdb_test_name + } + -re -wrap "No libthread_db loaded" { + pass $gdb_test_name + } + } + # Also turn off do_kfail_tls_access when connected to a + # gdbserver and we observe that accessing a TLS variable + # works. + if {[target_is_gdbserver]} { + gdb_test_multiple "print tls_main_tbss_1" \ + "Check TLS accessibility when connected to a gdbserver" { + -re -wrap "= 0" { + set do_kfail_tls_access 0 + pass $gdb_test_name + } + -re -wrap "Remote target failed to process qGetTLSAddr request" { + pass $gdb_test_name + } + } + } + } + + gdb_breakpoint [gdb_get_line_number "main-breakpoint-1"] + gdb_continue_to_breakpoint "main-breakpoint-1" + + set t $do_kfail_tls_access + set m "tls not available" + with_test_prefix "before assignments" { + gdb_test_with_kfail "print tls_main_tbss_1" ".* = 0" $t $m + gdb_test_with_kfail "print tls_main_tbss_2" ".* = 0" $t $m + gdb_test_with_kfail "print tls_main_tdata_1" ".* = 96" $t $m + gdb_test_with_kfail "print tls_main_tdata_2" ".* = 97" $t $m + + gdb_test_with_kfail "print tls_lib1_tbss_1" ".* = 0" $t $m + gdb_test_with_kfail "print tls_lib1_tbss_2" ".* = 0" $t $m + gdb_test_with_kfail "print tls_lib1_tdata_1" ".* = 196" $t $m + gdb_test_with_kfail "print tls_lib1_tdata_2" ".* = 197" $t $m + + gdb_test_with_kfail "print tls_lib2_tbss_1" ".* = 0" $t $m + gdb_test_with_kfail "print tls_lib2_tbss_2" ".* = 0" $t $m + gdb_test_with_kfail "print tls_lib2_tdata_1" ".* = 296" $t $m + gdb_test_with_kfail "print tls_lib2_tdata_2" ".* = 297" $t $m + + gdb_test_with_kfail "print tls_lib3_tbss_1" ".* = 0" $t $m + gdb_test_with_kfail "print tls_lib3_tbss_2" ".* = 0" $t $m + gdb_test_with_kfail "print tls_lib3_tdata_1" ".* = 396" $t $m + gdb_test_with_kfail "print tls_lib3_tdata_2" ".* = 397" $t $m + } + + gdb_breakpoint [gdb_get_line_number "main-breakpoint-2"] + gdb_continue_to_breakpoint "main-breakpoint-2" + + with_test_prefix "after assignments" { + gdb_test_with_kfail "print tls_main_tbss_1" ".* = 51" $t $m + gdb_test_with_kfail "print tls_main_tbss_2" ".* = 52" $t $m + gdb_test_with_kfail "print tls_main_tdata_1" ".* = 53" $t $m + gdb_test_with_kfail "print tls_main_tdata_2" ".* = 54" $t $m + + gdb_test_with_kfail "print tls_lib1_tbss_1" ".* = 151" $t $m + gdb_test_with_kfail "print tls_lib1_tbss_2" ".* = 152" $t $m + gdb_test_with_kfail "print tls_lib1_tdata_1" ".* = 153" $t $m + gdb_test_with_kfail "print tls_lib1_tdata_2" ".* = 154" $t $m + + gdb_test_with_kfail "print tls_lib2_tbss_1" ".* = 251" $t $m + gdb_test_with_kfail "print tls_lib2_tbss_2" ".* = 252" $t $m + gdb_test_with_kfail "print tls_lib2_tdata_1" ".* = 253" $t $m + gdb_test_with_kfail "print tls_lib2_tdata_2" ".* = 254" $t $m + + gdb_test_with_kfail "print tls_lib3_tbss_1" ".* = 351" $t $m + gdb_test_with_kfail "print tls_lib3_tbss_2" ".* = 352" $t $m + gdb_test_with_kfail "print tls_lib3_tdata_1" ".* = 353" $t $m + gdb_test_with_kfail "print tls_lib3_tdata_2" ".* = 354" $t $m + } + + set corefile ${::binfile}.core + set core_supported 0 + if { ![is_remote host] } { + set core_supported [gdb_gcore_cmd $corefile "save corefile"] + } + + # Finish test early if no core file was made. + if {!$core_supported} { + return + } + + clean_restart $filename + + set core_loaded [gdb_core_cmd $corefile "load corefile"] + if { $core_loaded == -1 } { + return + } + + with_test_prefix "core file" { + if {$force_internal_tls} { + gdb_test_no_output "maint set force-internal-tls-address-lookup on" + } + + gdb_test_with_kfail "print tls_main_tbss_1" ".* = 51" $t $m + gdb_test_with_kfail "print tls_main_tbss_2" ".* = 52" $t $m + gdb_test_with_kfail "print tls_main_tdata_1" ".* = 53" $t $m + gdb_test_with_kfail "print tls_main_tdata_2" ".* = 54" $t $m + + gdb_test_with_kfail "print tls_lib1_tbss_1" ".* = 151" $t $m + gdb_test_with_kfail "print tls_lib1_tbss_2" ".* = 152" $t $m + gdb_test_with_kfail "print tls_lib1_tdata_1" ".* = 153" $t $m + gdb_test_with_kfail "print tls_lib1_tdata_2" ".* = 154" $t $m + + gdb_test_with_kfail "print tls_lib2_tbss_1" ".* = 251" $t $m + gdb_test_with_kfail "print tls_lib2_tbss_2" ".* = 252" $t $m + gdb_test_with_kfail "print tls_lib2_tdata_1" ".* = 253" $t $m + gdb_test_with_kfail "print tls_lib2_tdata_2" ".* = 254" $t $m + + gdb_test_with_kfail "print tls_lib3_tbss_1" ".* = 351" $t $m + gdb_test_with_kfail "print tls_lib3_tbss_2" ".* = 352" $t $m + gdb_test_with_kfail "print tls_lib3_tdata_1" ".* = 353" $t $m + gdb_test_with_kfail "print tls_lib3_tdata_2" ".* = 354" $t $m + } +} + +if { [gdb_compile_shlib $lib1src $lib1obj {debug}] != "" } { + untested "failed to compile shared object" + return -1 +} +if { [gdb_compile_shlib $lib2src $lib2obj {debug}] != "" } { + untested "failed to compile shared object" + return -1 +} +if { [gdb_compile_shlib $lib3src $lib3obj {debug}] != "" } { + untested "failed to compile shared object" + return -1 +} + +# Certain linux target architectures implement support for internal +# TLS lookup which is used when thread stratum support (via +# libthread_db) is missing or when the linux-only GDB maintenance +# setting 'force-internal-tls-address-lookup' is 'on'. Thus for some +# of the testing scenarios, such as statically linked executables, +# this internal support will be used. Set 'do_kfail_tls_access' to 1 +# for those architectures which don't implement internal tls support. +if {[istarget *-*-linux*] + && ![is_any_target {*}$internal_tls_linux_targets]} { + set do_kfail_tls_access 1 +} elseif {[istarget *-*-linux*] && [is_x86_like_target]} { + # This covers the case of x86_64 with -m32: + set do_kfail_tls_access 1 +} else { + set do_kfail_tls_access 0 +} + +set binprefix $binfile + +with_test_prefix "default" { + set binfile $binprefix-default + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \ + [list debug shlib=${lib1obj} \ + shlib=${lib2obj} \ + shlib=${lib3obj}]] != "" } { + untested "failed to compile" + } else { + foreach_with_prefix force_internal_tls $internal_tls_iters { + # Depending on glibc version, it might not be appropriate + # for do_kfail_tls_access to be set here. That will be + # handled in 'do_tests', disabling it if necessary. + # + # Specifically, glibc versions 2.34 and later have the + # thread library (and libthread_db availability) in + # programs not linked against libpthread.so + do_tests $force_internal_tls $do_kfail_tls_access + } + } +} + +with_test_prefix "pthreads" { + set binfile $binprefix-pthreads + if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \ + [list debug shlib=${lib1obj} \ + shlib=${lib2obj} \ + shlib=${lib3obj}]] != "" } { + untested "failed to compile" + } else { + foreach_with_prefix force_internal_tls $internal_tls_iters { + do_tests $force_internal_tls + } + } +} diff --git a/gdb/testsuite/gdb.base/gold-gdb-index-2.c b/gdb/testsuite/gdb.base/tls-multiobj1.c index c72c0f0..6207173 100644 --- a/gdb/testsuite/gdb.base/gold-gdb-index-2.c +++ b/gdb/testsuite/gdb.base/tls-multiobj1.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2024-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 @@ -15,9 +15,12 @@ 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 "gold-gdb-index.h" +__thread int tls_lib1_tbss_1; +__thread int tls_lib1_tbss_2; +__thread int tls_lib1_tdata_1 = 196; +__thread int tls_lib1_tdata_2 = 197; -namespace N1 +void +lib1_func () { - void bar () { C1::baz (); } } diff --git a/gdb/testsuite/gdb.base/gold-gdb-index.h b/gdb/testsuite/gdb.base/tls-multiobj2.c index d665fdb..9ff8b67 100644 --- a/gdb/testsuite/gdb.base/gold-gdb-index.h +++ b/gdb/testsuite/gdb.base/tls-multiobj2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2024-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 @@ -15,11 +15,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -namespace N1 +__thread int tls_lib2_tbss_1; +__thread int tls_lib2_tbss_2; +__thread int tls_lib2_tdata_1 = 296; +__thread int tls_lib2_tdata_2 = 297; + +void +lib2_func () { - class C1 - { - public: - static void baz () {} - }; } diff --git a/gdb/testsuite/gdb.base/gdbindex-stabs.c b/gdb/testsuite/gdb.base/tls-multiobj3.c index 0b6f46a..3594eba0 100644 --- a/gdb/testsuite/gdb.base/gdbindex-stabs.c +++ b/gdb/testsuite/gdb.base/tls-multiobj3.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2024-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 @@ -13,9 +13,14 @@ 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/>. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +__thread int tls_lib3_tbss_1; +__thread int tls_lib3_tbss_2; +__thread int tls_lib3_tdata_1 = 396; +__thread int tls_lib3_tdata_2 = 397; void -stabs_function (void) /* marker-here */ +lib3_func () { } diff --git a/gdb/testsuite/gdb.base/tls-nothreads.c b/gdb/testsuite/gdb.base/tls-nothreads.c new file mode 100644 index 0000000..cac20f8 --- /dev/null +++ b/gdb/testsuite/gdb.base/tls-nothreads.c @@ -0,0 +1,57 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2024-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/>. */ + +__thread int tls_tbss_1; +__thread int tls_tbss_2; +__thread int tls_tbss_3; + +__thread int tls_tdata_1 = 21; +__thread int tls_tdata_2 = 22; +__thread int tls_tdata_3 = 23; + +volatile int data; + +void +use_it (int a) +{ + data = a; +} + +int +main (int argc, char **argv) +{ + use_it (-1); + + tls_tbss_1 = 24; /* main-breakpoint-1 */ + tls_tbss_2 = 25; + tls_tbss_3 = 26; + + tls_tdata_1 = 42; + tls_tdata_2 = 43; + tls_tdata_3 = 44; + + use_it (tls_tbss_1); + use_it (tls_tbss_2); + use_it (tls_tbss_3); + use_it (tls_tdata_1); + use_it (tls_tdata_2); + use_it (tls_tdata_3); + + use_it (100); /* main-breakpoint-2 */ + + return 0; +} diff --git a/gdb/testsuite/gdb.base/tls-nothreads.exp b/gdb/testsuite/gdb.base/tls-nothreads.exp new file mode 100644 index 0000000..dee7425 --- /dev/null +++ b/gdb/testsuite/gdb.base/tls-nothreads.exp @@ -0,0 +1,252 @@ +# Copyright 2024-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. + +# Using different compilation/linking scenarios, attempt to access +# thread-local variables in a non-threaded program. Also test that +# GDB internal TLS lookup works correctly. + +source $srcdir/$subdir/tls-common.exp.tcl + +standard_testfile + +proc do_tests {force_internal_tls {do_kfail_tls_access 0}} { + set filename [file tail $::binfile] + + clean_restart $filename + + if {![runto_main]} { + return + } + + if {$force_internal_tls} { + gdb_test_no_output "maint set force-internal-tls-address-lookup on" + } + + if { $do_kfail_tls_access && [istarget "*-*-linux*"] } { + # Turn off do_kfail_tls_access when libthread_db is loaded. + # This can happen for the default case when testing x86_64 + # w/ -m32 using glibc versions 2.34 or newer. + gdb_test_multiple "maint check libthread-db" "Check for loaded libthread_db" { + -re -wrap "libthread_db integrity checks passed." { + set do_kfail_tls_access 0 + pass $gdb_test_name + } + -re -wrap "No libthread_db loaded" { + pass $gdb_test_name + } + } + # Also turn off do_kfail_tls_access when connected to a + # gdbserver and we observe that accessing a TLS variable + # works. + if {[target_is_gdbserver]} { + gdb_test_multiple "print tls_tbss_1" "Check TLS accessibility when connected to a gdbserver" { + -re -wrap "= 0" { + set do_kfail_tls_access 0 + pass $gdb_test_name + } + -re -wrap "Remote target failed to process qGetTLSAddr request" { + pass $gdb_test_name + } + } + } + } + + gdb_breakpoint [gdb_get_line_number "main-breakpoint-1"] + gdb_continue_to_breakpoint "main-breakpoint-1" + + set t $do_kfail_tls_access + set m "tls not available" + with_test_prefix "before assignments" { + gdb_test_with_kfail "print tls_tbss_1" ".* = 0" $t $m + gdb_test_with_kfail "print tls_tbss_2" ".* = 0" $t $m + gdb_test_with_kfail "print tls_tbss_3" ".* = 0" $t $m + + gdb_test_with_kfail "print tls_tdata_1" ".* = 21" $t $m + gdb_test_with_kfail "print tls_tdata_2" ".* = 22" $t $m + gdb_test_with_kfail "print tls_tdata_3" ".* = 23" $t $m + } + + gdb_breakpoint [gdb_get_line_number "main-breakpoint-2"] + gdb_continue_to_breakpoint "main-breakpoint-2" + + with_test_prefix "after assignments" { + gdb_test_with_kfail "print tls_tbss_1" ".* = 24" $t $m + gdb_test_with_kfail "print tls_tbss_2" ".* = 25" $t $m + gdb_test_with_kfail "print tls_tbss_3" ".* = 26" $t $m + + gdb_test_with_kfail "print tls_tdata_1" ".* = 42" $t $m + gdb_test_with_kfail "print tls_tdata_2" ".* = 43" $t $m + gdb_test_with_kfail "print tls_tdata_3" ".* = 44" $t $m + } + + # Make a core file now, but save testing using it until the end + # in case core files are not supported. + set corefile ${::binfile}.core + set core_supported 0 + if { ![is_remote host] } { + set core_supported [gdb_gcore_cmd $corefile "save corefile"] + } + + # Now continue to end and see what happens when attempting to + # access a TLS variable when the program is no longer running. + gdb_continue_to_end + with_test_prefix "after exit" { + gdb_test "print tls_tbss_1" \ + "Cannot (?:read|find address of TLS symbol) `tls_tbss_1' without registers" + } + + with_test_prefix "stripped" { + set filename_stripped "${filename}.stripped" + set binfile_stripped [standard_output_file $filename_stripped] + set objcopy [gdb_find_objcopy] + set cmd "$objcopy --strip-debug ${::binfile} $binfile_stripped" + if {![catch {exec {*}$cmd} cmd_output]} { + clean_restart $filename_stripped + if {![runto_main]} { + return + } + + if {$force_internal_tls} { + gdb_test_no_output "maint set force-internal-tls-address-lookup on" + } + + # While there are no debug (e.g. DWARF) symbols, there + # are minimal symbols, so we should be able to place a + # breakpoint in use_it and continue to it. Continuing + # twice should put us past the assignments, at which point + # we can see if the TLS variables are still accessible. + gdb_test "break use_it" "Breakpoint 2 at $::hex" + gdb_test "continue" "Breakpoint 2, $::hex in use_it.*" + gdb_test "continue" "Breakpoint 2, $::hex in use_it.*" "continue 2" + + # Note that a cast has been added in order to avoid the + # "...has unknown type; cast it to its declared type" + # problem. + gdb_test_with_kfail "print (int) tls_tbss_1" ".* = 24" $t $m + gdb_test_with_kfail "print (int) tls_tbss_2" ".* = 25" $t $m + gdb_test_with_kfail "print (int) tls_tbss_3" ".* = 26" $t $m + + gdb_test_with_kfail "print (int) tls_tdata_1" ".* = 42" $t $m + gdb_test_with_kfail "print (int) tls_tdata_2" ".* = 43" $t $m + gdb_test_with_kfail "print (int) tls_tdata_3" ".* = 44" $t $m + + # Get rid of the "use_it" breakpoint + gdb_test_no_output "del 2" + + # Continue to program exit + gdb_continue_to_end + + # TLS variables should not be accessible after program exit + # (This case initially caused GDB to crash during development + # of GDB-internal TLS lookup support.) + with_test_prefix "after exit" { + gdb_test "print (int) tls_tbss_1" \ + "Cannot find address of TLS symbol `tls_tbss_1' without registers" + } + } + } + + # Finish test early if no core file was made. + if {!$core_supported} { + return + } + + clean_restart $filename + + set core_loaded [gdb_core_cmd $corefile "load corefile"] + if { $core_loaded == -1 } { + return + } + + with_test_prefix "core file" { + if {$force_internal_tls} { + gdb_test_no_output "maint set force-internal-tls-address-lookup on" + } + + gdb_test_with_kfail "print tls_tbss_1" ".* = 24" $t $m + gdb_test_with_kfail "print tls_tbss_2" ".* = 25" $t $m + gdb_test_with_kfail "print tls_tbss_3" ".* = 26" $t $m + + gdb_test_with_kfail "print tls_tdata_1" ".* = 42" $t $m + gdb_test_with_kfail "print tls_tdata_2" ".* = 43" $t $m + gdb_test_with_kfail "print tls_tdata_3" ".* = 44" $t $m + } +} + +# Certain linux target architectures implement support for internal +# TLS lookup which is used when thread stratum support (via +# libthread_db) is missing or when the linux-only GDB maintenance +# setting 'force-internal-tls-address-lookup' is 'on'. Thus for some +# of the testing scenarios, such as statically linked executables, +# this internal support will be used. Set 'do_kfail_tls_access' to 1 +# for those architectures which don't implement internal TLS support. +if {[istarget *-*-linux*] + && ![is_any_target {*}$internal_tls_linux_targets]} { + set do_kfail_tls_access 1 +} elseif {[istarget *-*-linux*] && [is_x86_like_target]} { + # This covers the case of x86_64 with -m32: + set do_kfail_tls_access 1 +} else { + set do_kfail_tls_access 0 +} + +set binprefix $binfile + +with_test_prefix "default" { + set binfile $binprefix-default + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested "failed to compile" + } else { + foreach_with_prefix force_internal_tls $internal_tls_iters { + # Depending on glibc version, it might not be appropriate + # for do_kfail_tls_access to be set here. That will be + # handled in 'do_tests', disabling it if necessary. + # + # Specifically, glibc versions 2.34 and later have the + # thread library (and libthread_db availability) in + # programs not linked against libpthread.so + do_tests $force_internal_tls $do_kfail_tls_access + } + } +} + +with_test_prefix "static" { + set binfile $binprefix-static + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags=-static"}] != "" } { + untested "failed to compile" + } else { + foreach_with_prefix force_internal_tls $internal_tls_iters { + do_tests $force_internal_tls $do_kfail_tls_access + } + } +} + +with_test_prefix "pthreads" { + set binfile $binprefix-pthreads + if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested "failed to compile" + } else { + foreach_with_prefix force_internal_tls $internal_tls_iters { + do_tests $force_internal_tls + } + } +} + +with_test_prefix "pthreads-static" { + set binfile $binprefix-pthreads-static + if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags=-static"}] != "" } { + untested "failed to compile" + } else { + foreach_with_prefix force_internal_tls $internal_tls_iters { + do_tests $force_internal_tls $do_kfail_tls_access + } + } +} diff --git a/gdb/testsuite/gdb.base/trace-commands.exp b/gdb/testsuite/gdb.base/trace-commands.exp index 1cabb20..d6732a3 100644 --- a/gdb/testsuite/gdb.base/trace-commands.exp +++ b/gdb/testsuite/gdb.base/trace-commands.exp @@ -1,4 +1,4 @@ -# Copyright 2006-2024 Free Software Foundation, Inc. +# Copyright 2006-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 diff --git a/gdb/testsuite/gdb.base/traced-thread.c b/gdb/testsuite/gdb.base/traced-thread.c index c06b0b2..d056d50 100644 --- a/gdb/testsuite/gdb.base/traced-thread.c +++ b/gdb/testsuite/gdb.base/traced-thread.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2023-2024 Free Software Foundation, Inc. + Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/traced-thread.exp b/gdb/testsuite/gdb.base/traced-thread.exp index 9b5c67a..b27549d 100644 --- a/gdb/testsuite/gdb.base/traced-thread.exp +++ b/gdb/testsuite/gdb.base/traced-thread.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/twice.exp b/gdb/testsuite/gdb.base/twice.exp index 46093fd..6445f90 100644 --- a/gdb/testsuite/gdb.base/twice.exp +++ b/gdb/testsuite/gdb.base/twice.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -25,15 +25,10 @@ close $fileid gdb_remote_download host ${srcdir}/${subdir}/twice.c -if { [gdb_compile $local_srcfile "${binfile}" executable $options] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $local_srcfile $options] != 0 } { + return } -# Start with a fresh gdb. - -clean_restart $binfile - if {[runto_main]} { # Test that GDB can still detect whether we have line numbers # even if we're executing code in an include file. @@ -47,4 +42,4 @@ if {[runto_main]} { gdb_test "step" "nothing \\(\\) at.*" } -remote_exec build "rm -f twice.c" +remote_exec build "rm -f twice.c" diff --git a/gdb/testsuite/gdb.base/type-and-typedef.c b/gdb/testsuite/gdb.base/type-and-typedef.c new file mode 100644 index 0000000..703d7f3 --- /dev/null +++ b/gdb/testsuite/gdb.base/type-and-typedef.c @@ -0,0 +1,48 @@ +/* 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/>. */ + +typedef struct foo /* struct foo defined here. */ +{ + int a; + int b; +} foo; /* typedef foo defined here. */ + +struct bar /* struct bar defined here. */ +{ + int a; + int b; +}; + +/* Yes, this really is typedef-ing 'bar' to something other than 'struct + bar'. Just testing that GDB handles this. This is not good code. */ +typedef struct foo bar; /* typedef bar defined here. */ + +/* The following must be a single line. This tests the 'struct baz' and + the 'typedef ... baz;' being on the same line. */ +typedef struct baz { int a; int b; } baz; /* baz defined here. */ + +volatile struct foo obj1 = { 1, 2 }; +volatile foo obj2 = { 1, 2 }; +volatile struct bar obj3 = { 1, 2 }; +volatile bar obj4 = { 1, 2 }; +volatile baz obj5 = { 1, 2 }; + +int +main () +{ + return obj1.b + obj2.b + obj3.b + obj4.b + obj5.b; +} diff --git a/gdb/testsuite/gdb.base/type-and-typedef.exp b/gdb/testsuite/gdb.base/type-and-typedef.exp new file mode 100644 index 0000000..1401ee8 --- /dev/null +++ b/gdb/testsuite/gdb.base/type-and-typedef.exp @@ -0,0 +1,65 @@ +# 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/>. + +# Compile a single CU containing a type and a typedef with the same +# name (think C's "typedef struct foo { ... } foo;"). Check that +# 'info types' shows both types. + +standard_testfile + +if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { + return +} + +# Line numbers needed by the test. +set struct_foo_lineno [gdb_get_line_number "struct foo defined here"] +set typedef_foo_lineno [gdb_get_line_number "typedef foo defined here"] +set struct_bar_lineno [gdb_get_line_number "struct bar defined here"] +set typedef_bar_lineno [gdb_get_line_number "typedef bar defined here"] +set baz_lineno [gdb_get_line_number "baz defined here"] + +# Check that the expected two types show up in global SRCFILE. +proc check_types { testname } { + gdb_test "info types foo" \ + [multi_line \ + "File (?:\[^\r\n\]+/)?[string_to_regexp $::srcfile]:" \ + "${::struct_foo_lineno}:\\s+struct foo;" \ + "${::typedef_foo_lineno}:\\s+typedef struct foo foo;"] \ + "$testname, check foo" + + gdb_test "info types bar" \ + [multi_line \ + "File (?:\[^\r\n\]+/)?[string_to_regexp $::srcfile]:" \ + "${::struct_bar_lineno}:\\s+struct bar;" \ + "${::typedef_bar_lineno}:\\s+typedef struct foo bar;"] \ + "$testname, check bar" + + gdb_test "info types baz" \ + [multi_line \ + "File (?:\[^\r\n\]+/)?[string_to_regexp $::srcfile]:" \ + "${::baz_lineno}:\\s+struct baz;" \ + "${::baz_lineno}:\\s+typedef struct baz baz;"] \ + "$testname, check baz" +} + +check_types "before inferior is started" + +clean_restart $testfile + +if {![runto_main]} { + return +} + +check_types "after starting the inferior" diff --git a/gdb/testsuite/gdb.base/type-opaque-lib.c b/gdb/testsuite/gdb.base/type-opaque-lib.c index 70626cb..56c1977 100644 --- a/gdb/testsuite/gdb.base/type-opaque-lib.c +++ b/gdb/testsuite/gdb.base/type-opaque-lib.c @@ -1,6 +1,6 @@ /* Test resolving of an opaque type from the loaded shared library. - Copyright 2007-2024 Free Software Foundation, Inc. + Copyright 2007-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -18,37 +18,37 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ struct struct_libtype_opaque -{ +{ int libfield_opaque; }; struct struct_libtype_opaque struct_libtype_opaque_use; struct struct_libtype_empty -{ +{ int libfield_empty; }; struct struct_libtype_empty struct_libtype_empty_use; struct struct_libtype_filled -{ +{ int libfield_filled; }; struct struct_libtype_filled struct_libtype_filled_use; union union_libtype_opaque -{ +{ int libfield_opaque; }; union union_libtype_opaque union_libtype_opaque_use; union union_libtype_empty -{ +{ int libfield_empty; }; union union_libtype_empty union_libtype_empty_use; union union_libtype_filled -{ +{ int libfield_filled; }; union union_libtype_filled union_libtype_filled_use; diff --git a/gdb/testsuite/gdb.base/type-opaque-main.c b/gdb/testsuite/gdb.base/type-opaque-main.c index 4b67d14..8696966 100644 --- a/gdb/testsuite/gdb.base/type-opaque-main.c +++ b/gdb/testsuite/gdb.base/type-opaque-main.c @@ -1,6 +1,6 @@ /* Test resolving of an opaque type from the loaded shared library. - Copyright 2007-2024 Free Software Foundation, Inc. + Copyright 2007-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -21,23 +21,23 @@ struct struct_libtype_opaque; struct struct_libtype_empty { - }; + }; struct struct_libtype_filled { long mainfield_filled; - }; + }; union union_libtype_opaque; union union_libtype_empty { - }; + }; union union_libtype_filled { long mainfield_filled; - }; + }; int main (void) { diff --git a/gdb/testsuite/gdb.base/type-opaque.exp b/gdb/testsuite/gdb.base/type-opaque.exp index 01ed4a0..dc4406a 100644 --- a/gdb/testsuite/gdb.base/type-opaque.exp +++ b/gdb/testsuite/gdb.base/type-opaque.exp @@ -1,4 +1,4 @@ -# Copyright 2004-2024 Free Software Foundation, Inc. +# Copyright 2004-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 @@ -26,13 +26,15 @@ set execsrc "${srcdir}/${subdir}/${srcfile}" remote_exec build "rm -f ${binfile}" -if { [gdb_compile_shlib $libsrc $libobj {debug}] != "" - || [gdb_compile $execsrc ${binfile} executable \ - [list debug shlib=${libobj}]] != "" } { - return -1 +if { [build_executable "build shlib" $libobj $libsrc {debug shlib}] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $execsrc \ + [list debug shlib=${libobj}]] != 0 } { + return } -clean_restart ${binfile} gdb_load_shlib ${libobj} if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/ui-redirect.exp b/gdb/testsuite/gdb.base/ui-redirect.exp index ed10916..c758697 100644 --- a/gdb/testsuite/gdb.base/ui-redirect.exp +++ b/gdb/testsuite/gdb.base/ui-redirect.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2010-2024 Free Software Foundation, Inc. +# Copyright (C) 2010-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 @@ -20,7 +20,7 @@ if { [prepare_for_testing "failed to prepare" ui-redirect start.c] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/unload.c b/gdb/testsuite/gdb.base/unload.c index 7173de8..7c6edfb 100644 --- a/gdb/testsuite/gdb.base/unload.c +++ b/gdb/testsuite/gdb.base/unload.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 @@ -41,7 +41,7 @@ int main() const char *msg; handle = dlopen (SHLIB_NAME, RTLD_LAZY); - + if (!handle) { fprintf (stderr, "%s\n", dlerror ()); @@ -68,7 +68,7 @@ int main() /* The second library should share the same memory address. */ handle = dlopen (SHLIB_NAME2, RTLD_LAZY); - + if (!handle) { fprintf (stderr, "%s\n", dlerror ()); diff --git a/gdb/testsuite/gdb.base/unload.exp b/gdb/testsuite/gdb.base/unload.exp index 8f129c7..7024faa 100644 --- a/gdb/testsuite/gdb.base/unload.exp +++ b/gdb/testsuite/gdb.base/unload.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 @@ -40,17 +40,21 @@ set lib_dlopen2 [shlib_target_file ${libname2}] set lib_syms [shlib_symbol_file ${libname}] set lib_syms2 [shlib_symbol_file ${libname2}] -set lib_opts debug +set lib_opts {debug shlib} set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME=\"${lib_dlopen}\" additional_flags=-DSHLIB_NAME2=\"${lib_dlopen2}\"] -if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != "" - || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != "" - || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build shlib 1" $lib_sl $libsrc $lib_opts] != 0 } { + return +} + +if { [build_executable "build shlib 2" $lib_sl2 $libsrc2 $lib_opts] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } { + return } -clean_restart $binfile gdb_load_shlib $lib_sl gdb_load_shlib $lib_sl2 diff --git a/gdb/testsuite/gdb.base/unloadshr.c b/gdb/testsuite/gdb.base/unloadshr.c index 708e9bc..e48de39 100644 --- a/gdb/testsuite/gdb.base/unloadshr.c +++ b/gdb/testsuite/gdb.base/unloadshr.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/unloadshr2.c b/gdb/testsuite/gdb.base/unloadshr2.c index f35a196..1bc6abd 100644 --- a/gdb/testsuite/gdb.base/unloadshr2.c +++ b/gdb/testsuite/gdb.base/unloadshr2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/until-nodebug.exp b/gdb/testsuite/gdb.base/until-nodebug.exp index 6445a6c..bd327a10 100644 --- a/gdb/testsuite/gdb.base/until-nodebug.exp +++ b/gdb/testsuite/gdb.base/until-nodebug.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -22,7 +22,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile nodebug]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.base/until-trailing-insns.c b/gdb/testsuite/gdb.base/until-trailing-insns.c index 4ddcf39..3f6d416 100644 --- a/gdb/testsuite/gdb.base/until-trailing-insns.c +++ b/gdb/testsuite/gdb.base/until-trailing-insns.c @@ -1,4 +1,4 @@ -/* Copyright 2022-2024 Free Software Foundation, Inc. +/* Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/until-trailing-insns.exp b/gdb/testsuite/gdb.base/until-trailing-insns.exp index ffd5df8..4456812 100644 --- a/gdb/testsuite/gdb.base/until-trailing-insns.exp +++ b/gdb/testsuite/gdb.base/until-trailing-insns.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 @@ -100,16 +100,16 @@ Dwarf::assemble $asm_file { cu {} { compile_unit { - {language @DW_LANG_C} - {name until-trailing-isns.c} - {stmt_list $L DW_FORM_sec_offset} - {low_pc 0 addr} + DW_AT_language @DW_LANG_C + DW_AT_name until-trailing-isns.c + DW_AT_stmt_list $L DW_FORM_sec_offset + DW_AT_low_pc 0 addr } { subprogram { - {external 1 flag} - {name main} - {low_pc $main_start addr} - {high_pc $main_len DW_FORM_data4} + DW_AT_external 1 flag + DW_AT_name main + DW_AT_low_pc $main_start addr + DW_AT_high_pc $main_len DW_FORM_data4 } } } @@ -160,7 +160,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \ return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/until.exp b/gdb/testsuite/gdb.base/until.exp index 046ccdb..1768c5a 100644 --- a/gdb/testsuite/gdb.base/until.exp +++ b/gdb/testsuite/gdb.base/until.exp @@ -1,4 +1,4 @@ -# Copyright 2003-2024 Free Software Foundation, Inc. +# Copyright 2003-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 @@ -72,4 +72,3 @@ delete_breakpoints gdb_test "until marker3" \ "($hex in |)main.*argc.*argv.*envp.*at.*${srcfile}:($bp_location20.*marker2 \\(43\\)|$bp_location21.*marker3 \\(.stack., .trace.\\)).*" \ "until func, not called by current frame" - diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64-2.exp b/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64-2.exp index b187b56..0e307d3 100644 --- a/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64-2.exp +++ b/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64-2.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 @@ -27,7 +27,7 @@ lappend srcfile_flags nopie set ldflags $srcfile_flags -if [info exists COMPILE] { +if {[info exists COMPILE]} { # Make sure that we use .eh_frame info, by generating it # using -fasynchronous-unwind-tables. if { [gdb_can_simple_compile fasynchronous-unwind-tables \ diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64-2.s b/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64-2.s index c141f71..582bb75 100644 --- a/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64-2.s +++ b/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64-2.s @@ -20,7 +20,7 @@ foo: nop popq %rbp .cfi_def_cfa 7, 8 -# SUCC: EXIT [100.0%] +# SUCC: EXIT [100.0%] ret .cfi_endproc .LFE0: @@ -45,7 +45,7 @@ bar: nop leave .cfi_def_cfa 7, 8 -# SUCC: EXIT [100.0%] +# SUCC: EXIT [100.0%] ret .cfi_endproc .LFE1: diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64.exp b/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64.exp index 0a2cd95..08944f9 100644 --- a/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64.exp +++ b/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 @@ -24,7 +24,7 @@ lappend srcfile_flags nopie set srcfile2_flags $srcfile_flags set ldflags $srcfile_flags -if [info exists COMPILE] { +if {[info exists COMPILE]} { standard_testfile unwind-on-each-insn.c unwind-on-each-insn-foo.c # When updating the .s file, use these flags to generate the file: #lappend srcfile2_flags additional_flags=-save-temps diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64.s b/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64.s index 0def4f6..d4d67f9 100644 --- a/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64.s +++ b/gdb/testsuite/gdb.base/unwind-on-each-insn-amd64.s @@ -22,7 +22,7 @@ foo: nop popq %rbp #.cfi_def_cfa 7, 8 -# SUCC: EXIT [100.0%] +# SUCC: EXIT [100.0%] ret .cfi_endproc .LFE0: @@ -53,7 +53,7 @@ bar: nop leave #.cfi_def_cfa 7, 8 -# SUCC: EXIT [100.0%] +# SUCC: EXIT [100.0%] ret .cfi_endproc .LFE1: diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn-foo.c b/gdb/testsuite/gdb.base/unwind-on-each-insn-foo.c index 5591eea..5798a69 100644 --- a/gdb/testsuite/gdb.base/unwind-on-each-insn-foo.c +++ b/gdb/testsuite/gdb.base/unwind-on-each-insn-foo.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn-i386.exp b/gdb/testsuite/gdb.base/unwind-on-each-insn-i386.exp index 7d00a1e..0285c54 100644 --- a/gdb/testsuite/gdb.base/unwind-on-each-insn-i386.exp +++ b/gdb/testsuite/gdb.base/unwind-on-each-insn-i386.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 @@ -24,7 +24,7 @@ lappend srcfile_flags nopie set srcfile2_flags $srcfile_flags set ldflags $srcfile_flags -if [info exists COMPILE] { +if {[info exists COMPILE]} { standard_testfile unwind-on-each-insn.c unwind-on-each-insn-foo.c # When updating the .s file, use these flags to generate the file: #lappend srcfile2_flags additional_flags=-save-temps diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn-i386.s b/gdb/testsuite/gdb.base/unwind-on-each-insn-i386.s index d0f96be..1714326 100644 --- a/gdb/testsuite/gdb.base/unwind-on-each-insn-i386.s +++ b/gdb/testsuite/gdb.base/unwind-on-each-insn-i386.s @@ -22,7 +22,7 @@ foo: popl %ebp .cfi_restore 5 # .cfi_def_cfa 4, 4 -# SUCC: EXIT [100.0%] +# SUCC: EXIT [100.0%] ret .cfi_endproc .LFE0: @@ -52,7 +52,7 @@ bar: leave .cfi_restore 5 # .cfi_def_cfa 4, 4 -# SUCC: EXIT [100.0%] +# SUCC: EXIT [100.0%] ret .cfi_endproc .LFE1: diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn.c b/gdb/testsuite/gdb.base/unwind-on-each-insn.c index dd1d367..16fca03 100644 --- a/gdb/testsuite/gdb.base/unwind-on-each-insn.c +++ b/gdb/testsuite/gdb.base/unwind-on-each-insn.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2022-2024 Free Software Foundation, Inc. + Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn.exp b/gdb/testsuite/gdb.base/unwind-on-each-insn.exp index 5f1a045..b826fa9 100644 --- a/gdb/testsuite/gdb.base/unwind-on-each-insn.exp +++ b/gdb/testsuite/gdb.base/unwind-on-each-insn.exp @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn.exp.tcl b/gdb/testsuite/gdb.base/unwind-on-each-insn.exp.tcl index ceedfea..9318d59 100644 --- a/gdb/testsuite/gdb.base/unwind-on-each-insn.exp.tcl +++ b/gdb/testsuite/gdb.base/unwind-on-each-insn.exp.tcl @@ -1,4 +1,4 @@ -# Copyright 2022-2024 Free Software Foundation, Inc. +# Copyright 2022-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 diff --git a/gdb/testsuite/gdb.base/unwindonsignal.c b/gdb/testsuite/gdb.base/unwindonsignal.c index 4de1bde..3addb44 100644 --- a/gdb/testsuite/gdb.base/unwindonsignal.c +++ b/gdb/testsuite/gdb.base/unwindonsignal.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/unwindonsignal.exp b/gdb/testsuite/gdb.base/unwindonsignal.exp index 3179355..2d402fe 100644 --- a/gdb/testsuite/gdb.base/unwindonsignal.exp +++ b/gdb/testsuite/gdb.base/unwindonsignal.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/user-namespace-attach.c b/gdb/testsuite/gdb.base/user-namespace-attach.c new file mode 100644 index 0000000..684ce1c --- /dev/null +++ b/gdb/testsuite/gdb.base/user-namespace-attach.c @@ -0,0 +1,35 @@ +/* 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/>. */ + +#include <sys/types.h> +#include <unistd.h> +#include <stdio.h> + +volatile int spin_p = 1; + +int +main () +{ + alarm (60); + + printf ("pid = %lld\n", ((long long) getpid ())); + + while (spin_p) + sleep (1); + + return 0; +} diff --git a/gdb/testsuite/gdb.base/user-namespace-attach.exp b/gdb/testsuite/gdb.base/user-namespace-attach.exp new file mode 100644 index 0000000..741093c --- /dev/null +++ b/gdb/testsuite/gdb.base/user-namespace-attach.exp @@ -0,0 +1,148 @@ +# 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/>. + +# Check that GDB can attach to a process started using 'unshare'. The +# inferior is started in a separate mnt namespace. + +require can_spawn_for_attach + +standard_testfile + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile] == -1} { + return +} + +# This test relies (at least in some parts) on the sysroot being +# 'target:'. Grab the current sysroot now so we can skip those tests +# if the board file has changed the sysroot. +set sysroot "" +set test "show sysroot" +gdb_test_multiple $test $test { + -re -wrap "The current system root is \"(.*)\"\\." { + set sysroot $expect_out(1,string) + } +} + +# Start a process using 'unshare FLAGS', then attach to the process +# from GDB. Check that the attach worked as expected. +proc run_test { flags } { + + # If FLAGS contains '--mount' then a separate mnt namespace will + # be created, in which case the executable will have been read + # from the 'target:'. Otherwise, the executable will have been + # read from the local filesystem, and there will be no prefix. + # + # Of course, this only applies if the sysroot is 'target:', some + # boards change this, so skip these tests on those boards. + if { [lsearch -exact [split $flags " "] "--mount"] != -1 } { + if { $::sysroot ne "target:" } { + return + } + + set prefix "target:" + } else { + set prefix "" + } + + set unshare_cmd "unshare $flags" + + # Run '/bin/true' using UNSHARE_CMD. If the flags in UNSHARE_CMD + # aren't supported then this will fail, this means we shouldn't + # spawn the command with our test executable and try attaching. + # + # This will also fail if /bin/true isn't present, or doesn't work + # as we expect. But this should be fine for many targets. + set res [remote_exec target "$unshare_cmd /bin/true"] + if { [lindex $res 0] != 0 } { + unsupported "unshare flags not supported" + return + } + + set inferior_spawn_id \ + [spawn_wait_for_attach [list "$unshare_cmd $::binfile"]] + if { $inferior_spawn_id == -1 } { + unsupported "failed to spawn for attach" + return + } + + set inferior_pid [spawn_id_get_pid $inferior_spawn_id] + + clean_restart + + set saw_bad_warning false + gdb_test_multiple "attach $inferior_pid" "attach to inferior" { + -re "^attach $::decimal\r\n" { + exp_continue + } + + -re "^warning: \[^\r\n\]+: could not open as an executable file: \[^\r\n\]+\r\n" { + set saw_bad_warning true + exp_continue + } + + -re "^warning: \[^\r\n\]+: can't open to read symbols: \[^\r\n\]+\r\n" { + set saw_bad_warning true + exp_continue + } + + -re "^warning: Could not load vsyscall page because no executable was specified\r\n" { + # This warning is a secondary consequence of the above bad + # warnings, so don't count this as a bad warnings, ignore + # it instead. + exp_continue + } + + -re "^warning:\\s+$::decimal\\s*\[^\r\n\]+: No such file or directory\r\n" { + # This unrelated warning is seen when GDB stops in libc, + # and the source code for libc is not available. + exp_continue + } + + -re "^warning: \[^\r\n\]+\r\n" { + # If we ignore "other" warnings then, should the above + # warnings strings change we'll start ignoring the bad + # warnings, and the test will appear to pass. + # + # If you are seeing a warning here that really has nothing + # to do with the test failing, then the correct solution + # is to add a new regexp to specifically match _that_ + # warning, and ignore it. + set saw_bad_warning true + exp_continue + } + + -re "^$::gdb_prompt $" { + gdb_assert { !$saw_bad_warning } $gdb_test_name + } + + -re "^\[^\r\n\]*\r\n" { + exp_continue + } + } + + # Ensure GDB could access the executable. + set binfile_re [string_to_regexp $::binfile] + gdb_test "info inferiors" \ + "\r\n\\*\\s+$::decimal\\s+\[^\r\n\]+\\s+${prefix}${binfile_re}\\s*" +} + +set test_flags [list \ + "--mount --map-root-user" \ + "--user" \ + "--user --map-root-user"] + +foreach_with_prefix flags $test_flags { + run_test $flags +} diff --git a/gdb/testsuite/gdb.base/utf8-identifiers.c b/gdb/testsuite/gdb.base/utf8-identifiers.c index f887459..e0c3fd3 100644 --- a/gdb/testsuite/gdb.base/utf8-identifiers.c +++ b/gdb/testsuite/gdb.base/utf8-identifiers.c @@ -2,7 +2,7 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/utf8-identifiers.exp b/gdb/testsuite/gdb.base/utf8-identifiers.exp index 0f9c6a3..8d19dbc 100644 --- a/gdb/testsuite/gdb.base/utf8-identifiers.exp +++ b/gdb/testsuite/gdb.base/utf8-identifiers.exp @@ -2,7 +2,7 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -23,7 +23,7 @@ load_lib completion-support.exp if { [is_c_compiler_gcc] } { # Gcc fully supports fextended-identifiers starting GCC 5. - require {expr [gcc_major_version] >= 5} + require {expr {[gcc_major_version] >= 5}} } require {have_host_locale C.UTF-8} @@ -36,7 +36,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} [list $srcfile]] } { return -1 } -if ![runto done] { +if {![runto done]} { return } diff --git a/gdb/testsuite/gdb.base/valgrind-bt.c b/gdb/testsuite/gdb.base/valgrind-bt.c index cd03723..b0aea95 100644 --- a/gdb/testsuite/gdb.base/valgrind-bt.c +++ b/gdb/testsuite/gdb.base/valgrind-bt.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/valgrind-bt.exp b/gdb/testsuite/gdb.base/valgrind-bt.exp index b3f3c09..f885419 100644 --- a/gdb/testsuite/gdb.base/valgrind-bt.exp +++ b/gdb/testsuite/gdb.base/valgrind-bt.exp @@ -1,4 +1,4 @@ -# Copyright 2009-2024 Free Software Foundation, Inc. +# Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/valgrind-disp-step.c b/gdb/testsuite/gdb.base/valgrind-disp-step.c index b95b5f4..6350ec6 100644 --- a/gdb/testsuite/gdb.base/valgrind-disp-step.c +++ b/gdb/testsuite/gdb.base/valgrind-disp-step.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2015-2024 Free Software Foundation, Inc. + Copyright 2015-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 diff --git a/gdb/testsuite/gdb.base/valgrind-disp-step.exp b/gdb/testsuite/gdb.base/valgrind-disp-step.exp index 00918d6..d76c3b4 100644 --- a/gdb/testsuite/gdb.base/valgrind-disp-step.exp +++ b/gdb/testsuite/gdb.base/valgrind-disp-step.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/valgrind-infcall-2.c b/gdb/testsuite/gdb.base/valgrind-infcall-2.c index cb77aca..89f18e8 100644 --- a/gdb/testsuite/gdb.base/valgrind-infcall-2.c +++ b/gdb/testsuite/gdb.base/valgrind-infcall-2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/valgrind-infcall-2.exp b/gdb/testsuite/gdb.base/valgrind-infcall-2.exp index 857e434..bc8a4bd 100644 --- a/gdb/testsuite/gdb.base/valgrind-infcall-2.exp +++ b/gdb/testsuite/gdb.base/valgrind-infcall-2.exp @@ -1,4 +1,4 @@ -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/valgrind-infcall.c b/gdb/testsuite/gdb.base/valgrind-infcall.c index 1903941..c3e025a 100644 --- a/gdb/testsuite/gdb.base/valgrind-infcall.c +++ b/gdb/testsuite/gdb.base/valgrind-infcall.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2012-2024 Free Software Foundation, Inc. + Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/valgrind-infcall.exp b/gdb/testsuite/gdb.base/valgrind-infcall.exp index 229425e..3b06c1d 100644 --- a/gdb/testsuite/gdb.base/valgrind-infcall.exp +++ b/gdb/testsuite/gdb.base/valgrind-infcall.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 @@ -54,7 +54,7 @@ while {$loop && $continue_count < 100} { pass "$test (false warning)" } } - set continue_count [expr $continue_count + 1] + set continue_count [expr {$continue_count + 1}] } set test "p gdb_test_infcall ()" diff --git a/gdb/testsuite/gdb.base/value-double-free.c b/gdb/testsuite/gdb.base/value-double-free.c index ebf4726..0332f8d 100644 --- a/gdb/testsuite/gdb.base/value-double-free.c +++ b/gdb/testsuite/gdb.base/value-double-free.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/value-double-free.exp b/gdb/testsuite/gdb.base/value-double-free.exp index e577152..8395b97 100644 --- a/gdb/testsuite/gdb.base/value-double-free.exp +++ b/gdb/testsuite/gdb.base/value-double-free.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 @@ -27,7 +27,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/value-history-unavailable.c b/gdb/testsuite/gdb.base/value-history-unavailable.c index b11498e..5ee20e4 100644 --- a/gdb/testsuite/gdb.base/value-history-unavailable.c +++ b/gdb/testsuite/gdb.base/value-history-unavailable.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright (C) 2023-2024 Free Software Foundation, Inc. + Copyright (C) 2023-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 diff --git a/gdb/testsuite/gdb.base/value-history-unavailable.exp b/gdb/testsuite/gdb.base/value-history-unavailable.exp index 8dc25db..6794953 100644 --- a/gdb/testsuite/gdb.base/value-history-unavailable.exp +++ b/gdb/testsuite/gdb.base/value-history-unavailable.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2023-2024 Free Software Foundation, Inc. +# Copyright (C) 2023-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 @@ -27,11 +27,11 @@ if {![runto_main]} { set target_char_mask [get_valueof "/u" "a.x\[0]" "255" "get target char mask"] set target_char_bit 0 -for {set i $target_char_mask} {$i > 0} {set i [expr $i >> 1]} { +for {set i $target_char_mask} {$i > 0} {set i [expr {$i >> 1}]} { incr target_char_bit } set target_char_rank -1 -for {set i $target_char_bit} {$i > 0} {set i [expr $i >> 1]} { +for {set i $target_char_bit} {$i > 0} {set i [expr {$i >> 1}]} { incr target_char_rank } diff --git a/gdb/testsuite/gdb.base/varargs.c b/gdb/testsuite/gdb.base/varargs.c index e0083c7..8613b05 100644 --- a/gdb/testsuite/gdb.base/varargs.c +++ b/gdb/testsuite/gdb.base/varargs.c @@ -1,4 +1,4 @@ -/* varargs.c - +/* varargs.c - * (Added as part of fix for bug 15306 - "call" to varargs functions fails) * This program is intended to let me try out "call" to varargs functions * with varying numbers of declared args and various argument types. @@ -80,7 +80,7 @@ test (void) dd = 2.0; dmax_val = find_max_double(3, 1.0, 4.0, 2.0); dmax_val = find_max_double(a, db, dc, dd); - + return 0; } diff --git a/gdb/testsuite/gdb.base/varargs.exp b/gdb/testsuite/gdb.base/varargs.exp index 6923ca8..ef07d4c 100644 --- a/gdb/testsuite/gdb.base/varargs.exp +++ b/gdb/testsuite/gdb.base/varargs.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -36,26 +36,20 @@ set allow_float_test [allow_float_test] set flags {} lappend flags debug lappend_include_file flags $srcdir/lib/unbuffer_output.c -if [support_complex_tests] { +if {[support_complex_tests]} { lappend flags "additional_flags=-DTEST_COMPLEX" } -# build the first test case -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ - executable $flags] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile $flags] != 0 } { + return } -# Start with a fresh gdb. - -clean_restart ${binfile} gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set print address off" gdb_test_no_output "set width 0" -if [gdb_skip_stdio_test "varargs.exp"] { +if {[gdb_skip_stdio_test "varargs.exp"]} { # Nothing in this module is testable without printf. return } @@ -92,7 +86,7 @@ if {$allow_float_test} { # Test _Complex type here if supported. -if [support_complex_tests] { +if {[support_complex_tests]} { global gdb_prompt set test "print find_max_float_real(4, fc1, fc2, fc3, fc4)" diff --git a/gdb/testsuite/gdb.base/vdso-warning.c b/gdb/testsuite/gdb.base/vdso-warning.c index c38538d..120c08d 100644 --- a/gdb/testsuite/gdb.base/vdso-warning.c +++ b/gdb/testsuite/gdb.base/vdso-warning.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/vdso-warning.exp b/gdb/testsuite/gdb.base/vdso-warning.exp index cf7fe9b..ea5f492 100644 --- a/gdb/testsuite/gdb.base/vdso-warning.exp +++ b/gdb/testsuite/gdb.base/vdso-warning.exp @@ -1,4 +1,4 @@ -# Copyright 2012-2024 Free Software Foundation, Inc. +# Copyright 2012-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 diff --git a/gdb/testsuite/gdb.base/vfork-follow-parent.c b/gdb/testsuite/gdb.base/vfork-follow-parent.c index ca0f07a..6889ebf 100644 --- a/gdb/testsuite/gdb.base/vfork-follow-parent.c +++ b/gdb/testsuite/gdb.base/vfork-follow-parent.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/vfork-follow-parent.exp b/gdb/testsuite/gdb.base/vfork-follow-parent.exp index d9fa88b..8cb785d 100644 --- a/gdb/testsuite/gdb.base/vfork-follow-parent.exp +++ b/gdb/testsuite/gdb.base/vfork-follow-parent.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 @@ -19,6 +19,8 @@ # schedule-multiple on" or "set detach-on-fork on". Test these two resolution # methods. +require allow_fork_tests + standard_testfile .c vforked-prog.c set binfile ${testfile}-exit diff --git a/gdb/testsuite/gdb.base/vforked-prog.c b/gdb/testsuite/gdb.base/vforked-prog.c index 02dd9a2..6222b14 100644 --- a/gdb/testsuite/gdb.base/vforked-prog.c +++ b/gdb/testsuite/gdb.base/vforked-prog.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1997-2024 Free Software Foundation, Inc. + Copyright 1997-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 diff --git a/gdb/testsuite/gdb.base/vla-datatypes.c b/gdb/testsuite/gdb.base/vla-datatypes.c index 6241e7e..859929a 100644 --- a/gdb/testsuite/gdb.base/vla-datatypes.c +++ b/gdb/testsuite/gdb.base/vla-datatypes.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/vla-datatypes.exp b/gdb/testsuite/gdb.base/vla-datatypes.exp index b46340a..e3413ad 100644 --- a/gdb/testsuite/gdb.base/vla-datatypes.exp +++ b/gdb/testsuite/gdb.base/vla-datatypes.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -19,7 +19,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } @@ -38,9 +38,9 @@ gdb_test "print short_vla" " = \\\{0, 2, 4, 6, 8\\\}" gdb_test "print unsigned_short_vla" " = \\\{0, 2, 4, 6, 8\\\}" gdb_test "print unsigned_char_vla" " = \"AAAAA\"" gdb_test "print foo_vla" \ - "\\\{\\\{a = 0\\\}, \\\{a = 2\\\}, \\\{a = 4\\\}, \\\{a = 6\\\}, \\\{a = 8\\\}\\\}" + "\\\{\\\{a = 0\\\}, \\\{a = 2\\\}, \\\{a = 4\\\}, \\\{a = 6\\\}, \\\{a = 8\\\}\\\}" gdb_test "print bar_vla" \ - "\\\{\\\{x = 0, y = \\\{a = 0\\\}\\\}, \\\{x = 2, y = \\\{a = 2\\\}\\\}, \\\{x = 4, y = \\\{a = 4\\\}\\\}, \\\{x = 6, y = \\\{a = 6\\\}\\\}, \\\{x = 8, y = \\\{a = 8\\\}\\\}\\\}" + "\\\{\\\{x = 0, y = \\\{a = 0\\\}\\\}, \\\{x = 2, y = \\\{a = 2\\\}\\\}, \\\{x = 4, y = \\\{a = 4\\\}\\\}, \\\{x = 6, y = \\\{a = 6\\\}\\\}, \\\{x = 8, y = \\\{a = 8\\\}\\\}\\\}" # Check whatis of VLA's. gdb_test "whatis int_vla" "type = int \\\[5\\\]" @@ -49,11 +49,11 @@ gdb_test "whatis double_vla" "type = double \\\[5\\\]" gdb_test "whatis float_vla" "type = float \\\[5\\\]" gdb_test "whatis long_vla" "type = long( int)? \\\[5\\\]" gdb_test "whatis unsigned_long_vla" \ - "type = (long unsigned int|unsigned long) \\\[5\\\]" + "type = (long unsigned int|unsigned long) \\\[5\\\]" gdb_test "whatis char_vla" "type = char \\\[5\\\]" gdb_test "whatis short_vla" "type = short( int)? \\\[5\\\]" gdb_test "whatis unsigned_short_vla" \ - "type = (short unsigned int|unsigned short) \\\[5\\\]" + "type = (short unsigned int|unsigned short) \\\[5\\\]" gdb_test "whatis unsigned_char_vla" "type = unsigned char \\\[5\\\]" gdb_test "whatis foo_vla" "type = struct foo \\\[5\\\]" gdb_test "whatis bar_vla" "type = BAR \\\[5\\\]" @@ -71,44 +71,44 @@ gdb_test "ptype unsigned_short_vla" "type = unsigned short \\\[5\\\]" gdb_test "ptype unsigned_char_vla" "type = unsigned char \\\[5\\\]" gdb_test "ptype foo_vla" "type = struct foo {\r\n\\s+int a;\r\n} \\\[5\\\]" gdb_test "ptype bar_vla" \ - "type = struct bar {\r\n\\s+int x;\r\n\\s+struct foo y;\r\n} \\\[5\\\]" + "type = struct bar {\r\n\\s+int x;\r\n\\s+struct foo y;\r\n} \\\[5\\\]" # Check the size of the VLA's. gdb_breakpoint [gdb_get_line_number "break_end_of_vla_factory"] gdb_continue_to_breakpoint "break_end_of_vla_factory" gdb_test "print int_size == sizeof(int_vla)" " = 1" "size of int_vla" gdb_test "print uint_size == sizeof(unsigned_int_vla)" " = 1" \ - "size of unsigned_int_vla" + "size of unsigned_int_vla" gdb_test "print double_size == sizeof(double_vla)" " = 1" \ - "size of double_vla" + "size of double_vla" gdb_test "print float_size == sizeof(float_vla)" " = 1" \ - "size of float_vla" + "size of float_vla" gdb_test "print long_size == sizeof(long_vla)" " = 1" \ - "size of long_vla" + "size of long_vla" gdb_test "print char_size == sizeof(char_vla)" " = 1" \ - "size of char_vla" + "size of char_vla" gdb_test "print short_size == sizeof(short_vla)" " = 1" \ - "size of short_vla" + "size of short_vla" gdb_test "print ushort_size == sizeof(unsigned_short_vla)" " = 1" \ - "size of unsigned_short_vla" + "size of unsigned_short_vla" gdb_test "print uchar_size == sizeof(unsigned_char_vla)" " = 1" \ - "size of unsigned_char_vla" + "size of unsigned_char_vla" gdb_test "print foo_size == sizeof(foo_vla)" " = 1" "size of foo_vla" gdb_test "print bar_size == sizeof(bar_vla)" " = 1" "size of bar_vla" # Check side effects for sizeof argument. set sizeof_int [get_sizeof "int" 4] gdb_test_no_output "set variable int_vla\[0\] = 42" \ - "set variable int_vla\[0\] = 42" + "set variable int_vla\[0\] = 42" gdb_test "print sizeof (++int_vla\[0\])" " = ${sizeof_int}" gdb_test "print int_vla\[0\]" " = 42" \ - "print int_vla\[0\] - sizeof no side effects" + "print int_vla\[0\] - sizeof no side effects" gdb_test "ptype ++int_vla\[0\]" "type = int" gdb_test "print int_vla\[0\]" " = 42" \ - "print int_vla\[0\] - ptype no side effects" + "print int_vla\[0\] - ptype no side effects" gdb_test "whatis ++int_vla\[0\]" "type = int" gdb_test "print int_vla\[0\]" " = 42" \ - "print int_vla\[0\] - whatis no side effects" + "print int_vla\[0\] - whatis no side effects" diff --git a/gdb/testsuite/gdb.base/vla-optimized-out.c b/gdb/testsuite/gdb.base/vla-optimized-out.c index b83b2bf..24ec103 100644 --- a/gdb/testsuite/gdb.base/vla-optimized-out.c +++ b/gdb/testsuite/gdb.base/vla-optimized-out.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/vla-optimized-out.exp b/gdb/testsuite/gdb.base/vla-optimized-out.exp index b57e474..2393ab7 100644 --- a/gdb/testsuite/gdb.base/vla-optimized-out.exp +++ b/gdb/testsuite/gdb.base/vla-optimized-out.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -33,7 +33,7 @@ proc vla_optimized_out {exe_suffix options} { return -1 } - if ![runto f1] { + if {![runto f1]} { return } @@ -89,4 +89,3 @@ foreach {test_prefix options} $test_matrix { vla_optimized_out $test_prefix $options } } - diff --git a/gdb/testsuite/gdb.base/vla-ptr.c b/gdb/testsuite/gdb.base/vla-ptr.c index 31bca8d..58823df 100644 --- a/gdb/testsuite/gdb.base/vla-ptr.c +++ b/gdb/testsuite/gdb.base/vla-ptr.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/vla-ptr.exp b/gdb/testsuite/gdb.base/vla-ptr.exp index df1b8f0..22ac0a3 100644 --- a/gdb/testsuite/gdb.base/vla-ptr.exp +++ b/gdb/testsuite/gdb.base/vla-ptr.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -20,7 +20,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/vla-sideeffect.c b/gdb/testsuite/gdb.base/vla-sideeffect.c index 15cf5c3..11367aa 100644 --- a/gdb/testsuite/gdb.base/vla-sideeffect.c +++ b/gdb/testsuite/gdb.base/vla-sideeffect.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/vla-sideeffect.exp b/gdb/testsuite/gdb.base/vla-sideeffect.exp index 8215ec2..aff9ac0 100644 --- a/gdb/testsuite/gdb.base/vla-sideeffect.exp +++ b/gdb/testsuite/gdb.base/vla-sideeffect.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -22,7 +22,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } @@ -31,23 +31,24 @@ gdb_continue_to_breakpoint "vla-filled" # Check side effects for sizeof argument. set sizeof_int [get_sizeof "int" 4] -set sizeof_vla [ expr "10" * "$sizeof_int" ] + +set sizeof_vla [expr {10 * $sizeof_int}] gdb_test "print sizeof (vla1\[i++\])" " = ${sizeof_int}" gdb_test "print i" " = 0" \ - "print i - sizeof no side effects" + "print i - sizeof no side effects" gdb_test "print sizeof (++vla1\[0\])" " = ${sizeof_int}" gdb_test "print vla1\[0\]" " = 10" \ - "print vla1\[0\] - sizeof no side effects" + "print vla1\[0\] - sizeof no side effects" gdb_test "ptype ++vla1\[0\]" "type = int" gdb_test "print vla1\[0\]" " = 10" \ - "print vla1\[0\] - ptype no side effects" + "print vla1\[0\] - ptype no side effects" gdb_test "whatis ++vla1\[0\]" "type = int" gdb_test "print vla1\[0\]" " = 10" \ - "print vla1\[0\] - whatis no side effects" + "print vla1\[0\] - whatis no side effects" gdb_test "print sizeof (vla2\[i++\])" " = ${sizeof_vla}" @@ -58,7 +59,7 @@ gdb_test "print sizeof (vla2\[i++ + sizeof(j++)\])" " = ${sizeof_vla}" gdb_test "print i" " = 2" \ "print i - sizeof with side effects, 2" gdb_test "print j" " = 0" \ - "print j - sizeof with no side effects" + "print j - sizeof with no side effects" gdb_test "ptype vla2\[i++\]" "type = int \\\[10\\\]" gdb_test "print i" " = 2" \ @@ -68,7 +69,7 @@ gdb_test "ptype vla2\[i++ + sizeof(j++)\]" "type = int \\\[10\\\]" gdb_test "print i" " = 2" \ "print i - ptype with side effects, 2" gdb_test "print j" " = 0" \ - "print j - ptype with no side effects" + "print j - ptype with no side effects" gdb_test "whatis vla2\[i++\]" "type = int \\\[10\\\]" gdb_test "print i" " = 2" \ @@ -78,4 +79,4 @@ gdb_test "whatis vla2\[i++ + sizeof(j++)\]" "type = int \\\[10\\\]" gdb_test "print i" " = 2" \ "print i - whatis with side effects, 2" gdb_test "print j" " = 0" \ - "print j - whatis with no side effects" + "print j - whatis with no side effects" diff --git a/gdb/testsuite/gdb.base/vla-struct-fields.c b/gdb/testsuite/gdb.base/vla-struct-fields.c index bbd0197..62716ea 100644 --- a/gdb/testsuite/gdb.base/vla-struct-fields.c +++ b/gdb/testsuite/gdb.base/vla-struct-fields.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/vla-struct-fields.exp b/gdb/testsuite/gdb.base/vla-struct-fields.exp index deb66fa..72af212 100644 --- a/gdb/testsuite/gdb.base/vla-struct-fields.exp +++ b/gdb/testsuite/gdb.base/vla-struct-fields.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -22,7 +22,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/vla-stub-define.c b/gdb/testsuite/gdb.base/vla-stub-define.c index 2cc6f09..14b83ba 100644 --- a/gdb/testsuite/gdb.base/vla-stub-define.c +++ b/gdb/testsuite/gdb.base/vla-stub-define.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/vla-stub.c b/gdb/testsuite/gdb.base/vla-stub.c index 169469d..babab1d 100644 --- a/gdb/testsuite/gdb.base/vla-stub.c +++ b/gdb/testsuite/gdb.base/vla-stub.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/vla-stub.exp b/gdb/testsuite/gdb.base/vla-stub.exp index 11b4b48..274f821 100644 --- a/gdb/testsuite/gdb.base/vla-stub.exp +++ b/gdb/testsuite/gdb.base/vla-stub.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/volatile.exp b/gdb/testsuite/gdb.base/volatile.exp index ef9a615..e85d415 100644 --- a/gdb/testsuite/gdb.base/volatile.exp +++ b/gdb/testsuite/gdb.base/volatile.exp @@ -1,4 +1,4 @@ -# Copyright 1997-2024 Free Software Foundation, Inc. +# Copyright 1997-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 @@ -27,7 +27,7 @@ # const volatile pointers to const vars # const volatile pointers to volatile vars # ... etc. (you get the idea) -# Mostly with char and unsigned char. +# Mostly with char and unsigned char. # # test running programs @@ -54,7 +54,7 @@ proc local_compiler_xfail_check { } { if {[test_compiler_info gcc-2-*]} { if { ![test_debug_format "HP"] \ && ![test_debug_format "DWARF \[0-9\]"] } then { - setup_xfail "*-*-*" + setup_xfail "*-*-*" } } } diff --git a/gdb/testsuite/gdb.base/warning.exp b/gdb/testsuite/gdb.base/warning.exp index 4d0878e..65b42e7 100644 --- a/gdb/testsuite/gdb.base/warning.exp +++ b/gdb/testsuite/gdb.base/warning.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/watch-before-fork.c b/gdb/testsuite/gdb.base/watch-before-fork.c index 34a5553..d2108d5 100644 --- a/gdb/testsuite/gdb.base/watch-before-fork.c +++ b/gdb/testsuite/gdb.base/watch-before-fork.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2021-2024 Free Software Foundation, Inc. + Copyright 2021-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 diff --git a/gdb/testsuite/gdb.base/watch-before-fork.exp b/gdb/testsuite/gdb.base/watch-before-fork.exp index 6cf06df..509561e 100644 --- a/gdb/testsuite/gdb.base/watch-before-fork.exp +++ b/gdb/testsuite/gdb.base/watch-before-fork.exp @@ -1,4 +1,4 @@ -# Copyright 2021-2024 Free Software Foundation, Inc. +# Copyright 2021-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 @@ -20,6 +20,8 @@ # This test uses "awatch". require allow_hw_watchpoint_access_tests +require allow_fork_tests + standard_testfile if {[build_executable "failed to prepare" $testfile $srcfile debug]} { diff --git a/gdb/testsuite/gdb.base/watch-bitfields.c b/gdb/testsuite/gdb.base/watch-bitfields.c index 6e62b27..cc967a5 100644 --- a/gdb/testsuite/gdb.base/watch-bitfields.c +++ b/gdb/testsuite/gdb.base/watch-bitfields.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/watch-bitfields.exp b/gdb/testsuite/gdb.base/watch-bitfields.exp index 1c0d808..b53f343 100644 --- a/gdb/testsuite/gdb.base/watch-bitfields.exp +++ b/gdb/testsuite/gdb.base/watch-bitfields.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/watch-cond-infcall.c b/gdb/testsuite/gdb.base/watch-cond-infcall.c index 8ea0d6c..feaef8b 100644 --- a/gdb/testsuite/gdb.base/watch-cond-infcall.c +++ b/gdb/testsuite/gdb.base/watch-cond-infcall.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/watch-cond-infcall.exp b/gdb/testsuite/gdb.base/watch-cond-infcall.exp index 874f6d2..301fd6c 100644 --- a/gdb/testsuite/gdb.base/watch-cond-infcall.exp +++ b/gdb/testsuite/gdb.base/watch-cond-infcall.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/watch-cond.c b/gdb/testsuite/gdb.base/watch-cond.c index e934151..4cde9cc 100644 --- a/gdb/testsuite/gdb.base/watch-cond.c +++ b/gdb/testsuite/gdb.base/watch-cond.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/watch-cond.exp b/gdb/testsuite/gdb.base/watch-cond.exp index 6a6deac..0990f53 100644 --- a/gdb/testsuite/gdb.base/watch-cond.exp +++ b/gdb/testsuite/gdb.base/watch-cond.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/watch-non-mem.c b/gdb/testsuite/gdb.base/watch-non-mem.c index 82ac976..37efe19 100644 --- a/gdb/testsuite/gdb.base/watch-non-mem.c +++ b/gdb/testsuite/gdb.base/watch-non-mem.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/watch-non-mem.exp b/gdb/testsuite/gdb.base/watch-non-mem.exp index 98c2085..5915e7f 100644 --- a/gdb/testsuite/gdb.base/watch-non-mem.exp +++ b/gdb/testsuite/gdb.base/watch-non-mem.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/watch-read.c b/gdb/testsuite/gdb.base/watch-read.c index 694cf67..e66e0f9 100644 --- a/gdb/testsuite/gdb.base/watch-read.c +++ b/gdb/testsuite/gdb.base/watch-read.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/watch-read.exp b/gdb/testsuite/gdb.base/watch-read.exp index f56d84d..8e4d8ba 100644 --- a/gdb/testsuite/gdb.base/watch-read.exp +++ b/gdb/testsuite/gdb.base/watch-read.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/watch-vfork.c b/gdb/testsuite/gdb.base/watch-vfork.c index 03747be..ef9771a 100644 --- a/gdb/testsuite/gdb.base/watch-vfork.c +++ b/gdb/testsuite/gdb.base/watch-vfork.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/watch-vfork.exp b/gdb/testsuite/gdb.base/watch-vfork.exp index f7e268f..503727d 100644 --- a/gdb/testsuite/gdb.base/watch-vfork.exp +++ b/gdb/testsuite/gdb.base/watch-vfork.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2009-2024 Free Software Foundation, Inc. +# Copyright 2009-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 @@ -17,6 +17,8 @@ standard_testfile .c +require allow_fork_tests + if { [build_executable ${testfile}.exp ${testfile} $srcfile {debug}] } { untested "failed to compile" return -1 diff --git a/gdb/testsuite/gdb.base/watch_thread_num.c b/gdb/testsuite/gdb.base/watch_thread_num.c index 9413881..f58f208 100644 --- a/gdb/testsuite/gdb.base/watch_thread_num.c +++ b/gdb/testsuite/gdb.base/watch_thread_num.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2002-2024 Free Software Foundation, Inc. + Copyright 2002-2025 Free Software Foundation, Inc. Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003, 2007, 2008, 2009 Free Software Foundation, Inc. @@ -51,9 +51,9 @@ int main () { for (i = 0; i < NUM; i++) { - res = pthread_create (&threads[i], - NULL, - thread_function, + res = pthread_create (&threads[i], + NULL, + thread_function, (void *) i); } @@ -96,4 +96,3 @@ void *thread_function (void *arg) { pthread_exit (NULL); } - diff --git a/gdb/testsuite/gdb.base/watch_thread_num.exp b/gdb/testsuite/gdb.base/watch_thread_num.exp index 577059b..2031583 100644 --- a/gdb/testsuite/gdb.base/watch_thread_num.exp +++ b/gdb/testsuite/gdb.base/watch_thread_num.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 @@ -27,12 +27,10 @@ require allow_hw_watchpoint_access_tests standard_testfile .c -if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile {debug pthreads}] != 0 } { + return } -clean_restart ${binfile} - if {![runto_main]} { return } @@ -100,4 +98,3 @@ for {set i 1} {$i <= 5} {incr i} { } gdb_test "thread" ".*Current thread is $thread_num .*" $check } - diff --git a/gdb/testsuite/gdb.base/watchpoint-adjacent.c b/gdb/testsuite/gdb.base/watchpoint-adjacent.c new file mode 100644 index 0000000..b9e3a51 --- /dev/null +++ b/gdb/testsuite/gdb.base/watchpoint-adjacent.c @@ -0,0 +1,72 @@ +/* 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/>. */ + +#include <stdint.h> +#include <assert.h> + +typedef unsigned long long type_ll; + +#ifndef VAR_TYPE +# error "VAR_TYPE not defined" +#endif + +/* Place A and B within this wrapper struct. FIRST ensures that A is + (usually) going to start at an 8-byte boundary. The goal here is + that, when VAR_TYPE is less than 8 bytes, both A and B are placed + within the same 8-byte region, and that the region starts at an + 8-byte boundary. */ + +struct wrapper +{ + unsigned long long first; + + VAR_TYPE a, b; +}; + +volatile struct wrapper obj; + +/* Write to obj.a and obj.b, but don't read these fields. */ +void +writer (void) +{ + obj.a = 1; + obj.b = 2; +} + +/* Read from obj.a and obj.b, but don't write to these fields. */ +int +reader (void) +{ + int v = obj.b - obj.a; + v--; + return v; +} + +int +main (void) +{ + /* Ensure that obj.a, obj.b, and obj.c were placed as we needed. */ + assert ((((uintptr_t) &obj.a) & 0x7) == 0); + assert ((((uintptr_t) &obj.a) + sizeof (obj.a)) == (((uintptr_t) &obj.b))); + assert (sizeof (obj.a) == sizeof (obj.b)); + + writer (); + + int val = reader (); /* Break for read test. */ + + return val; +} diff --git a/gdb/testsuite/gdb.base/watchpoint-adjacent.exp b/gdb/testsuite/gdb.base/watchpoint-adjacent.exp new file mode 100644 index 0000000..17bad71 --- /dev/null +++ b/gdb/testsuite/gdb.base/watchpoint-adjacent.exp @@ -0,0 +1,182 @@ +# 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/>. + +# The inferior has two adjacent variables. We add a 'watch' on one +# field, and an 'rwatch' on the other. Running the inferior writes to +# both fields. Check GDB reports the expected 'watch' watchpoint. +# +# Multiple inferiors are compiled, using a variety of types for the +# two fields. + +require allow_hw_watchpoint_multi_tests + +standard_testfile + +# When printing a value, for some variable types, GDB will add a +# suffix containing an alternative representation of the value. For +# example, characters will be printed as decimal, and then as the +# character. +# +# Return a regexp to match the suffix for a variable of VAR_TYPE. +# This doesn't match the specific value contents, it will match all +# possible suffix values for something of VAR_TYPE. +proc get_value_suffix { var_type } { + if { $var_type eq "char" } { + set suffix " '\[^'\]+'" + } else { + set suffix "" + } + + return $suffix +} + +# Start FILENAME, then set a watch and rwatch watchpoint on WATCH_VAR +# and RWATCH_VAR respectively. Continue the inferior and expect to +# see GDB stop due to WATCH_VAR being written too. +proc run_write_test { filename var_type watch_var rwatch_var } { + clean_restart $filename + + if { ![runto_main] } { + return + } + + delete_breakpoints + + gdb_test_no_output "set breakpoint always-inserted on" + + gdb_test "watch obj.$watch_var" \ + "Hardware watchpoint $::decimal: obj.$watch_var" + set wp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*"] + gdb_test "rwatch obj.$rwatch_var" \ + "Hardware read watchpoint $::decimal: obj.$rwatch_var" + + if { $watch_var eq "a" } { + set new_val 1 + } else { + set new_val 2 + } + + set suffix [get_value_suffix $var_type] + + gdb_test "continue" \ + [multi_line \ + "Hardware watchpoint $wp_num: obj.$watch_var" \ + "" \ + "Old value = 0${suffix}" \ + "New value = ${new_val}${suffix}" \ + ".*"] + +} + +# Start FILENAME, continue until the call to the `reader` function in +# the inferior. Then create an 'rwatch' watchpoint on RWATCH var, +# which will be either 'a' or 'b'. Next create 'watch' watchpoints on +# both the 'a' and 'b' variables, watching for writes. +# +# Continue the inferior, both 'a' and 'b' are read, and GDB should stop +# and let us know that we stopped at the 'rwatch' watchpoint. +# +# On some architectures, for some variable sizes, the hardware cannot +# figure out which watchpoint triggered as the hardware might have +# imprecise reporting of watchpoint event addresses. In this case the +# backend code will report the address of all possible watchpoints to +# core GDB. Core GDB will test the 'watch' watchpoints to see if the +# value has changed, and if none have, GDB will report the first +# 'rwatch' watchpoint, assuming that this might be the watchpoint that +# triggered the stop. +proc run_read_test { filename var_type rwatch_var rwatch_first watch_vars } { + clean_restart $filename + + if { ![runto_main] } { + return + } + + gdb_breakpoint [gdb_get_line_number "Break for read test"] + gdb_continue_to_breakpoint "prepare for read test" + delete_breakpoints + + gdb_test_no_output "set breakpoint always-inserted on" + + if { $rwatch_first } { + gdb_test "rwatch obj.${rwatch_var}" \ + "Hardware read watchpoint $::decimal: obj.$rwatch_var" + set wp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*"] + } + + foreach v $watch_vars { + gdb_test "watch obj.$v" \ + "Hardware watchpoint $::decimal: obj.$v" + } + + if { !$rwatch_first } { + gdb_test "rwatch obj.${rwatch_var}" \ + "Hardware read watchpoint $::decimal: obj.$rwatch_var" + set wp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*"] + } + + if { $rwatch_var eq "a" } { + set val 1 + } else { + set val 2 + } + + set suffix [get_value_suffix $var_type] + + gdb_test "continue" \ + [multi_line \ + "Hardware read watchpoint ${wp_num}: obj.$rwatch_var" \ + "" \ + "Value = ${val}${suffix}" \ + ".*"] +} + +# Build a binary using VAR_TYPE as the test variable type. Then call +# run_test twice. +proc build_and_run_test { var_type } { + set filename ${::testfile}-${var_type} + + set flags [list debug additional_flags=-DVAR_TYPE=${var_type}] + if {[build_executable "failed to build" $filename $::srcfile $flags]} { + return + } + + set test_list [list \ + { a {a b} } \ + { b {a b} } \ + { a {b} } \ + { b {a} }] + foreach_with_prefix test $test_list { + set rwatch_var [lindex $test 0] + set watch_vars [lindex $test 1] + + foreach_with_prefix rwatch_first { true false } { + run_read_test $filename $var_type $rwatch_var $rwatch_first $watch_vars + } + } + + foreach test { {a b} {b a} } { + set watch_var [lindex $test 0] + set rwatch_var [lindex $test 1] + + with_test_prefix "watch: ${watch_var}, rwatch: ${rwatch_var}" { + run_write_test $filename $var_type $watch_var $rwatch_var + } + } +} + +# Run the test with a series of different types. +foreach_with_prefix var_type { type_ll int short char float double } { + build_and_run_test $var_type +} diff --git a/gdb/testsuite/gdb.base/watchpoint-cond-gone-stripped.c b/gdb/testsuite/gdb.base/watchpoint-cond-gone-stripped.c index a33f99a..ca88d76 100644 --- a/gdb/testsuite/gdb.base/watchpoint-cond-gone-stripped.c +++ b/gdb/testsuite/gdb.base/watchpoint-cond-gone-stripped.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/watchpoint-cond-gone.c b/gdb/testsuite/gdb.base/watchpoint-cond-gone.c index 2679ddd..4c51a80 100644 --- a/gdb/testsuite/gdb.base/watchpoint-cond-gone.c +++ b/gdb/testsuite/gdb.base/watchpoint-cond-gone.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/watchpoint-cond-gone.exp b/gdb/testsuite/gdb.base/watchpoint-cond-gone.exp index 3d8bb5b..c789c60 100644 --- a/gdb/testsuite/gdb.base/watchpoint-cond-gone.exp +++ b/gdb/testsuite/gdb.base/watchpoint-cond-gone.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -27,7 +27,7 @@ if {[prepare_for_testing_full "failed to prepare" \ # Problem does not occur otherwise. gdb_test_no_output "set can-use-hw-watchpoints 0" -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/watchpoint-delete.c b/gdb/testsuite/gdb.base/watchpoint-delete.c index 706d8b3..a95bb10 100644 --- a/gdb/testsuite/gdb.base/watchpoint-delete.c +++ b/gdb/testsuite/gdb.base/watchpoint-delete.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2010-2024 Free Software Foundation, Inc. + Copyright 2010-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 diff --git a/gdb/testsuite/gdb.base/watchpoint-delete.exp b/gdb/testsuite/gdb.base/watchpoint-delete.exp index c15133b..cdf532f 100644 --- a/gdb/testsuite/gdb.base/watchpoint-delete.exp +++ b/gdb/testsuite/gdb.base/watchpoint-delete.exp @@ -1,4 +1,4 @@ -# Copyright 2010-2024 Free Software Foundation, Inc. +# Copyright 2010-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 @@ -22,7 +22,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { # It is more compatible this way. gdb_test_no_output "set can-use-hw-watchpoints 0" -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-attach.c b/gdb/testsuite/gdb.base/watchpoint-hw-attach.c index 765c2f0..0eed7b3 100644 --- a/gdb/testsuite/gdb.base/watchpoint-hw-attach.c +++ b/gdb/testsuite/gdb.base/watchpoint-hw-attach.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2018-2024 Free Software Foundation, Inc. + Copyright 2018-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 diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp b/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp index ff3585a..a2a6f7a 100644 --- a/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp +++ b/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp @@ -1,4 +1,4 @@ -# Copyright 2018-2024 Free Software Foundation, Inc. +# Copyright 2018-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 @@ -26,29 +26,18 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { return -1 } -if ![runto_main] { - return -1 -} +set test_spawn_id [spawn_wait_for_attach $binfile] +set testpid [spawn_id_get_pid $test_spawn_id] -# Run to the point where mypid in the test program has been -# populated. -gdb_breakpoint [gdb_get_line_number "pidacquired"] -gdb_continue_to_breakpoint "pidacquired" - -# Get the PID of the test process. -set testpid [get_integer_valueof "mypid" 0] +gdb_test "attach $testpid" "Attaching to program: .*, process $testpid.*" "attach once" gdb_test "detach" "Detaching from program: .*, process $testpid\r\n\\\[Inferior $decimal \\(process $testpid\\) detached\\\]" -if {$testpid == ""} { - return -1 -} - # A clean restart is needed to force the hardware watchpoint setup # logic to run post attach rather than post inferior launch. -clean_restart $binfile +clean_restart $testfile -gdb_test "attach $testpid" "Attaching to program: .*, process $testpid.*" "attach" +gdb_test "attach $testpid" "Attaching to program: .*, process $testpid.*" "attach twice" # Ensure the test program is in the top frame so the required # variables are in scope. @@ -62,3 +51,5 @@ gdb_test "watch watched_variable" \ gdb_test "continue" \ "continue.*Continuing.*\.Hardware watchpoint $decimal: watched_variable.*Old value = 0.*New value = 4.*watched_variable\\);" + +kill_wait_spawned_process $test_spawn_id diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.c b/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.c index 8fabd51..3d88b10 100644 --- a/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.c +++ b/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.exp b/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.exp index 2948c90..906654e 100644 --- a/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.exp +++ b/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.exp @@ -1,4 +1,4 @@ -# Copyright 2009-2024 Free Software Foundation, Inc. +# Copyright 2009-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 @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${test} ${srcfile}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/watchpoint-hw.c b/gdb/testsuite/gdb.base/watchpoint-hw.c index 13d395d..0288b91 100644 --- a/gdb/testsuite/gdb.base/watchpoint-hw.c +++ b/gdb/testsuite/gdb.base/watchpoint-hw.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2008-2024 Free Software Foundation, Inc. + Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/watchpoint-hw.exp b/gdb/testsuite/gdb.base/watchpoint-hw.exp index 0755c2e..820a6db 100644 --- a/gdb/testsuite/gdb.base/watchpoint-hw.exp +++ b/gdb/testsuite/gdb.base/watchpoint-hw.exp @@ -1,4 +1,4 @@ -# Copyright 2008-2024 Free Software Foundation, Inc. +# Copyright 2008-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 diff --git a/gdb/testsuite/gdb.base/watchpoint-reuse-slot.c b/gdb/testsuite/gdb.base/watchpoint-reuse-slot.c index 2838785..4b04765 100644 --- a/gdb/testsuite/gdb.base/watchpoint-reuse-slot.c +++ b/gdb/testsuite/gdb.base/watchpoint-reuse-slot.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp b/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp index 6409279..23ef746 100644 --- a/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp +++ b/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp @@ -1,4 +1,4 @@ -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -158,7 +158,7 @@ proc valid_addr_p {cmd offset width} { # registers to represent the whole unaligned region. Breakpoint # addresses must still be aligned though. if {$cmd == "hbreak" } { - if { [expr ($offset) % 4] != 0 } { + if {$offset % 4 != 0} { return 0 } } @@ -170,20 +170,20 @@ proc valid_addr_p {cmd offset width} { } } else { # Watchpoints can be of length 1, 2, 4 or 8 bytes. - if { [expr $width % 2] != 0 } { + if { $width % 2 != 0 } { return 0 } } - if { [expr ($offset) % 8] == 0 && $width == 8 } { + if {$offset % 8 == 0 && $width == 8} { # If WIDTH is 8 byte, the address should be 8-byte aligned. return 1 - } elseif { [expr ($offset) % 4] == 0 } { + } elseif {$offset % 4 == 0} { return 1 - } elseif { [expr ($offset) % 4] == 2 && $width == 2 } { + } elseif {$offset % 4 == 2 && $width == 2} { # Halfword watchpoints and breakpoints. return 1 - } elseif { [expr ($offset) % 4] == 1 && $width == 1 && $cmd != "hbreak" } { + } elseif {$offset % 4 == 1 && $width == 1 && $cmd != "hbreak"} { # Single byte watchpoints. return 1 } else { @@ -249,7 +249,7 @@ proc run_watchpoints_tests {hw_wp_p} { for {set x 0} {$x < 4} {incr x} { if { ![valid_addr_p $cmd1 $x $width] - || ![valid_addr_p $cmd2 $x+1 $width] } { + || ![valid_addr_p $cmd2 [expr {$x+1}] $width] } { # Skip tests if requested address or length # of breakpoint or watchpoint don't meet # target or kernel requirements. diff --git a/gdb/testsuite/gdb.base/watchpoint-running.c b/gdb/testsuite/gdb.base/watchpoint-running.c index 3ba1cb2..8cd7c44 100644 --- a/gdb/testsuite/gdb.base/watchpoint-running.c +++ b/gdb/testsuite/gdb.base/watchpoint-running.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2023-2024 Free Software Foundation, Inc. + Copyright 2023-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 diff --git a/gdb/testsuite/gdb.base/watchpoint-running.exp b/gdb/testsuite/gdb.base/watchpoint-running.exp index abba43f..cb68e18 100644 --- a/gdb/testsuite/gdb.base/watchpoint-running.exp +++ b/gdb/testsuite/gdb.base/watchpoint-running.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 @@ -22,7 +22,7 @@ set allow_hw_watchpoint_tests_p [allow_hw_watchpoint_tests] standard_testfile -if [build_executable "failed to prepare" $testfile $srcfile {debug}] { +if {[build_executable "failed to prepare" $testfile $srcfile {debug}]} { return -1 } @@ -43,7 +43,7 @@ proc test {stop_mode hw} { # default. append ::GDBFLAGS " -ex \"maint set target-non-stop on\"" } - clean_restart $::binfile + clean_restart $::testfile } gdb_test_no_output "set can-use-hw-watchpoints $hw" @@ -86,7 +86,7 @@ proc test {stop_mode hw} { # sufficient time to ever wrap around.) gdb_assert {$val1 != $val2} "values are different" - set wp_str [expr ($hw)?"Hardware watchpoint":"Watchpoint"] + set wp_str [expr {($hw)?"Hardware watchpoint":"Watchpoint"}] # Now set a watchpoint, while the inferior is running. Since # we're watching a global, and we can read global memory while the @@ -129,7 +129,7 @@ foreach hw {0 1} { continue } foreach stop_mode {all-stop non-stop} { - set wp_type [expr ($hw)?"hardware":"software"] + set wp_type [expr {($hw)?"hardware":"software"}] with_test_prefix "$stop_mode: $wp_type" { test $stop_mode $hw } diff --git a/gdb/testsuite/gdb.base/watchpoint-solib-shr.c b/gdb/testsuite/gdb.base/watchpoint-solib-shr.c index 373bf92..d573569 100644 --- a/gdb/testsuite/gdb.base/watchpoint-solib-shr.c +++ b/gdb/testsuite/gdb.base/watchpoint-solib-shr.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 diff --git a/gdb/testsuite/gdb.base/watchpoint-solib.c b/gdb/testsuite/gdb.base/watchpoint-solib.c index 1a50256..6dda8fe 100644 --- a/gdb/testsuite/gdb.base/watchpoint-solib.c +++ b/gdb/testsuite/gdb.base/watchpoint-solib.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2004-2024 Free Software Foundation, Inc. + Copyright 2004-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 @@ -38,7 +38,7 @@ void open_shlib () void (*foo) (int); handle = dlopen (SHLIB_NAME, RTLD_LAZY); - + if (!handle) { #ifdef __WIN32__ diff --git a/gdb/testsuite/gdb.base/watchpoint-solib.exp b/gdb/testsuite/gdb.base/watchpoint-solib.exp index bafc759..906bd18 100644 --- a/gdb/testsuite/gdb.base/watchpoint-solib.exp +++ b/gdb/testsuite/gdb.base/watchpoint-solib.exp @@ -1,4 +1,4 @@ -# Copyright 2007-2024 Free Software Foundation, Inc. +# Copyright 2007-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 @@ -40,16 +40,17 @@ set lib_sl [standard_output_file $libname] set lib_dlopen [shlib_target_file ${libname}] set lib_syms [shlib_symbol_file ${libname}] -set lib_opts debug +set lib_opts {debug shlib} set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME=\"${lib_dlopen}\"] -if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != "" - || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build shlib" $lib_sl $libsrc $lib_opts] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } { + return } -clean_restart $binfile gdb_load_shlib $lib_sl runto_main diff --git a/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.c b/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.c index 66208f5..83a2508 100644 --- a/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.c +++ b/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-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 diff --git a/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp b/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp index 154514f..765ab7a 100644 --- a/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp +++ b/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2014-2024 Free Software Foundation, Inc. +# Copyright 2014-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 @@ -125,11 +125,11 @@ if {!$hw_watchpoints_supported} { delete_breakpoints proc test {always_inserted} { - global srcfile binfile + global srcfile with_test_prefix "always-inserted $always_inserted" { - clean_restart $binfile + clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/watchpoint-unaligned.c b/gdb/testsuite/gdb.base/watchpoint-unaligned.c index 6f70925..ca2fa45 100644 --- a/gdb/testsuite/gdb.base/watchpoint-unaligned.c +++ b/gdb/testsuite/gdb.base/watchpoint-unaligned.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 @@ -18,6 +18,8 @@ #include <stdint.h> #include <assert.h> +static volatile int volatile_dummy; + static int again; static volatile struct @@ -53,6 +55,40 @@ write_size8twice (void) data.u.size8twice[offset] = first; data.u.size8twice[offset + 1] = second; #endif + + /* Setting a breakpoint on an instruction after an instruction triggering a + watchpoint makes it ambiguous which one will be reported. + Insert a dummy instruction in between to make sure the watchpoint gets + reported. */ + volatile_dummy = 1; + + return; /* write_size8twice_return */ +} + +static void +read_size8twice (void) +{ + static uint64_t volatile first; + static uint64_t volatile second; + +#ifdef __aarch64__ + volatile void *p = &data.u.size8twice[offset]; + asm volatile ("ldp %0, %1, [%2]" + : "=r" (first), "=r" (second) /* output */ + : "r" (p) /* input */ + : /* clobber */); +#else + first = data.u.size8twice[offset]; + second = data.u.size8twice[offset + 1]; +#endif + + /* Setting a breakpoint on an instruction after an instruction triggering a + watchpoint makes it ambiguous which one will be reported. + Insert a dummy instruction inbetween to make sure the watchpoint gets + reported. */ + volatile_dummy = 1; + + return; /* read_size8twice_return */ } int @@ -63,6 +99,7 @@ main (void) assert (sizeof (data) == 8 + 3 * 8); write_size8twice (); + read_size8twice (); while (size) { diff --git a/gdb/testsuite/gdb.base/watchpoint-unaligned.exp b/gdb/testsuite/gdb.base/watchpoint-unaligned.exp index 999dd3a..13dcfba 100644 --- a/gdb/testsuite/gdb.base/watchpoint-unaligned.exp +++ b/gdb/testsuite/gdb.base/watchpoint-unaligned.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } @@ -43,14 +43,14 @@ if {[istarget "s390*-*-*"]} { foreach wpsize $sizes { for {set wpoffset 0} {$wpoffset < 8 / $wpsize} {incr wpoffset} { - set wpstart [expr $wpoffset * $wpsize] - set wpend [expr ($wpoffset + 1) * $wpsize] + set wpstart [expr {$wpoffset * $wpsize}] + set wpend [expr {($wpoffset + 1) * $wpsize}] set wpendaligned $alignedend($wpend) foreach rdsize $sizes { for {set rdoffset 0} {$rdoffset < 8 / $rdsize} {incr rdoffset} { - set rdstart [expr $rdoffset * $rdsize] - set rdend [expr ($rdoffset + 1) * $rdsize] - set expect_hit [expr max ($wpstart, $rdstart) < min ($wpend, $rdend)] + set rdstart [expr {$rdoffset * $rdsize}] + set rdend [expr {($rdoffset + 1) * $rdsize}] + set expect_hit [expr {max ($wpstart, $rdstart) < min ($wpend, $rdend)}] set test "$rwatch data.u.size$wpsize\[$wpoffset\]" set wpnum "" gdb_test_multiple $test $test { @@ -88,7 +88,7 @@ foreach wpsize $sizes { if {$expect_hit == 0 && $rdstart < $wpendaligned} { setup_xfail external/20207 "aarch64*-*-linux*" } - if {!$expect_hit && [expr max ($wpstart / 8, $rdstart / 8) < min (($wpend + 7) / 8, ($rdend + 7) / 8)]} { + if {!$expect_hit && max ($wpstart / 8, $rdstart / 8) < min (($wpend + 7) / 8, ($rdend + 7) / 8)} { setup_xfail breakpoints/23131 "powerpc*-*-*" } fail $test @@ -139,7 +139,7 @@ foreach_with_prefix wpcount {4 7} { } } set test "wpcount($wpcount)" - if {!$wpoffset_to_wpnum([expr $wpcount - 1])} { + if {!$wpoffset_to_wpnum([expr {$wpcount - 1}])} { untested $test continue } @@ -151,6 +151,63 @@ foreach_with_prefix wpcount {4 7} { gdb_assert $got_hit $test } +proc size8twice { function cmd offset index } { + clean_restart $::testfile + + if { ![runto $function] } { + return -1 + } + + # Set offset in the inferior. + gdb_test_no_output "set var offset = $offset" + + # Set a breakpoint. + set bp_src_string "${function}_return" + set bp_loc [gdb_get_line_number $bp_src_string] + gdb_breakpoint $bp_loc \ + "Breakpoint $::decimal at $::hex" "$bp_src_string" + + # Set a hardware watchpoint. + set watch_index [expr {$offset + $index}] + set test "$cmd data.u.size8twice\[$watch_index\]" + set wpnum 0 + gdb_test_multiple $test "" { + -re -wrap "Hardware (read )?watchpoint ($::decimal): .*" { + set wpnum $expect_out(2,string) + pass $gdb_test_name + } + -re -wrap "Watchpoint ($::decimal): .*" { + if {[istarget "arm*-*-*"]} { + untested $gdb_test_name + } else { + fail $gdb_test_name + } + } + } + + if { ! $wpnum } { + # No hardware watchpoint, we're done. + return 0 + } + + # Try to trigger the hardware watchpoint. + set got_hit 0 + gdb_test_multiple "continue" "" { + -re -wrap "\r\nCould not insert hardware watchpoint .*" { + } + -re -wrap "Hardware (read )?watchpoint $wpnum:.*(New value|Value) = .*" { + set got_hit 1 + send_gdb "continue\n" + exp_continue + } + -re -wrap " $bp_src_string .*" { + } + } + gdb_assert { $got_hit } + + return $got_hit +} + # We've got an array with 3 8-byte elements. Do a store of 16 bytes, # to: # - elements 0 and 1 (offset == 0), and @@ -158,49 +215,21 @@ foreach_with_prefix wpcount {4 7} { # For each case, check setting a watchpoint at: # - the first written element (index == 0), and # - the second element (index == 1). -foreach_with_prefix offset { 0 1 } { - foreach_with_prefix index { 0 1 } { - - clean_restart $binfile - - if ![runto_main] { - return -1 - } - - gdb_test_no_output "set var offset = $offset" - gdb_breakpoint [gdb_get_line_number "final_return"] \ - "Breakpoint $decimal at $hex" "final_return" - set watch_index [expr $offset + $index] - set test "watch data.u.size8twice\[$watch_index\]" - set wpnum 0 - gdb_test_multiple $test $test { - -re "Hardware watchpoint (\[0-9\]+): .*\r\n$gdb_prompt $" { - set wpnum $expect_out(1,string) - pass $gdb_test_name - } - -re "Watchpoint (\[0-9\]+): .*\r\n$gdb_prompt $" { - if {[istarget "arm*-*-*"]} { - untested $gdb_test_name - } else { - fail $gdb_test_name - } +foreach_with_prefix fun { write_size8twice read_size8twice } { + if { $fun == "write_size8twice" } { + set cmd "watch" + } else { + set cmd "rwatch" + } + foreach_with_prefix offset { 0 1 } { + foreach_with_prefix index { 0 1 } { + set res [size8twice $fun $cmd $offset $index] + if { $res != 1 } { + break } } - if {$wpnum} { - set test "continue" - set got_hit 0 - gdb_test_multiple $test $test { - -re "\r\nCould not insert hardware watchpoint .*\r\n$gdb_prompt $" { - } - -re "Hardware watchpoint $wpnum:.*New value = .*\r\n$gdb_prompt $" { - set got_hit 1 - send_gdb "continue\n" - exp_continue - } - -re " final_return .*\r\n$gdb_prompt $" { - } - } - gdb_assert $got_hit "size8twice write" + if { $res != 1 } { + break } } } diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp index 2449663..fec74dc 100644 --- a/gdb/testsuite/gdb.base/watchpoint.exp +++ b/gdb/testsuite/gdb.base/watchpoint.exp @@ -1,4 +1,4 @@ -# Copyright 1992-2024 Free Software Foundation, Inc. +# Copyright 1992-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 @@ -55,23 +55,23 @@ proc initialize {} { global decimal global srcfile - if [gdb_test "break marker1" "Breakpoint 1 at $hex: file .*$srcfile, line $decimal.*" "set breakpoint at marker1" ] { + if {[gdb_test "break marker1" "Breakpoint 1 at $hex: file .*$srcfile, line $decimal.*" "set breakpoint at marker1" ]} { return 0 } - if [gdb_test "break marker2" "Breakpoint 2 at $hex: file .*$srcfile, line $decimal.*" "set breakpoint at marker2" ] { + if {[gdb_test "break marker2" "Breakpoint 2 at $hex: file .*$srcfile, line $decimal.*" "set breakpoint at marker2" ]} { return 0 } - if [gdb_test "info break" "1\[ \]*breakpoint.*marker1.*\r\n2\[ \]*breakpoint.*marker2.*" "info break" ] { + if {[gdb_test "info break" "1\[ \]*breakpoint.*marker1.*\r\n2\[ \]*breakpoint.*marker2.*" "info break" ]} { return 0 } gdb_test "watch ival3" ".*\[Ww\]atchpoint 3: ival3.*" "set watchpoint on ival3" - if [gdb_test "info watch" "3\[ \]*.*watchpoint.*ival3" "watchpoint found in watchpoint/breakpoint table" ] { + if {[gdb_test "info watch" "3\[ \]*.*watchpoint.*ival3" "watchpoint found in watchpoint/breakpoint table" ]} { return 0 } @@ -80,7 +80,7 @@ proc initialize {} { # to use it. This allows the test program to run at full speed until # we get to the first marker function. - if [gdb_test_no_output "disable 3" "disable watchpoint" ] { + if {[gdb_test_no_output "disable 3" "disable watchpoint" ]} { return 0 } @@ -99,8 +99,8 @@ proc test_simple_watchpoint {} { # Ensure that the watchpoint is disabled when we startup. - if [gdb_test_no_output "disable 3" \ - "disable watchpoint in test_simple_watchpoint" ] { + if {[gdb_test_no_output "disable 3" \ + "disable watchpoint in test_simple_watchpoint" ]} { return 0 } @@ -121,7 +121,7 @@ proc test_simple_watchpoint {} { # After reaching the marker function, enable the watchpoint. - if [gdb_test_no_output "enable 3" "enable watchpoint" ] { + if {[gdb_test_no_output "enable 3" "enable watchpoint" ]} { return } @@ -165,7 +165,7 @@ Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count # Check that the hit count is reported correctly gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 3 times.*" "watchpoint hit count is 3" - + # Continue until the next change, from 2 to 3. gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" "watchpoint hit, fourth time" @@ -188,14 +188,14 @@ Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count # Disable the watchpoint so we run at full speed until we exit. - if [gdb_test_no_output "disable 3" "watchpoint disabled" ] { + if {[gdb_test_no_output "disable 3" "watchpoint disabled" ]} { return } # Run until process exits. - if [target_info exists gdb,noresults] { return } + if {[target_info exists gdb,noresults]} { return } gdb_continue_to_end "continue to exit in test_simple_watchpoint" } @@ -213,8 +213,8 @@ proc test_disabling_watchpoints {} { # Ensure that the watchpoint is disabled when we startup. - if [gdb_test_no_output "disable 3" \ - "disable watchpoint in test_disabling_watchpoints" ] { + if {[gdb_test_no_output "disable 3" \ + "disable watchpoint in test_disabling_watchpoints" ]} { return 0 } @@ -236,7 +236,7 @@ proc test_disabling_watchpoints {} { # After reaching the marker function, enable the watchpoint. - if [gdb_test_no_output "enable 3" "watchpoint enabled" ] { + if {[gdb_test_no_output "enable 3" "watchpoint enabled" ]} { return } @@ -245,14 +245,14 @@ proc test_disabling_watchpoints {} { # Don't check the old value, because on VxWorks the variable value # will not have been reinitialized. gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = .*New value = 0.*ival3 = count; ival4 = count;.*" "watchpoint hit in test_disabling_watchpoints, first time" - + # Continue until the next change, from 0 to 1. gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" "watchpoint hit in test_disabling_watchpoints, second time" - + # Disable the watchpoint but leave breakpoints - if [gdb_test_no_output "disable 3" \ - "disable watchpoint #2 in test_disabling_watchpoints" ] { + if {[gdb_test_no_output "disable 3" \ + "disable watchpoint #2 in test_disabling_watchpoints" ]} { return 0 } @@ -265,8 +265,8 @@ proc test_disabling_watchpoints {} { # Make sure we hit no more watchpoints. gdb_test "cont" "Continuing.*Breakpoint.*marker2 \\(\\).*" \ "disabled watchpoint skipped" - - if [target_info exists gdb,noresults] { return } + + if {[target_info exists gdb,noresults]} { return } gdb_continue_to_end "continue to exit in test_disabling_watchpoints" } @@ -286,7 +286,7 @@ proc test_stepping {} { gdb_test "p func1 ()" "= 73" \ "calling function with watchpoint enabled" - # + # # "finish" brings us back to main. # On some targets (e.g. alpha) gdb will stop from the finish in midline # of the marker1 call. This is due to register restoring code on @@ -357,7 +357,7 @@ proc test_watchpoint_triggered_in_syscall {} { global gdb_prompt # These tests won't work without printf support. - if [gdb_skip_stdio_test "watchpoints triggered in syscall"] { + if {[gdb_skip_stdio_test "watchpoints triggered in syscall"]} { return } # Run until we get to the first marker function. @@ -391,10 +391,10 @@ proc test_watchpoint_triggered_in_syscall {} { set test "sent 123" gdb_test_multiple "123" $test { - -re ".*\[Ww\]atchpoint.*buf\\\[0\\\].*Old value = 0.*New value = 49\[^\n\]*\n" { set x [expr $x+1] ; exp_continue } - -re ".*\[Ww\]atchpoint.*buf\\\[1\\\].*Old value = 0.*New value = 50\[^\n\]*\n" { set x [expr $x+1] ; exp_continue } - -re ".*\[Ww\]atchpoint.*buf\\\[2\\\].*Old value = 0.*New value = 51\[^\n\]*\n" { set x [expr $x+1] ; exp_continue } - -re ".*\[Ww\]atchpoint.*buf\\\[3\\\].*Old value = 0.*New value = 10\[^\n\]*\n" { set x [expr $x+1] ; exp_continue } + -re ".*\[Ww\]atchpoint.*buf\\\[0\\\].*Old value = 0.*New value = 49\[^\n\]*\n" { set x [expr {$x+1}] ; exp_continue } + -re ".*\[Ww\]atchpoint.*buf\\\[1\\\].*Old value = 0.*New value = 50\[^\n\]*\n" { set x [expr {$x+1}] ; exp_continue } + -re ".*\[Ww\]atchpoint.*buf\\\[2\\\].*Old value = 0.*New value = 51\[^\n\]*\n" { set x [expr {$x+1}] ; exp_continue } + -re ".*\[Ww\]atchpoint.*buf\\\[3\\\].*Old value = 0.*New value = 10\[^\n\]*\n" { set x [expr {$x+1}] ; exp_continue } -re ".*$gdb_prompt $" { pass $test } } @@ -402,27 +402,27 @@ proc test_watchpoint_triggered_in_syscall {} { # should have printed. set test "print buf\[0\]" gdb_test_multiple $test $test { - -re ".*= 49.*$gdb_prompt $" { set y [expr $y+1]; pass $test } + -re ".*= 49.*$gdb_prompt $" { set y [expr {$y+1}]; pass $test } -re ".*= 0.*$gdb_prompt $" { $test } } set test "print buf\[1\]" gdb_test_multiple $test $test { - -re ".*= 50.*$gdb_prompt $" { set y [expr $y+1]; pass $test } + -re ".*= 50.*$gdb_prompt $" { set y [expr {$y+1}]; pass $test } -re ".*= 0.*$gdb_prompt $" { pass $test } } set test "print buf\[2\]" gdb_test_multiple $test $test { - -re ".*= 51.*$gdb_prompt $" { set y [expr $y+1]; pass $test } + -re ".*= 51.*$gdb_prompt $" { set y [expr {$y+1}]; pass $test } -re ".*= 0.*$gdb_prompt $" { pass $test } } set test "print buf\[3\]" gdb_test_multiple $test $test { - -re ".*= 10.*$gdb_prompt $" { set y [expr $y+1]; pass $test } + -re ".*= 10.*$gdb_prompt $" { set y [expr {$y+1}]; pass $test } -re ".*= 0.*$gdb_prompt $" { pass $test } } # Did we find what we were looking for? If not, flunk it. - if {[expr $x==$y]} { pass $testname } else { fail "$testname (only triggered $x watchpoints, expected $y)"} + if {$x==$y} { pass $testname } else { fail "$testname (only triggered $x watchpoints, expected $y)"} # Continue until we hit the finishing marker function. # Make sure we hit no more watchpoints. @@ -432,7 +432,7 @@ proc test_watchpoint_triggered_in_syscall {} { # Disable everything so we can finish the program at full speed gdb_test_no_output "disable" "disable in test_watchpoint_triggered_in_syscall" - if [target_info exists gdb,noresults] { return } + if {[target_info exists gdb,noresults]} { return } gdb_continue_to_end "continue to exit in test_watchpoint_triggered_in_syscall" } @@ -457,28 +457,28 @@ proc test_complex_watchpoint {} { gdb_test "cont" "Continuing.*Breakpoint.*marker5 \\(\\).*" \ "did not trigger wrong watchpoint" - # Test watches of things declared locally in a function. - # In particular, test that a watch of stack-based things - # is deleted when the stack-based things go out of scope. - # + # Test watches of things declared locally in a function. + # In particular, test that a watch of stack-based things + # is deleted when the stack-based things go out of scope. + # gdb_test_no_output "disable" "disable in test_complex_watchpoint, first time" - gdb_test "break marker6" ".*Breakpoint.*" - gdb_test "cont" "Continuing.*Breakpoint.*marker6 \\(\\).*" \ - "continue to marker6" + gdb_test "break marker6" ".*Breakpoint.*" + gdb_test "cont" "Continuing.*Breakpoint.*marker6 \\(\\).*" \ + "continue to marker6" gdb_breakpoint [gdb_get_line_number "func2 breakpoint here"] gdb_continue_to_breakpoint "func2 breakpoint here, first time" - # Test a watch of a single stack-based variable, whose scope - # is the function we're now in. This should auto-delete when - # execution exits the scope of the watchpoint. - # + # Test a watch of a single stack-based variable, whose scope + # is the function we're now in. This should auto-delete when + # execution exits the scope of the watchpoint. + # gdb_test "watch local_a" \ "^(?:Hardware w|W)atchpoint $::decimal: local_a" \ "set local watch" - gdb_test "cont" "\[Ww\]atchpoint.*local_a.*" "trigger local watch" + gdb_test "cont" "\[Ww\]atchpoint.*local_a.*" "trigger local watch" set test "self-delete local watch" - gdb_test_multiple "cont" $test { + gdb_test_multiple "cont" $test { -re "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*\r\n$gdb_prompt $" { pass $test } @@ -498,43 +498,43 @@ proc test_complex_watchpoint {} { } gdb_continue_to_breakpoint "func2 breakpoint here, second time" - # We should be in "func2" again now. Test a watch of an - # expression which includes both a stack-based local and - # something whose scope is larger than this invocation - # of "func2". This should also auto-delete. - # + # We should be in "func2" again now. Test a watch of an + # expression which includes both a stack-based local and + # something whose scope is larger than this invocation + # of "func2". This should also auto-delete. + # gdb_test "watch local_a + ival5" \ "^(?:Hardware w|W)atchpoint $::decimal: local_a . ival5" \ "set partially local watch" - gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \ - "trigger1 partially local watch" - gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \ - "trigger2 partially local watch" - gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" \ - "self-delete partially local watch" - - # We should be in "func2" again now. Test a watch of a - # static (non-stack-based) local. Since this has scope - # across any invocations of "func2", it should not auto- - # delete. - # + gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \ + "trigger1 partially local watch" + gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: local_a . ival5.*" \ + "trigger2 partially local watch" + gdb_test "cont" "Continuing.*\[Ww\]atchpoint .* deleted because the program has left the block in.*which its expression is valid.*" \ + "self-delete partially local watch" + + # We should be in "func2" again now. Test a watch of a + # static (non-stack-based) local. Since this has scope + # across any invocations of "func2", it should not auto- + # delete. + # gdb_continue_to_breakpoint "func2 breakpoint here, third time" gdb_test "watch static_b" \ "^(?:Hardware w|W)atchpoint $::decimal: static_b" \ - "set static local watch" - gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: static_b.*" \ - "trigger static local watch" - gdb_test "cont" "Continuing.*marker6 \\(\\).*" \ - "continue after trigger static local watch" - gdb_test "info break" ".*watchpoint.*static_b.*" \ - "static local watch did not self-delete" - - # We should be in "recurser" now. Test a watch of a stack- - # based local. Symbols mentioned in a watchpoint are bound - # at watchpoint-creation. Thus, a watch of a stack-based - # local to a recursing function should be bound only to that - # one invocation, and should not trigger for other invocations. - # + "set static local watch" + gdb_test "cont" "Continuing.*\[Ww\]atchpoint .*: static_b.*" \ + "trigger static local watch" + gdb_test "cont" "Continuing.*marker6 \\(\\).*" \ + "continue after trigger static local watch" + gdb_test "info break" ".*watchpoint.*static_b.*" \ + "static local watch did not self-delete" + + # We should be in "recurser" now. Test a watch of a stack- + # based local. Symbols mentioned in a watchpoint are bound + # at watchpoint-creation. Thus, a watch of a stack-based + # local to a recursing function should be bound only to that + # one invocation, and should not trigger for other invocations. + # with_test_prefix "local_x" { gdb_test "tbreak recurser" ".*breakpoint.*" gdb_test "cont" "Continuing.*recurser.*" @@ -548,8 +548,8 @@ proc test_complex_watchpoint {} { "self-delete local watch in recursive call" } - # Repeat the preceding test, but this time use "recurser::local_x" as - # the variable to track. + # Repeat the preceding test, but this time use "recurser::local_x" as + # the variable to track. with_test_prefix "recurser::local_x" { gdb_test "cont" "Continuing.*marker6.*" "continue to marker6" gdb_test "tbreak recurser" ".*breakpoint.*" @@ -567,7 +567,7 @@ proc test_complex_watchpoint {} { # Disable everything so we can finish the program at full speed gdb_test_no_output "disable" "disable in test_complex_watchpoint, second time" - if [target_info exists gdb,noresults] { return } + if {[target_info exists gdb,noresults]} { return } gdb_continue_to_end "continue to exit in test_complex_watchpoint" } @@ -661,8 +661,8 @@ proc test_wide_location_1 {} { # Platforms where the target can't watch such a large region # should clear hw_expected below. if { $no_hw || !$allow_hw_watchpoint_tests_p - || [istarget arm*-*-*] - || ([istarget powerpc*-*-*] && ![is_lp64_target])} { + || [istarget arm*-*-*] + || ([istarget powerpc*-*-*] && ![is_lp64_target])} { set hw_expected 0 } else { set hw_expected 1 @@ -709,8 +709,8 @@ proc test_wide_location_2 {} { # Platforms where the target can't watch such a large region # should clear hw_expected below. if { $no_hw || !$allow_hw_watchpoint_tests_p - || [istarget arm*-*-*] - || [istarget powerpc*-*-*]} { + || [istarget arm*-*-*] + || [istarget powerpc*-*-*]} { set hw_expected 0 } else { set hw_expected 1 @@ -855,7 +855,7 @@ proc test_no_hw_watchpoints {} { gdb_test "watch ival3 if count > 1 thread 1 " \ "watch ival3 if count > 1 thread 1 \r\nWatchpoint \[0-9\]*: ival3.*" \ - "set slow condition watch w/thread" + "set slow condition watch w/thread" gdb_test_no_output "delete \$bpnum" "delete watch w/condition and thread" @@ -872,7 +872,7 @@ proc test_no_hw_watchpoints {} { # Re-enable hardware watchpoints if necessary. if {$allow_hw_watchpoint_tests_p} { - gdb_test_no_output "set can-use-hw-watchpoints 1" "" + gdb_test_no_output "set can-use-hw-watchpoints 1" "" } } @@ -941,7 +941,7 @@ proc test_watch_register_location {} { # Start with a fresh gdb. set prev_timeout $timeout -set timeout 600 +set timeout 600 verbose "Timeout now 600 sec.\n" test_no_hw_watchpoints @@ -964,7 +964,7 @@ proc do_tests {} { test_disabling_watchpoints - if ![target_info exists gdb,cannot_call_functions] { + if {![target_info exists gdb,cannot_call_functions]} { test_stepping } } @@ -978,9 +978,9 @@ proc do_tests {} { "disable fast watches, 2" } - # Only enabled for some targets merely because it has not been tested + # Only enabled for some targets merely because it has not been tested # elsewhere. - # On sparc-sun-sunos4.1.3, GDB was running all the way to the marker4 + # On sparc-sun-sunos4.1.3, GDB was running all the way to the marker4 # breakpoint before stopping for the watchpoint. I don't know why. if {[istarget "hppa*-*-*"]} { test_watchpoint_triggered_in_syscall diff --git a/gdb/testsuite/gdb.base/watchpoints.c b/gdb/testsuite/gdb.base/watchpoints.c index b72f8ab..44bd421 100644 --- a/gdb/testsuite/gdb.base/watchpoints.c +++ b/gdb/testsuite/gdb.base/watchpoints.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2009-2024 Free Software Foundation, Inc. + Copyright 2009-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 @@ -27,7 +27,7 @@ int ival2 = -1; int ival3 = -1; int ival4 = -1; -int +int main () { for (count = 0; count < 4; count++) { diff --git a/gdb/testsuite/gdb.base/watchpoints.exp b/gdb/testsuite/gdb.base/watchpoints.exp index ae05fb6..e7d1a0f 100644 --- a/gdb/testsuite/gdb.base/watchpoints.exp +++ b/gdb/testsuite/gdb.base/watchpoints.exp @@ -1,4 +1,4 @@ -# Copyright 2009-2024 Free Software Foundation, Inc. +# Copyright 2009-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 @@ -38,26 +38,26 @@ with_test_prefix "before inferior start" { # hardware watchpoint. gdb_test_no_output "set can-use-hw-watchpoints 0" "" gdb_test "watch ival1" "Watchpoint \[0-9\]+: ival1" \ - "create watchpoint" + "create watchpoint" # The next tests are written to match the current state of gdb: access # and read watchpoints require hardware watchpoint support, with this # turned off these can't be created. gdb_test "awatch ival1" \ - "Can't set read/access watchpoint when hardware watchpoints are disabled." \ - "create access watchpoint" + "Can't set read/access watchpoint when hardware watchpoints are disabled." \ + "create access watchpoint" gdb_test "rwatch ival1" \ - "Can't set read/access watchpoint when hardware watchpoints are disabled." \ - "create read watchpoint" + "Can't set read/access watchpoint when hardware watchpoints are disabled." \ + "create read watchpoint" } # This will turn hardware watchpoints back on and delete the watchpoint # we just created. - clean_restart ${binfile} + clean_restart $testfile # Disable hardware watchpoints if necessary. if {!$allow_hw_watchpoint_tests_p} { - gdb_test_no_output "set can-use-hw-watchpoints 0" "" + gdb_test_no_output "set can-use-hw-watchpoints 0" "" } runto_main @@ -93,13 +93,13 @@ with_test_prefix "before inferior start" { gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival1\r\n\[ \t]+breakpoint already hit 3 times.*" "watchpoint ival1 hit count is 3" # Disable ival1 watchpoint gdb_test_no_output "disable 2" "" - + # Continue until the next change, from 1 to 2. gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" "watchpoint hit, third time" # Check that the hit count is reported correctly gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 3 times.*" "watchpoint hit count is 3" - + # Continue until the next change, from 2 to 3. gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" "watchpoint hit, fourth time" diff --git a/gdb/testsuite/gdb.base/wchar.c b/gdb/testsuite/gdb.base/wchar.c index 24e0a6f..6fee56b 100644 --- a/gdb/testsuite/gdb.base/wchar.c +++ b/gdb/testsuite/gdb.base/wchar.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2011-2024 Free Software Foundation, Inc. + Copyright 2011-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 @@ -47,4 +47,3 @@ main (void) do_nothing (difficile); do_nothing (mixed); } - diff --git a/gdb/testsuite/gdb.base/wchar.exp b/gdb/testsuite/gdb.base/wchar.exp index 0fc97cf..f0e4777 100644 --- a/gdb/testsuite/gdb.base/wchar.exp +++ b/gdb/testsuite/gdb.base/wchar.exp @@ -1,4 +1,4 @@ -# Copyright 2011-2024 Free Software Foundation, Inc. +# Copyright 2011-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 @@ -72,3 +72,7 @@ gdb_test "print repeat_p" "= $hex L\"A$cent$cent\"\.\.\." \ # From PR cli/14977, but here because it requires wchar_t. gdb_test "printf \"%ls\\n\", 0" "\\(null\\)" + +# From PR exp/33124 - a bug when converting escapes. +set wbs {L'\\'} +gdb_test "print $wbs" " = $decimal [string_to_regexp $wbs]" diff --git a/gdb/testsuite/gdb.base/weaklib1.c b/gdb/testsuite/gdb.base/weaklib1.c index 9d64f67..75f0742 100644 --- a/gdb/testsuite/gdb.base/weaklib1.c +++ b/gdb/testsuite/gdb.base/weaklib1.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2006-2024 Free Software Foundation, Inc. + Copyright 2006-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 @@ -21,4 +21,4 @@ void __attribute__((weak)) bar (void) { puts ("bar in u1"); -} +} diff --git a/gdb/testsuite/gdb.base/weaklib2.c b/gdb/testsuite/gdb.base/weaklib2.c index b40a0f9..c901848 100644 --- a/gdb/testsuite/gdb.base/weaklib2.c +++ b/gdb/testsuite/gdb.base/weaklib2.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2006-2024 Free Software Foundation, Inc. + Copyright 2006-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 @@ -20,12 +20,12 @@ void bar (void); void foo (void) -{ +{ bar (); -} +} void bar (void) -{ +{ puts ("bar in u2"); -} +} diff --git a/gdb/testsuite/gdb.base/whatis-exp.exp b/gdb/testsuite/gdb.base/whatis-exp.exp index 1f8522f..ffcfc44 100644 --- a/gdb/testsuite/gdb.base/whatis-exp.exp +++ b/gdb/testsuite/gdb.base/whatis-exp.exp @@ -1,4 +1,4 @@ -# Copyright 1998-2024 Free Software Foundation, Inc. +# Copyright 1998-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 @@ -23,7 +23,7 @@ # computing the value, but just the type # of the result. It goes through the evaluate_subexp_standard # with the EVAL_AVOID_SIDE_EFFECTS flag rather than EVAL_NORMAL -# +# # # test running programs diff --git a/gdb/testsuite/gdb.base/whatis-ptype-typedefs.c b/gdb/testsuite/gdb.base/whatis-ptype-typedefs.c index fb11ca2..1e87907 100644 --- a/gdb/testsuite/gdb.base/whatis-ptype-typedefs.c +++ b/gdb/testsuite/gdb.base/whatis-ptype-typedefs.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 2017-2024 Free Software Foundation, Inc. + Copyright 2017-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 diff --git a/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp b/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp index 7088299..744c6ee 100644 --- a/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp +++ b/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Free Software Foundation, Inc. +# Copyright 2017-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 @@ -30,7 +30,7 @@ standard_testfile proc prepare {lang} { global srcfile testfile - if [target_info exists no_long_long] { + if {[target_info exists no_long_long]} { set options [list debug additional_flags=-DNO_LONG_LONG] } else { set options [list debug] diff --git a/gdb/testsuite/gdb.base/whatis.c b/gdb/testsuite/gdb.base/whatis.c index 53a4879..c722cf2 100644 --- a/gdb/testsuite/gdb.base/whatis.c +++ b/gdb/testsuite/gdb.base/whatis.c @@ -1,6 +1,6 @@ /* This test program is part of GDB, the GNU debugger. - Copyright 1992-2024 Free Software Foundation, Inc. + Copyright 1992-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 @@ -254,15 +254,15 @@ int main () v_short = 3; v_signed_short = 4; - v_unsigned_short = 5; + v_unsigned_short = 5; v_int = 6; v_signed_int = 7; - v_unsigned_int = 8; + v_unsigned_int = 8; v_long = 9; v_signed_long = 10; - v_unsigned_long = 11; + v_unsigned_long = 11; #ifndef NO_LONG_LONG v_long_long = 12; diff --git a/gdb/testsuite/gdb.base/whatis.exp b/gdb/testsuite/gdb.base/whatis.exp index 7111983..5fa29af 100644 --- a/gdb/testsuite/gdb.base/whatis.exp +++ b/gdb/testsuite/gdb.base/whatis.exp @@ -1,4 +1,4 @@ -# Copyright 1988-2024 Free Software Foundation, Inc. +# Copyright 1988-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 @@ -19,7 +19,7 @@ # test running programs # -if [target_info exists no_long_long] { +if {[target_info exists no_long_long]} { set exec_opts [list debug additional_flags=-DNO_LONG_LONG] } else { set exec_opts [list debug] @@ -122,7 +122,7 @@ proc do_test {dir options} { "whatis unsigned long" - if ![target_info exists no_long_long] { + if {![target_info exists no_long_long]} { gdb_test "whatis v_unsigned_long_long" \ "type = (unsigned long long|long long unsigned int)" \ "whatis unsigned long long" @@ -192,7 +192,7 @@ proc do_test {dir options} { "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \ "whatis unsigned long array" - if ![target_info exists no_long_long] { + if {![target_info exists no_long_long]} { gdb_test "whatis v_unsigned_long_long_array" \ "type = (unsigned long long|long long unsigned int) \\\[2\\\]" \ "whatis unsigned long long array" @@ -260,7 +260,7 @@ proc do_test {dir options} { "type = (unsigned (int|long|long int)|long unsigned int) \\*" \ "whatis unsigned long pointer" - if ![target_info exists no_long_long] { + if {![target_info exists no_long_long]} { gdb_test "whatis v_long_long_pointer" \ "type = long long(| int) \\*" \ "whatis long long pointer" @@ -464,7 +464,7 @@ proc do_test {dir options} { "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \ "whatis unsigned long function" - if ![target_info exists no_long_long] { + if {![target_info exists no_long_long]} { gdb_test "whatis v_long_long_func" \ "type = long long(| int) \\($void\\)" \ "whatis long long function" diff --git a/gdb/testsuite/gdb.base/with-mf-inc.c b/gdb/testsuite/gdb.base/with-mf-inc.c index eeef8b3..c1443d7 100644 --- a/gdb/testsuite/gdb.base/with-mf-inc.c +++ b/gdb/testsuite/gdb.base/with-mf-inc.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/with-mf-main.c b/gdb/testsuite/gdb.base/with-mf-main.c index 2de1205..dde2e1e 100644 --- a/gdb/testsuite/gdb.base/with-mf-main.c +++ b/gdb/testsuite/gdb.base/with-mf-main.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2020-2024 Free Software Foundation, Inc. + Copyright 2020-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 diff --git a/gdb/testsuite/gdb.base/with-mf.exp b/gdb/testsuite/gdb.base/with-mf.exp index 6f2a1d8..9c0e67c 100644 --- a/gdb/testsuite/gdb.base/with-mf.exp +++ b/gdb/testsuite/gdb.base/with-mf.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2020-2024 Free Software Foundation, Inc. +# Copyright 2020-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 @@ -29,7 +29,7 @@ if { [ensure_gdb_index $binfile] == -1 } { return -1 } -clean_restart $binfile +clean_restart $testfile gdb_test "with language ada -- print g_s" \ " = \\(a => 1, b => 2, c => 3\\)" diff --git a/gdb/testsuite/gdb.base/with.c b/gdb/testsuite/gdb.base/with.c index 67028e3..c7d9850 100644 --- a/gdb/testsuite/gdb.base/with.c +++ b/gdb/testsuite/gdb.base/with.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2019-2024 Free Software Foundation, Inc. + Copyright 2019-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 diff --git a/gdb/testsuite/gdb.base/with.exp b/gdb/testsuite/gdb.base/with.exp index 2e54825..d70196c 100644 --- a/gdb/testsuite/gdb.base/with.exp +++ b/gdb/testsuite/gdb.base/with.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2019-2024 Free Software Foundation, Inc. +# Copyright 2019-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 @@ -25,7 +25,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} { return -1 } -clean_restart $binfile +clean_restart $testfile # Test "maint with". VALUES is a list of values. A nested "with" is # performed with each combination of pair of values from this list. @@ -178,15 +178,18 @@ with_test_prefix "user-defined" { # Check repeating. with_test_prefix "repeat" { - clean_restart $binfile + clean_restart $testfile # "with" with no command reinvokes the previous command. + + # Test after a "no repeat" command (which "delete" is). + gdb_test "delete 9999" "No breakpoint number 9999\\." gdb_test "with language ada" \ "No previous command to relaunch" \ "reinvoke with no previous command to relaunch" + # Test after a repeatable command. gdb_test "print g_s" " = {a = 1, b = 2, c = 3}" - gdb_test "with language ada" \ " = \\(a => 1, b => 2, c => 3\\)" \ "reinvoke with language" @@ -209,9 +212,9 @@ with_test_prefix "repeat" { # Basic run control. with_test_prefix "run control" { - clean_restart $binfile + clean_restart $testfile - if ![runto_main] { + if {![runto_main]} { return } @@ -220,6 +223,49 @@ with_test_prefix "run control" { "return 0;.*=>.*" } +# Some parameters are not global, but per-inferior. Make sure we save +# and restore the correct value, based on the current inferior. If a +# per-inferior parameter does not provide a getter for the value +# (depending on the current inferior), the `with` environment will not +# save (and later restore) the proper value if the last modified +# inferior is not the current one. +with_test_prefix "per-inferior parameters" { + clean_restart + + # Add a second inferior. + gdb_test "add-inferior" "Added inferior 2.*" + + # Set some parameters on each inferior. + foreach_with_prefix inf {1 2} { + gdb_test "inferior ${inf}" "Switching to inferior ${inf}.*" \ + "switch to inferior ${inf} before set" + gdb_test_no_output "set inferior-tty /inf${inf}-tty" + gdb_test_no_output "set cwd /inf${inf}-cwd" + gdb_test_no_output "set args /inf${inf}-args" + gdb_test_no_output "set remote exec-file /inf${inf}-ref" + # Outputs a warning, ignore it. + gdb_test "set tdesc filename /inf${inf}-tf" + } + + gdb_test "inferior 1" "Switching to inferior 1.*" "switch back to inferior 1" + + gdb_test "with inferior-tty tmp-value -- print 1" " = 1" + gdb_test "show inferior-tty" "/inf1-tty.*" + + gdb_test "with cwd tmp-value -- print 1" " = 1" + gdb_test "show cwd" "/inf1-cwd.*" + + gdb_test "with args tmp-value -- print 1" " = 1" + gdb_test "show args" "/inf1-args.*" + + gdb_test "with remote exec-file tmp-value -- print 1" " = 1" + gdb_test "show remote exec-file" "/inf1-ref.*" + + # Again, this prints some warnings around the " = 1", ignore them. + gdb_test "with tdesc filename tmp-value -- print 1" " = 1.*" + gdb_test "show tdesc filename" "/inf1-tf.*" +} + # Check errors. with_test_prefix "errors" { gdb_test "with" "Missing arguments\\." diff --git a/gdb/testsuite/gdb.base/wrap-line.exp b/gdb/testsuite/gdb.base/wrap-line.exp index d5001bf..f763588 100644 --- a/gdb/testsuite/gdb.base/wrap-line.exp +++ b/gdb/testsuite/gdb.base/wrap-line.exp @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Free Software Foundation, Inc. +# Copyright 2023-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 @@ -30,11 +30,11 @@ proc fill_line { width } { # Take into account that the prompt also takes space. set prefix [string length "(gdb) "] - set start [expr $prefix + 1] + set start [expr {$prefix + 1}] # Print chars. for { set i $start } { $i <= $width } { incr i } { - set c [expr $i % 10] + set c [expr {$i % 10}] send_gdb $c append res $c } @@ -93,7 +93,7 @@ proc test_wrap { width_auto_detected } { if { $wrap_mode == $wrap_mode_terminal } { gdb_assert { $gdb_width == $readline_width } } elseif { $wrap_mode == $wrap_mode_readline } { - gdb_assert { $gdb_width == [expr $readline_width + 1] } + gdb_assert { $gdb_width == [expr {$readline_width + 1}] } } else { set have_wrap 0 } diff --git a/gdb/testsuite/gdb.base/write_mem.c b/gdb/testsuite/gdb.base/write_mem.c index 33d0419..3de5bf9 100644 --- a/gdb/testsuite/gdb.base/write_mem.c +++ b/gdb/testsuite/gdb.base/write_mem.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2024 Free Software Foundation, Inc. +/* Copyright (C) 2018-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 diff --git a/gdb/testsuite/gdb.base/write_mem.exp b/gdb/testsuite/gdb.base/write_mem.exp index 3f2380c..3a07813 100644 --- a/gdb/testsuite/gdb.base/write_mem.exp +++ b/gdb/testsuite/gdb.base/write_mem.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2018-2024 Free Software Foundation, Inc. +# Copyright (C) 2018-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 diff --git a/gdb/testsuite/gdb.base/wrong_frame_bt_full-main.c b/gdb/testsuite/gdb.base/wrong_frame_bt_full-main.c index f960b47..eef098a 100644 --- a/gdb/testsuite/gdb.base/wrong_frame_bt_full-main.c +++ b/gdb/testsuite/gdb.base/wrong_frame_bt_full-main.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2015-2024 Free Software Foundation, Inc. +/* Copyright (C) 2015-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/wrong_frame_bt_full-opaque.c b/gdb/testsuite/gdb.base/wrong_frame_bt_full-opaque.c index 0c519c5..d7daaf5 100644 --- a/gdb/testsuite/gdb.base/wrong_frame_bt_full-opaque.c +++ b/gdb/testsuite/gdb.base/wrong_frame_bt_full-opaque.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2015-2024 Free Software Foundation, Inc. +/* Copyright (C) 2015-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp b/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp index ddc34d4..035cb8e 100644 --- a/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp +++ b/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2024 Free Software Foundation, Inc. +# Copyright (C) 2015-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 @@ -26,8 +26,8 @@ set opaque_testfile wrong_frame_bt_full-opaque set opaque_objfile [standard_output_file "$opaque_testfile.o"] if {[gdb_compile "${srcdir}/${subdir}/$opaque_testfile.c" \ - $opaque_objfile \ - object {}] != ""} { + $opaque_objfile \ + object {}] != ""} { untested "failed to compile" return -1 } @@ -42,7 +42,7 @@ if {[gdb_compile \ clean_restart ${main_testfile} -if ![runto opaque_routine] { +if {![runto opaque_routine]} { untested "could not run to opaque_routine" return -1 } |
