1# Copyright 2003, 2007, 2008, 2009, 2010, 2011 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# Tests for PR gdb/1355, which is a reference to PR gcc/12066. 17# 2003-08-26 Michael Chastain <mec@shout.net> 18 19# This file is part of the gdb testsuite. 20 21set ws "\[\r\n\t \]*" 22set nl "\[\r\n\]+" 23 24if $tracelevel then { 25 strace $tracelevel 26 } 27 28if { [skip_cplus_tests] } { continue } 29 30# 31# test running programs 32# 33 34set testfile "gdb1355" 35set srcfile ${testfile}.cc 36set binfile ${objdir}/${subdir}/${testfile} 37 38if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { 39 untested gdb1355.exp 40 return -1 41} 42 43if [get_compiler_info ${binfile} "c++"] { 44 return -1 45} 46 47gdb_exit 48gdb_start 49gdb_reinitialize_dir $srcdir/$subdir 50gdb_load ${binfile} 51 52if ![runto_main] then { 53 perror "couldn't run to main" 54 continue 55} 56 57# See http://sources.redhat.com/gdb/bugs/1355 58# See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12066 59# 60# g++ -gstabs+ does not emit stabs for fundamental types. 61# They get emitted later inside other types, so they have no names 62# and gdb cannot handle them. 63 64set s_head "${ws}(struct|class) mystruct \{(${ws}public:|)" 65set s_tail ".*" 66 67set f_i "${ws}int m_int;" 68set f_c "${ws}char m_char;" 69set f_li "${ws}long( int)? m_long_int;" 70set f_ui "${ws}unsigned int m_unsigned_int;" 71set f_lui "${ws}(long unsigned int|unsigned long) m_long_unsigned_int;" 72set f_si "${ws}short( int)? m_short_int;" 73set f_sui "${ws}(short unsigned int|unsigned short) m_short_unsigned_int;" 74set f_uc "${ws}unsigned char m_unsigned_char;" 75set f_f "${ws}float m_float;" 76set f_d "${ws}double m_double;" 77set f_ld "${ws}long double m_long_double;" 78set f_b "${ws}bool m_bool;" 79 80set itc "<invalid type code ${decimal}>" 81set bad_i "${ws}(${itc}|int) m_int;"; 82set bad_c "${ws}(${itc}|char) m_char;" 83set bad_li "${ws}(${itc}|long int) m_long_int;" 84set bad_ui "${ws}(${itc}|unsigned int) m_unsigned_int;" 85set bad_lui "${ws}(${itc}|long unsigned int) m_long_unsigned_int;" 86set bad_si "${ws}(${itc}|short int) m_short_int;" 87set bad_sui "${ws}(${itc}|short unsigned int) m_short_unsigned_int;" 88set bad_uc "${ws}(${itc}|unsigned char) m_unsigned_char;" 89set bad_f "${ws}(${itc}|float) m_float;" 90set bad_d "${ws}(${itc}|double) m_double;" 91set bad_ld "${ws}(${itc}|long double) m_long_double;" 92set bad_b "${ws}(${itc}|bool) m_bool;" 93 94gdb_test_multiple "ptype s1" "ptype s1" { 95 -re "type = ${s_head}${f_i}${f_c}${f_li}${f_ui}${f_lui}${f_si}${f_sui}${f_uc}${f_f}${f_d}${f_ld}${f_b}${s_tail}\}$nl$gdb_prompt $" { 96 pass "ptype s1" 97 } 98 -re "type = ${s_head}${bad_i}${bad_c}${bad_li}${bad_ui}${bad_lui}${bad_si}${bad_sui}${bad_uc}${bad_f}${bad_d}${bad_ld}${bad_b}${s_tail}\}$nl$gdb_prompt $" { 99 # This happened with gcc HEAD 2003-08-20 08:00:00 UTC, -gstabs+. 100 kfail "gdb/1355" "ptype s1" 101 } 102} 103 104gdb_test_multiple "print s1" "print s1" { 105 -re "$decimal = \{m_int = 117, m_char = 97 'a', m_long_int = 118, m_unsigned_int = 119, m_long_unsigned_int = 120, m_short_int = 123, m_short_unsigned_int = 124, m_unsigned_char = 98 'b', m_float = 125, m_double = 126, m_long_double = 127, m_bool = true\}$nl$gdb_prompt $" { 106 pass "print s1" 107 } 108 -re "$decimal = \{m_int = 117, m_char = 97 'a', m_long_int = 118, m_unsigned_int = 119, m_long_unsigned_int = 120, m_short_int = 123, m_short_unsigned_int = 124, m_unsigned_char = 98 'b', m_float = 125, m_double = 126, m_long_double = 127, m_bool = 117\}$nl$gdb_prompt $" { 109 # This pattern is very picky, but if more different output 110 # shows up, I can just add more arms. -- chastain 2003-08-26 111 # 112 # This happened with gcc HEAD 2003-08-20 08:00:00 UTC, -gstabs+. 113 # Look at the value of m_bool. It looks like gdb latched onto 114 # random int type and then used the data at structure offset 0. 115 kfail "gdb/1355" "print s1" 116 } 117} 118