Update copyright year range in all GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / typedef-void-finish.exp
1 # Copyright 2019-2020 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 typedef-void-finish.S
28
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
33
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]
37
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]
41
42 cu {} {
43 DW_TAG_compile_unit {
44 {DW_AT_producer "GNU C 8.1"}
45 {DW_AT_language @DW_LANG_C}
46 {DW_AT_name void-type.c}
47 {DW_AT_comp_dir /tmp}
48 } {
49 declare_labels main_type void_typedef
50
51 main_type: DW_TAG_base_type {
52 {DW_AT_byte_size 4 DW_FORM_sdata}
53 {DW_AT_encoding @DW_ATE_signed}
54 }
55
56 void_typedef: DW_TAG_typedef {
57 {name foo}
58 }
59
60 DW_TAG_subprogram {
61 {name func}
62 {low_pc $func_start addr}
63 {high_pc "$func_start + $func_length" addr}
64 {type :$void_typedef}
65 }
66 DW_TAG_subprogram {
67 {name main}
68 {low_pc $main_start addr}
69 {high_pc "$main_start + $main_length" addr}
70 {type :$main_type}
71 }
72 }
73 }
74 }
75
76 if { [prepare_for_testing "failed to prepare" ${testfile} \
77 [list $srcfile $asm_file] {nodebug}] } {
78 return -1
79 }
80
81 if {![runto_main]} {
82 return -1
83 }
84
85 gdb_test "break func" "Breakpoint .*" \
86 "set breakpoint in func"
87 gdb_continue_to_breakpoint "continue to func"
88
89 set skip_python [skip_python_tests]
90 if {!$skip_python} {
91 gdb_test "python finishbp = gdb.FinishBreakpoint()" \
92 "Temporary breakpoint.*" "set FinishBreakpoint"
93 }
94
95 gdb_test "finish" [multi_line \
96 "Run till exit from #0 $hex in func \\\(\\\)" \
97 ".*$hex in main \\\(\\\)"]
98
99 if {!$skip_python} {
100 gdb_test "python print (finishbp.return_value)" "None" \
101 "check that return_value is None"
102 }
This page took 0.033587 seconds and 4 git commands to generate.