aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2010-08-19 13:33:15 +0000
committerDoug Evans <dje@google.com>2010-08-19 13:33:15 +0000
commitd30f5e1f70ffa9fab08ccdacdba1bd6365d2511d (patch)
treea578156b090268842ed34a2a077d2eb6b6519cd2 /gdb/testsuite
parent2837d59e6b7e523fee86a5a5a050ecb5554ccd1b (diff)
downloadfsf-binutils-gdb-d30f5e1f70ffa9fab08ccdacdba1bd6365d2511d.zip
fsf-binutils-gdb-d30f5e1f70ffa9fab08ccdacdba1bd6365d2511d.tar.gz
fsf-binutils-gdb-d30f5e1f70ffa9fab08ccdacdba1bd6365d2511d.tar.bz2
PR exp/11926
* parser-defs.h (parse_float, parse_c_float): Declare. * parse.c (parse_float, parse_c_float): New function. * c-exp.y (parse_number): Call parse_c_float. * objc-exp.y (parse_number): Ditto. * p-exp.y (parse_number): Ditto. Use ANSI/ISO-style definition. * jv-exp.y (parse_number): Call parse_float, fix suffix handling. testsuite/ * gdb.base/printcmds.exp (test_float_accepted): New function. Move existing float tests there. Add tests for floats with suffixes. (test_float_rejected): New function. * gdb.java/jv-print.exp (test_float_accepted): New function. (test_float_rejected): New function. * gdb.objc/print.exp: New file. * gdb.pascal/print.exp: New file. * lib/objc.exp: New file.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog12
-rw-r--r--gdb/testsuite/gdb.base/printcmds.exp43
-rw-r--r--gdb/testsuite/gdb.java/jv-print.exp24
-rw-r--r--gdb/testsuite/gdb.objc/print.exp68
-rw-r--r--gdb/testsuite/gdb.pascal/print.exp64
-rw-r--r--gdb/testsuite/lib/objc.exp30
6 files changed, 230 insertions, 11 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 3bc7810..547deaf 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,15 @@
+2010-08-19 Doug Evans <dje@google.com>
+
+ PR exp/11926
+ * gdb.base/printcmds.exp (test_float_accepted): New function.
+ Move existing float tests there. Add tests for floats with suffixes.
+ (test_float_rejected): New function.
+ * gdb.java/jv-print.exp (test_float_accepted): New function.
+ (test_float_rejected): New function.
+ * gdb.objc/print.exp: New file.
+ * gdb.pascal/print.exp: New file.
+ * lib/objc.exp: New file.
+
2010-08-19 Pierre Muller <muller@ics.u-strasbg.fr>
* gdb.base/default.exp (info set): Avoid full buffer error and force
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index 4c82ab3..d377597 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -102,17 +102,6 @@ proc test_integer_literals_rejected {} {
test_print_reject "p DEADBEEF"
- # Gdb currently fails this test for all configurations. The C
- # lexer thinks that 123DEADBEEF is a floating point number, but
- # then fails to notice that atof() only eats the 123 part.
- # FIXME: This should be put into PRMS.
- # Fixed, 4/25/97, by Bob Manson.
-
- test_print_reject "p 123DEADBEEF"
- test_print_reject "p 123foobar.bazfoo3"
- test_print_reject "p 123EEEEEEEEEEEEEEEEE33333k333"
- gdb_test "p 123.4+56.7" "180.(099\[0-9]*|100\[0-9\]*)" "check for floating addition"
-
# Test various octal values.
test_print_reject "p 09"
@@ -129,6 +118,36 @@ proc test_integer_literals_rejected {} {
test_print_reject "p 0b12"
}
+proc test_float_accepted {} {
+ # This test is useful to catch successful parsing of the first fp value.
+ gdb_test "p 123.4+56.7" " = 180.(099\[0-9]*|100\[0-9\]*)" "check for floating addition"
+
+ # Test all the suffixes (including no suffix).
+ gdb_test "p 1." " = 1"
+ gdb_test "p 1.5" " = 1.5"
+ gdb_test "p 1.f" " = 1"
+ gdb_test "p 1.5f" " = 1.5"
+ gdb_test "p 1.l" " = 1"
+ gdb_test "p 1.5l" " = 1.5"
+}
+
+proc test_float_rejected {} {
+ # Gdb use to fail this test for all configurations. The C
+ # lexer thought that 123DEADBEEF was a floating point number, but
+ # then failed to notice that atof() only eats the 123 part.
+ # Fixed, 4/25/97, by Bob Manson.
+ test_print_reject "p 123DEADBEEF"
+
+ test_print_reject "p 123foobar.bazfoo3"
+ test_print_reject "p 123EEEEEEEEEEEEEEEEE33333k333"
+ test_print_reject "p 0x1.1"
+
+ # Test bad suffixes.
+ test_print_reject "p 1.1x"
+ test_print_reject "p 1.1ff"
+ test_print_reject "p 1.1ll"
+}
+
proc test_print_all_chars {} {
global gdb_prompt
@@ -781,6 +800,8 @@ if ![runto_main] then {
test_integer_literals_accepted
test_integer_literals_rejected
+test_float_accepted
+test_float_rejected
test_character_literals_accepted
test_print_all_chars
test_print_repeats_10
diff --git a/gdb/testsuite/gdb.java/jv-print.exp b/gdb/testsuite/gdb.java/jv-print.exp
index c78f7d7..cdb598c 100644
--- a/gdb/testsuite/gdb.java/jv-print.exp
+++ b/gdb/testsuite/gdb.java/jv-print.exp
@@ -97,6 +97,28 @@ proc test_integer_literals_rejected {} {
test_print_reject "p 0xAG"
}
+proc test_float_accepted {} {
+ # Test parsing of fp value with legit text following.
+ gdb_test "p 1234.5+1" " = 1235.5" "check fp + text"
+
+ # Test all the suffixes (including no suffix).
+ gdb_test "p 1." " = 1"
+ gdb_test "p 1.5" " = 1.5"
+ gdb_test "p 1.f" " = 1"
+ gdb_test "p 1.5f" " = 1.5"
+ gdb_test "p 1.d" " = 1"
+ gdb_test "p 1.5d" " = 1.5"
+}
+
+proc test_float_rejected {} {
+ # Test invalid fp values.
+ test_print_reject "p 0x1.1"
+
+ # Test bad suffixes.
+ test_print_reject "p 1.1x"
+ test_print_reject "p 1.1ff"
+ test_print_reject "p 1.1dd"
+}
# Start with a fresh gdb.
@@ -117,6 +139,8 @@ if [set_lang_java] then {
test_integer_literals_accepted
test_character_literals_accepted
test_integer_literals_rejected
+ test_float_accepted
+ test_float_rejected
} else {
warning "Java print command tests suppressed"
}
diff --git a/gdb/testsuite/gdb.objc/print.exp b/gdb/testsuite/gdb.objc/print.exp
new file mode 100644
index 0000000..2988d20
--- /dev/null
+++ b/gdb/testsuite/gdb.objc/print.exp
@@ -0,0 +1,68 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2010 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 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, see <http://www.gnu.org/licenses/>.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@gnu.org
+
+# Test printing of various values.
+# NOTE: The tests here intentionally do not require an objc compiler.
+
+if $tracelevel {
+ strace $tracelevel
+}
+
+load_lib "objc.exp"
+
+proc test_float_accepted {} {
+ # Test parsing of fp value with legit text following.
+ gdb_test "p 1234.5+1" " = 1235.5" "check fp + text"
+
+ # Test all the suffixes (including no suffix).
+ gdb_test "p 1." " = 1"
+ gdb_test "p 1.5" " = 1.5"
+ setup_kfail gdb/11925 "*-*-*"
+ gdb_test "p 1.f" " = 1"
+ setup_kfail gdb/11925 "*-*-*"
+ gdb_test "p 1.5f" " = 1.5"
+ setup_kfail gdb/11925 "*-*-*"
+ gdb_test "p 1.l" " = 1"
+ setup_kfail gdb/11925 "*-*-*"
+ gdb_test "p 1.5l" " = 1.5"
+}
+
+proc test_float_rejected {} {
+ # Test invalid fp values.
+ test_print_reject "p 0x1.1"
+
+ # Test bad suffixes.
+ test_print_reject "p 1.1x"
+ test_print_reject "p 1.1ff"
+ test_print_reject "p 1.1ll"
+}
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+if [set_lang_objc] {
+ test_float_accepted
+ test_float_rejected
+} else {
+ warning "Objective-c print tests suppressed"
+}
diff --git a/gdb/testsuite/gdb.pascal/print.exp b/gdb/testsuite/gdb.pascal/print.exp
new file mode 100644
index 0000000..61f6d37
--- /dev/null
+++ b/gdb/testsuite/gdb.pascal/print.exp
@@ -0,0 +1,64 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2010 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 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, see <http://www.gnu.org/licenses/>.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@gnu.org
+
+# Test printing of various values.
+# NOTE: The tests here intentionally do not require a pascal compiler.
+
+if $tracelevel {
+ strace $tracelevel
+}
+
+load_lib "pascal.exp"
+
+proc test_float_accepted {} {
+ # Test parsing of fp value with legit text following.
+ gdb_test "p 1234.5+1" " = 1235.5" "check fp + text"
+
+ # Test all the suffixes (including no suffix).
+ gdb_test "p 1." " = 1"
+ gdb_test "p 1.5" " = 1.5"
+ gdb_test "p 1.f" " = 1"
+ gdb_test "p 1.5f" " = 1.5"
+ gdb_test "p 1.l" " = 1"
+ gdb_test "p 1.5l" " = 1.5"
+}
+
+proc test_float_rejected {} {
+ # Test invalid fp values.
+ test_print_reject "p 0x1.1"
+
+ # Test bad suffixes.
+ test_print_reject "p 1.1x"
+ test_print_reject "p 1.1ff"
+ test_print_reject "p 1.1ll"
+}
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+if [set_lang_pascal] {
+ test_float_accepted
+ test_float_rejected
+} else {
+ warning "Pascal print tests suppressed"
+}
diff --git a/gdb/testsuite/lib/objc.exp b/gdb/testsuite/lib/objc.exp
new file mode 100644
index 0000000..190c715
--- /dev/null
+++ b/gdb/testsuite/lib/objc.exp
@@ -0,0 +1,30 @@
+# This test code is part of GDB, the GNU debugger.
+
+# Copyright 2010 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 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, see <http://www.gnu.org/licenses/>.
+
+# Auxiliary function to set the language to fortran.
+# The result is 1 (true) for success, 0 (false) for failure.
+
+proc set_lang_objc {} {
+ if [gdb_test_no_output "set language objective-c"] {
+ return 0
+ }
+ if [gdb_test "show language" ".* source language is \"objective-c\"." \
+ "set language to \"objective-c\""] {
+ return 0
+ }
+ return 1;
+}