This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] Make test-cp-name-parser usable
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 2 Aug 2011 19:01:52 +0200
- Subject: [patch] Make test-cp-name-parser usable
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