]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/typedef-void-finish.exp
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / typedef-void-finish.exp
1 # Copyright 2019-2022 Free Software Foundation, Inc.
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 # PR gdb/21855 concerns a crash in "finish" where the function's
17 # return type is a typedef of void.
18
19 load_lib dwarf.exp
20 load_lib gdb-python.exp
21
22 # This test can only be run on targets which support DWARF-2 and use gas.
23 if {![dwarf2_support]} {
24 return 0
25 }
26
27 standard_testfile void-type.c .S
28
29 # Make some DWARF for the test.
30 set asm_file [standard_output_file $srcfile2]
31 Dwarf::assemble $asm_file {
32 global srcfile
33
34 cu {} {
35 DW_TAG_compile_unit {
36 {DW_AT_producer "GNU C 8.1"}
37 {DW_AT_language @DW_LANG_C}
38 {DW_AT_name $srcfile}
39 {DW_AT_comp_dir /tmp}
40 } {
41 declare_labels main_type void_typedef
42
43 main_type: DW_TAG_base_type {
44 {DW_AT_byte_size 4 DW_FORM_sdata}
45 {DW_AT_encoding @DW_ATE_signed}
46 }
47
48 void_typedef: DW_TAG_typedef {
49 {name foo}
50 }
51
52 DW_TAG_subprogram {
53 {MACRO_AT_func {func}}
54 {type :$void_typedef}
55 }
56 DW_TAG_subprogram {
57 {MACRO_AT_func {main}}
58 {type :$main_type}
59 }
60 }
61 }
62 }
63
64 if { [prepare_for_testing "failed to prepare" ${testfile} \
65 [list $srcfile $asm_file] {nodebug}] } {
66 return -1
67 }
68
69 if {![runto_main]} {
70 return -1
71 }
72
73 gdb_test "break func" "Breakpoint .*" \
74 "set breakpoint in func"
75 gdb_continue_to_breakpoint "continue to func"
76
77 set skip_python [skip_python_tests]
78 if {!$skip_python} {
79 gdb_test "python finishbp = gdb.FinishBreakpoint()" \
80 "Temporary breakpoint.*" "set FinishBreakpoint"
81 }
82
83 gdb_test "finish" [multi_line \
84 "Run till exit from #0 $hex in func \\\(\\\)" \
85 ".*$hex in main \\\(\\\)"]
86
87 if {!$skip_python} {
88 gdb_test "python print (finishbp.return_value)" "None" \
89 "check that return_value is None"
90 }