Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Make test-cp-name-parser usable
@ 2011-08-02 17:02 Jan Kratochvil
  2011-08-03 20:37 ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kratochvil @ 2011-08-02 17:02 UTC (permalink / raw)
  To: gdb-patches

Hi,

I found during `make test-cp-name-parser' a dead-loop

#0  0x00000000004065ef in xfree (ptr=0x623a40) at cp-name-parser.y:2108
#1  0x00000000004065f4 in xfree (ptr=0x623a40) at cp-name-parser.y:2108
#2  0x00000000004065f4 in xfree (ptr=0x623a40) at cp-name-parser.y:2108

I do not see how easily enough to fix it and I do not think a small memory
leak matters for a test program.

And also a bit misleading that parsing errors were not indicated.
That commented string was already there during initial check-in.


Thanks,
Jan


gdb/
2011-08-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* cp-name-parser.y (xfree): Remove the call of free.
	(main): Uncomment "Demangling error\n".

--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -2036,13 +2036,12 @@ trim_chars (char *lexptr, char **extra_chars)
 }
 
 /* When this file is built as a standalone program, xmalloc comes from
-   libiberty --- in which case we have to provide xfree ourselves.  */
+   libiberty --- in which case we have to provide xfree ourselves.
+   A call to free would get translated xfree back again.  Leak is OK.  */
 
 void
 xfree (void *ptr)
 {
-  if (ptr != NULL)
-    free (ptr);
 }
 
 int
@@ -2071,7 +2070,7 @@ main (int argc, char **argv)
 	str2 = cplus_demangle (buf, DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE);
 	if (str2 == NULL)
 	  {
-	    /* printf ("Demangling error\n"); */
+	    printf ("Demangling error\n");
 	    if (c)
 	      printf ("%s%c%s\n", buf, c, extra_chars);
 	    else


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

* Re: [patch] Make test-cp-name-parser usable
  2011-08-02 17:02 [patch] Make test-cp-name-parser usable Jan Kratochvil
@ 2011-08-03 20:37 ` Daniel Jacobowitz
  2011-08-03 20:56   ` Tom Tromey
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2011-08-03 20:37 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

On Tue, Aug 2, 2011 at 1:01 PM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> gdb/
> 2011-08-02  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
>        * cp-name-parser.y (xfree): Remove the call of free.
>        (main): Uncomment "Demangling error\n".

OK.

> --- a/gdb/cp-name-parser.y
> +++ b/gdb/cp-name-parser.y
> @@ -2036,13 +2036,12 @@ trim_chars (char *lexptr, char **extra_chars)
>  }
>
>  /* When this file is built as a standalone program, xmalloc comes from
> -   libiberty --- in which case we have to provide xfree ourselves.  */
> +   libiberty --- in which case we have to provide xfree ourselves.
> +   A call to free would get translated xfree back again.  Leak is OK.  */

"translated back to xfree again"

What does the translation - is it as simple as #undef free or (free) (ptr)?

-- 
Thanks,
Daniel


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

* Re: [patch] Make test-cp-name-parser usable
  2011-08-03 20:37 ` Daniel Jacobowitz
@ 2011-08-03 20:56   ` Tom Tromey
  2011-08-04  9:51     ` Jan Kratochvil
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2011-08-03 20:56 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Jan Kratochvil, gdb-patches

>>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes:

Daniel> "translated back to xfree again"

Daniel> What does the translation - is it as simple as #undef free or
Daniel> (free) (ptr)?

A sed script in the .y.c rule in gdb/Makefile.

Tom


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

* Re: [patch] Make test-cp-name-parser usable
  2011-08-03 20:56   ` Tom Tromey
@ 2011-08-04  9:51     ` Jan Kratochvil
  2011-08-05 20:19       ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kratochvil @ 2011-08-04  9:51 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Daniel Jacobowitz, gdb-patches

On Wed, 03 Aug 2011 22:56:36 +0200, Tom Tromey wrote:
> >>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes:
> Daniel> What does the translation - is it as simple as #undef free or
> Daniel> (free) (ptr)?
> 
> A sed script in the .y.c rule in gdb/Makefile.

	     -e 's/\([ \t;,(]\)free\([ \t]*[&(),]\)/\1xfree\2/g' \
	     -e 's/\([ \t;,(]\)free$$/\1xfree/g' \

If it is a concern patched it differently.

I will check it in if no comments appear.


Thanks,
Jan


gdb/
2011-08-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* cp-name-parser.y (xfree): Wrap the name free by CONCAT2.
	(main): Uncomment "Demangling error\n".

--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -2042,7 +2042,7 @@ void
 xfree (void *ptr)
 {
   if (ptr != NULL)
-    free (ptr);
+    CONCAT2 (fr,ee) (ptr);
 }
 
 int
@@ -2071,7 +2071,7 @@ main (int argc, char **argv)
 	str2 = cplus_demangle (buf, DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE);
 	if (str2 == NULL)
 	  {
-	    /* printf ("Demangling error\n"); */
+	    printf ("Demangling error\n");
 	    if (c)
 	      printf ("%s%c%s\n", buf, c, extra_chars);
 	    else


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

* Re: [patch] Make test-cp-name-parser usable
  2011-08-04  9:51     ` Jan Kratochvil
@ 2011-08-05 20:19       ` Daniel Jacobowitz
  2011-08-06 14:15         ` Jan Kratochvil
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2011-08-05 20:19 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Tom Tromey, gdb-patches

On Thu, Aug 4, 2011 at 5:51 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Wed, 03 Aug 2011 22:56:36 +0200, Tom Tromey wrote:
>> >>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes:
>> Daniel> What does the translation - is it as simple as #undef free or
>> Daniel> (free) (ptr)?
>>
>> A sed script in the .y.c rule in gdb/Makefile.
>
>             -e 's/\([ \t;,(]\)free\([ \t]*[&(),]\)/\1xfree\2/g' \
>             -e 's/\([ \t;,(]\)free$$/\1xfree/g' \

Wow, I'd forgotten about that.

> If it is a concern patched it differently.

Thanks!  I appreciate it.  You might want an explanatory comment, this
looks sufficiently odd.  It's OK with me either way.

-- 
Thanks,
Daniel


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

* Re: [patch] Make test-cp-name-parser usable
  2011-08-05 20:19       ` Daniel Jacobowitz
@ 2011-08-06 14:15         ` Jan Kratochvil
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Kratochvil @ 2011-08-06 14:15 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Tom Tromey, gdb-patches

On Fri, 05 Aug 2011 22:18:50 +0200, Daniel Jacobowitz wrote:
> Thanks!  I appreciate it.  You might want an explanatory comment, this
> looks sufficiently odd.  It's OK with me either way.

Checked in with the comment.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2011-08/msg00036.html

--- src/gdb/ChangeLog	2011/08/05 16:38:34	1.13256
+++ src/gdb/ChangeLog	2011/08/06 14:13:48	1.13257
@@ -1,3 +1,8 @@
+2011-08-06  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* cp-name-parser.y (xfree): Wrap the name free by CONCAT2.
+	(main): Uncomment "Demangling error\n".
+
 2011-08-05  Paul Pluzhnikov  <ppluzhnikov@google.com>
 
 	* solib-target.c (segment_attributes): Make them static.
--- src/gdb/cp-name-parser.y	2011/03/18 13:51:41	1.20
+++ src/gdb/cp-name-parser.y	2011/08/06 14:13:49	1.21
@@ -2042,7 +2042,10 @@
 xfree (void *ptr)
 {
   if (ptr != NULL)
-    free (ptr);
+    {
+      /* Literal `free' would get translated back to xfree again.  */
+      CONCAT2 (fr,ee) (ptr);
+    }
 }
 
 int
@@ -2071,7 +2074,7 @@
 	str2 = cplus_demangle (buf, DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE);
 	if (str2 == NULL)
 	  {
-	    /* printf ("Demangling error\n"); */
+	    printf ("Demangling error\n");
 	    if (c)
 	      printf ("%s%c%s\n", buf, c, extra_chars);
 	    else


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

end of thread, other threads:[~2011-08-06 14:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-02 17:02 [patch] Make test-cp-name-parser usable Jan Kratochvil
2011-08-03 20:37 ` Daniel Jacobowitz
2011-08-03 20:56   ` Tom Tromey
2011-08-04  9:51     ` Jan Kratochvil
2011-08-05 20:19       ` Daniel Jacobowitz
2011-08-06 14:15         ` Jan Kratochvil

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