| # Copyright 2019-2026 Free Software Foundation, Inc. |
| |
| # This 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 whether we can load a corefile, enable TUI and then invoke |
| # "run" without having a segfault. |
| # |
| # Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1765117 |
| |
| require gcore_cmd_available |
| |
| tuiterm_env |
| |
| standard_testfile tui-layout.c |
| |
| set core [standard_output_file "${testfile}.core"] |
| |
| if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } { |
| return -1 |
| } |
| |
| # Only run on native boards. |
| require {target_can_use_run_cmd core} |
| |
| if { ![runto_main] } { |
| return -1 |
| } |
| |
| if { ![gdb_gcore_cmd "$core" "save a corefile"] } { |
| untested "could not generate a corefile" |
| return -1 |
| } |
| |
| set src_line "return 0;" |
| set src_line_nr [gdb_get_line_number $src_line] |
| |
| set run_re \ |
| "\\\[Inferior $decimal \\\(process $decimal\\\) exited normally\\]" |
| |
| with_test_prefix cli { |
| set re_kfail \ |
| "[string_to_regexp fbsd-nat.c]:$decimal: internal-error: wait_1: " |
| set re_quit [string_to_regexp "Quit this debugging session? (y or n) "] |
| set re_core_file [string_to_regexp "Create a core file of GDB? (y or n) "] |
| clean_restart $testfile |
| gdb_test "core-file $core" $src_line "load corefile" |
| set ok 0 |
| gdb_test_multiple "run" "run until the end" { |
| -early -re $re_kfail { |
| kfail tdep/33176 $gdb_test_name |
| # Get back gdb prompt. |
| gdb_expect { |
| -re ($re_quit|$re_core_file) { |
| send_gdb "n\n" |
| exp_continue |
| } |
| -re "$gdb_prompt " { |
| } |
| } |
| } |
| -re -wrap $run_re { |
| set ok 1 |
| pass $gdb_test_name |
| } |
| } |
| if {!$ok} { |
| return |
| } |
| } |
| |
| with_test_prefix tui { |
| Term::clean_restart 24 80 $testfile |
| if {![Term::enter_tui]} { |
| unsupported "TUI not supported" |
| return |
| } |
| |
| set text [Term::get_all_lines] |
| gdb_assert {![string match "No Source Available" $text]} \ |
| "initial source listing" |
| |
| send_gdb "core-file $core\n" |
| Term::wait_for "Program terminated" |
| Term::check_contents "load corefile" "$src_line_nr *$src_line.*$gdb_prompt .*" |
| |
| Term::command "run" |
| Term::check_contents "run until the end" $run_re |
| } |