From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32207 invoked by alias); 28 Oct 2013 03:43:21 -0000 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 Received: (qmail 32194 invoked by uid 89); 28 Oct 2013 03:43:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 28 Oct 2013 03:43:18 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 30FDD116544; Sun, 27 Oct 2013 23:43:43 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id owvB0SnHoRoE; Sun, 27 Oct 2013 23:43:43 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id C81581162E1; Sun, 27 Oct 2013 23:43:42 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id EF29EE128D; Mon, 28 Oct 2013 07:43:12 +0400 (RET) Date: Mon, 28 Oct 2013 03:43:00 -0000 From: Joel Brobecker To: Yao Qi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Fix ada inferior-data cleanup Message-ID: <20131028034312.GA3066@adacore.com> References: <1382759789-777-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1382759789-777-1-git-send-email-yao@codesourcery.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2013-10/txt/msg00845.txt.bz2 > 'struct ada_inferior_data' is registered to per-inferior-data with > cleanup ada_inferior_data_cleanup, which means the data will be > destroyed when the inferior exits. It is unnecessary to call > observer_attach_inferior_exit to do cleanups again. Can you explain where the data actually gets destroyed? I've been going through the code, and I just can't find where this would be happening. Adding a debug trace confirms that the cleanup routine never gets called if you remeove the inferior-exit observer. > Regression tested by "make check RUNTESTFLAGS='--directory=gdb.ada'" > on x86 Fedora 16 linux. > > gdb: > > 2013-10-26 Yao Qi > > * ada-lang.c (ada_inferior_data_cleanup): Don't get data from > inferior_data. Don't check NULL. Free 'arg'. > (ada_inferior_exit): Remove. > (_initialize_ada_language): Don't call > observer_attach_inferior_exit. > --- > gdb/ada-lang.c | 17 +---------------- > 1 files changed, 1 insertions(+), 16 deletions(-) > > diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c > index 75f9fe8..600f835 100644 > --- a/gdb/ada-lang.c > +++ b/gdb/ada-lang.c > @@ -336,11 +336,7 @@ static const struct inferior_data *ada_inferior_data; > static void > ada_inferior_data_cleanup (struct inferior *inf, void *arg) > { > - struct ada_inferior_data *data; > - > - data = inferior_data (inf, ada_inferior_data); > - if (data != NULL) > - xfree (data); > + xfree (arg); > } > > /* Return our inferior data for the given inferior (INF). > @@ -366,16 +362,6 @@ get_ada_inferior_data (struct inferior *inf) > return data; > } > > -/* Perform all necessary cleanups regarding our module's inferior data > - that is required after the inferior INF just exited. */ > - > -static void > -ada_inferior_exit (struct inferior *inf) > -{ > - ada_inferior_data_cleanup (inf, NULL); > - set_inferior_data (inf, ada_inferior_data, NULL); > -} > - > /* Utilities */ > > /* If TYPE is a TYPE_CODE_TYPEDEF type, return the target type after > @@ -12958,7 +12944,6 @@ With an argument, catch only exceptions with the given name."), > NULL, xcalloc, xfree); > > /* Setup per-inferior data. */ > - observer_attach_inferior_exit (ada_inferior_exit); > ada_inferior_data > = register_inferior_data_with_cleanup (NULL, ada_inferior_data_cleanup); > } > -- > 1.7.7.6 -- Joel