[PATCH] Fix cleanups
Keith Seitz <[email protected]> Wed, 05 Jun 2013 13:23:13 -0700
| Newsgroups | gmane.comp.debugging.insight |
|---|---|
| Message-ID | <[email protected]> |
Hi, Gdb now asserts on dangling cleanups left in the code, so I've taken the time to audit the gdbtk code to make sure that cleanups are handled correctly. I've committed the attached patch. Keith ChangeLog 2013-06-05 Keith Seitz <[email protected]> * generic/gdbtk.c (tk_command): Use xfree instead of free. * generic/gdbtk-hooks.c (gdbtk_call_command): Remove unused cleanup. * generic/gdbtk-cmds.c (gdb_load_info): If bfd_check_format fails, run the cleanup.
cleanups.patch
(text/x-patch, 2.8 KB)
Index: generic/gdbtk.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -p -r1.53 -r1.54
--- generic/gdbtk.c 30 Mar 2012 07:04:59 -0000 1.53
+++ generic/gdbtk.c 5 Jun 2013 20:19:46 -0000 1.54
@@ -1,5 +1,5 @@
/* Startup code for Insight
- Copyright (C) 1994-2012 Free Software Foundation, Inc.
+ Copyright (C) 1994-2013 Free Software Foundation, Inc.
Written by Stu Grossman <[email protected]> of Cygnus Support.
@@ -739,7 +739,7 @@ tk_command (char *cmd, int from_tty)
result = xstrdup (Tcl_GetStringResult (gdbtk_interp));
- old_chain = make_cleanup (free, result);
+ old_chain = make_cleanup (xfree, result);
if (retval != TCL_OK)
error ("%s", result);
Index: generic/gdbtk-hooks.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-hooks.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -p -r1.58 -r1.59
--- generic/gdbtk-hooks.c 10 Nov 2012 17:49:57 -0000 1.58
+++ generic/gdbtk-hooks.c 5 Jun 2013 20:19:46 -0000 1.59
@@ -1,7 +1,7 @@
/* Startup code for Insight.
Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 200, 2002, 2003, 2004,
- 2008, 2010, 2011, 2012 Free Software Foundation, Inc.
+ 2008, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
Written by Stu Grossman <[email protected]> of Cygnus Support.
@@ -528,9 +528,6 @@ static void
gdbtk_call_command (struct cmd_list_element *cmdblk,
char *arg, int from_tty)
{
- struct cleanup *old_chain;
-
- old_chain = make_cleanup (null_cleanup, 0);
running_now = 0;
if (cmdblk->class == class_run || cmdblk->class == class_trace)
{
@@ -545,8 +542,6 @@ gdbtk_call_command (struct cmd_list_elem
}
else
cmd_func (cmdblk, arg, from_tty);
-
- do_cleanups (old_chain);
}
/* Called after a `set' command succeeds. Runs the Tcl hook
Index: generic/gdbtk-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-cmds.c,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -p -r1.131 -r1.132
--- generic/gdbtk-cmds.c 13 Apr 2013 17:01:11 -0000 1.131
+++ generic/gdbtk-cmds.c 5 Jun 2013 20:19:46 -0000 1.132
@@ -1,5 +1,5 @@
/* Tcl/Tk command definitions for Insight.
- Copyright (C) 1994-2012 Free Software Foundation, Inc.
+ Copyright (C) 1994-2013 Free Software Foundation, Inc.
Written by Stu Grossman <[email protected]> of Cygnus Support.
Substantially augmented by Martin Hunt, Keith Seitz & Jim Ingham of
@@ -969,6 +969,7 @@ gdb_load_info (ClientData clientData, Tc
if (!bfd_check_format (loadfile_bfd, bfd_object))
{
+ do_cleanups (old_cleanups);
gdbtk_set_result (interp, "Bad Object File");
return TCL_ERROR;
}