* [patch] Handle 0 result from sscanf when parsing fp values.
@ 2010-08-17 0:31 Doug Evans
2010-08-17 8:18 ` Andreas Schwab
0 siblings, 1 reply; 15+ messages in thread
From: Doug Evans @ 2010-08-17 0:31 UTC (permalink / raw)
To: gdb-patches
Hi.
I was getting an internal error from "p 0x1.1".
(gdb) p 0x1.1
gdb/gdbtypes.c:1385: internal-error: check_typedef: Assertion `type' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
This is due to sscanf returning 0 and c-exp.y:parse_number not handling it.
NOTE: Not all glibc's trigger this, and you have to do "p 0x1.1" first,
otherwise the global yylval (c_lval) variable will just get reused,
and no crash (or error!).
I will commit the following in two days if there are no objections.
NOTE: This patch uses gdb_assert_not_reached.
ref: http://sourceware.org/ml/gdb-patches/2010-08/msg00250.html
2010-08-16 Doug Evans <dje@google.com>
* c-exp.y (parse_number): Handle 0 result from sscanf.
* objc-exp.y (parse_number): Ditto.
testsuite/
* gdb.base/printcmds.exp (test_float_literals_rejected): New proc.
Call it to test handling of bad floating point numbers.
* gdb.objc/printcmds.exp: New file.
Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.76
diff -u -p -u -p -r1.76 c-exp.y
--- c-exp.y 28 Jun 2010 20:18:26 -0000 1.76
+++ c-exp.y 17 Aug 2010 00:17:29 -0000
@@ -1371,12 +1371,18 @@ parse_number (char *p, int len, int pars
&putithere->typed_val_float.dval, s);
p[len] = saved_char; /* restore the input stream */
- if (num == 1)
- putithere->typed_val_float.type =
- parse_type->builtin_double;
-
- if (num == 2 )
+ switch (num)
{
+ case 0:
+ free (s);
+ return ERROR;
+
+ case 1:
+ putithere->typed_val_float.type =
+ parse_type->builtin_double;
+ break;
+
+ case 2:
/* See if it has any float suffix: 'f' for float, 'l' for long
double. */
if (!strcasecmp (s, "f"))
@@ -1390,6 +1396,10 @@ parse_number (char *p, int len, int pars
free (s);
return ERROR;
}
+ break;
+
+ default:
+ gdb_assert_not_reached ("unexpected sscanf result");
}
free (s);
Index: objc-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/objc-exp.y,v
retrieving revision 1.38
diff -u -p -u -p -r1.38 objc-exp.y
--- objc-exp.y 5 Mar 2010 20:18:14 -0000 1.38
+++ objc-exp.y 17 Aug 2010 00:17:29 -0000
@@ -1016,8 +1016,9 @@ parse_number (p, len, parsed_float, puti
/* It's a float since it contains a point or an exponent. */
- sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c",
- &putithere->typed_val_float.dval, &c);
+ if (sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c",
+ &putithere->typed_val_float.dval, &c) != 1)
+ return ERROR;
/* See if it has `f' or `l' suffix (float or long double). */
Index: testsuite/gdb.base/printcmds.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/printcmds.exp,v
retrieving revision 1.35
diff -u -p -u -p -r1.35 printcmds.exp
--- testsuite/gdb.base/printcmds.exp 21 Jul 2010 18:08:27 -0000 1.35
+++ testsuite/gdb.base/printcmds.exp 17 Aug 2010 00:17:29 -0000
@@ -146,6 +146,10 @@ proc test_integer_literals_rejected {} {
test_print_reject "p 0b12"
}
+proc test_float_literals_rejected {} {
+ test_print_reject "p 0x1.1"
+}
+
proc test_print_all_chars {} {
global gdb_prompt
@@ -794,6 +798,7 @@ if [set_lang_c] then {
if [runto_main] then {
test_integer_literals_accepted
test_integer_literals_rejected
+ test_float_literals_rejected
test_character_literals_accepted
test_print_all_chars
test_print_repeats_10
Index: testsuite/gdb.objc/printcmds.exp
===================================================================
RCS file: testsuite/gdb.objc/printcmds.exp
diff -N testsuite/gdb.objc/printcmds.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.objc/printcmds.exp 17 Aug 2010 00:17:29 -0000
@@ -0,0 +1,53 @@
+# 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
+
+if $tracelevel {
+ strace $tracelevel
+}
+
+# Set the current language to Objective-C. This counts as a test. If it
+# fails, then we skip the other tests.
+
+proc set_lang_objc {} {
+ global gdb_prompt
+
+ if [gdb_test_no_output "set language objective-c" "set language objective-c"] {
+ return 0
+ }
+
+ if [gdb_test "show language" ".* source language is \"objective-c\".*"] {
+ return 0
+ }
+ return 1;
+}
+
+proc test_float_literals_rejected {} {
+ test_print_reject "p 0x1.1"
+}
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+if [set_lang_objc] {
+ test_float_literals_rejected
+}
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch] Handle 0 result from sscanf when parsing fp values.
2010-08-17 0:31 [patch] Handle 0 result from sscanf when parsing fp values Doug Evans
@ 2010-08-17 8:18 ` Andreas Schwab
2010-08-17 11:37 ` Doug Evans
0 siblings, 1 reply; 15+ messages in thread
From: Andreas Schwab @ 2010-08-17 8:18 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
dje@google.com (Doug Evans) writes:
> Index: objc-exp.y
> ===================================================================
> RCS file: /cvs/src/src/gdb/objc-exp.y,v
> retrieving revision 1.38
> diff -u -p -u -p -r1.38 objc-exp.y
> --- objc-exp.y 5 Mar 2010 20:18:14 -0000 1.38
> +++ objc-exp.y 17 Aug 2010 00:17:29 -0000
> @@ -1016,8 +1016,9 @@ parse_number (p, len, parsed_float, puti
>
> /* It's a float since it contains a point or an exponent. */
>
> - sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c",
> - &putithere->typed_val_float.dval, &c);
> + if (sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c",
> + &putithere->typed_val_float.dval, &c) != 1)
Shouldn't that be "< 1" since there can be two conversions?
Andreas.
--
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E
"And now for something completely different."
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch] Handle 0 result from sscanf when parsing fp values.
2010-08-17 8:18 ` Andreas Schwab
@ 2010-08-17 11:37 ` Doug Evans
2010-08-18 20:38 ` Doug Evans
0 siblings, 1 reply; 15+ messages in thread
From: Doug Evans @ 2010-08-17 11:37 UTC (permalink / raw)
To: Andreas Schwab; +Cc: gdb-patches
On Tue, Aug 17, 2010 at 1:18 AM, Andreas Schwab <schwab@redhat.com> wrote:
> dje@google.com (Doug Evans) writes:
>
>> Index: objc-exp.y
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/objc-exp.y,v
>> retrieving revision 1.38
>> diff -u -p -u -p -r1.38 objc-exp.y
>> --- objc-exp.y 5 Mar 2010 20:18:14 -0000 1.38
>> +++ objc-exp.y 17 Aug 2010 00:17:29 -0000
>> @@ -1016,8 +1016,9 @@ parse_number (p, len, parsed_float, puti
>>
>> /* It's a float since it contains a point or an exponent. */
>>
>> - sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c",
>> - &putithere->typed_val_float.dval, &c);
>> + if (sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c",
>> + &putithere->typed_val_float.dval, &c) != 1)
>
> Shouldn't that be "< 1" since there can be two conversions?
>
> Andreas.
Both p-exp.y and jv-exp.y check sscanf(...) != 1, the %c is there to
catch garbage after the number.
But it turns out p-exp.y and jv-exp.y are also broken in that they
assume the "f" in "1.1f" is accepted by sscanf as part of the number.
[They don't do what c-exp.y does which is capture the second
conversion as a string and check for valid vs invalid suffixes there.]
Blech.
I can see that if I'm going to test for sscanf(...) != 1 in objc-exp.y
I am going to have to nul-terminate the string first (as the other
*-exp.y files do).
Otherwise "p 1.1+1" will get flagged as an error. I'll fix that.
As it turns out, in objective-c "1.1f" never makes it that far as the
caller to objc-exp.y:parse_number will flag 1.1f as an error and never
call parse_number.
I was prepared to fix "not checking result of sscanf", but I wasn't
going to fix all of them in this patch, and the closer I look the more
bugs I find.
Guess I'll (try to) fix them too.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch] Handle 0 result from sscanf when parsing fp values.
2010-08-17 11:37 ` Doug Evans
@ 2010-08-18 20:38 ` Doug Evans
2010-08-20 7:34 ` [patch] Fix new FAIL `reject p 0x1.1' [Re: [patch] Handle 0 result from sscanf when parsing fp values.] Jan Kratochvil
0 siblings, 1 reply; 15+ messages in thread
From: Doug Evans @ 2010-08-18 20:38 UTC (permalink / raw)
To: Andreas Schwab; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 933 bytes --]
Here's my new patch.
I plan to check this in tomorrow.
2010-08-18 Doug Evans <dje@google.com>
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.
[-- Attachment #2: gdb-100818-hex-float-crash-2.patch.txt --]
[-- Type: text/plain, Size: 20306 bytes --]
2010-08-18 Doug Evans <dje@google.com>
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.
Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.76
diff -u -p -r1.76 c-exp.y
--- c-exp.y 28 Jun 2010 20:18:26 -0000 1.76
+++ c-exp.y 18 Aug 2010 20:16:24 -0000
@@ -1323,10 +1323,8 @@ parse_number (char *p, int len, int pars
if (parsed_float)
{
- /* It's a float since it contains a point or an exponent. */
- char *s;
- int num; /* number of tokens scanned by scanf */
- char saved_char;
+ const char *suffix;
+ int suffix_len;
/* If it ends at "df", "dd" or "dl", take it as type of decimal floating
point. Return DECFLOAT. */
@@ -1364,35 +1362,10 @@ parse_number (char *p, int len, int pars
return DECFLOAT;
}
- s = malloc (len);
- saved_char = p[len];
- p[len] = 0; /* null-terminate the token */
- num = sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%s",
- &putithere->typed_val_float.dval, s);
- p[len] = saved_char; /* restore the input stream */
-
- if (num == 1)
- putithere->typed_val_float.type =
- parse_type->builtin_double;
-
- if (num == 2 )
- {
- /* See if it has any float suffix: 'f' for float, 'l' for long
- double. */
- if (!strcasecmp (s, "f"))
- putithere->typed_val_float.type =
- parse_type->builtin_float;
- else if (!strcasecmp (s, "l"))
- putithere->typed_val_float.type =
- parse_type->builtin_long_double;
- else
- {
- free (s);
- return ERROR;
- }
- }
-
- free (s);
+ if (! parse_c_float (parse_gdbarch, p, len,
+ &putithere->typed_val_float.dval,
+ &putithere->typed_val_float.type))
+ return ERROR;
return FLOAT;
}
Index: jv-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/jv-exp.y,v
retrieving revision 1.39
diff -u -p -r1.39 jv-exp.y
--- jv-exp.y 6 May 2010 00:08:44 -0000 1.39
+++ jv-exp.y 18 Aug 2010 20:16:25 -0000
@@ -703,25 +703,28 @@ parse_number (char *p, int len, int pars
if (parsed_float)
{
- /* It's a float since it contains a point or an exponent. */
- char c;
- int num = 0; /* number of tokens scanned by scanf */
- char saved_char = p[len];
-
- p[len] = 0; /* null-terminate the token */
- num = sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c",
- &putithere->typed_val_float.dval, &c);
- p[len] = saved_char; /* restore the input stream */
- if (num != 1) /* check scanf found ONLY a float ... */
+ const char *suffix;
+ int suffix_len;
+
+ if (! parse_float (p, len, &putithere->typed_val_float.dval, &suffix))
return ERROR;
- /* See if it has `f' or `d' suffix (float or double). */
- c = tolower (p[len - 1]);
+ suffix_len = p + len - suffix;
- if (c == 'f' || c == 'F')
- putithere->typed_val_float.type = parse_type->builtin_float;
- else if (isdigit (c) || c == '.' || c == 'd' || c == 'D')
+ if (suffix_len == 0)
putithere->typed_val_float.type = parse_type->builtin_double;
+ else if (suffix_len == 1)
+ {
+ /* See if it has `f' or `d' suffix (float or double). */
+ if (tolower (*suffix) == 'f')
+ putithere->typed_val_float.type =
+ parse_type->builtin_float;
+ else if (tolower (*suffix) == 'd')
+ putithere->typed_val_float.type =
+ parse_type->builtin_double;
+ else
+ return ERROR;
+ }
else
return ERROR;
Index: objc-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/objc-exp.y,v
retrieving revision 1.38
diff -u -p -r1.38 objc-exp.y
--- objc-exp.y 5 Mar 2010 20:18:14 -0000 1.38
+++ objc-exp.y 18 Aug 2010 20:16:25 -0000
@@ -1012,26 +1012,10 @@ parse_number (p, len, parsed_float, puti
if (parsed_float)
{
- char c;
-
- /* It's a float since it contains a point or an exponent. */
-
- sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c",
- &putithere->typed_val_float.dval, &c);
-
- /* See if it has `f' or `l' suffix (float or long double). */
-
- c = tolower (p[len - 1]);
-
- if (c == 'f')
- putithere->typed_val_float.type = parse_type->builtin_float;
- else if (c == 'l')
- putithere->typed_val_float.type = parse_type->builtin_long_double;
- else if (isdigit (c) || c == '.')
- putithere->typed_val_float.type = parse_type->builtin_double;
- else
+ if (! parse_c_float (parse_gdbarch, p, len,
+ &putithere->typed_val_float.dval,
+ &putithere->typed_val_float.type))
return ERROR;
-
return FLOAT;
}
Index: p-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/p-exp.y,v
retrieving revision 1.50
diff -u -p -r1.50 p-exp.y
--- p-exp.y 8 May 2010 09:18:02 -0000 1.50
+++ p-exp.y 18 Aug 2010 20:16:25 -0000
@@ -791,11 +791,7 @@ name_not_typename : NAME
/*** Needs some error checking for the float case ***/
static int
-parse_number (p, len, parsed_float, putithere)
- char *p;
- int len;
- int parsed_float;
- YYSTYPE *putithere;
+parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
{
/* FIXME: Shouldn't these be unsigned? We don't deal with negative values
here, and we do kind of silly things like cast to unsigned. */
@@ -820,30 +816,10 @@ parse_number (p, len, parsed_float, puti
if (parsed_float)
{
- /* It's a float since it contains a point or an exponent. */
- char c;
- int num = 0; /* number of tokens scanned by scanf */
- char saved_char = p[len];
-
- p[len] = 0; /* null-terminate the token */
- num = sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c",
- &putithere->typed_val_float.dval, &c);
- p[len] = saved_char; /* restore the input stream */
- if (num != 1) /* check scanf found ONLY a float ... */
+ if (! parse_c_float (parse_gdbarch, p, len,
+ &putithere->typed_val_float.dval,
+ &putithere->typed_val_float.type))
return ERROR;
- /* See if it has `f' or `l' suffix (float or long double). */
-
- c = tolower (p[len - 1]);
-
- if (c == 'f')
- putithere->typed_val_float.type = parse_type->builtin_float;
- else if (c == 'l')
- putithere->typed_val_float.type = parse_type->builtin_long_double;
- else if (isdigit (c) || c == '.')
- putithere->typed_val_float.type = parse_type->builtin_double;
- else
- return ERROR;
-
return FLOAT;
}
Index: parse.c
===================================================================
RCS file: /cvs/src/src/gdb/parse.c,v
retrieving revision 1.103
diff -u -p -r1.103 parse.c
--- parse.c 18 Aug 2010 19:02:32 -0000 1.103
+++ parse.c 18 Aug 2010 20:16:25 -0000
@@ -1038,8 +1038,6 @@ prefixify_subexp (struct expression *ine
return result;
}
\f
-/* This page contains the two entry points to this file. */
-
/* Read an expression from the string *STRINGPTR points to,
parse it, and return a pointer to a struct expression that we malloc.
Use block BLOCK as the lexical context for variable names;
@@ -1252,6 +1250,73 @@ void
null_post_parser (struct expression **exp, int void_context_p)
{
}
+
+/* Parse floating point value P of length LEN.
+ Return 0 (false) if invalid, 1 (true) if valid.
+ The successfully parsed number is stored in D.
+ *SUFFIX points to the suffix of the number in P.
+
+ NOTE: This accepts the floating point syntax that sscanf accepts. */
+
+int
+parse_float (const char *p, int len, DOUBLEST *d, const char **suffix)
+{
+ char *copy;
+ char *s;
+ int n, num;
+
+ copy = xmalloc (len + 1);
+ memcpy (copy, p, len);
+ copy[len] = 0;
+
+ num = sscanf (copy, "%" DOUBLEST_SCAN_FORMAT "%n", d, &n);
+ xfree (copy);
+
+ /* The sscanf man page suggests not making any assumptions on the effect
+ of %n on the result, so we don't.
+ That is why we simply test num == 0. */
+ if (num == 0)
+ return 0;
+
+ *suffix = p + n;
+ return 1;
+}
+
+/* Parse floating point value P of length LEN, using the C syntax for floats.
+ Return 0 (false) if invalid, 1 (true) if valid.
+ The successfully parsed number is stored in *D.
+ Its type is taken from builtin_type (gdbarch) and is stored in *T. */
+
+int
+parse_c_float (struct gdbarch *gdbarch, const char *p, int len,
+ DOUBLEST *d, struct type **t)
+{
+ const char *suffix;
+ int suffix_len;
+ const struct builtin_type *builtin_types = builtin_type (gdbarch);
+
+ if (! parse_float (p, len, d, &suffix))
+ return 0;
+
+ suffix_len = p + len - suffix;
+
+ if (suffix_len == 0)
+ *t = builtin_types->builtin_double;
+ else if (suffix_len == 1)
+ {
+ /* Handle suffixes: 'f' for float, 'l' for long double. */
+ if (tolower (*suffix) == 'f')
+ *t = builtin_types->builtin_float;
+ else if (tolower (*suffix) == 'l')
+ *t = builtin_types->builtin_long_double;
+ else
+ return 0;
+ }
+ else
+ return 0;
+
+ return 1;
+}
\f
/* Stuff for maintaining a stack of types. Currently just used by C, but
probably useful for any language which declares its types "backwards". */
Index: parser-defs.h
===================================================================
RCS file: /cvs/src/src/gdb/parser-defs.h,v
retrieving revision 1.36
diff -u -p -r1.36 parser-defs.h
--- parser-defs.h 4 Jun 2010 21:39:47 -0000 1.36
+++ parser-defs.h 18 Aug 2010 20:16:25 -0000
@@ -204,6 +204,12 @@ extern struct type *follow_types (struct
extern void null_post_parser (struct expression **, int);
+extern int parse_float (const char *p, int len, DOUBLEST *d,
+ const char **suffix);
+
+extern int parse_c_float (struct gdbarch *gdbarch, const char *p, int len,
+ DOUBLEST *d, struct type **t);
+
/* During parsing of a C expression, the pointer to the next character
is in this variable. */
Index: testsuite/gdb.base/printcmds.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/printcmds.exp,v
retrieving revision 1.36
diff -u -p -r1.36 printcmds.exp
--- testsuite/gdb.base/printcmds.exp 18 Aug 2010 16:37:21 -0000 1.36
+++ testsuite/gdb.base/printcmds.exp 18 Aug 2010 20:16:25 -0000
@@ -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
Index: testsuite/gdb.java/jv-print.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.java/jv-print.exp,v
retrieving revision 1.14
diff -u -p -r1.14 jv-print.exp
--- testsuite/gdb.java/jv-print.exp 18 Aug 2010 16:37:21 -0000 1.14
+++ testsuite/gdb.java/jv-print.exp 18 Aug 2010 20:16:25 -0000
@@ -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"
}
Index: testsuite/gdb.objc/print.exp
===================================================================
RCS file: testsuite/gdb.objc/print.exp
diff -N testsuite/gdb.objc/print.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.objc/print.exp 18 Aug 2010 20:16:25 -0000
@@ -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 "objective-c.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"
+}
Index: testsuite/gdb.pascal/print.exp
===================================================================
RCS file: testsuite/gdb.pascal/print.exp
diff -N testsuite/gdb.pascal/print.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.pascal/print.exp 18 Aug 2010 20:16:25 -0000
@@ -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"
+}
Index: testsuite/lib/objective-c.exp
===================================================================
RCS file: testsuite/lib/objective-c.exp
diff -N testsuite/lib/objective-c.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/lib/objective-c.exp 18 Aug 2010 20:16:25 -0000
@@ -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;
+}
^ permalink raw reply [flat|nested] 15+ messages in thread
* [patch] Fix new FAIL `reject p 0x1.1' [Re: [patch] Handle 0 result from sscanf when parsing fp values.]
2010-08-18 20:38 ` Doug Evans
@ 2010-08-20 7:34 ` Jan Kratochvil
2010-08-20 7:37 ` [patch] Fix new FAIL `reject p 0x1.1' [fixup] " Jan Kratochvil
0 siblings, 1 reply; 15+ messages in thread
From: Jan Kratochvil @ 2010-08-20 7:34 UTC (permalink / raw)
To: Doug Evans; +Cc: Andreas Schwab, gdb-patches
Hi,
0x1.1 is a perfectly valid hexadecimal floating point. The new testcase:
PASS CentOS-4.8 glibc-2.3.4-2.43.el4_8.3
FAIL CentOS-5.5 glibc-2.5-49.el5_5.4
FAIL Fedora 13+14
OK to check-in?
Thanks,
Jan
gdb/testsuite/
2010-08-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/printcmds.exp (p 0x1.1): PASS on parse as 1.0625.
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -140,7 +140,8 @@ proc test_float_rejected {} {
test_print_reject "p 123foobar.bazfoo3"
test_print_reject "p 123EEEEEEEEEEEEEEEEE33333k333"
- test_print_reject "p 0x1.1"
+ # Older glibc does not support hex float, newer does.
+ test_print_reject "p 0x1.1" " = 1\\.0625\r\n"
# Test bad suffixes.
test_print_reject "p 1.1x"
^ permalink raw reply [flat|nested] 15+ messages in thread
* [patch] Fix new FAIL `reject p 0x1.1' [fixup] [Re: [patch] Handle 0 result from sscanf when parsing fp values.]
2010-08-20 7:34 ` [patch] Fix new FAIL `reject p 0x1.1' [Re: [patch] Handle 0 result from sscanf when parsing fp values.] Jan Kratochvil
@ 2010-08-20 7:37 ` Jan Kratochvil
2010-08-20 11:58 ` Joseph S. Myers
0 siblings, 1 reply; 15+ messages in thread
From: Jan Kratochvil @ 2010-08-20 7:37 UTC (permalink / raw)
To: Doug Evans; +Cc: Andreas Schwab, gdb-patches
[fixup]
On Fri, 20 Aug 2010 09:34:30 +0200, Jan Kratochvil wrote:
Hi,
0x1.1 is a perfectly valid hexadecimal floating point. The new testcase:
PASS CentOS-4.8 glibc-2.3.4-2.43.el4_8.3
FAIL CentOS-5.5 glibc-2.5-49.el5_5.4
FAIL Fedora 13+14
OK to check-in?
Thanks,
Jan
gdb/testsuite/
2010-08-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/printcmds.exp (p 0x1.1): PASS on parse as 1.0625.
* gdb.java/jv-print.exp (p 0x1.1): PASS on parse as 1.0625.
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -140,7 +140,8 @@ proc test_float_rejected {} {
test_print_reject "p 123foobar.bazfoo3"
test_print_reject "p 123EEEEEEEEEEEEEEEEE33333k333"
- test_print_reject "p 0x1.1"
+ # Older glibc does not support hex float, newer does.
+ test_print_reject "p 0x1.1" " = 1\\.0625\r\n"
# Test bad suffixes.
test_print_reject "p 1.1x"
--- a/gdb/testsuite/gdb.java/jv-print.exp
+++ b/gdb/testsuite/gdb.java/jv-print.exp
@@ -112,7 +112,8 @@ proc test_float_accepted {} {
proc test_float_rejected {} {
# Test invalid fp values.
- test_print_reject "p 0x1.1"
+ # Older glibc does not support hex float, newer does.
+ test_print_reject "p 0x1.1" " = 1\\.0625\r\n"
# Test bad suffixes.
test_print_reject "p 1.1x"
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch] Fix new FAIL `reject p 0x1.1' [fixup] [Re: [patch] Handle 0 result from sscanf when parsing fp values.]
2010-08-20 7:37 ` [patch] Fix new FAIL `reject p 0x1.1' [fixup] " Jan Kratochvil
@ 2010-08-20 11:58 ` Joseph S. Myers
2010-08-23 15:35 ` Doug Evans
0 siblings, 1 reply; 15+ messages in thread
From: Joseph S. Myers @ 2010-08-20 11:58 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Doug Evans, Andreas Schwab, gdb-patches
On Fri, 20 Aug 2010, Jan Kratochvil wrote:
> [fixup]
>
> On Fri, 20 Aug 2010 09:34:30 +0200, Jan Kratochvil wrote:
> Hi,
>
> 0x1.1 is a perfectly valid hexadecimal floating point. The new testcase:
It's not valid in C source code (a binary exponent is required), though it
is valid as input to strtod (like INF, NAN, NAN(n-char-sequence_opt) etc.)
- is the intention here that GDB deliberately accepts something beyond
what would be valid in C source code?
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch] Fix new FAIL `reject p 0x1.1' [fixup] [Re: [patch] Handle 0 result from sscanf when parsing fp values.]
2010-08-20 11:58 ` Joseph S. Myers
@ 2010-08-23 15:35 ` Doug Evans
2010-08-23 18:55 ` [patch] Fix new FAIL `reject p 0x1.1' [fixup] Jan Kratochvil
0 siblings, 1 reply; 15+ messages in thread
From: Doug Evans @ 2010-08-23 15:35 UTC (permalink / raw)
To: Joseph S. Myers; +Cc: Jan Kratochvil, Andreas Schwab, gdb-patches
On Fri, Aug 20, 2010 at 4:58 AM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> On Fri, 20 Aug 2010, Jan Kratochvil wrote:
>
>> [fixup]
>>
>> On Fri, 20 Aug 2010 09:34:30 +0200, Jan Kratochvil wrote:
>> Hi,
>>
>> 0x1.1 is a perfectly valid hexadecimal floating point. The new testcase:
>
> It's not valid in C source code (a binary exponent is required), though it
> is valid as input to strtod (like INF, NAN, NAN(n-char-sequence_opt) etc.)
> - is the intention here that GDB deliberately accepts something beyond
> what would be valid in C source code?
I don't know what gdb is intended to accept.
My main concern here is that there is a testcase that exercises the
code in question.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch] Fix new FAIL `reject p 0x1.1' [fixup]
2010-08-23 15:35 ` Doug Evans
@ 2010-08-23 18:55 ` Jan Kratochvil
2010-08-23 19:49 ` Doug Evans
0 siblings, 1 reply; 15+ messages in thread
From: Jan Kratochvil @ 2010-08-23 18:55 UTC (permalink / raw)
To: Doug Evans; +Cc: Joseph S. Myers, Andreas Schwab, gdb-patches
On Mon, 23 Aug 2010 17:35:07 +0200, Doug Evans wrote:
> On Fri, Aug 20, 2010 at 4:58 AM, Joseph S. Myers <joseph@codesourcery.com> wrote:
> > On Fri, 20 Aug 2010, Jan Kratochvil wrote:
> >> On Fri, 20 Aug 2010 09:34:30 +0200, Jan Kratochvil wrote:
> >> 0x1.1 is a perfectly valid hexadecimal floating point. Â The new testcase:
> >
> > It's not valid in C source code (a binary exponent is required), though it
> > is valid as input to strtod (like INF, NAN, NAN(n-char-sequence_opt) etc.)
> > - is the intention here that GDB deliberately accepts something beyond
> > what would be valid in C source code?
>
> I don't know what gdb is intended to accept.
So far I believe GDB is intended to be more relaxed than the C compiler.
(PR symtab/11846 -> is accepted interchangeable with .)
(static symbols get resolved from not-current CUs)
etc.
While thanks for catching it I still believe now my testcase update is the
appropriate fix - if glibc supports then extended input syntax let the GDB
user benefit from it.
Thanks,
Jan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch] Fix new FAIL `reject p 0x1.1' [fixup]
2010-08-23 18:55 ` [patch] Fix new FAIL `reject p 0x1.1' [fixup] Jan Kratochvil
@ 2010-08-23 19:49 ` Doug Evans
2010-08-23 19:57 ` Doug Evans
0 siblings, 1 reply; 15+ messages in thread
From: Doug Evans @ 2010-08-23 19:49 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Joseph S. Myers, Andreas Schwab, gdb-patches
On Mon, Aug 23, 2010 at 11:54 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Mon, 23 Aug 2010 17:35:07 +0200, Doug Evans wrote:
>> On Fri, Aug 20, 2010 at 4:58 AM, Joseph S. Myers <joseph@codesourcery.com> wrote:
>> > On Fri, 20 Aug 2010, Jan Kratochvil wrote:
>> >> On Fri, 20 Aug 2010 09:34:30 +0200, Jan Kratochvil wrote:
>> >> 0x1.1 is a perfectly valid hexadecimal floating point. The new testcase:
>> >
>> > It's not valid in C source code (a binary exponent is required), though it
>> > is valid as input to strtod (like INF, NAN, NAN(n-char-sequence_opt) etc.)
>> > - is the intention here that GDB deliberately accepts something beyond
>> > what would be valid in C source code?
>>
>> I don't know what gdb is intended to accept.
>
> So far I believe GDB is intended to be more relaxed than the C compiler.
In general sure, but general rules need to be re-evaluated for each
context in which they're applied.
In this context ... I'm not sure, but I don't have a strong opinion either. :-)
> (PR symtab/11846 -> is accepted interchangeable with .)
> (static symbols get resolved from not-current CUs)
> etc.
>
> While thanks for catching it I still believe now my testcase update is the
> appropriate fix - if glibc supports then extended input syntax let the GDB
> user benefit from it.
It's ok with me.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch] Fix new FAIL `reject p 0x1.1' [fixup]
2010-08-23 19:49 ` Doug Evans
@ 2010-08-23 19:57 ` Doug Evans
2010-08-31 19:38 ` Jan Kratochvil
0 siblings, 1 reply; 15+ messages in thread
From: Doug Evans @ 2010-08-23 19:57 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Joseph S. Myers, Andreas Schwab, gdb-patches
On Mon, Aug 23, 2010 at 12:49 PM, Doug Evans <dje@google.com> wrote:
>> While thanks for catching it I still believe now my testcase update is the
>> appropriate fix - if glibc supports then extended input syntax let the GDB
>> user benefit from it.
>
> It's ok with me.
I should add that IWBN to have an additional testcase that exercises
sscanf (...) == 0 on newer glibcs.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch] Fix new FAIL `reject p 0x1.1' [fixup]
2010-08-23 19:57 ` Doug Evans
@ 2010-08-31 19:38 ` Jan Kratochvil
2010-08-31 22:51 ` Doug Evans
0 siblings, 1 reply; 15+ messages in thread
From: Jan Kratochvil @ 2010-08-31 19:38 UTC (permalink / raw)
To: Doug Evans; +Cc: Joseph S. Myers, Andreas Schwab, gdb-patches
On Mon, 23 Aug 2010 21:57:19 +0200, Doug Evans wrote:
> On Mon, Aug 23, 2010 at 12:49 PM, Doug Evans <dje@google.com> wrote:
> >> While thanks for catching it I still believe now my testcase update is the
> >> appropriate fix - if glibc supports then extended input syntax let the GDB
> >> user benefit from it.
> >
> > It's ok with me.
>
> I should add that IWBN to have an additional testcase that exercises
> sscanf (...) == 0 on newer glibcs.
OK, I forgot first. OK to check-in? Tested both cases (RHEL-4.8 and
Fedora14snapshot).
Thanks,
Jan
gdb/testsuite/
2010-08-31 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/printcmds.exp (test_float_accepted): Import gdb_prompt.
Move here, negate and extend by XFAIL the "p 0x1.1" test from ...
(test_float_rejected): ... here.
* gdb.java/jv-print.exp (test_float_accepted): Import gdb_prompt.
Move here, negate and extend by XFAIL the "p 0x1.1" test from ...
(test_float_rejected): ... here.
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -119,6 +119,8 @@ proc test_integer_literals_rejected {} {
}
proc test_float_accepted {} {
+ global gdb_prompt
+
# 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"
@@ -129,6 +131,18 @@ proc test_float_accepted {} {
gdb_test "p 1.5f" " = 1.5"
gdb_test "p 1.l" " = 1"
gdb_test "p 1.5l" " = 1.5"
+
+ # Test hexadecimal floating point.
+ set test "p 0x1.1"
+ gdb_test_multiple $test $test {
+ -re " = 1\\.0625\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "Invalid number \"0x1\\.1\"\\.\r\n$gdb_prompt $" {
+ # Older glibc does not support hex float, newer does.
+ xfail $test
+ }
+ }
}
proc test_float_rejected {} {
@@ -140,7 +154,6 @@ proc test_float_rejected {} {
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"
--- a/gdb/testsuite/gdb.java/jv-print.exp
+++ b/gdb/testsuite/gdb.java/jv-print.exp
@@ -98,6 +98,8 @@ proc test_integer_literals_rejected {} {
}
proc test_float_accepted {} {
+ global gdb_prompt
+
# Test parsing of fp value with legit text following.
gdb_test "p 1234.5+1" " = 1235.5" "check fp + text"
@@ -108,12 +110,21 @@ proc test_float_accepted {} {
gdb_test "p 1.5f" " = 1.5"
gdb_test "p 1.d" " = 1"
gdb_test "p 1.5d" " = 1.5"
+
+ # Test hexadecimal floating point.
+ set test "p 0x1.1"
+ gdb_test_multiple $test $test {
+ -re " = 1\\.0625\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "Invalid number \"0x1\\.1\"\r\n$gdb_prompt $" {
+ # Older glibc does not support hex float, newer does.
+ xfail $test
+ }
+ }
}
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"
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch] Fix new FAIL `reject p 0x1.1' [fixup]
2010-08-31 19:38 ` Jan Kratochvil
@ 2010-08-31 22:51 ` Doug Evans
2010-09-02 15:11 ` Jan Kratochvil
0 siblings, 1 reply; 15+ messages in thread
From: Doug Evans @ 2010-08-31 22:51 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
On Tue, Aug 31, 2010 at 12:37 PM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
>
> On Mon, 23 Aug 2010 21:57:19 +0200, Doug Evans wrote:
> > On Mon, Aug 23, 2010 at 12:49 PM, Doug Evans <dje@google.com> wrote:
> > >> While thanks for catching it I still believe now my testcase update is the
> > >> appropriate fix - if glibc supports then extended input syntax let the GDB
> > >> user benefit from it.
> > >
> > > It's ok with me.
> >
> > I should add that IWBN to have an additional testcase that exercises
> > sscanf (...) == 0 on newer glibcs.
>
> OK, I forgot first. OK to check-in? Tested both cases (RHEL-4.8 and
> Fedora14snapshot).
>
>
> Thanks,
> Jan
>
>
> gdb/testsuite/
> 2010-08-31 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * gdb.base/printcmds.exp (test_float_accepted): Import gdb_prompt.
> Move here, negate and extend by XFAIL the "p 0x1.1" test from ...
> (test_float_rejected): ... here.
> * gdb.java/jv-print.exp (test_float_accepted): Import gdb_prompt.
> Move here, negate and extend by XFAIL the "p 0x1.1" test from ...
> (test_float_rejected): ... here.
Apologies for the resend. Somehow it went out as text/html (which the
list rejects).
This is ok with me, but I think you also want to similarly patch
gdb.{objc,pascal}/print.exp, right?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch] Fix new FAIL `reject p 0x1.1' [fixup]
2010-08-31 22:51 ` Doug Evans
@ 2010-09-02 15:11 ` Jan Kratochvil
2010-09-06 22:29 ` Jan Kratochvil
0 siblings, 1 reply; 15+ messages in thread
From: Jan Kratochvil @ 2010-09-02 15:11 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
On Wed, 01 Sep 2010 00:51:25 +0200, Doug Evans wrote:
> This is ok with me, but I think you also want to similarly patch
> gdb.{objc,pascal}/print.exp, right?
Yes.
Tested on fedora14snapshot.x86_64 (PASS) and epel-4.x86_64 (XFAIL).
I will check it in later if not replied.
Thanks,
Jan
gdb/testsuite/
2010-09-02 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/printcmds.exp (test_float_accepted): Import gdb_prompt.
Move here, negate and extend by XFAIL the "p 0x1.1" test from ...
(test_float_rejected): ... here.
* gdb.java/jv-print.exp (test_float_accepted): Import gdb_prompt.
Move here, negate and extend by XFAIL the "p 0x1.1" test from ...
(test_float_rejected): ... here.
* gdb.objc/print.exp (test_float_accepted): Import gdb_prompt.
Move here, negate and extend by XFAIL the "p 0x1.1" test from ...
(test_float_rejected): ... here.
* gdb.pascal/print.exp (test_float_accepted): Import gdb_prompt.
Move here, negate and extend by XFAIL the "p 0x1.1" test from ...
(test_float_rejected): ... here.
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -119,6 +119,8 @@ proc test_integer_literals_rejected {} {
}
proc test_float_accepted {} {
+ global gdb_prompt
+
# 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"
@@ -129,6 +131,18 @@ proc test_float_accepted {} {
gdb_test "p 1.5f" " = 1.5"
gdb_test "p 1.l" " = 1"
gdb_test "p 1.5l" " = 1.5"
+
+ # Test hexadecimal floating point.
+ set test "p 0x1.1"
+ gdb_test_multiple $test $test {
+ -re " = 1\\.0625\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "Invalid number \"0x1\\.1\"\\.\r\n$gdb_prompt $" {
+ # Older glibc does not support hex float, newer does.
+ xfail $test
+ }
+ }
}
proc test_float_rejected {} {
@@ -140,7 +154,6 @@ proc test_float_rejected {} {
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"
--- a/gdb/testsuite/gdb.java/jv-print.exp
+++ b/gdb/testsuite/gdb.java/jv-print.exp
@@ -98,6 +98,8 @@ proc test_integer_literals_rejected {} {
}
proc test_float_accepted {} {
+ global gdb_prompt
+
# Test parsing of fp value with legit text following.
gdb_test "p 1234.5+1" " = 1235.5" "check fp + text"
@@ -108,12 +110,21 @@ proc test_float_accepted {} {
gdb_test "p 1.5f" " = 1.5"
gdb_test "p 1.d" " = 1"
gdb_test "p 1.5d" " = 1.5"
+
+ # Test hexadecimal floating point.
+ set test "p 0x1.1"
+ gdb_test_multiple $test $test {
+ -re " = 1\\.0625\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "Invalid number \"0x1\\.1\"\r\n$gdb_prompt $" {
+ # Older glibc does not support hex float, newer does.
+ xfail $test
+ }
+ }
}
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"
--- a/gdb/testsuite/gdb.objc/print.exp
+++ b/gdb/testsuite/gdb.objc/print.exp
@@ -28,6 +28,8 @@ if $tracelevel {
load_lib "objc.exp"
proc test_float_accepted {} {
+ global gdb_prompt
+
# Test parsing of fp value with legit text following.
gdb_test "p 1234.5+1" " = 1235.5" "check fp + text"
@@ -42,12 +44,21 @@ proc test_float_accepted {} {
gdb_test "p 1.l" " = 1"
setup_kfail gdb/11925 "*-*-*"
gdb_test "p 1.5l" " = 1.5"
+
+ # Test hexadecimal floating point.
+ set test "p 0x1.1"
+ gdb_test_multiple $test $test {
+ -re " = 1\\.0625\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "Invalid number \"0x1\\.1\"\\.\r\n$gdb_prompt $" {
+ # Older glibc does not support hex float, newer does.
+ xfail $test
+ }
+ }
}
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"
--- a/gdb/testsuite/gdb.pascal/print.exp
+++ b/gdb/testsuite/gdb.pascal/print.exp
@@ -28,6 +28,8 @@ if $tracelevel {
load_lib "pascal.exp"
proc test_float_accepted {} {
+ global gdb_prompt
+
# Test parsing of fp value with legit text following.
gdb_test "p 1234.5+1" " = 1235.5" "check fp + text"
@@ -38,12 +40,21 @@ proc test_float_accepted {} {
gdb_test "p 1.5f" " = 1.5"
gdb_test "p 1.l" " = 1"
gdb_test "p 1.5l" " = 1.5"
+
+ # Test hexadecimal floating point.
+ set test "p 0x1.1"
+ gdb_test_multiple $test $test {
+ -re " = 1\\.0625\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "Invalid number \"0x1\\.1\"\\.\r\n$gdb_prompt $" {
+ # Older glibc does not support hex float, newer does.
+ xfail $test
+ }
+ }
}
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"
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch] Fix new FAIL `reject p 0x1.1' [fixup]
2010-09-02 15:11 ` Jan Kratochvil
@ 2010-09-06 22:29 ` Jan Kratochvil
0 siblings, 0 replies; 15+ messages in thread
From: Jan Kratochvil @ 2010-09-06 22:29 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
On Thu, 02 Sep 2010 16:20:48 +0200, Jan Kratochvil wrote:
> I will check it in later if not replied.
Checked-in:
http://sourceware.org/ml/gdb-cvs/2010-09/msg00048.html
Thanks,
Jan
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2010-09-06 15:49 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-17 0:31 [patch] Handle 0 result from sscanf when parsing fp values Doug Evans
2010-08-17 8:18 ` Andreas Schwab
2010-08-17 11:37 ` Doug Evans
2010-08-18 20:38 ` Doug Evans
2010-08-20 7:34 ` [patch] Fix new FAIL `reject p 0x1.1' [Re: [patch] Handle 0 result from sscanf when parsing fp values.] Jan Kratochvil
2010-08-20 7:37 ` [patch] Fix new FAIL `reject p 0x1.1' [fixup] " Jan Kratochvil
2010-08-20 11:58 ` Joseph S. Myers
2010-08-23 15:35 ` Doug Evans
2010-08-23 18:55 ` [patch] Fix new FAIL `reject p 0x1.1' [fixup] Jan Kratochvil
2010-08-23 19:49 ` Doug Evans
2010-08-23 19:57 ` Doug Evans
2010-08-31 19:38 ` Jan Kratochvil
2010-08-31 22:51 ` Doug Evans
2010-09-02 15:11 ` Jan Kratochvil
2010-09-06 22:29 ` Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).