]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2019-2024 Free Software Foundation, Inc. |
494409bb SDJ |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | # Test whether we can load a corefile, enable TUI and then invoke | |
17 | # "run" without having a segfault. | |
18 | # | |
19 | # Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1765117 | |
20 | ||
8c74a764 | 21 | tuiterm_env |
494409bb SDJ |
22 | |
23 | standard_testfile tui-layout.c | |
24 | ||
f1025b23 | 25 | set core [standard_output_file "${testfile}.core"] |
494409bb SDJ |
26 | |
27 | if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } { | |
28 | return -1 | |
29 | } | |
30 | ||
31 | # Only run on native boards. | |
ed7d5797 | 32 | require {target_can_use_run_cmd core} |
494409bb SDJ |
33 | |
34 | if { ![runto_main] } { | |
494409bb SDJ |
35 | return -1 |
36 | } | |
37 | ||
38 | if { ![gdb_gcore_cmd "$core" "save a corefile"] } { | |
39 | untested "could not generate a corefile" | |
40 | return -1 | |
41 | } | |
42 | ||
6b81ded4 TV |
43 | set src_line "return 0;" |
44 | set src_line_nr [gdb_get_line_number $src_line] | |
45 | ||
46 | set run_re \ | |
47 | "\\\[Inferior $decimal \\\(process $decimal\\\) exited normally\\]" | |
48 | ||
49 | if { [info exists USE_TUI] && $USE_TUI == 0 } { | |
50 | clean_restart $testfile | |
51 | gdb_test "core-file $core" $src_line "load corefile" | |
52 | gdb_test "run" $run_re "run until the end" | |
53 | return | |
54 | } | |
55 | ||
494409bb SDJ |
56 | Term::clean_restart 24 80 $testfile |
57 | if {![Term::enter_tui]} { | |
58 | unsupported "TUI not supported" | |
581bea2c | 59 | return |
494409bb SDJ |
60 | } |
61 | ||
62 | set text [Term::get_all_lines] | |
63 | gdb_assert {![string match "No Source Available" $text]} \ | |
64 | "initial source listing" | |
65 | ||
f57b5a39 TV |
66 | send_gdb "core-file $core\n" |
67 | Term::wait_for "Program terminated" | |
6b81ded4 | 68 | Term::check_contents "load corefile" "$src_line_nr *$src_line.*$gdb_prompt .*" |
494409bb SDJ |
69 | |
70 | Term::command "run" | |
6b81ded4 | 71 | Term::check_contents "run until the end" $run_re |