[RFA] dangling cleanup in find_frame_funname

Keith Seitz keiths@redhat.com
Mon May 20 18:40:00 GMT 2013


On 05/20/2013 02:23 AM, Joel Brobecker wrote:
>
> In this case, I am leaning towards using a cleanup, something like this:
>
>    struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
>    while (fi != NULL)
>      {
>        char *func_name;
>        enum language func_lang;
>
>        find_frame_funname (fi, &func_name, &func_lang, NULL);
>        if (func_name != NULL)
>          make_cleanup (xfree, func_name);
>        if (func_name != NULL
>            && strcmp (func_name, data->exception_info->catch_exception_sym) == 0)
>          break; /* We found the frame we were looking for...  */
>        fi = get_prev_frame (fi);
>      }
>    do_cleanups (old_chain);
>
> I find the code a little simpler to maintain that way. WDYT?
>

I'm all for making things easier to maintain! :-)

I've attached a new version of this patch. Look reasonable?

2013-05-20  Keith Seitz  <keiths@redhat.com>

	* ada-lang.c (is_known_support_routine): Add explicit free of
	'func_name' from find_frame_funname.
	(ada_unhandled_exception_name_addr_from_raise): Add cleanups
	for func_name from find_frame_funname.
	* python/py-frame.c (frapy_name): Add explicit free of
	'name' from find_frame_funname.
	* stack.c (find_frame_funname): Add comment explaining that
	funcp must be freed by the caller.
	Return copy of symbol names instead of pointers.
	(print_frame): Add a cleanup for 'funname' from
	find_frame_funname.
	* stack.h (find_frame_funname): Remove "const" from
	'funname' parameter.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: find_frame_funname-dangling-cleanup-2.patch
Type: text/x-patch
Size: 5527 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20130520/ce2c9fe5/attachment.bin>


More information about the Gdb-patches mailing list