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