From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1455 invoked by alias); 10 Dec 2013 00:57:41 -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 1444 invoked by uid 89); 10 Dec 2013 00:57:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.5 required=5.0 tests=AWL,BAYES_00,GARBLED_BODY autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Dec 2013 00:57:39 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1VqBdb-000261-6b from Yao_Qi@mentor.com ; Mon, 09 Dec 2013 16:57:23 -0800 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 9 Dec 2013 16:57:22 -0800 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Mon, 9 Dec 2013 16:57:22 -0800 Message-ID: <52A6669F.9030100@codesourcery.com> Date: Tue, 10 Dec 2013 00:57:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Pedro Alves CC: Mark Kettenis , Subject: Re: [PATCH 2/3] skip_prolgoue (amd64) References: <1385735051-27558-1-git-send-email-yao@codesourcery.com> <1385735051-27558-3-git-send-email-yao@codesourcery.com> <201311291436.rATEaZ5Z030292@glazunov.sibelius.xs4all.nl> <201311291605.rATG5XVb030184@glazunov.sibelius.xs4all.nl> <52994E79.4000004@codesourcery.com> <5299B9D0.2020304@redhat.com> <529C37A2.9000207@codesourcery.com> <529E9462.9010001@codesourcery.com> <529F1B1F.2040606@redhat.com> <52A426E8.2030808@codesourcery.com> <52A5AF41.6080207@redhat.com> <52A5BF2F.9060708@codesourcery.com> <52A5C202.8010109@redhat.com> <52A5CC0D.4080004@codesourcery.com> <52A5E2EE.5040501@redhat.com> In-Reply-To: <52A5E2EE.5040501@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00356.txt.bz2 On 12/09/2013 11:34 PM, Pedro Alves wrote: >> "wait -> handle event -> wait" is like a loop or circle to me, and we >> >can flush at any point(s) of this circle, depending on what heuristic >> >we are using. > Again, the point is making it so that the cache does not enlarge > the race window with the inferior itself. IOW, make the cache > transparent WRT to chances of seeing a teared value, prologue, or > whatever. Between starting to handle an event and finishing > it, a very short time passes. Between finishing handling an > event and the next event, an unbound amount of time passes. > If we don't flush the cache just before handling the event, > having the cache active has a much much wider race window width > than without the cache active. OK, I am convinced. Here is the patch to flush cache in every "overlay_cache_invalid = 1" place. Beside this, I also invalidate both target cache and overlay cache in infrun_thread_stop_requested_callback, because handle_inferior_event is called in it. -- Yao (齐尧) gdb: 2013-12-10 Yao Qi * infrun.c: Include "target-dcache.h". (prepare_for_detach): Call target_dcache_invalidate. (wait_for_inferior): Likewise. (fetch_inferior_event): Likewise. (infrun_thread_stop_requested_callback): Likewise. Set overlay_cache_invalid to 1. --- gdb/infrun.c | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 3b55583..d8f9787 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -60,6 +60,7 @@ #include "objfiles.h" #include "completer.h" #include "target-descriptions.h" +#include "target-dcache.h" /* Prototypes for local functions */ @@ -2475,6 +2476,13 @@ infrun_thread_stop_requested_callback (struct thread_info *info, void *arg) old_chain = make_cleanup_restore_current_thread (); + overlay_cache_invalid = 1; + /* Flush target cache before starting to handle each event. + Target was running and cache could be stale. This is just a + heuristic. Running threads may modify target memory, but we + don't get any event. */ + target_dcache_invalidate (); + /* Go through handle_inferior_event/normal_stop, so we always have consistent output as if the stop event had been reported. */ @@ -2677,6 +2685,11 @@ prepare_for_detach (void) memset (ecs, 0, sizeof (*ecs)); overlay_cache_invalid = 1; + /* Flush target cache before starting to handle each event. + Target was running and cache could be stale. This is just a + heuristic. Running threads may modify target memory, but we + don't get any event. */ + target_dcache_invalidate (); if (deprecated_target_wait_hook) ecs->ptid = deprecated_target_wait_hook (pid_ptid, &ecs->ws, 0); @@ -2740,6 +2753,12 @@ wait_for_inferior (void) overlay_cache_invalid = 1; + /* Flush target cache before starting to handle each event. + Target was running and cache could be stale. This is just a + heuristic. Running threads may modify target memory, but we + don't get any event. */ + target_dcache_invalidate (); + if (deprecated_target_wait_hook) ecs->ptid = deprecated_target_wait_hook (waiton_ptid, &ecs->ws, 0); else @@ -2805,6 +2824,11 @@ fetch_inferior_event (void *client_data) make_cleanup_restore_current_thread (); overlay_cache_invalid = 1; + /* Flush target cache before starting to handle each event. Target + was running and cache could be stale. This is just a heuristic. + Running threads may modify target memory, but we don't get any + event. */ + target_dcache_invalidate (); make_cleanup_restore_integer (&execution_direction); execution_direction = target_execution_direction (); -- 1.7.7.6