1 # Copyright 2019-2020 Free Software Foundation, Inc.
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.
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.
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/>.
16 # PR gdb/21855 concerns a crash in "finish" where the function's
17 # return type is a typedef of void.
20 load_lib gdb-python.exp
22 # This test can only be run on targets which support DWARF-2 and use gas.
23 if {![dwarf2_support]} {
27 standard_testfile void-type.c typedef-void-finish.S
29 # Make some DWARF for the test.
30 set asm_file [standard_output_file $srcfile2]
31 Dwarf::assemble $asm_file {
32 global srcdir subdir srcfile
34 set func_result [function_range func ${srcdir}/${subdir}/${srcfile}]
35 set func_start [lindex $func_result 0]
36 set func_length [lindex $func_result 1]
38 set main_result [function_range main ${srcdir}/${subdir}/${srcfile}]
39 set main_start [lindex $main_result 0]
40 set main_length [lindex $main_result 1]
44 {DW_AT_producer "GNU C 8.1"}
45 {DW_AT_language @DW_LANG_C}
46 {DW_AT_name void-type.c}
49 declare_labels main_type void_typedef
51 main_type: DW_TAG_base_type {
52 {DW_AT_byte_size 4 DW_FORM_sdata}
53 {DW_AT_encoding @DW_ATE_signed}
56 void_typedef: DW_TAG_typedef {
62 {low_pc $func_start addr}
63 {high_pc "$func_start + $func_length" addr}
68 {low_pc $main_start addr}
69 {high_pc "$main_start + $main_length" addr}
76 if { [prepare_for_testing "failed to prepare" ${testfile} \
77 [list $srcfile $asm_file] {nodebug}] } {
85 gdb_test "break func" "Breakpoint .*" \
86 "set breakpoint in func"
87 gdb_continue_to_breakpoint "continue to func"
89 set skip_python [skip_python_tests]
91 gdb_test "python finishbp = gdb.FinishBreakpoint()" \
92 "Temporary breakpoint.*" "set FinishBreakpoint"
95 gdb_test "finish" [multi_line \
96 "Run till exit from #0 $hex in func \\\(\\\)" \
97 ".*$hex in main \\\(\\\)"]
100 gdb_test "python print (finishbp.return_value)" "None" \
101 "check that return_value is None"