]>
Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2018-2020 Free Software Foundation, Inc. |
eb77c9df AB |
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 | # This tests some non-standard DWARF spotted in an Intel C Compiler | |
17 | # generated binary. | |
18 | # | |
19 | # The DWARF standard (V5 3.3.2) says that a void C function should not | |
20 | # have a DW_AT_type attribute, however, an ICC compiled binary was | |
21 | # found to have a DW_AT_type that referenced a signed integer type, of | |
22 | # size 0, with the name 'void'. | |
23 | # | |
24 | # This 'void' integer type would cause GDB to crash in some cases, one | |
25 | # that was seen was when using 'finish' to leave the void function. | |
26 | ||
27 | load_lib dwarf.exp | |
28 | ||
29 | # This test can only be run on targets which support DWARF-2 and use gas. | |
30 | if {![dwarf2_support]} { | |
31 | return 0 | |
32 | } | |
33 | ||
34 | standard_testfile void-type.c void-type.S | |
35 | ||
36 | # Make some DWARF for the test. | |
37 | set asm_file [standard_output_file $srcfile2] | |
38 | Dwarf::assemble $asm_file { | |
39 | global srcdir subdir srcfile | |
40 | ||
41 | set func_result [function_range func ${srcdir}/${subdir}/${srcfile}] | |
42 | set func_start [lindex $func_result 0] | |
43 | set func_length [lindex $func_result 1] | |
44 | ||
45 | set main_result [function_range main ${srcdir}/${subdir}/${srcfile}] | |
46 | set main_start [lindex $main_result 0] | |
47 | set main_length [lindex $main_result 1] | |
48 | ||
49 | cu {} { | |
50 | DW_TAG_compile_unit { | |
51 | {DW_AT_producer "Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.5.212 Build 20150212"} | |
52 | {DW_AT_language @DW_LANG_C} | |
53 | {DW_AT_name void-type.c} | |
54 | {DW_AT_comp_dir /tmp} | |
55 | } { | |
35ee2dc2 | 56 | declare_labels int_type void_type ptr_type |
eb77c9df | 57 | |
35ee2dc2 | 58 | int_type: DW_TAG_base_type { |
eb77c9df AB |
59 | {DW_AT_byte_size 4 DW_FORM_sdata} |
60 | {DW_AT_encoding @DW_ATE_signed} | |
61 | {DW_AT_name int} | |
62 | } | |
63 | ||
35ee2dc2 | 64 | void_type: DW_TAG_base_type { |
eb77c9df AB |
65 | {DW_AT_byte_size 0 DW_FORM_sdata} |
66 | {DW_AT_encoding @DW_ATE_signed} | |
67 | {DW_AT_name void} | |
68 | } | |
69 | ||
70 | ptr_type: DW_TAG_pointer_type { | |
35ee2dc2 | 71 | {DW_AT_type :$void_type} |
eb77c9df AB |
72 | } |
73 | ||
74 | DW_TAG_subprogram { | |
75 | {name func} | |
76 | {low_pc $func_start addr} | |
77 | {high_pc "$func_start + $func_length" addr} | |
35ee2dc2 | 78 | {type :$void_type} |
eb77c9df AB |
79 | } |
80 | DW_TAG_subprogram { | |
81 | {name main} | |
82 | {low_pc $main_start addr} | |
83 | {high_pc "$main_start + $main_length" addr} | |
35ee2dc2 | 84 | {type :$int_type} |
eb77c9df AB |
85 | } |
86 | ||
87 | DW_TAG_variable { | |
88 | {DW_AT_name "var_a"} | |
89 | {DW_AT_type :$int_type} | |
90 | {DW_AT_external 1 DW_FORM_flag} | |
91 | {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_a"]} SPECIAL_expr} | |
92 | } | |
93 | ||
94 | DW_TAG_variable { | |
95 | {DW_AT_name "var_ptr"} | |
96 | {DW_AT_type :$ptr_type} | |
97 | {DW_AT_external 1 DW_FORM_flag} | |
98 | {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_ptr"]} SPECIAL_expr} | |
99 | } | |
100 | } | |
101 | } | |
102 | } | |
103 | ||
104 | if { [prepare_for_testing "failed to prepare" ${testfile} \ | |
105 | [list $srcfile $asm_file] {nodebug}] } { | |
106 | return -1 | |
107 | } | |
108 | ||
109 | if ![runto_main] { | |
110 | return -1 | |
111 | } | |
112 | ||
113 | # Place a breakpoint in 'func' and continue to there. | |
114 | gdb_breakpoint func | |
115 | gdb_continue_to_breakpoint "func" | |
116 | ||
117 | # Check how GDB handles the void* variable. | |
118 | gdb_test "p *var_ptr" "Attempt to dereference a generic pointer." \ | |
119 | "check that dereferencing a void* gives a suitable message" | |
120 | ||
121 | # Now finish, returning to main. | |
122 | gdb_test "finish" [multi_line \ | |
123 | "Run till exit from #0 $hex in func \\\(\\\)" \ | |
124 | "$hex in main \\\(\\\)"] \ | |
125 | "check that finish completes" |