From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79616 invoked by alias); 19 Aug 2015 08:22:44 -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 79607 invoked by uid 89); 19 Aug 2015 08:22:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f51.google.com Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 19 Aug 2015 08:22:43 +0000 Received: by paccq16 with SMTP id cq16so108912751pac.1 for ; Wed, 19 Aug 2015 01:22:41 -0700 (PDT) X-Received: by 10.66.158.3 with SMTP id wq3mr22400862pab.38.1439972561598; Wed, 19 Aug 2015 01:22:41 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id sp1sm20708914pab.4.2015.08.19.01.22.39 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 19 Aug 2015 01:22:40 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Bail out of processing stop if hook-stop resumes target / changes context References: <1439836415-22008-1-git-send-email-palves@redhat.com> Date: Wed, 19 Aug 2015 08:22:00 -0000 In-Reply-To: <1439836415-22008-1-git-send-email-palves@redhat.com> (Pedro Alves's message of "Mon, 17 Aug 2015 19:33:35 +0100") Message-ID: <86zj1n1ycy.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00501.txt.bz2 Pedro Alves writes: Hi Pedro, > - if (stop_command) > - catch_errors (hook_stop_stub, stop_command, > - "Error while running hook_stop:\n", RETURN_MASK_ALL); > + if (stop_command !=3D NULL) > + { > + struct stop_context *saved_context =3D save_stop_context (); > + struct cleanup *old_chain > + =3D make_cleanup (release_stop_context_cleanup, saved_context); > + > + catch_errors (hook_stop_stub, stop_command, > + "Error while running hook_stop:\n", RETURN_MASK_ALL); > + > + /* If the stop hook resumes the target, then there's no point in > + trying to notify about the previous stop; its context is > + gone. Likewise if the command switches thread or inferior -- > + the observers would print a stop for the wrong > + thread/inferior. */ > + if (stop_context_changed (saved_context)) > + { > + do_cleanups (old_chain); > + return 1; > + } > + do_cleanups (old_chain); > + } I am wondering why don't we let interpreter in async to execute stop_command, and we simply return here. In this way, we don't have to know whether stop_command resumes the target or switches the thread. Once there is no event from event loop, the target really stops and hook-stop is already executed. --=20 Yao (=E9=BD=90=E5=B0=A7)