1# Copyright 2004, 2007 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# Please email any bugs, comments, and/or additions to this file to: 17# bug-gdb@prep.ai.mit.edu 18 19# Test resolving of an opaque type from the loaded shared library. 20 21if $tracelevel then { 22 strace $tracelevel 23} 24 25set testfile type-opaque-main 26set libfile type-opaque-lib 27set srcfile ${testfile}.c 28set binfile ${objdir}/${subdir}/${testfile} 29 30set libsrc "${srcdir}/${subdir}/${libfile}.c" 31set libobj "${objdir}/${subdir}/${libfile}.so" 32set execsrc "${srcdir}/${subdir}/${srcfile}" 33 34remote_exec build "rm -f ${binfile}" 35 36# Are we on a target board? No support for downloading shared libraries 37# to a target yet. 38if ![isnative] then { 39 return 0 40} 41 42# get the value of gcc_compiled 43if [get_compiler_info ${binfile}] { 44 return -1 45} 46 47if { [gdb_compile_shlib $libsrc $libobj {debug}] != "" 48 || [gdb_compile $execsrc ${binfile} executable \ 49 [list debug shlib=${libobj}]] != "" } { 50 return -1 51} 52 53gdb_exit 54gdb_start 55gdb_reinitialize_dir $srcdir/$subdir 56gdb_load ${binfile} 57 58if ![runto_main] then { 59 fail "Can't run to main" 60 return 0 61} 62 63 64# DWARF3: An incomplete structure, union or class type is represented by 65# a structure, union or class entry that does not have a byte size attribute 66# and that has a DW_AT_declaration attribute. 67 68 69proc body { struct } { 70 global gdb_prompt 71 72 73 # <1><15f>: Abbrev Number: 8 (DW_TAG_structure_type) 74 # DW_AT_name : libtype_opaque 75 # DW_AT_declaration : 1 76 77 set name "opaque $struct type resolving" 78 gdb_test_multiple "ptype pointer_${struct}_opaque" $name \ 79 { 80 -re "libfield_opaque.*$gdb_prompt $" { 81 pass $name 82 } 83 } 84 85 86 # <1><9e>: Abbrev Number: 2 (DW_TAG_structure_type) 87 # DW_AT_name : libtype_empty 88 # DW_AT_byte_size : 0 89 # DW_AT_decl_file : 1 90 # DW_AT_decl_line : 25 91 92 set name "empty $struct type resolving" 93 gdb_test_multiple "ptype pointer_${struct}_empty" $name \ 94 { 95 -re "\\{\[ \t\r\n\]*<no data fields>\[ \t\r\n\]*\\}.*$gdb_prompt $" { 96 pass $name 97 } 98 -re "libfield_empty.*$gdb_prompt $" { 99 fail $name 100 } 101 } 102 103 104 # <1><b0>: Abbrev Number: 3 (DW_TAG_structure_type) 105 # DW_AT_sibling : <e3> 106 # DW_AT_name : libtype_filled 107 # DW_AT_byte_size : 4 108 # DW_AT_decl_file : 1 109 # DW_AT_decl_line : 29 110 # <2><c7>: Abbrev Number: 4 (DW_TAG_member) 111 # DW_AT_name : mainfield_filled 112 # DW_AT_decl_file : 1 113 # DW_AT_decl_line : 30 114 # DW_AT_type : <e3> 115 # DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0) 116 117 set name "filled $struct type resolving" 118 gdb_test_multiple "ptype pointer_${struct}_filled" $name \ 119 { 120 -re "mainfield_filled.*$gdb_prompt $" { 121 pass $name 122 } 123 -re "libfield_filled.*$gdb_prompt $" { 124 fail $name 125 } 126 } 127 128 129} 130 131 132body struct 133body union 134