| 1 | # Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2003, 2004 |
| 2 | # Free Software Foundation, Inc. |
| 3 | |
| 4 | # This program is free software; you can redistribute it and/or modify |
| 5 | # it under the terms of the GNU General Public License as published by |
| 6 | # the Free Software Foundation; either version 2 of the License, or |
| 7 | # (at your option) any later version. |
| 8 | # |
| 9 | # This program is distributed in the hope that it will be useful, |
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | # GNU General Public License for more details. |
| 13 | # |
| 14 | # You should have received a copy of the GNU General Public License |
| 15 | # along with this program; if not, write to the Free Software |
| 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | |
| 18 | # Please email any bugs, comments, and/or additions to this file to: |
| 19 | # bug-gdb@prep.ai.mit.edu |
| 20 | |
| 21 | # This file was written by Fred Fish. (fnf@cygnus.com) |
| 22 | |
| 23 | set ws "\[\r\n\t \]+" |
| 24 | |
| 25 | if $tracelevel then { |
| 26 | strace $tracelevel |
| 27 | } |
| 28 | |
| 29 | if { [skip_cplus_tests] } { continue } |
| 30 | |
| 31 | set testfile "templates" |
| 32 | set srcfile ${testfile}.cc |
| 33 | set binfile ${objdir}/${subdir}/${testfile} |
| 34 | |
| 35 | # Create and source the file that provides information about the compiler |
| 36 | # used to compile the test case. |
| 37 | if [get_compiler_info ${binfile} "c++"] { |
| 38 | return -1 |
| 39 | } |
| 40 | source ${binfile}.ci |
| 41 | |
| 42 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { |
| 43 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
| 44 | } |
| 45 | |
| 46 | # |
| 47 | # Test printing of the types of templates. |
| 48 | # |
| 49 | |
| 50 | proc test_ptype_of_templates {} { |
| 51 | global gdb_prompt |
| 52 | global ws |
| 53 | |
| 54 | send_gdb "ptype T5<int>\n" |
| 55 | gdb_expect { |
| 56 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { |
| 57 | pass "ptype T5<int>" |
| 58 | } |
| 59 | -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}${ws}T5 \\(int\\);${ws}T5 \\(const class T5<int> &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned int\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}${ws}$gdb_prompt $" { pass "ptype T5<int> -- new with unsigned int" } |
| 60 | -re "type = class T5<int> \\{.*public:.*static int X;.*int x;.*int val;.*T5 \\(int\\);.*T5 \\(const class T5<int> &\\);.*void ~T5 \\(int\\);.*static void \\* new \\(unsigned long\\);.*static void delete \\(void ?\\*\\);.*int value \\((void|)\\);.*\\}\r\n$gdb_prompt $" { pass "ptype T5<int> -- new with unsigned long" } |
| 61 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;((${ws}T5<int> & operator=\\(T5<int> const ?&\\);)|(${ws}T5\\(int\\);)|(${ws}T5\\((T5<int> const|const T5<int>) ?&\\);)|(${ws}~T5\\((void|)\\);)|(${ws}static void \\* operator new\\(unsigned( int| long)?\\);)|(${ws}static void operator delete\\(void ?\\*\\);)|(${ws}int value\\((void|)\\);))*${ws}\}\r\n$gdb_prompt $" { |
| 62 | pass "ptype T5<int> (obsolescent gcc or gdb)" |
| 63 | } |
| 64 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\(unsigned( int| long|)\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { |
| 65 | # This also triggers gdb/1113... |
| 66 | kfail "gdb/1111" "ptype T5<int>" |
| 67 | } |
| 68 | -re ".*$gdb_prompt $" { |
| 69 | fail "ptype T5<int>" |
| 70 | } |
| 71 | timeout { |
| 72 | fail "ptype T5<int> (timeout)" |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | send_gdb "ptype t5i\n" |
| 77 | gdb_expect { |
| 78 | -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5\\(int\\);${ws}T5\\(T5<int> const ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\\}\r\n$gdb_prompt $" { pass "ptype T5<int> -- with several fixes from 4.17" } |
| 79 | -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5 \\(int\\);${ws}T5 \\(const class T5<int> &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned int\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}\r\n$gdb_prompt $" { pass "ptype t5i<int> -- new with unsigned int" } |
| 80 | -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5 \\(int\\);${ws}T5 \\(const class T5<int> &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned long\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}\r\n$gdb_prompt $" { pass "ptype t5i<int> -- new with unsigned long" } |
| 81 | -re "type = class T5<int> \{.*public:.*static int X;.*int x;.*int val;.*.*T5 \\(int\\);.*.*void ~T5 \\(int\\).*.*.*int value \\((void|)\\);.*\}.*$gdb_prompt $" { |
| 82 | pass "ptype t5i" |
| 83 | } |
| 84 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { |
| 85 | pass "ptype t5i" |
| 86 | } |
| 87 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;((${ws}T5<int> & operator=\\(T5<int> const ?&\\);)|(${ws}T5\\(int\\);)|(${ws}T5\\(T5<int> const ?&\\);)|(${ws}~T5\\((void|)\\);)|(${ws}static void \\* operator new\\(unsigned( int| long)?\\);)|(${ws}static void operator delete\\(void ?\\*\\);)|(${ws}int value\\((void|)\\);))*${ws}\}\r\n$gdb_prompt $" { |
| 88 | pass "ptype t5i (obsolescent gcc or gdb)" |
| 89 | } |
| 90 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\(unsigned( int| long|)\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { |
| 91 | # This also triggers gdb/1113... |
| 92 | kfail "gdb/1111" "ptype T5<int>" |
| 93 | } |
| 94 | -re ".*$gdb_prompt $" { |
| 95 | fail "ptype t5i" |
| 96 | } |
| 97 | timeout { |
| 98 | fail "ptype t5i (timeout)" |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | # |
| 104 | # Test breakpoint setting on template methods. |
| 105 | # |
| 106 | |
| 107 | proc test_template_breakpoints {} { |
| 108 | global gdb_prompt |
| 109 | global testfile |
| 110 | global srcdir |
| 111 | global hp_aCC_compiler |
| 112 | |
| 113 | send_gdb "break T5<int>::T5\n" |
| 114 | gdb_expect { |
| 115 | -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2. T5<int>::T5\\(int\\) at .*\[\r\n\]*.3. T5<int>::T5\\((T5<int> const|const T5<int>) ?&\\) at .*\[\r\n\]*> $" { |
| 116 | gdb_test "0" \ |
| 117 | "canceled" \ |
| 118 | "constructor breakpoint (obsolete format!)" |
| 119 | } |
| 120 | -re ".0. cancel\[\r\n\]*.1. all\[\r\n\]*.2. T5<int>::T5\\((T5<int> const|const T5<int>) ?&\\) at .*templates.cc:.*\[\r\n\]*.3. T5<int>::T5\\(int\\) at .*templates.cc:.*\[\r\n\]*> $" { |
| 121 | gdb_test "0" \ |
| 122 | "canceled" \ |
| 123 | "constructor breakpoint" |
| 124 | } |
| 125 | -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2. T5 at .*\[\r\n\]*.3. T5 at .*\[\r\n\]*> $" { |
| 126 | setup_kfail "gdb/1062" "*-*-*" |
| 127 | gdb_test "0" \ |
| 128 | "nonsense intended to insure that this test fails" \ |
| 129 | "constructor breakpoint" |
| 130 | } |
| 131 | -re ".*\n> $" { |
| 132 | gdb_test "0" \ |
| 133 | "nonsense intended to insure that this test fails" \ |
| 134 | "constructor breakpoint (bad menu choices)" |
| 135 | } |
| 136 | -re ".*$gdb_prompt $" { fail "constructor breakpoint" } |
| 137 | default { fail "constructor breakpoint (timeout)" } |
| 138 | } |
| 139 | |
| 140 | # See CLLbs14792 |
| 141 | if {$hp_aCC_compiler} {setup_xfail hppa*-*-* CLLbs14792} |
| 142 | |
| 143 | gdb_test_multiple "break T5<int>::~T5" "destructor_breakpoint" { |
| 144 | -re "Breakpoint.*at.* file .*${testfile}.cc, line.*$gdb_prompt $" |
| 145 | { |
| 146 | pass "destructor breakpoint" |
| 147 | } |
| 148 | -re "the class `T5<int>' does not have destructor defined\r\nHint: try 'T5<int>::~T5<TAB> or 'T5<int>::~T5<ESC-\\?>\r\n\\(Note leading single quote.\\)\r\n$gdb_prompt $" |
| 149 | { |
| 150 | kfail "gdb/1112" "destructor breakpoint" |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | gdb_test "break T5<int>::value" \ |
| 155 | "Breakpoint.*at.* file .*${testfile}.cc, line.*" \ |
| 156 | "value method breakpoint" |
| 157 | |
| 158 | delete_breakpoints |
| 159 | } |
| 160 | |
| 161 | # |
| 162 | # Test calling of template methods. |
| 163 | # |
| 164 | |
| 165 | proc test_template_calls {} { |
| 166 | global gdb_prompt |
| 167 | global hp_aCC_compiler |
| 168 | |
| 169 | if [target_info exists gdb,cannot_call_functions] { |
| 170 | setup_xfail "*-*-*" 2416 |
| 171 | fail "This target can not call functions" |
| 172 | return |
| 173 | } |
| 174 | |
| 175 | if {!$hp_aCC_compiler} {setup_xfail hppa*-*-*} |
| 176 | send_gdb "print t5i.value()\n" |
| 177 | gdb_expect { |
| 178 | -re ".* = 2\[\r\n\]*$gdb_prompt $" { pass "print t5i.value()" } |
| 179 | -re "Cannot invoke functions on this machine.*$gdb_prompt $" { |
| 180 | fail "print t5i.value()" |
| 181 | } |
| 182 | -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { |
| 183 | setup_xfail hppa*-*-* CLLbs16899 |
| 184 | xfail "print t5i.value" |
| 185 | } |
| 186 | -re ".*$gdb_prompt $" { fail "print t5i.value()" } |
| 187 | timeout { fail "print t5i.value() (timeout)" } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | |
| 192 | proc do_tests {} { |
| 193 | global prms_id |
| 194 | global bug_id |
| 195 | global subdir |
| 196 | global objdir |
| 197 | global srcdir |
| 198 | global binfile |
| 199 | global gdb_prompt |
| 200 | |
| 201 | set prms_id 0 |
| 202 | set bug_id 0 |
| 203 | |
| 204 | # Start with a fresh gdb. |
| 205 | |
| 206 | gdb_exit |
| 207 | gdb_start |
| 208 | gdb_reinitialize_dir $srcdir/$subdir |
| 209 | gdb_load $binfile |
| 210 | |
| 211 | runto_main |
| 212 | |
| 213 | test_ptype_of_templates |
| 214 | test_template_breakpoints |
| 215 | |
| 216 | if [ runto_main] { |
| 217 | test_template_calls |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | do_tests |
| 222 | |
| 223 | |
| 224 | # More tests for different kinds of template parameters, |
| 225 | # templates with partial specializations, nested templates, etc. |
| 226 | # These have been tested only with HP aCC. They probably won't |
| 227 | # work with other compilers because of differences in mangling |
| 228 | # schemes. |
| 229 | # Added by Satish Pai <pai@apollo.hp.com> 1997-09-25 |
| 230 | # As of 2000-06-03, C++ support has been improved to the point that g++ can |
| 231 | # pass all of theses, excluding what appears to be one that exposes a stabs bug. - djb |
| 232 | |
| 233 | # I don't know how HP could be passing these tests without this. They |
| 234 | # weren't breakpointing past a point where the below expressions were |
| 235 | # initialized in the actual source. - djb |
| 236 | |
| 237 | send_gdb "b 770\n" |
| 238 | gdb_expect { |
| 239 | -re ".*$gdb_prompt $" |
| 240 | } |
| 241 | send_gdb "c\n" |
| 242 | gdb_expect { |
| 243 | -re ".*$gdb_prompt $" |
| 244 | } |
| 245 | send_gdb "print fint\n" |
| 246 | gdb_expect { |
| 247 | -re "\\$\[0-9\]* = \\{x = 0, t = 0\\}\r\n$gdb_prompt $" { pass "print fint" } |
| 248 | -re "$gdb_prompt $" { fail "print fint" } |
| 249 | timeout { fail "(timeout) print fint" } |
| 250 | } |
| 251 | |
| 252 | send_gdb "print fvpchar\n" |
| 253 | gdb_expect { |
| 254 | -re "\\$\[0-9\]* = \\{x = 0, t = 0x0\\}\r\n$gdb_prompt $" { pass "print fvpchar" } |
| 255 | -re "$gdb_prompt $" { fail "print fvpchar" } |
| 256 | timeout { fail "(timeout) print fvpchar" } |
| 257 | } |
| 258 | |
| 259 | # Template Foo<T> |
| 260 | |
| 261 | # Neither stabs nor DWARF-2 contains type information about templates |
| 262 | # (as opposed to instantiations of templates), so in those |
| 263 | # circumstances we expect GDB to not find a symbol. HP has a debug |
| 264 | # format that contains more info, though, so it's also correct to |
| 265 | # print out template info. (This affects several subsequent tests as |
| 266 | # well.) |
| 267 | |
| 268 | # NOTE: carlton/2003-02-26: However, because of a bug in the way GDB |
| 269 | # handles nested types, we don't get this right in the DWARF-2 case. |
| 270 | |
| 271 | send_gdb "ptype Foo\n" |
| 272 | gdb_expect { |
| 273 | -re "type = template <(class |)T> (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Foo<volatile char \\*>\r\n\[ \t\]*(class |)Foo<char>\r\n\[ \t\]*(class |)Foo<int>\r\n$gdb_prompt $" { pass "ptype Foo" } |
| 274 | -re "type = template <(class |)T> (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Foo" } |
| 275 | -re "type = class Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int foo\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" |
| 276 | { # GCC 3.1, DWARF-2 output. |
| 277 | kfail "gdb/57" "ptype Foo" } |
| 278 | -re "No symbol \"Foo\" in current context.\r\n$gdb_prompt $" |
| 279 | { # GCC 2.95.3, stabs+ output. |
| 280 | pass "ptype Foo" } |
| 281 | -re "$gdb_prompt $" { fail "ptype Foo" } |
| 282 | timeout { fail "(timeout) ptype Foo" } |
| 283 | } |
| 284 | # -re "type = class Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int foo(int, int);\r\n\\}\r\n$gdb_prompt $" |
| 285 | |
| 286 | # ptype Foo<int> |
| 287 | |
| 288 | send_gdb "ptype fint\n" |
| 289 | gdb_expect { |
| 290 | -re "type = (class |)Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int foo\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype fint" } |
| 291 | -re "$gdb_prompt $" { fail "ptype fint" } |
| 292 | timeout { fail "(timeout) ptype fint" } |
| 293 | } |
| 294 | |
| 295 | # ptype Foo<char> |
| 296 | |
| 297 | send_gdb "ptype fchar\n" |
| 298 | gdb_expect { |
| 299 | -re "type = (class |)Foo<char> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*.*char foo\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype fchar" } |
| 300 | -re "$gdb_prompt $" { fail "ptype fchar" } |
| 301 | timeout { fail "(timeout) ptype fchar" } |
| 302 | } |
| 303 | |
| 304 | # ptype Foo<volatile char *> |
| 305 | |
| 306 | send_gdb "ptype fvpchar\n" |
| 307 | gdb_expect { |
| 308 | -re "type = (class |)Foo<volatile char ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char \\* foo\\(int,.*char.*\\*\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype fvpchar" } |
| 309 | -re "$gdb_prompt $" { fail "ptype fvpchar" } |
| 310 | timeout { fail "(timeout) ptype fvpchar" } |
| 311 | } |
| 312 | |
| 313 | # print a function from Foo<volatile char *> |
| 314 | |
| 315 | # This test is sensitive to whitespace matching, so we'll do it twice, |
| 316 | # varying the spacing, because of PR gdb/33. |
| 317 | |
| 318 | send_gdb "print Foo<volatile char *>::foo\n" |
| 319 | gdb_expect { |
| 320 | -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<volatile char ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { pass "print Foo<volatile char *>::foo" } |
| 321 | -re "No symbol \"Foo<volatile char \\*>\" in current context.\r\n$gdb_prompt $" |
| 322 | { |
| 323 | # This used to be a kfail gdb/33, but it shouldn't occur any more now. |
| 324 | fail "print Foo<volatile char *>::foo" |
| 325 | } |
| 326 | -re "$gdb_prompt $" { fail "print Foo<volatile char *>::foo" } |
| 327 | timeout { fail "(timeout) print Foo<volatile char *>::foo" } |
| 328 | } |
| 329 | |
| 330 | send_gdb "print Foo<volatile char*>::foo\n" |
| 331 | gdb_expect { |
| 332 | -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<volatile char ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { pass "print Foo<volatile char*>::foo" } |
| 333 | -re "No symbol \"Foo<volatile char\\*>\" in current context.\r\n$gdb_prompt $" |
| 334 | { |
| 335 | # This used to be a kfail gdb/33, but it shouldn't occur any more now. |
| 336 | fail "print Foo<volatile char *>::foo" |
| 337 | } |
| 338 | -re "$gdb_prompt $" { fail "print Foo<volatile char*>::foo" } |
| 339 | timeout { fail "(timeout) print Foo<volatile char*>::foo" } |
| 340 | } |
| 341 | |
| 342 | # Template Bar<T, int> |
| 343 | |
| 344 | # same as Foo for g++ |
| 345 | send_gdb "ptype Bar\n" |
| 346 | gdb_expect { |
| 347 | -re "type = template <(class |)T, (class |)sz> (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Bar<int,(\\(int\\)|)1>\r\n\[ \t\]*(class |)Bar<int,(\\(int\\)|)33>\r\n$gdb_prompt $" { pass "ptype Bar" } |
| 348 | -re "type = <(class |)T, (class |)sz> (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Bar" } |
| 349 | -re "ptype Bar\r\ntype = class Bar<int,33> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);\r\n}\r\n$gdb_prompt $" |
| 350 | { # GCC 3.1, DWARF-2 output. |
| 351 | kfail "gdb/57" "ptype Bar" } |
| 352 | -re "No symbol \"Bar\" in current context.\r\n$gdb_prompt $" |
| 353 | { # GCC 2.95.3, stabs+ output. |
| 354 | pass "ptype Bar" } |
| 355 | -re "$gdb_prompt $" { fail "ptype Bar" } |
| 356 | timeout { fail "(timeout) ptype Bar" } |
| 357 | } |
| 358 | |
| 359 | |
| 360 | # ptype Bar<int,33> |
| 361 | |
| 362 | send_gdb "ptype bint\n" |
| 363 | gdb_expect { |
| 364 | -re "type = (class |)Bar<int,(\\(int\\)|)33> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int bar\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bint" } |
| 365 | -re "$gdb_prompt $" { fail "ptype bint" } |
| 366 | timeout { fail "(timeout) ptype bint" } |
| 367 | } |
| 368 | |
| 369 | # ptype Bar<int, (4>3)> |
| 370 | |
| 371 | send_gdb "ptype bint2\n" |
| 372 | gdb_expect { |
| 373 | -re "type = (class |)Bar<int,(\\(int\\)|)1> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int bar\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bint2" } |
| 374 | -re "$gdb_prompt $" { fail "ptype bint2" } |
| 375 | timeout { fail "(timeout) ptype bint2" } |
| 376 | } |
| 377 | |
| 378 | # Template Baz<T, char> |
| 379 | |
| 380 | # Same as Foo, for g++ |
| 381 | send_gdb "ptype Baz\n" |
| 382 | gdb_expect { |
| 383 | -re "type = template <(class |)T, (class |)sz> (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Baz<char,(\\(char\\)|)97>\r\n\[ \t\]*(class |)Baz<int,(\\(char\\)|)115>\r\n$gdb_prompt $" { pass "ptype Baz" } |
| 384 | -re "type = <(class |)T, (class |)sz> (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Baz" } |
| 385 | -re "type = class Baz<int,'s'> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\);\r\n}\r\n$gdb_prompt $" |
| 386 | { # GCC 3.1, DWARF-2 output. |
| 387 | kfail "gdb/57" "ptype Baz" } |
| 388 | -re "No symbol \"Baz\" in current context.\r\n$gdb_prompt $" |
| 389 | { # GCC 2.95.3, stabs+ output. |
| 390 | pass "ptype Baz" } |
| 391 | -re "$gdb_prompt $" { fail "ptype Baz" } |
| 392 | timeout { fail "(timeout) ptype Baz" } |
| 393 | } |
| 394 | |
| 395 | |
| 396 | # ptype Baz<int, 's'> |
| 397 | |
| 398 | send_gdb "ptype bazint\n" |
| 399 | gdb_expect { |
| 400 | -re "type = (class |)Baz<int,(\\(char\\)|)(115|\\'s\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int baz\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bazint" } |
| 401 | -re "$gdb_prompt $" { fail "ptype bazint" } |
| 402 | timeout { fail "(timeout) ptype bazint" } |
| 403 | } |
| 404 | |
| 405 | # ptype Baz<char, 'a'> |
| 406 | |
| 407 | send_gdb "ptype bazint2\n" |
| 408 | gdb_expect { |
| 409 | -re "type = (class |)Baz<char,(\\(char\\)|)(97|\\'a\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*.*char baz\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bazint2" } |
| 410 | -re "$gdb_prompt $" { fail "ptype bazint2" } |
| 411 | timeout { fail "(timeout) ptype bazint2" } |
| 412 | } |
| 413 | |
| 414 | # Template Qux<T, int (*f)(int) > |
| 415 | # Same as Foo for g++ |
| 416 | send_gdb "ptype Qux\n" |
| 417 | gdb_expect { |
| 418 | -re "type = template <(class |)T, (class |)sz> (class |)Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Qux<int,&string>\r\n\[ \t\]*(class |)Qux<char,&string>\r\n$gdb_prompt $" { pass "ptype Qux" } |
| 419 | -re ".*type = template <(class |)T.*, (class |)sz> (class |)Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}.*$gdb_prompt $" { pass "ptype Qux" } |
| 420 | -re "type = class Qux<char,&string> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char qux\\(int, char\\);\r\n}\r\n$gdb_prompt $" |
| 421 | { # GCC 3.1, DWARF-2 output. |
| 422 | kfail "gdb/57" "ptype Qux" } |
| 423 | -re "No symbol \"Qux\" in current context.\r\n$gdb_prompt $" |
| 424 | { # GCC 2.95.3, stabs+ output. |
| 425 | pass "ptype Qux" } |
| 426 | -re "$gdb_prompt $" { fail "ptype Qux" } |
| 427 | timeout { fail "(timeout) ptype Qux" } |
| 428 | } |
| 429 | |
| 430 | # pt Qux<int,&string> |
| 431 | |
| 432 | send_gdb "ptype quxint\n" |
| 433 | gdb_expect { |
| 434 | -re "type = class Qux<int,&string> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int qux\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype quxint" } |
| 435 | -re "$gdb_prompt $" { fail "ptype quxint" } |
| 436 | timeout { fail "(timeout) ptype quxint" } |
| 437 | } |
| 438 | |
| 439 | # pt Qux<char,0> |
| 440 | |
| 441 | # commented out this as quxint2 declaration was commented out in |
| 442 | # templates.exp -- ovidiu |
| 443 | # send_gdb "ptype quxint2\n" |
| 444 | # gdb_expect { |
| 445 | # -re "type = class Qux<char,&string> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char qux\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype quxint2" } |
| 446 | # -re "$gdb_prompt $" { fail "ptype quxint2" } |
| 447 | # timeout { fail "(timeout) ptype quxint2" } |
| 448 | # } |
| 449 | |
| 450 | # Template Spec<T1, T2> |
| 451 | |
| 452 | # Same as Foo for g++ |
| 453 | send_gdb "ptype Spec\n" |
| 454 | gdb_expect { |
| 455 | -re "type = template <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Spec<int,int \\*>\r\n\[ \t\]*(class |)Spec<int,char>\r\n$gdb_prompt $" { pass "ptype Spec" } |
| 456 | -re "type = <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Spec" } |
| 457 | -re "type = class Spec<int,char> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*int spec\\(char\\);\r\n}\r\n$gdb_prompt $" |
| 458 | { # GCC 3.1, DWARF-2 output. |
| 459 | kfail "gdb/57" "ptype Spec" } |
| 460 | -re "No symbol \"Spec\" in current context.\r\n$gdb_prompt $" |
| 461 | { # GCC 2.95.3, stabs+ output. |
| 462 | pass "ptype Spec" } |
| 463 | -re "$gdb_prompt $" { fail "ptype Spec" } |
| 464 | timeout { fail "(timeout) ptype Spec" } |
| 465 | } |
| 466 | |
| 467 | # pt Spec<char,0> |
| 468 | |
| 469 | send_gdb "ptype siip\n" |
| 470 | gdb_expect { |
| 471 | -re "type = class Spec<int,int ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*.*int spec\\(int ?\\*\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype siip" } |
| 472 | -re "$gdb_prompt $" { fail "ptype siip" } |
| 473 | timeout { fail "(timeout) ptype siip" } |
| 474 | } |
| 475 | |
| 476 | # pt Garply<int> |
| 477 | |
| 478 | send_gdb "ptype Garply<int>\n" |
| 479 | gdb_expect { |
| 480 | -re "type = class Garply<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int garply\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype Garply<int>" } |
| 481 | -re "$gdb_prompt $" { fail "ptype Garply<int>" } |
| 482 | timeout { fail "(timeout) ptype Garply<int>" } |
| 483 | } |
| 484 | |
| 485 | # ptype of nested template name |
| 486 | |
| 487 | send_gdb "ptype Garply<Garply<char> >\n" |
| 488 | gdb_expect { |
| 489 | -re "type = (class |)Garply<Garply<char> > \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*(class |)Garply<char> t;\r\n\r\n\[ \t\]*.*(class |)Garply<char> garply\\(int, (class |)Garply<char>\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype Garply<Garply<char> >" } |
| 490 | -re "$gdb_prompt $" { fail "ptype Garply<Garply<char> >" } |
| 491 | timeout { fail "(timeout) ptype Garply<Garply<char> >" } |
| 492 | } |
| 493 | |
| 494 | # print out a function from a nested template name |
| 495 | |
| 496 | send_gdb "print Garply<Garply<char> >::garply\n" |
| 497 | gdb_expect { |
| 498 | -re "\\$\[0-9\]* = \\{(class |)Garply<char> \\((class |)Garply<Garply<char> > \\*(| const), int, (class |)Garply<char>\\)\\} $hex <Garply<Garply<char>\[ \t\]*>::garply\\(int, (class |)Garply<char>\\)>\r\n$gdb_prompt $" { pass "print Garply<Garply<char> >::garply" } |
| 499 | -re ".*$gdb_prompt $" { fail "print Garply<Garply<char> >::garply" } |
| 500 | timeout { fail "print Garply<Garply<char> >::garply (timeout)" } |
| 501 | } |
| 502 | |
| 503 | # djb - 06-03-2000 |
| 504 | # Now should work fine |
| 505 | send_gdb "break Garply<Garply<char> >::garply\n" |
| 506 | gdb_expect { |
| 507 | -re "Breakpoint \[0-9\]* at $hex: file .*templates.cc, line.*\r\n$gdb_prompt $" { pass "break Garply<Garply<char> >::garply" } |
| 508 | -re ".*$gdb_prompt $" { fail "break Garply<Garply<char> >::garply" } |
| 509 | timeout { fail "break Garply<Garply<char> >::garply (timeout)" } |
| 510 | } |