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