From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16294 invoked by alias); 5 May 2010 23:08:35 -0000 Received: (qmail 16286 invoked by uid 22791); 5 May 2010 23:08:34 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 May 2010 23:08:30 +0000 Received: (qmail 24923 invoked from network); 5 May 2010 23:08:25 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 5 May 2010 23:08:25 -0000 From: Pedro Alves To: Michael Snyder Subject: Re: [RFA] remote.c, clean-up mix-up Date: Wed, 05 May 2010 23:08:00 -0000 User-Agent: KMail/1.12.2 (Linux/2.6.31-20-generic; KDE/4.3.2; x86_64; ; ) Cc: "gdb-patches@sourceware.org" References: <4BE1F306.8060006@vmware.com> In-Reply-To: <4BE1F306.8060006@vmware.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201005060008.20450.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-05/txt/msg00139.txt.bz2 On Wednesday 05 May 2010 23:36:54, Michael Snyder wrote: > I'm not sure if this clean-up ever happens, because the declaration > merely shadows an outer declaration of the same name, and the > do_cleanups call happens outside the scope of this declaration. It runs when the outer do_cleanups runs. But that's not the point. > > This is my **GUESS** as to what might be intended here. > If anybody has an alternate hypothesis, it's probably > better than mine. A null_cleanup's intention is _always_ to start a new cleanup scope. If the variable is unused, it either means the new cleanup scope wasn't neecessary in the first place, or, there's a do_cleanups call missing for this inner cleanups scope. As I said in the other email, there appears to be a bug here that may hint at what was meant. See the other uses of gdb_xml_create_parser_and_cleanup in the tree: osdata.c: back_to = make_cleanup (null_cleanup, NULL); parser = gdb_xml_create_parser_and_cleanup (_("osdata"), osdata_elements, &data); gdb_xml_use_dtd (parser, "osdata.dtd"); before_deleting_result = make_cleanup (clear_parsing_data, &data); if (gdb_xml_parse (parser, xml) == 0) /* Parsed successfully, don't need to delete the result. */ discard_cleanups (before_deleting_result); do_cleanups (back_to); solib-target.c: back_to = make_cleanup (null_cleanup, NULL); parser = gdb_xml_create_parser_and_cleanup (_("target library list"), library_list_elements, &result); gdb_xml_use_dtd (parser, "library-list.dtd"); before_deleting_result = make_cleanup (solib_target_free_library_list, &result); if (gdb_xml_parse (parser, library) == 0) /* Parsed successfully, don't need to delete the result. */ discard_cleanups (before_deleting_result); do_cleanups (back_to); memory-map.c: back_to = make_cleanup (null_cleanup, NULL); parser = gdb_xml_create_parser_and_cleanup (_("target memory map"), memory_map_elements, &data); /* Note: 'clear_result' will zero 'result'. */ before_deleting_result = make_cleanup (clear_result, &result); data.memory_map = &result; if (gdb_xml_parse (parser, memory_map) == 0) /* Parsed successfully, don't need to delete the result. */ discard_cleanups (before_deleting_result); do_cleanups (back_to); Note how all of them install a cleanup for deleting the result of the parsing, in case parsing fails midway, when pieces of the result had already been allocated. > > remote2.txt > 2010-05-05 Michael Snyder > > * remote.c (remote_threads_info): Remove shadowing declaration. > > Index: remote.c > =================================================================== > RCS file: /cvs/src/src/gdb/remote.c,v > retrieving revision 1.407 > diff -u -p -5 -r1.407 remote.c > --- remote.c 5 May 2010 22:27:15 -0000 1.407 > +++ remote.c 5 May 2010 22:31:28 -0000 > @@ -2510,12 +2510,12 @@ remote_threads_info (struct target_ops * > struct cleanup *back_to = make_cleanup (xfree, xml); > if (xml && *xml) > { > struct gdb_xml_parser *parser; > struct threads_parsing_context context; > - struct cleanup back_to = make_cleanup (null_cleanup, NULL); > > + back_to = make_cleanup (null_cleanup, NULL); > context.items = 0; > parser = gdb_xml_create_parser_and_cleanup (_("threads"), > threads_elements, > &context); > -- Pedro Alves