Fix: Null pointer dereference in ldlex.l
[binutils-gdb.git] / gdb / testsuite / gdb.base / type-opaque.exp
blob4d6fcddea56957476f63d7351fc7c98b698430fb
1 # Copyright 2004-2023 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 # Test resolving of an opaque type from the loaded shared library.
18 require allow_shlib_tests
20 standard_testfile type-opaque-main.c
22 set libfile type-opaque-lib
23 set libsrc "${srcdir}/${subdir}/${libfile}.c"
24 set libobj [standard_output_file ${libfile}.so]
25 set execsrc "${srcdir}/${subdir}/${srcfile}"
27 remote_exec build "rm -f ${binfile}"
29 if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
30 || [gdb_compile $execsrc ${binfile} executable \
31 [list debug shlib=${libobj}]] != "" } {
32 return -1
35 clean_restart ${binfile}
36 gdb_load_shlib ${libobj}
38 if {![runto_main]} {
39 return 0
43 # DWARF3: An incomplete structure, union or class type is represented by
44 # a structure, union or class entry that does not have a byte size attribute
45 # and that has a DW_AT_declaration attribute.
48 proc body { struct } {
49 global gdb_prompt
52 # <1><15f>: Abbrev Number: 8 (DW_TAG_structure_type)
53 # DW_AT_name : libtype_opaque
54 # DW_AT_declaration : 1
56 set name "opaque $struct type resolving"
57 gdb_test_multiple "ptype pointer_${struct}_opaque" $name \
59 -re "libfield_opaque.*$gdb_prompt $" {
60 pass $name
65 # <1><9e>: Abbrev Number: 2 (DW_TAG_structure_type)
66 # DW_AT_name : libtype_empty
67 # DW_AT_byte_size : 0
68 # DW_AT_decl_file : 1
69 # DW_AT_decl_line : 25
71 set name "empty $struct type resolving"
72 gdb_test_multiple "ptype pointer_${struct}_empty" $name \
74 -re "\\{\[ \t\r\n\]*<no data fields>\[ \t\r\n\]*\\}.*$gdb_prompt $" {
75 pass $name
77 -re "libfield_empty.*$gdb_prompt $" {
78 fail $name
83 # <1><b0>: Abbrev Number: 3 (DW_TAG_structure_type)
84 # DW_AT_sibling : <e3>
85 # DW_AT_name : libtype_filled
86 # DW_AT_byte_size : 4
87 # DW_AT_decl_file : 1
88 # DW_AT_decl_line : 29
89 # <2><c7>: Abbrev Number: 4 (DW_TAG_member)
90 # DW_AT_name : mainfield_filled
91 # DW_AT_decl_file : 1
92 # DW_AT_decl_line : 30
93 # DW_AT_type : <e3>
94 # DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0)
96 set name "filled $struct type resolving"
97 gdb_test_multiple "ptype pointer_${struct}_filled" $name \
99 -re "mainfield_filled.*$gdb_prompt $" {
100 pass $name
102 -re "libfield_filled.*$gdb_prompt $" {
103 fail $name
111 body struct
112 body union