aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Blandy <jimb@codesourcery.com>2002-02-21 20:34:16 +0000
committerJim Blandy <jimb@codesourcery.com>2002-02-21 20:34:16 +0000
commita640f7fc6bbb0f1f5b4ac05631528f28ce2754cd (patch)
tree54f3efdd25f224b5f765a84dca5eded7e12477a1
parentb3ba81f8eed13d730f98839fb63d0eb89226b97b (diff)
downloadfsf-binutils-gdb-a640f7fc6bbb0f1f5b4ac05631528f28ce2754cd.zip
fsf-binutils-gdb-a640f7fc6bbb0f1f5b4ac05631528f28ce2754cd.tar.gz
fsf-binutils-gdb-a640f7fc6bbb0f1f5b4ac05631528f28ce2754cd.tar.bz2
* gdb.base/ptype.exp, gdb.base/ptype.c: Add tests for printing
types of pointers to prototyped functions.
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/ptype.c28
-rw-r--r--gdb/testsuite/gdb.base/ptype.exp52
3 files changed, 85 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 7b6f57e..645e78b 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2002-02-21 Jim Blandy <jimb@redhat.com>
+
+ * gdb.base/ptype.exp, gdb.base/ptype.c: Add tests for printing
+ types of pointers to prototyped functions.
+
2002-02-20 Andrew Cagney <ac131313@redhat.com>
* gdb.base/sizeof.c (main): Call fill_structs. Print value of
diff --git a/gdb/testsuite/gdb.base/ptype.c b/gdb/testsuite/gdb.base/ptype.c
index 7b8ca24..2c85c7c 100644
--- a/gdb/testsuite/gdb.base/ptype.c
+++ b/gdb/testsuite/gdb.base/ptype.c
@@ -226,6 +226,34 @@ enum misordered {two = 2, one = 1, zero = 0, three = 3};
in the executable, at least for AIX xlc. */
enum misordered v_misordered = three;
+/**** Pointers to functions *******/
+
+typedef int (*func_type) (int (*) (int, float), float);
+double (*old_fptr) ();
+double (*new_fptr) (void);
+int (*fptr) (int, float);
+int *(*fptr2) (int (*) (int, float), float);
+int (*xptr) (int (*) (), int (*) (void), int);
+int (*(*ffptr) (char)) (short);
+int (*(*(*fffptr) (char)) (short)) (long);
+
+/* Here are the sort of stabs we expect to see for the above:
+
+ .stabs "func_type:t(0,100)=*(0,101)=g(0,1)(0,102)=*(0,103)=g(0,1)(0,1)(0,14)#(0,14)#",128,0,234,0
+ .stabs "old_fptr:G(0,110)=*(0,111)=f(0,15)",32,0,231,0
+ .stabs "new_fptr:G(0,120)=*(0,121)=g(0,15)(0,122)=(0,122)#",32,0,232,0
+ .stabs "fptr:G(0,130)=*(0,103)#",32,0,233,0
+ .stabs "fptr2:G(0,140)=*(0,141)=g(0,142)=*(0,1)(0,102)(0,14)#",32,0,235,0
+ .stabs "xptr:G(0,150)=*(0,151)=g(0,1)(0,152)=*(0,153)=f(0,1)(0,154)=*(0,155)=g(0,1)(0,122)#(0,1)#",32,0,236,0
+ .stabs "ffptr:G(0,160)=*(0,161)=g(0,162)=*(0,163)=g(0,1)(0,8)#(0,2)#",32,0,237,0\
+ .stabs "fffptr:G(0,170)=*(0,171)=g(0,172)=*(0,173)=g(0,174)=*(0,175)=g(0,1)(0,3)#(0,8)#(0,2)#",32,0,237,0
+
+ Most of these use Sun's extension for prototyped function types ---
+ the 'g' type descriptor. As of around 9 Feb 2002, GCC didn't emit
+ those, but GDB can read them, so the related tests in ptype.exp
+ will all xfail. */
+
+
/***********/
int main ()
diff --git a/gdb/testsuite/gdb.base/ptype.exp b/gdb/testsuite/gdb.base/ptype.exp
index 6e0bda5..2851e89 100644
--- a/gdb/testsuite/gdb.base/ptype.exp
+++ b/gdb/testsuite/gdb.base/ptype.exp
@@ -533,6 +533,58 @@ gdb_test "ptype nested_su.inner_struct_instance.inner_int" "type = int.*" "ptype
gdb_test "ptype nested_su.inner_union_instance" "type = union ${outer}inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype nested union"
+
+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.
+# - Otherwise, it's a failure.
+proc ptype_maybe_prototyped { id prototyped plain } {
+ global gdb_prompt
+ global gcc_compiled
+
+ # Turn `prototyped' and `plain', which are literal strings, into
+ # regular expressions by quoting any special characters they contain.
+ regsub -all "\[\]\[*()\]" $prototyped "\\\\&" prototyped
+ regsub -all "\[\]\[*()\]" $plain "\\\\&" plain
+
+ send_gdb "ptype $id\n"
+ gdb_expect {
+ -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 "$gdb_prompt $" {
+ fail "ptype $id"
+ }
+ timeout {
+ fail "ptype $id (timeout)"
+ }
+ }
+}
+
+ptype_maybe_prototyped "func_type" "int (*)(int (*)(int, float), float)" \
+ "int (*)()"
+ptype_maybe_prototyped "old_fptr" "double (*)()" "double (*)()"
+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 (*)()"
+ptype_maybe_prototyped "ffptr" "int (*(*)(char))(short int)" \
+ "int (*(*)())()"
+ptype_maybe_prototyped "fffptr" "int (*(*(*)(char))(short int))(long int)" \
+ "int (*(*(*)())())()"
+
# 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.