[PATCH] get_frame_name API update

Keith Seitz <[email protected]> Wed, 05 Jun 2013 13:31:49 -0700
Newsgroups gmane.comp.debugging.insight
Message-ID <[email protected]>
Hi,

A little while ago, I addressed some dangling cleanup issues with 
get_frame_name by tweaking the API -- the return frame name is now 
malloc'd, and it is up to the caller to free the memory. The attached 
patch updates insight.

With this patch, insight can once again be built, but there are still 
problems. The register window is having some crashing issues which I 
have yet to investigate.

Keith

ChangeLog
2013-06-05  Keith Seitz  <[email protected]>

	* generic/gdbtk-stack.c (get_frame_name): Change type of 'funname'
	to char * to follow recent API updates in gdb.
	Free 'funname' after appending it to the list.
	Remove check for NULL funname in a branch where it could only
	ever be NULL.
get_frame_name.patch (text/x-patch, 1 KB)
Index: generic/gdbtk-stack.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-stack.c,v
retrieving revision 1.41
diff -u -p -r1.41 gdbtk-stack.c
--- generic/gdbtk-stack.c	25 May 2012 11:36:08 -0000	1.41
+++ generic/gdbtk-stack.c	5 Jun 2013 19:08:40 -0000
@@ -1,5 +1,5 @@
 /* Tcl/Tk command definitions for Insight - Stack.
-   Copyright (C) 2001-2012 Free Software Foundation, Inc.
+   Copyright (C) 2001-2013 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -524,7 +524,7 @@ static void
 get_frame_name (Tcl_Interp *interp, Tcl_Obj *list, struct frame_info *fi)
 {
   struct symbol *func = NULL;
-  const char *funname = NULL;
+  char *funname = NULL;
   enum language funlang = language_unknown;
   Tcl_Obj *objv[1];
 
@@ -553,6 +553,7 @@ get_frame_name (Tcl_Interp *interp, Tcl_
     {
       objv[0] = Tcl_NewStringObj (funname, -1);
       Tcl_ListObjAppendElement (interp, list, objv[0]);
+      xfree (funname);
     }
   else
     {