Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / void-type.exp
blobc0adcc47f738bcec059c4f006eab59c30681e7a2
1 # Copyright 2018-2024 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 # This tests some non-standard DWARF spotted in an Intel C Compiler
17 # generated binary.
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'.
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.
27 load_lib dwarf.exp
29 # This test can only be run on targets which support DWARF-2 and use gas.
30 require dwarf2_support
32 standard_testfile .c .S
34 # Make some DWARF for the test.
35 set asm_file [standard_output_file $srcfile2]
36 Dwarf::assemble $asm_file {
37     global srcfile
39     cu {} {
40         DW_TAG_compile_unit {
41                 {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"}
42                 {DW_AT_language @DW_LANG_C}
43                 {DW_AT_name     $srcfile}
44                 {DW_AT_comp_dir /tmp}
45         } {
46             declare_labels int_type void_type ptr_type
48             int_type: DW_TAG_base_type {
49                 {DW_AT_byte_size 4 DW_FORM_sdata}
50                 {DW_AT_encoding  @DW_ATE_signed}
51                 {DW_AT_name      int}
52             }
54             void_type: DW_TAG_base_type {
55                 {DW_AT_byte_size 0 DW_FORM_sdata}
56                 {DW_AT_encoding  @DW_ATE_signed}
57                 {DW_AT_name      void}
58             }
60             ptr_type: DW_TAG_pointer_type {
61                 {DW_AT_type :$void_type}
62             }
64             DW_TAG_subprogram {
65                 {MACRO_AT_func {func}}
66                 {type :$void_type}
67             }
68             DW_TAG_subprogram {
69                 {MACRO_AT_func {main}}
70                 {type :$int_type}
71             }
73             DW_TAG_variable {
74                 {DW_AT_name "var_a"}
75                 {DW_AT_type :$int_type}
76                 {DW_AT_external 1 DW_FORM_flag}
77                 {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_a"]} SPECIAL_expr}
78             }
80             DW_TAG_variable {
81                 {DW_AT_name "var_ptr"}
82                 {DW_AT_type :$ptr_type}
83                 {DW_AT_external 1 DW_FORM_flag}
84                 {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_ptr"]} SPECIAL_expr}
85             }
86         }
87     }
90 if { [prepare_for_testing "failed to prepare" ${testfile} \
91           [list $srcfile $asm_file] {nodebug}] } {
92     return -1
95 if ![runto_main] {
96     return -1
99 # Place a breakpoint in 'func' and continue to there.
100 gdb_breakpoint func
101 gdb_continue_to_breakpoint "func"
103 # Check how GDB handles the void* variable.
104 gdb_test "p *var_ptr" "Attempt to dereference a generic pointer." \
105     "check that dereferencing a void* gives a suitable message"
107 # Now finish, returning to main.
108 gdb_test "finish" [multi_line \
109                        "Run till exit from #0  $hex in func \\\(\\\)" \
110                        "$hex in main \\\(\\\)"] \
111     "check that finish completes"