From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4540 invoked by alias); 3 Mar 2013 23:06:30 -0000 Received: (qmail 4531 invoked by uid 22791); 3 Mar 2013 23:06:30 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 03 Mar 2013 23:06:24 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r23N6KcJ001950 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 3 Mar 2013 18:06:20 -0500 Received: from psique (ovpn-113-39.phx2.redhat.com [10.3.113.39]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r23N6F64012438 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Sun, 3 Mar 2013 18:06:18 -0500 From: Sergio Durigan Junior To: "Pierre Muller" Cc: Subject: Re: [patch] Fix crash in read_pe_exported_syms References: <20130302110216.GA6765@calimero.vinschen.de> <00e101ce175a$f921f210$eb65d630$@muller@ics-cnrs.unistra.fr> X-URL: http://www.redhat.com Date: Sun, 03 Mar 2013 23:06:00 -0000 In-Reply-To: <00e101ce175a$f921f210$eb65d630$@muller@ics-cnrs.unistra.fr> (Pierre Muller's message of "Sat, 2 Mar 2013 16:31:11 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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: 2013-03/txt/msg00075.txt.bz2 Hi Pierre, On Saturday, March 02 2013, Pierre Muller wrote: > I still didn't really get a fully correct picture of the correct way to handle > the cleanups, but I think that your analysis is correct and that this patch should > be approved by a global maintainer. Not sure if you meant that you want to understand how cleanups work, but anyway... Think of cleanups as a stack. When you call `make_cleanup', you are asking for a new operation to be put in the stack, and you receive the pointer to the last operation in that stack (before yours, which becomes the new head). When you call `do_cleanups', you are telling GDB to iterate over the stack in reverse and execute each operation until the one you provide as the argument of the function. `discard_cleanups' does a similar job, but instead of executing each operation, it discards them. When you know that you will have many cleanups and don't want to keep track of each one individually, you can use the same trick as `read_pe_exported_syms': you register a dummy cleanup (null_cleanup, which does nothing) and then start calling `make_cleanup' without caring about its return value. Then, when the time comes (e.g., you are about to return from the function), you can either call `do_cleanups' or `discard_cleanups' using as the argument the one you received in the first call to `make_cleanup' with a dummy cleanup, and you'll be sure that all the cleanup chain will be executed or discarded up to the point where you started your function. Sorry if you already knew all that and I misunderstood your question :-). > PS: It would also be better that this goes in before branching 7.6! I agree. -- Sergio