Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [BUG] Parser error for "pointer to a function pointer"
@ 2011-09-04  9:22 Abhijit Halder
  2011-09-04 10:43 ` Abhijit Halder
  0 siblings, 1 reply; 5+ messages in thread
From: Abhijit Halder @ 2011-09-04  9:22 UTC (permalink / raw)
  To: gdb-patches

Hello everybody,

While working with gdb I have encountered the following problem.

GNU gdb (GDB) 7.3.50.20110814-cvs
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) ptype int(**)(void)
A syntax error in expression, near `*)(void)'.


I have made the following changes to fix this issue.


--- src/gdb/c-exp.y	2011-05-06 19:42:17.000000000 +0530
+++ dst/gdb/c-exp.y	2011-09-04 13:57:16.082207664 +0530
@@ -19,7 +19,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

 /* Parse a C expression from text in a string,
-   and return the result as a  struct expression  pointer.
+   and return the result as a  struct expression pointer.
    That structure contains arithmetic operations in reverse polish,
    with constants represented by operations that are followed by special data.
    See expression.h for the details of the format.
@@ -926,12 +926,12 @@ const_or_volatile_or_space_identifier:

 abs_decl:	'*'
 			{ push_type (tp_pointer); $$ = 0; }
-	|	'*' abs_decl
-			{ push_type (tp_pointer); $$ = $2; }
+	|	abs_decl '*'
+			{ push_type (tp_pointer); $$ = $1; }
 	|	'&'
 			{ push_type (tp_reference); $$ = 0; }
-	|	'&' abs_decl
-			{ push_type (tp_reference); $$ = $2; }
+	|	abs_decl '&'
+			{ push_type (tp_reference); $$ = $1; }
 	|	direct_abs_decl
 	;

Thanks,
Abhijit Halder


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] Parser error for "pointer to a function pointer"
  2011-09-04  9:22 [BUG] Parser error for "pointer to a function pointer" Abhijit Halder
@ 2011-09-04 10:43 ` Abhijit Halder
  2011-09-04 10:47   ` Abhijit Halder
  0 siblings, 1 reply; 5+ messages in thread
From: Abhijit Halder @ 2011-09-04 10:43 UTC (permalink / raw)
  To: gdb-patches

On Sun, Sep 4, 2011 at 2:08 PM, Abhijit Halder
<abhijit.k.halder@gmail.com> wrote:
> Hello everybody,
>
> While working with gdb I have encountered the following problem.
>
> GNU gdb (GDB) 7.3.50.20110814-cvs
> Copyright (C) 2011 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "i686-pc-linux-gnu".
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>.
> (gdb) ptype int(**)(void)
> A syntax error in expression, near `*)(void)'.
>
>
> I have made the following changes to fix this issue.
>
>
> --- src/gdb/c-exp.y     2011-05-06 19:42:17.000000000 +0530
> +++ dst/gdb/c-exp.y     2011-09-04 13:57:16.082207664 +0530
> @@ -19,7 +19,7 @@
>    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
>
>  /* Parse a C expression from text in a string,
> -   and return the result as a  struct expression  pointer.
> +   and return the result as a  struct expression pointer.
>    That structure contains arithmetic operations in reverse polish,
>    with constants represented by operations that are followed by special data.
>    See expression.h for the details of the format.
> @@ -926,12 +926,12 @@ const_or_volatile_or_space_identifier:
>
>  abs_decl:      '*'
>                        { push_type (tp_pointer); $$ = 0; }
> -       |       '*' abs_decl
> -                       { push_type (tp_pointer); $$ = $2; }
> +       |       abs_decl '*'
> +                       { push_type (tp_pointer); $$ = $1; }
>        |       '&'
>                        { push_type (tp_reference); $$ = 0; }
> -       |       '&' abs_decl
> -                       { push_type (tp_reference); $$ = $2; }
> +       |       abs_decl '&'
> +                       { push_type (tp_reference); $$ = $1; }
>        |       direct_abs_decl
>        ;
>
> Thanks,
> Abhijit Halder
>

A regression happens with the above fix.
The above fix is not working for the following:
(gdb)ptype int (*(**(*)(char))(short int))(long int

The following is working fine.

--- src/gdb/c-exp.y	2011-05-06 19:42:17.000000000 +0530
+++ dst/gdb/c-exp.y	2011-09-04 15:57:51.212167205 +0530
@@ -926,6 +926,8 @@ const_or_volatile_or_space_identifier:

 abs_decl:	'*'
 			{ push_type (tp_pointer); $$ = 0; }
+	|	abs_decl '*'
+			{ push_type (tp_pointer); $$ = $1; }
 	|	'*' abs_decl
 			{ push_type (tp_pointer); $$ = $2; }
 	|	'&'



Thanks,
Abhijit Halder


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] Parser error for "pointer to a function pointer"
  2011-09-04 10:43 ` Abhijit Halder
@ 2011-09-04 10:47   ` Abhijit Halder
  2011-09-04 13:54     ` Abhijit Halder
  0 siblings, 1 reply; 5+ messages in thread
From: Abhijit Halder @ 2011-09-04 10:47 UTC (permalink / raw)
  To: gdb-patches

On Sun, Sep 4, 2011 at 4:07 PM, Abhijit Halder
<abhijit.k.halder@gmail.com> wrote:
> On Sun, Sep 4, 2011 at 2:08 PM, Abhijit Halder
> <abhijit.k.halder@gmail.com> wrote:
>> Hello everybody,
>>
>> While working with gdb I have encountered the following problem.
>>
>> GNU gdb (GDB) 7.3.50.20110814-cvs
>> Copyright (C) 2011 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "i686-pc-linux-gnu".
>> For bug reporting instructions, please see:
>> <http://www.gnu.org/software/gdb/bugs/>.
>> (gdb) ptype int(**)(void)
>> A syntax error in expression, near `*)(void)'.
>>
>>
>> I have made the following changes to fix this issue.
>>
>>
>> --- src/gdb/c-exp.y     2011-05-06 19:42:17.000000000 +0530
>> +++ dst/gdb/c-exp.y     2011-09-04 13:57:16.082207664 +0530
>> @@ -19,7 +19,7 @@
>>    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
>>
>>  /* Parse a C expression from text in a string,
>> -   and return the result as a  struct expression  pointer.
>> +   and return the result as a  struct expression pointer.
>>    That structure contains arithmetic operations in reverse polish,
>>    with constants represented by operations that are followed by special data.
>>    See expression.h for the details of the format.
>> @@ -926,12 +926,12 @@ const_or_volatile_or_space_identifier:
>>
>>  abs_decl:      '*'
>>                        { push_type (tp_pointer); $$ = 0; }
>> -       |       '*' abs_decl
>> -                       { push_type (tp_pointer); $$ = $2; }
>> +       |       abs_decl '*'
>> +                       { push_type (tp_pointer); $$ = $1; }
>>        |       '&'
>>                        { push_type (tp_reference); $$ = 0; }
>> -       |       '&' abs_decl
>> -                       { push_type (tp_reference); $$ = $2; }
>> +       |       abs_decl '&'
>> +                       { push_type (tp_reference); $$ = $1; }
>>        |       direct_abs_decl
>>        ;
>>
>> Thanks,
>> Abhijit Halder
>>
>
> A regression happens with the above fix.
> The above fix is not working for the following:
> (gdb)ptype int (*(*(*)(char))(short int))(long int
                          ^^^
>
> The following is working fine.
>
> --- src/gdb/c-exp.y     2011-05-06 19:42:17.000000000 +0530
> +++ dst/gdb/c-exp.y     2011-09-04 15:57:51.212167205 +0530
> @@ -926,6 +926,8 @@ const_or_volatile_or_space_identifier:
>
>  abs_decl:      '*'
>                        { push_type (tp_pointer); $$ = 0; }
> +       |       abs_decl '*'
> +                       { push_type (tp_pointer); $$ = $1; }
>        |       '*' abs_decl
>                        { push_type (tp_pointer); $$ = $2; }
>        |       '&'
>
>
>
> Thanks,
> Abhijit Halder
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] Parser error for "pointer to a function pointer"
  2011-09-04 10:47   ` Abhijit Halder
@ 2011-09-04 13:54     ` Abhijit Halder
  2011-09-04 14:52       ` Jan Kratochvil
  0 siblings, 1 reply; 5+ messages in thread
From: Abhijit Halder @ 2011-09-04 13:54 UTC (permalink / raw)
  To: gdb-patches

On Sun, Sep 4, 2011 at 4:13 PM, Abhijit Halder
<abhijit.k.halder@gmail.com> wrote:
> On Sun, Sep 4, 2011 at 4:07 PM, Abhijit Halder
> <abhijit.k.halder@gmail.com> wrote:
>> On Sun, Sep 4, 2011 at 2:08 PM, Abhijit Halder
>> <abhijit.k.halder@gmail.com> wrote:
>>> Hello everybody,
>>>
>>> While working with gdb I have encountered the following problem.
>>>
>>> GNU gdb (GDB) 7.3.50.20110814-cvs
>>> Copyright (C) 2011 Free Software Foundation, Inc.
>>> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>>> This is free software: you are free to change and redistribute it.
>>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>>> and "show warranty" for details.
>>> This GDB was configured as "i686-pc-linux-gnu".
>>> For bug reporting instructions, please see:
>>> <http://www.gnu.org/software/gdb/bugs/>.
>>> (gdb) ptype int(**)(void)
>>> A syntax error in expression, near `*)(void)'.
>>>
>>>
>>> I have made the following changes to fix this issue.
>>>
>>>
>>> --- src/gdb/c-exp.y     2011-05-06 19:42:17.000000000 +0530
>>> +++ dst/gdb/c-exp.y     2011-09-04 13:57:16.082207664 +0530
>>> @@ -19,7 +19,7 @@
>>>    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
>>>
>>>  /* Parse a C expression from text in a string,
>>> -   and return the result as a  struct expression  pointer.
>>> +   and return the result as a  struct expression pointer.
>>>    That structure contains arithmetic operations in reverse polish,
>>>    with constants represented by operations that are followed by special data.
>>>    See expression.h for the details of the format.
>>> @@ -926,12 +926,12 @@ const_or_volatile_or_space_identifier:
>>>
>>>  abs_decl:      '*'
>>>                        { push_type (tp_pointer); $$ = 0; }
>>> -       |       '*' abs_decl
>>> -                       { push_type (tp_pointer); $$ = $2; }
>>> +       |       abs_decl '*'
>>> +                       { push_type (tp_pointer); $$ = $1; }
>>>        |       '&'
>>>                        { push_type (tp_reference); $$ = 0; }
>>> -       |       '&' abs_decl
>>> -                       { push_type (tp_reference); $$ = $2; }
>>> +       |       abs_decl '&'
>>> +                       { push_type (tp_reference); $$ = $1; }
>>>        |       direct_abs_decl
>>>        ;
>>>
>>> Thanks,
>>> Abhijit Halder
>>>
>>
>> A regression happens with the above fix.
>> The above fix is not working for the following:
>> (gdb)ptype int (*(*(*)(char))(short int))(long int
>                          ^^^
Oopps!!! Sorry for the typo again.
The regression happened for (gdb)ptype int (*(*(*)(char))(short int))(long int)
But once again the following still throws error (gdb)ptype int
(*(**(*)(char))(short int))(long int)
>>
>> The following is working fine.
>>
>> --- src/gdb/c-exp.y     2011-05-06 19:42:17.000000000 +0530
>> +++ dst/gdb/c-exp.y     2011-09-04 15:57:51.212167205 +0530
>> @@ -926,6 +926,8 @@ const_or_volatile_or_space_identifier:
>>
>>  abs_decl:      '*'
>>                        { push_type (tp_pointer); $$ = 0; }
>> +       |       abs_decl '*'
>> +                       { push_type (tp_pointer); $$ = $1; }
>>        |       '*' abs_decl
>>                        { push_type (tp_pointer); $$ = $2; }
>>        |       '&'
>>
>>
>>
>> Thanks,
>> Abhijit Halder
>>
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] Parser error for "pointer to a function pointer"
  2011-09-04 13:54     ` Abhijit Halder
@ 2011-09-04 14:52       ` Jan Kratochvil
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Kratochvil @ 2011-09-04 14:52 UTC (permalink / raw)
  To: Abhijit Halder; +Cc: gdb-patches, Keith Seitz

On Sun, 04 Sep 2011 12:47:13 +0200, Abhijit Halder wrote:
> The regression happened for (gdb)ptype int (*(*(*)(char))(short int))(long int)
> But once again the following still throws error (gdb)ptype int
> (*(**(*)(char))(short int))(long int)

There are some known Bugs in it, Keith Seitz had some fixes but IMO never
prepared to be posted.

Definitely there should be testcases, both for the cases you have fixed and
for the cases you found to be regressing (as they probably weren't caught by
the testsuite I guess).


Thanks,
Jan


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-09-04 14:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-04  9:22 [BUG] Parser error for "pointer to a function pointer" Abhijit Halder
2011-09-04 10:43 ` Abhijit Halder
2011-09-04 10:47   ` Abhijit Halder
2011-09-04 13:54     ` Abhijit Halder
2011-09-04 14:52       ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox