Fix test names starting with uppercase output by basic functions
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / ptype.exp
index fec31eb816e2a0a246f87604640cf80b69f6e2ae..296b67a47eb197826abea163665f735cc28f59b7 100644 (file)
@@ -1,70 +1,51 @@
-#   Copyright (C) 1988, 1990, 1991, 1992, 1994 Free Software Foundation, Inc.
+# Copyright 1988-2016 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
-
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # This file was written by Rob Savoye. (rob@cygnus.com)
 
-if $tracelevel then {
-       strace $tracelevel
-       }
-
 #
 # test running programs
 #
-set prms_id 0
-set bug_id 0
 
-set testfile "ptype"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    perror "Couldn't compile ${srcfile}"
+standard_testfile .c ptype1.c
+
+if {[prepare_for_testing ${testfile}.exp ${testfile} \
+        [list $srcfile $srcfile2] {debug nowarnings}]} {
     return -1
 }
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
-if [get_compiler_info ${binfile}] {
-    return -1;
+if [get_compiler_info] {
+    return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # Test ptype of unnamed enumeration members before any action causes
 # the partial symbol table to be expanded to full symbols.  This fails
 # with stabs compilers which fail to use a nameless stab (such as
 # pre-2.4.5 versions of gcc and most non-gcc compilers).
 
-send_gdb "ptype red1\n"
-expect {
-    -re "type = enum primary1_tag \{red1, green1, blue1\}.*$gdb_prompt $"\
-       {
-           # The workaround is in effect.  As this is a compiler, not GDB,
-           # bug, we'll make it a PASS but perhaps it should be an XFAIL.
-           pass "ptype unnamed enumeration member (worked around)"
-       }
-    -re "type = enum \{red1, green1, blue1\}.*$gdb_prompt $"\
-                       { pass "ptype unnamed enumeration member" }
-    -re ".*$gdb_prompt $"      { fail "ptype unnamed enumeration member" }
-    timeout            { fail "(timeout) ptype unnamed enumeration member" }
+gdb_test_multiple "ptype red1" "ptype unnamed enumeration member" {
+    -re "type = enum primary1_tag \{red1, green1, blue1\}.*$gdb_prompt $" {
+       # The workaround is in effect.  As this is a compiler, not GDB,
+       # bug, we'll make it a PASS but perhaps it should be an XFAIL.
+       pass "ptype unnamed enumeration member (worked around)"
+    }
+    -re "type = enum \{red1, green1, blue1\}.*$gdb_prompt $" {
+       pass "ptype unnamed enumeration member"
+    }
 }
 
 #
@@ -73,131 +54,55 @@ expect {
 # Here and elsewhere, we accept
 # "long", "long int", or "int" for long variables (whatis.exp already
 # has an XFAIL for "int" (Sun cc bug), so no need to fail it here).
-send_gdb "ptype struct t_struct\n"
-expect {
-    -re "type = struct t_struct \{.*
-    (unsigned |)char v_char_member;.*
-    (short|short int) v_short_member;.*
-    int v_int_member;.*
-    (long|long int|int) v_long_member;.*
-    float v_float_member;.*
-    double v_double_member;.*
-\}.*$gdb_prompt $"                      { pass "ptype structure" }
-    -re ".*$gdb_prompt $"      { fail "ptype structure" }
-    timeout            { fail "(timeout) ptype structure" }
-}
+gdb_test "ptype struct t_struct" "type = struct t_struct \{.*\[\r\n\]    (unsigned |)char v_char_member;.*\[\r\n\]    (short|short int) v_short_member;.*\[\r\n\]    int v_int_member;.*\[\r\n\]    (long|long int|int) v_long_member;.*\[\r\n\]    float v_float_member;.*\[\r\n\]    double v_double_member;.*\[\r\n\]\}.*" "ptype structure" 
+
 
 # Test the equivalence between '.' and '->' for struct member references.
 
 if [gdb_test "ptype v_struct1.v_float_member"  "type = float"]<0 then {
-    gdb_exit
-    gdb_start
     return -1
 }
 if [gdb_test "ptype v_struct1->v_float_member" "type = float"]<0 then {
-    gdb_exit
-    gdb_start
     return -1
 }
 if [gdb_test "ptype v_t_struct_p.v_float_member"       "type = float"]<0 then {
-    gdb_exit
-    gdb_start
     return -1
 }
 if [gdb_test "ptype v_t_struct_p->v_float_member"      "type = float"]<0 then {
-    gdb_exit
-    gdb_start
     return -1
 }
 
 
-send_gdb "ptype struct link\n"
-expect {
-    -re "type = struct link \{.*
-    struct link \[*\]next;.*
-    struct link \[*(\]+linkfunc\[)(\]+(struct link \[*\], int\[)\]|);.*
-    struct t_struct stuff.1..2..3.;.*
-\}.*$gdb_prompt $"                      { pass "ptype linked list structure" }
-    -re ".*$gdb_prompt $"      { 
-
-       # IBM's xlc puts out bogus stabs--the stuff field is type 42,
-       # which isn't defined.
-
-       fail "ptype linked list structure (compiler bug in IBM's xlc)"
-    }
-    timeout            { fail "(timeout) ptype linked list structure" }
-}
+# IBM's xlc puts out bogus stabs--the stuff field is type 42,
+# which isn't defined.
 
+gdb_test "ptype struct link" "type = struct link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.1..2..3.;\[\r\n\]+\}.*" "ptype linked list structure" 
 
 #
 # test ptype command with unions
 #
-send_gdb "ptype union t_union\n"
-expect {
-    -re "type = union t_union \{.*
-    (unsigned |)char v_char_member;.*
-    (short|short int) v_short_member;.*
-    int v_int_member;.*
-    (long|long int|int) v_long_member;.*
-    float v_float_member;.*
-    double v_double_member;.*
-\}.*$gdb_prompt $"                      { pass "ptype union" }
-    -re ".*$gdb_prompt $"      { fail "ptype union" }
-    timeout            { fail "(timeout) ptype union" }
-}
-
-
-send_gdb "ptype union tu_link\n"
-expect {
-    -re "type = union tu_link .*
-    struct link \[*\]next;.*
-    struct link \[(\*\]+linkfunc\[)(\]+(struct link \[*\], int\[)\]|);.*
-    struct t_struct stuff.1..2..3.;.*
-\}.*$gdb_prompt $"                      { pass "ptype linked list union" }
-    -re ".*$gdb_prompt $" {
-
-       # IBM's xlc puts out bogus stabs--the stuff field is type 42,
-       # which isn't defined.
-
-       fail "ptype linked list union (compiler bug in IBM's xlc)"
-    }
-    timeout            { fail "(timeout) ptype linked list union" }
-}
+gdb_test "ptype union t_union" "type = union t_union \{.*\[\r\n\]    (unsigned |)char v_char_member;.*\[\r\n\]    (short|short int) v_short_member;.*\[\r\n\]    int v_int_member;.*\[\r\n\]    (long|long int|int) v_long_member;.*\[\r\n\]    float v_float_member;.*\[\r\n\]    double v_double_member;.*\[\r\n\]\}.*" "ptype union" 
 
+# IBM's xlc puts out bogus stabs--the stuff field is type 42,
+# which isn't defined.
+gdb_test "ptype union tu_link" "type = union tu_link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.1..2..3.;\[\r\n\]+\}.*" "ptype linked list union" 
 
 #
 # test ptype command with enums
 #
 
-send_gdb "ptype primary\n"
-expect {
-    -re "type = enum .red, green, blue.*$gdb_prompt $"       { pass "ptype unnamed enumeration" }
-    -re ".*$gdb_prompt $"      { fail "ptype unnamed enumeration" }
-    timeout            { fail "(timeout) ptype unnamed enumeration" }
-}
+gdb_test "ptype primary" "type = enum .red, green, blue.*" "ptype unnamed enumeration" 
 
-
-send_gdb "ptype enum colors\n"
-expect {
-    -re "type = enum colors \{yellow, purple, pink\}.*$gdb_prompt $"\
-       { pass "ptype named enumeration" }
-    -re ".*$gdb_prompt $"      { fail "ptype named enumeration" }
-    timeout            { fail "(timeout) ptype named enumeration" }
-}
+gdb_test "ptype enum colors" "type = enum colors \{yellow, purple, pink\}.*" "ptype named enumeration" 
 
 
 #
 # test ptype command with enums as typedef
 #
-send_gdb "ptype boolean\n"
-expect {
-    -re "type = enum \{FALSE, TRUE\}.*$gdb_prompt $"   { pass "ptype unnamed typedef'd enumeration" }
-    -re ".*$gdb_prompt $"      { fail "ptype unnamed typedef'd enumeration" }
-    timeout            { fail "(timeout) ptype unnamed typedef'd enumeration" }
-}
+gdb_test "ptype boolean" "type = enum (boolean |)\{FALSE, TRUE\}.*" "ptype unnamed typedef'd enumeration" 
 
 # And check that whatis shows the name, not "enum {...}".
-
+# This probably fails for all DWARF 1 cases, so assume so for now. -fnf
 # The problem with xlc is that the stabs look like
 #   :t51=eFALSE:0,TRUE:1,;
 #   boolean:t55=51
@@ -205,59 +110,39 @@ expect {
 # GDB's behavior is correct; the type which the variable is defined
 # as (51) doesn't have a name.  Only 55 has a name.
 
-if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "i*86-*-sysv4*" }
-gdb_test "whatis v_boolean" "type = boolean" \
+if {!$gcc_compiled} {
+    setup_xfail "rs6000-*-*" "i*86-*-sysv4*"
+    setup_xfail "hppa*-*-*" CLLbs14773
+}
+
+# For get_debug_format to do its job, we need to have a current source file.
+gdb_test "list main" ".*"
+get_debug_format
+gdb_test "whatis v_boolean" "type = (enum |)boolean" \
   "whatis unnamed typedef'd enum (compiler bug in IBM's xlc)"
 
 # Same thing with struct and union.
-gdb_test "ptype t_struct3" "type = struct \{.*
+gdb_test "ptype t_struct3" "type = struct (t_struct3 |)\{.*
  *double v_double_member;.*
  *int v_int_member;.*\}" "printing typedef'd struct"
 
-gdb_test "ptype t_union3" "type = union \{.*
+gdb_test "ptype t_union3" "type = union (t_union3 |)\{.*
  *double v_double_member;.*
  *int v_int_member;.*\}" "printing typedef'd union"
 
-send_gdb "ptype enum bvals\n"
-expect {
-    -re "type = enum bvals \{false, true\}.*$gdb_prompt $"   { pass "ptype named typedef'd enumf'd enum" }
-    -re ".*$gdb_prompt $"      { fail "ptype named typedef'd enumeration" }
-    timeout            { fail "(timeout) ptype named typedef'd enumeration" }
-}
-
+gdb_test "ptype enum bvals" "type = enum bvals \{my_false, my_true\}.*" "ptype named typedef'd enumf'd enum"
 
 #
 # test ptype command with out-of-order enum values
 #
-send_gdb "ptype enum misordered\n"
-expect {
-    -re "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*$gdb_prompt $"\
-       { pass "ptype misordered enumeration" }
-    -re ".*$gdb_prompt $"      { fail "ptype misordered  enumeration" }
-    timeout            { fail "(timeout) ptype misordered enumeration" }
-}
-
+gdb_test "ptype enum misordered" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype misordered enumeration" 
 
 #
 # test ptype command with a named enum's value
 #
-send_gdb "ptype three\n"
-expect {
-    -re "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*$gdb_prompt $"\
-       { pass "ptype named enumeration member" }
-    -re ".*$gdb_prompt $"      { fail "ptype named enumeration member" }
-    timeout            { fail "(timeout) ptype named enumeration member" }
-}
-
-
-send_gdb "ptype red\n"
-expect {
-    -re "type = enum \{red, green, blue\}.*$gdb_prompt $"\
-       { pass "ptype unnamed enumeration member" }
-    -re ".*$gdb_prompt $"      { fail "ptype unnamed enumeration member" }
-    timeout            { fail "(timeout) ptype unnamed enumeration member" }
-}
+gdb_test "ptype three" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype named enumeration member" 
 
+gdb_test "ptype red" "type = enum \{red, green, blue\}.*" "ptype unnamed enumeration member #2" 
 
 #
 # test ptype command with basic C types
@@ -267,19 +152,18 @@ expect {
 # acts like whatis for basic types.  If it is thought to be necessary to
 # test both whatis and ptype for all the types, the tests should be
 # merged into whatis.exp, or else maintenance will be a royal pain -kingdon
-#setup_xfail "i960-*-*" 1821
-#setup_xfail "mips-idt-*" "mips-sgi-*" "a29k-*-*"
+#setup_xfail "mips-sgi-*"
 #send "ptype v_char\n"
-#expect {
+#gdb_expect {
 #    -re "type = char.*$gdb_prompt $"  { pass "ptype char" }
 #    -re ".*$gdb_prompt $"     { fail "ptype char" }
 #    timeout           { fail "(timeout) ptype char" }
 #}
 #
 #
-#setup_xfail "mips-*-*" "a29k-*-*"
+#setup_xfail "mips-*-*"
 #send "ptype v_signed_char\n"
-#expect {
+#gdb_expect {
 #    -re "type = signed char.*$gdb_prompt $"   { pass "ptype signed char" }
 #    -re ".*$gdb_prompt $"     { fail "ptype signed char" }
 #    timeout           { fail "(timeout) ptype signed char" }
@@ -287,23 +171,16 @@ expect {
 #
 #
 #send "ptype v_unsigned_char\n"
-#expect {
+#gdb_expect {
 #    -re "type = unsigned char.*$gdb_prompt $" { pass "ptype unsigned char" }
 #    -re ".*$gdb_prompt $"     { fail "ptype unsigned char" }
 #    timeout           { fail "(timeout) ptype unsigned char" }
 #}
 
-
-send_gdb "ptype v_short\n"
-expect {
-    -re "type = short(| int).*$gdb_prompt $"   { pass "ptype short" }
-    -re ".*$gdb_prompt $"      { fail "ptype short" }
-    timeout            { fail "(timeout) ptype short" }
-}
-
+gdb_test "ptype v_short" "type = short(| int).*" "ptype short" 
 
 #send "ptype v_signed_short\n"
-#expect {
+#gdb_expect {
 #    -re "type = short.*$gdb_prompt $" { pass "ptype signed short" }
 #    -re ".*$gdb_prompt $"     { fail "ptype signed short" }
 #    timeout           { fail "(timeout) ptype signed short" }
@@ -311,23 +188,17 @@ expect {
 #
 #
 #send "ptype v_unsigned_short\n"
-#expect {
+#gdb_expect {
 #    -re "type = unsigned short.*$gdb_prompt $"        { pass "ptype unsigned short" }
 #    -re ".*$gdb_prompt $"     { fail "ptype unsigned short" }
 #    timeout           { fail "(timeout) ptype unsigned short" }
 #}
 
 
-send_gdb "ptype v_int\n"
-expect {
-    -re "type = int.*$gdb_prompt $"    { pass "ptype int" }
-    -re ".*$gdb_prompt $"      { fail "ptype int" }
-    timeout            { fail "(timeout) ptype int" }
-}
-
+gdb_test "ptype v_int" "type = int.*" "ptype int" 
 
 #send "ptype v_signed_int\n"
-#expect {
+#gdb_expect {
 #    -re "type = int.*$gdb_prompt $"   { pass "ptype signed int" }
 #    -re ".*$gdb_prompt $"     { fail "ptype signed int" }
 #    timeout           { fail "(timeout) ptype signed int" }
@@ -335,7 +206,7 @@ expect {
 #
 #
 #send "ptype v_unsigned_int\n"
-#expect {
+#gdb_expect {
 #    -re "type = unsigned int.*$gdb_prompt $"  { pass "ptype unsigned int" }
 #    -re ".*$gdb_prompt $"     { fail "ptype unsigned int" }
 #    timeout           { fail "(timeout) ptype unsigned int" }
@@ -343,7 +214,7 @@ expect {
 #
 #
 #send "ptype v_long\n"
-#expect {
+#gdb_expect {
 #    -re "type = long.*$gdb_prompt $"  { pass "ptype long" }
 #    -re ".*$gdb_prompt $"     { fail "ptype long" }
 #    timeout           { fail "(timeout) ptype long" }
@@ -351,7 +222,7 @@ expect {
 #
 #
 #send "ptype v_signed_long\n"
-#expect {
+#gdb_expect {
 #    -re "type = long.*$gdb_prompt $"  { pass "ptype signed long" }
 #    -re ".*$gdb_prompt $"     { fail "ptype signed long" }
 #    timeout           { fail "(timeout) ptype signed long" }
@@ -359,7 +230,7 @@ expect {
 #
 #
 #send "ptype v_unsigned_long\n"
-#expect {
+#gdb_expect {
 #    -re "type = unsigned long.*$gdb_prompt $" { pass "ptype unsigned long" }
 #    -re ".*$gdb_prompt $"     { fail "ptype unsigned long" }
 #    timeout           { fail "(timeout) ptype unsigned long" }
@@ -367,7 +238,7 @@ expect {
 #
 #
 #send "ptype v_float\n"
-#expect {
+#gdb_expect {
 #    -re "type = float.*$gdb_prompt $" { pass "ptype float" }
 #    -re ".*$gdb_prompt $"     { fail "ptype float" }
 #    timeout           { fail "(timeout) ptype float" }
@@ -375,7 +246,7 @@ expect {
 #
 #
 #send "ptype v_double\n"
-#expect {
+#gdb_expect {
 #    -re "type = double.*$gdb_prompt $"        { pass "ptype double" }
 #    -re ".*$gdb_prompt $"     { fail "ptype double" }
 #    timeout           { fail "(timeout) ptype double" }
@@ -385,19 +256,18 @@ expect {
 #
 # test ptype command with arrays
 #
-#setup_xfail "i960-*-*" 1821
-#setup_xfail "mips-idt-*" "mips-sgi-*" "a29k-*-*"
+#setup_xfail "mips-sgi-*"
 #send "ptype v_char_array\n"
-#expect {
+#gdb_expect {
 #    -re "type = char .2..*$gdb_prompt $"      { pass "ptype char array" }
 #    -re ".*$gdb_prompt $"     { fail "ptype char array" }
 #    timeout           { fail "(timeout) ptype char array" }
 #}
 #
 #
-#setup_xfail "mips-*-*" "a29k-*-*"
+#setup_xfail "mips-*-*"
 #send "ptype v_signed_char_array\n"
-#expect {
+#gdb_expect {
 #    -re "type = (|signed )char .2..*$gdb_prompt $"    { pass "ptype signed char array" }
 #    -re ".*$gdb_prompt $"     { fail "ptype signed char array" }
 #    timeout           { fail "(timeout) ptype signed char array" }
@@ -405,7 +275,7 @@ expect {
 #
 #
 #send "ptype v_unsigned_char_array\n"
-#expect {
+#gdb_expect {
 #    -re "type = unsigned char .2..*$gdb_prompt $"     { pass "ptype unsigned char array" }
 #    -re ".*$gdb_prompt $"     { fail "ptype unsigned char array" }
 #    timeout           { fail "(timeout) ptype unsigned char array" }
@@ -414,7 +284,7 @@ expect {
 #
 #
 #send "ptype v_int_array\n"
-#expect {
+#gdb_expect {
 #    -re "type = int .2..*$gdb_prompt $"       { pass "ptype int array" }
 #    -re ".*$gdb_prompt $"     { fail "ptype int array" }
 #    timeout           { fail "(timeout) ptype int array" }
@@ -422,7 +292,7 @@ expect {
 #
 #
 #send "ptype v_signed_int_array\n"
-#expect {
+#gdb_expect {
 #    -re "type = int .2..*$gdb_prompt $"       { pass "ptype signed int array" }
 #    -re ".*$gdb_prompt $"     { fail "ptype signed int array" }
 #    timeout           { fail "(timeout) ptype signed int array" }
@@ -430,7 +300,7 @@ expect {
 #
 #
 #send "ptype v_unsigned_int_array\n"
-#expect {
+#gdb_expect {
 #    -re "type = unsigned int .2..*$gdb_prompt $"      { pass "ptype unsigned int array" }
 #    -re ".*$gdb_prompt $"     { fail "ptype unsigned int array" }
 #    timeout           { fail "(timeout) ptype unsigned int array" }
@@ -438,7 +308,7 @@ expect {
 #
 #
 #send "ptype v_long_array\n"
-#expect {
+#gdb_expect {
 #    -re "type = (long|int|long int) .2..*$gdb_prompt $"       { 
 #      pass "ptype long array" }
 #    -re ".*$gdb_prompt $"     { fail "ptype long array" }
@@ -447,7 +317,7 @@ expect {
 #
 #
 #send "ptype v_signed_long_array\n"
-#expect {
+#gdb_expect {
 #    -re "type = (long|int|long int) .2..*$gdb_prompt $"       { 
 #      pass "ptype signed long array" }
 #    -re ".*$gdb_prompt $"     { fail "ptype signed long array" }
@@ -456,7 +326,7 @@ expect {
 #
 #
 #send "ptype v_unsigned_long_array\n"
-#expect {
+#gdb_expect {
 #    -re "type = unsigned long .2..*$gdb_prompt $"     { pass "ptype unsigned long array" }
 #    -re ".*$gdb_prompt $"     { fail "ptype unsigned long array" }
 #    timeout           { fail "(timeout) ptype unsigned long array" }
@@ -464,7 +334,7 @@ expect {
 #
 #
 #send "ptype v_float_array\n"
-#expect {
+#gdb_expect {
 #    -re "type = float .2..*$gdb_prompt $"     { pass "ptype float array" }
 #    -re ".*$gdb_prompt $"     { fail "ptype float array" }
 #    timeout           { fail "(timeout) ptype float array" }
@@ -472,7 +342,7 @@ expect {
 #
 #
 #send "ptype v_double_array\n"
-#expect {
+#gdb_expect {
 #    -re "type = double .2..*$gdb_prompt $"    { pass "ptype double array" }
 #    -re ".*$gdb_prompt $"     { fail "ptype double array" }
 #    timeout           { fail "(timeout) ptype double array" }
@@ -482,23 +352,24 @@ expect {
 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "i*86-*-sysv4*" }
 gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
 
+gdb_test "ptype pv_char_array" "type = (|unsigned )char \\(\\*\\)\\\[0?\\\]"
+
 #
 ##
 ## test ptype command with pointers
 ##
-#setup_xfail "i960-*-*" 1821
-#setup_xfail "mips-idt-*" "mips-sgi-*" "a29k-*-*"
+#setup_xfail "mips-sgi-*"
 #send "ptype v_char_pointer\n"
-#expect {
+#gdb_expect {
 #    -re "type = char \*.*$gdb_prompt $"       { pass "ptype char pointer" }
 #    -re ".*$gdb_prompt $"     { fail "ptype char pointer" }
 #    timeout           { fail "(timeout) ptype char pointer" }
 #}
 #
 #
-#setup_xfail "mips-*-*" "a29k-*-*"
+#setup_xfail "mips-*-*"
 #send "ptype v_signed_char_pointer\n"
-#expect {
+#gdb_expect {
 #    -re "type = (|signed )char \*.*$gdb_prompt $"
 #      { pass "ptype signed char pointer" }
 #    -re ".*$gdb_prompt $"     { fail "ptype signed char pointer" }
@@ -507,7 +378,7 @@ gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
 #
 #
 #send "ptype v_unsigned_char_pointer\n"
-#expect {
+#gdb_expect {
 #    -re "type = unsigned char \*.*$gdb_prompt $"      { pass "ptype unsigned char pointer" }
 #    -re ".*$gdb_prompt $"     { fail "ptype unsigned char pointer" }
 #    timeout           { fail "(timeout) ptype unsigned char pointer" }
@@ -515,7 +386,7 @@ gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
 #
 #
 #send "ptype v_short_pointer\n"
-#expect {
+#gdb_expect {
 #    -re "type = (short|short int) \*.*$gdb_prompt $"  { pass "ptype short pointer" }
 #    -re ".*$gdb_prompt $"     { fail "ptype short pointer" }
 #    timeout           { fail "(timeout) ptype short pointer" }
@@ -523,7 +394,7 @@ gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
 #
 #
 #send "ptype v_signed_short_pointer\n"
-#expect {
+#gdb_expect {
 #    -re "type = short \*.*$gdb_prompt $"      { pass "ptype signed short pointer" }
 #    -re ".*$gdb_prompt $"     { fail "ptype signed short pointer" }
 #    timeout           { fail "(timeout) ptype signed short pointer" }
@@ -531,7 +402,7 @@ gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
 #
 #
 #send "ptype v_unsigned_short_pointer\n"
-#expect {
+#gdb_expect {
 #    -re "type = unsigned short \*.*$gdb_prompt $"     { pass "ptype unsigned short pointer" }
 #    -re ".*$gdb_prompt $"     { fail "ptype unsigned short pointer" }
 #    timeout           { fail "(timeout) ptype unsigned short pointer" }
@@ -539,7 +410,7 @@ gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
 #
 #
 #send "ptype v_int_pointer\n"
-#expect {
+#gdb_expect {
 #    -re "type = int \*.*$gdb_prompt $"        { pass "ptype int pointer" }
 #    -re ".*$gdb_prompt $"     { fail "ptype int pointer" }
 #    timeout           { fail "(timeout) ptype int pointer" }
@@ -547,7 +418,7 @@ gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
 #
 #
 #send "ptype v_signed_int_pointer\n"
-#expect {
+#gdb_expect {
 #    -re "type = int \*.*$gdb_prompt $"        { pass "ptype signed int pointer" }
 #    -re ".*$gdb_prompt $"     { fail "ptype signed int pointer" }
 #    timeout           { fail "(timeout) ptype signed int pointer" }
@@ -555,7 +426,7 @@ gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
 #
 #
 #send "ptype v_unsigned_int_pointer\n"
-#expect {
+#gdb_expect {
 #    -re "type = unsigned int \*.*$gdb_prompt $"       { pass "ptype unsigned int pointer" }
 #    -re ".*$gdb_prompt $"     { fail "ptype unsigned int pointer" }
 #    timeout           { fail "(timeout) ptype unsigned int pointer" }
@@ -563,7 +434,7 @@ gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
 #
 #
 #send "ptype v_long_pointer\n"
-#expect {
+#gdb_expect {
 #    -re "type = long \*.*$gdb_prompt $"       { pass "ptype long pointer" }
 #    -re ".*$gdb_prompt $"     { fail "ptype long pointer" }
 #    timeout           { fail "(timeout) ptype long pointer" }
@@ -571,7 +442,7 @@ gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
 #
 #
 #send "ptype v_signed_long_pointer\n"
-#expect {
+#gdb_expect {
 #    -re "type = long \*.*$gdb_prompt $"       { pass "ptype signed long pointer" }
 #    -re ".*$gdb_prompt $"     { fail "ptype signed long pointer" }
 #    timeout           { fail "(timeout) ptype signed long pointer" }
@@ -579,7 +450,7 @@ gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
 #
 #
 #send "ptype v_unsigned_long_pointer\n"
-#expect {
+#gdb_expect {
 #    -re "type = unsigned long \*.*$gdb_prompt $"      { pass "ptype unsigned long pointer" }
 #    -re ".*$gdb_prompt $"     { fail "ptype unsigned long pointer" }
 #    timeout           { fail "(timeout) ptype unsigned long pointer" }
@@ -587,7 +458,7 @@ gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
 #
 #
 #send "ptype v_float_pointer\n"
-#expect {
+#gdb_expect {
 #    -re "type = float \*.*$gdb_prompt $"      { pass "ptype float pointer" }
 #    -re ".*$gdb_prompt $"     { fail "ptype float pointer" }
 #    timeout           { fail "(timeout) ptype float pointer" }
@@ -595,7 +466,7 @@ gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
 #
 #
 #send "ptype v_double_pointer\n"
-#expect {
+#gdb_expect {
 #    -re "type = double \*.*$gdb_prompt $"     { pass "ptype double pointer" }
 #    -re ".*$gdb_prompt $"     { fail "ptype double pointer" }
 #    timeout           { fail "(timeout) ptype double pointer" }
@@ -604,115 +475,142 @@ gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
 #
 # test ptype command with nested structure and union
 #
-send_gdb "ptype struct outer_struct\n"
-expect {
-    -re "type = struct outer_struct \{.*
-    int outer_int;.*
-    struct inner_struct inner_struct_instance;.*
-    union inner_union inner_union_instance;.*
-    (long|long int|int) outer_long;.*
-\}.*$gdb_prompt $"                { pass "ptype outer structure" }
-    -re ".*$gdb_prompt $"      { fail "ptype outer structure" }
-    timeout            { fail "(timeout) ptype outer structure" }
-}
+gdb_test "ptype struct outer_struct" "type = struct outer_struct \{.*\[\r\n\]+\
+.*int outer_int;.*\[\r\n\]+\
+.*(struct|) inner_struct inner_struct_instance;.*\[\r\n\]+\
+.*(union|) inner_union inner_union_instance;.*\[\r\n\]+\
+.*(long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype outer structure"
 
+gdb_test "ptype struct inner_struct" "type = struct inner_struct \{.*\[\r\n\]    int inner_int;.*\[\r\n\]    (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype inner structure"
 
-send_gdb "ptype struct inner_struct\n"
-expect {
-    -re "type = struct inner_struct \{.*
-    int inner_int;.*
-    (long|long int|int) inner_long;.*
-\}.*$gdb_prompt $"                { pass "ptype inner structure" }
-    -re ".*$gdb_prompt $"      { fail "ptype inner structure" }
-    timeout            { fail "(timeout) ptype inner structure" }
-}
+gdb_test "ptype union inner_union" "type = union inner_union \{.*\[\r\n\]    int inner_union_int;.*\[\r\n\]    (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype inner union"
 
+gdb_test "ptype nested_su" "type = struct outer_struct \{.*\[\r\n\]    int outer_int;.*\[\r\n\]    (struct |)inner_struct inner_struct_instance;.*\[\r\n\]    (union |)inner_union inner_union_instance;.*\[\r\n\]    (long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype nested structure"
 
-send_gdb "ptype union inner_union\n"
-expect {
-    -re "type = union inner_union \{.*
-    int inner_union_int;.*
-    (long|long int|int) inner_union_long;.*
-\}.*$gdb_prompt $"                { pass "ptype inner union" }
-    -re ".*$gdb_prompt $"      { fail "ptype inner union" }
-    timeout            { fail "(timeout) ptype inner union" }
-}
+gdb_test "ptype nested_su.outer_int" "type = int.*" "ptype outer int"
 
+gdb_test "ptype nested_su.inner_struct_instance" "type = struct inner_struct \{.*\[\r\n\]    int inner_int;.*\[\r\n\]    (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype nested structure #2"
 
-send_gdb "ptype nested_su\n"
-expect {
-    -re "type = struct outer_struct \{.*
-    int outer_int;.*
-    struct inner_struct inner_struct_instance;.*
-    union inner_union inner_union_instance;.*
-    (long|long int|int) outer_long;.*
-\}.*$gdb_prompt $"                { pass "ptype nested structure" }
-    -re ".*$gdb_prompt $"      { fail "ptype nested structure" }
-    timeout            { fail "(timeout) ptype nested structure" }
-}
+gdb_test "ptype nested_su.inner_struct_instance.inner_int" "type = int.*" "ptype inner int"
 
+gdb_test "ptype nested_su.inner_union_instance" "type = union inner_union \{.*\[\r\n\]    int inner_union_int;.*\[\r\n\]    (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype nested union"
 
-send_gdb "ptype nested_su.outer_int\n"
-expect {
-    -re "type = int.*$gdb_prompt $"           { pass "ptype outer int" }
-    -re ".*$gdb_prompt $"      { fail "ptype outer int" }
-    timeout            { fail "(timeout) ptype outer int" }
-}
+# Print the type description of variable the_highest, and verify that
+# the type description for the fields whose type is anonymous are
+# correctly printed (at nesting level 1 and 2).
 
+gdb_test "ptype the_highest" \
+         "type = struct highest \{.*\[\r\n\] *int a;.*\[\r\n\] *struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{\.\.\.\} anonymous_level_2;.*\[\r\n\] *\} anonymous_level_1;.*\[\r\n\]}.*" \
+         "ptype the_highest" 
 
-send_gdb "ptype nested_su.inner_struct_instance\n"
-expect {
-    -re "type = struct inner_struct \{.*
-    int inner_int;.*
-    (long|long int|int) inner_long;.*
-\}.*$gdb_prompt $"                { pass "ptype nested structure" }
-    -re ".*$gdb_prompt $"      { fail "ptype nested structure" }
-    timeout            { fail "(timeout) ptype nested structure" }
-}
+# Print the type descrption for one of the fields of variable the_highest.
+# The purpose is to verify that the type of a field that was printed above
+# as "struct {...}" is now printed in a more descriptive way (because the
+# nesting level is now one level less).
 
+gdb_test "ptype the_highest.anonymous_level_1" \
+         "type = struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{.*\[\r\n\] *int c;.*\[\r\n\] *\} anonymous_level_2;.*\[\r\n\]}.*" \
+         "ptype the_highest" 
 
-send_gdb "ptype nested_su.inner_struct_instance.inner_int\n"
-expect {
-    -re "type = int.*$gdb_prompt $"           { pass "ptype inner int" }
-    -re ".*$gdb_prompt $"      { fail "ptype inner int" }
-    timeout            { fail "(timeout) ptype inner int" }
-}
+get_debug_format
 
+# Print the type of the identifier ID, and check the response:
+# - Expect to see PROTOTYPED as the type.  PROTOTYPED is not a regular
+#   expression; it's a literal string.
+# - If we instead see the unprototyped type PLAIN, and we're using STABS
+#   generated by GCC, that's an xfail; as of 9 Feb 2002, GCC never emits
+#   prototyped function types in STABS.  Like PROTOTYPED, PLAIN is a
+#   literal string, not a regular expression.
+# - If we see OVERPROTOTYPED, it's an xfail for RealView; RealView
+#   does not distinguish prototyped and unprototyped functions, and
+#   GDB defaults to prototyped.
+# - Otherwise, it's a failure.
+proc ptype_maybe_prototyped { id prototyped plain { overprototyped "NO-MATCH" } } {
+    global gdb_prompt
+    global gcc_compiled
+
+    # Turn the arguments, which are literal strings, into
+    # regular expressions by quoting any special characters they contain.
+    foreach var { prototyped plain overprototyped } {
+       eval "set val \$$var"
+       regsub -all "\[\]\[*()\]" $val "\\\\&" val
+       regsub -all "short int" $val "short( int)?" val
+       regsub -all "long int" $val "long( int)?" val
+       eval "set $var \$val"
+    }
 
-send_gdb "ptype nested_su.inner_union_instance\n"
-expect {
-    -re "type = union inner_union \{.*
-    int inner_union_int;.*
-    (long|long int|int) inner_union_long;.*
-\}.*$gdb_prompt $"                { pass "ptype nested union" }
-    -re ".*$gdb_prompt $"      { fail "ptype nested union" }
-    timeout            { fail "(timeout) ptype nested union" }
+    gdb_test_multiple "ptype $id" "ptype $id" {
+        -re "type = $prototyped\[\r\n\]+$gdb_prompt $" {
+            pass "ptype $id"
+        }
+        -re "type = $plain\[\r\n\]+$gdb_prompt $" {
+            if {$gcc_compiled} { setup_xfail_format "stabs" }
+            fail "ptype $id (compiler doesn't emit prototyped types)"
+        }
+        -re "type = $overprototyped\[\r\n\]+$gdb_prompt $" {
+            if { [test_compiler_info "armcc-*"] } {
+               setup_xfail "*-*-*"
+           }
+            fail "ptype $id (compiler doesn't emit unprototyped types)"
+        }
+    }
 }
 
+ptype_maybe_prototyped "func_type" "int (*)(int (*)(int, float), float)" \
+                                   "int (*)()"
+ptype_maybe_prototyped "old_fptr" "double (*)()" "double (*)()" \
+                                  "double (*)(void)"
+ptype_maybe_prototyped "new_fptr" "double (*)(void)" "double (*)()"
+ptype_maybe_prototyped "fptr" "int (*)(int, float)" "int (*)()"
+ptype_maybe_prototyped "fptr2" "int *(*)(int (*)(int, float), float)" \
+                               "int *(*)()"
+ptype_maybe_prototyped "xptr" "int (*)(int (*)(), int (*)(void), int)" \
+                              "int (*)()" \
+                              "int (*)(int (*)(void), int (*)(void), int)"
+ptype_maybe_prototyped "ffptr" "int (*(*)(char))(short int)" \
+                               "int (*(*)())()"
+ptype_maybe_prototyped "fffptr" "int (*(*(*)(char))(short int))(long int)" \
+                                "int (*(*(*)())())()"
+
+# Test printing type of typedefs in different scopes, with same name
+# but different type.
+
+gdb_test "list intfoo" ".*"
+gdb_test "ptype foo" "type = int" "ptype foo typedef after first list of intfoo"
+gdb_test "list charfoo" ".*"
+gdb_test "ptype foo" "type = char" "ptype foo typedef after first list of charfoo"
+gdb_test "list intfoo" ".*"
+gdb_test "ptype foo" "type = int" "ptype foo typedef after second list of intfoo"
+gdb_test "list charfoo" ".*"
+gdb_test "ptype foo" "type = char" "ptype foo typedef after second list of charfoo"
+
 # Test printing type of string constants and array constants, but
 # requires a running process.  These call malloc, and can take a long
 # time to execute over a slow serial link, so increase the timeout.
 
-# UDI can't do this (PR 2416).  XFAIL is not suitable, because attempting
-# the operation causes a slow painful death rather than a nice simple failure.
-
-if ![istarget "*-*-udi*"] then {
-  if [runto_main] then {
-    setup_xfail "a29k-*-udi" 2416
-    gdb_test "ptype \"abc\""   "type = char \\\[4\\\]"
-    setup_xfail "a29k-*-udi" 2416
-    gdb_test "ptype {'a','b','c'}"     "type = char \\\[3\\\]"
-    setup_xfail "a29k-*-udi" 2416
-    gdb_test "ptype {0,1,2}"           "type = int \\\[3\\\]"
-    setup_xfail "a29k-*-udi" 2416
-    gdb_test "ptype {(long)0,(long)1,(long)2}"   "type = long \\\[3\\\]"
-    setup_xfail "a29k-*-udi" 2416
-    gdb_test "ptype {(float)0,(float)1,(float)2}" "type = float \\\[3\\\]"
-    setup_xfail "a29k-*-udi" 2416
-    gdb_test "ptype {{0,1,2},{3,4,5}}" "type = int \\\[2\\\]\\\[3\\\]"
-    setup_xfail "a29k-*-udi" 2416
-    gdb_test "ptype {4,5,6}\[2\]"      "type = int"
-    setup_xfail "a29k-*-udi" 2416
-    gdb_test "ptype *&{4,5,6}\[1\]"    "type = int"
+if [runto_main] then {
+
+  if [target_info exists gdb,cannot_call_functions] {
+    unsupported "this target can not call functions"
+    continue
   }
+
+  # We need to up this because this can be really slow on some boards.
+  # (malloc() is called as part of the test).
+  set prev_timeout $timeout
+  set timeout 60
+
+  gdb_test "ptype \"abc\""     "type = char \\\[4\\\]"
+  gdb_test "ptype {'a','b','c'}"       "type = char \\\[3\\\]"
+  gdb_test "ptype {0,1,2}"             "type = int \\\[3\\\]"
+  gdb_test "ptype {(long)0,(long)1,(long)2}"     "type = long \\\[3\\\]"
+  gdb_test "ptype {(float)0,(float)1,(float)2}" "type = float \\\[3\\\]"
+  gdb_test "ptype {{0,1,2},{3,4,5}}"   "type = int \\\[2\\\]\\\[3\\\]"
+  gdb_test "ptype {4,5,6}\[2\]"        "type = int"
+  gdb_test "ptype *&{4,5,6}\[1\]"      "Attempt to take address of value not located in memory."
+
+  set timeout $prev_timeout
+
+  # Test ptype of user register
+  gdb_test "ptype \$pc" "void \\(\\*\\)\\(\\)" "ptype \$pc"
 }
This page took 0.036656 seconds and 4 git commands to generate.