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