From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30600 invoked by alias); 16 Jan 2017 17:28:22 -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 30560 invoked by uid 89); 16 Jan 2017 17:28:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=sk:remove_, resumed, resume, delaying X-HELO: sesbmg23.ericsson.net Received: from sesbmg23.ericsson.net (HELO sesbmg23.ericsson.net) (193.180.251.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Jan 2017 17:28:07 +0000 Received: from ESESSHC002.ericsson.se (Unknown_Domain [153.88.183.24]) by (Symantec Mail Security) with SMTP id 7D.3D.12009.4A20D785; Mon, 16 Jan 2017 18:28:05 +0100 (CET) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.24) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 16 Jan 2017 18:27:50 +0100 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=antoine.tremblay@ericsson.com; Received: from elxa4wqvvz1 (192.75.88.130) by DB6PR0701MB1880.eurprd07.prod.outlook.com (10.168.10.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.6; Mon, 16 Jan 2017 17:26:59 +0000 References: <20161129120702.9490-1-antoine.tremblay@ericsson.com> User-agent: mu4e 0.9.19; emacs 25.1.1 From: Antoine Tremblay To: Yao Qi CC: Subject: Re: [PATCH 1/2] This patch fixes GDBServer's run control for single stepping In-Reply-To: <20161129120702.9490-1-antoine.tremblay@ericsson.com> Date: Mon, 16 Jan 2017 17:28:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: BN6PR17CA0033.namprd17.prod.outlook.com (10.175.189.19) To DB6PR0701MB1880.eurprd07.prod.outlook.com (10.168.10.152) X-MS-Office365-Filtering-Correlation-Id: 519be1ea-cd16-47f7-1d8e-08d43e34e0c0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DB6PR0701MB1880; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0701MB1880;3:iAsr2iZusRcqecohLPea8/VRHi/5cLco4huSGVucG/wrWvVsK4A8Nn3nmjY7vccM4BzWgI63syJMA2oh3zyO9TK/awNyFZd/vclfqdxUADH/mmjZbRjl+Nyj8oQxAF37SLlLuYQ3aJN3P/NSns+aZ2mKjHgpoHk9WCTHes9GqOcaj8EnKjlN5C3/dBGGJyhLxaZtd6KcbOsQwlI2sgdcLf8Asrxt/M/LBykZpDhZkeUb+N3Bfk4fLyLbsfnGo5jBRMdebNb7YIQXxmQh+JJnSw== X-Microsoft-Exchange-Diagnostics: 1;DB6PR0701MB1880;25:J0FngQJ/6Nas0ByI+cu1R+C1QcW9/4ASW/7dcxvyW1DdoxuacCLv8oNWyRoNHp8lSeA2AINI/Yv22fCOPGhbGiAZNrdYEBXJQNEinkroyD5Vq5TorFPwRt2ayDrd/qmi6gFCBy9sFFp0y/1tFei/RFjYBw5zgRl7V6EPWynkoWDAlXkxlEV51wcSlBRCzgiVFyejRMSfvCuapnbkOfVVi0mq+L/ofb6YOB31wetOVneTmAbSLAYEwsDNVCCx5tYGuzc3kMHmG1OHSPfaxdqVb15NB2Hng70/Rc5whTvyG/tTOfMIrM+dWpMCAtV9iXHxQ2hj1vMz1xfRCMk2a1Q/bfJUQisf0fd7Fi71RgakNlZIvc3AxgE6Cv9Sv+wfG2vDSD/bLovLsOYML6iV2pnMM1BHO0njlzh0Vs/TiVPwY0MkXEX3s93mu3cIzPMrUtk4SZYJHcjyf0KQxC9l55L0wPgij+NNL+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S8/v1U4gJ0fxD6PjTh+pe7KyzTGDpe0Mj3x8yBUJHS22grEfsPOeWZHNjz/BF0hcQH7jsjGy/sqniaMKBIdLcFs/7OaSJ1kej1qcglv9uVqvgrFInSKfZNRj4FkoY2bJ3WsdMpWS1WovP3W3e6DddQJ1JTIfu96W0Y3ey5qB0876zG5yLzrZH7n X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(211171220733660); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148);SRVR:DB6PR0701MB1880;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0701MB1880; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0701MB1880;4:EZIOpnt4bcT6h/JPrDCR7FrDbqtlu/MuM3KI67DrGHRi2KPImcNYHNl9TVJXWPMeseWUy+HCxEBv7NYzt4O3uAWeB+BGd4dzo+s/RkNIKTXYrLbIGmrm2pbl16FVxjUVstQJyEaGkVtujrs8J08L6NnZMxcstWzsbajz5vJwKOgKuPuOYeNnpFbPpWZqOUt8BrXV3pno+crlDbe3XlScn5GHgdY+5EGPoxBbIy165UVnN1M+Bi2zTm0Qt8VcBspo2zNNi3C/Kgb5zHdOYnZ2SFy0HpqH7rm7ajF1DOoIjXnkWp2f8oOm1tyDzJlAx0dIWx3ZzbdGWeVjZbtSFQyW2W0k8y+lMuC6hTDEdqvQU279P04xeBq50ukrI0i3NqxnVbN1B+bnmqL2YoEAhVRc7ZBcLul95O2Yn1vDFc7pMzq2sTKcl3HrbUxpf7xbgzyONl2nDWLBwwW5QPcaq98u7DCbl7PjKJ6r92SDiUZjWdCycjKX34Se/Jb+KwxA6uMUcOyGTnpvp5I0lHCBJ/OVlz3iPMcocolL3IBX5+3K4eON5j9YNNrSBbWrAYuGXYY9u5y9rWcD4w2dbOPxHNaT2jbmh6xWaMpSd4c65JyNa4riyVENGXqmX5tgK7M38Ffk X-Forefront-PRVS: 01894AD3B8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(199003)(51444003)(54534003)(189002)(50986999)(7736002)(106356001)(66066001)(305945005)(92566002)(27001)(5003940100001)(48376002)(105586002)(86362001)(101416001)(4326007)(54356999)(76176999)(36756003)(2906002)(3846002)(6116002)(110136003)(189998001)(6666003)(2950100002)(25786008)(8676002)(81156014)(6306002)(83506001)(1411001)(50466002)(42186005)(33646002)(81166006)(47776003)(38730400001)(97736004)(6916009)(39060400001)(4001350100001)(229853002)(6496003)(5660300001)(68736007)(6486002)(4226002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0701MB1880;H:elxa4wqvvz1;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DB6PR0701MB1880;23:bVZIDSKCaANnsQ2s7UuBXoADhQuki7K6eZJ2+3S?= =?us-ascii?Q?UCYVCpWg6ucw7tnAeDbYZAgZCeCtgH/eUSW51RhTUYktBPIpK1w/Bm2jth52?= =?us-ascii?Q?Qfgi68H9PCHFaLQCKY6Q5ptjxz6xeEN0V3OIqZhSHC2SNCL3vYAT0/yT1cZZ?= =?us-ascii?Q?/jOOM3EHaS4X75oSGzM1JhPz8t0ODd/jNI+DVVtznVIfVHonucdWvzp6ks/R?= =?us-ascii?Q?1UrqNrbfj4Ti3IxVnsVBk5ODx1xFyjMWZNjVgJpXvXdMzbAdubj6lpoP01gh?= =?us-ascii?Q?OdvMtfIKpdtCv0lxi4I7CNzH/U6boG+jXAcVWlzHXNhFiqqGPNP6s7R/yOiT?= =?us-ascii?Q?NigdW+rwW5lXOzHhXntj8aDqxJqWuQwhjZKRl/aK4VRc6nWC8uhM98q8lQPl?= =?us-ascii?Q?v7BUwRacpPfNLDpUOX0ykHEK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uvri3JmozWS1aPPfyCphLfAgkSUfCmctH7Q3bNIUg1YERGYat3UdL2R+50eAIA8gj5jZey/atnRzZ5cQBrKmdaj/3tLqwQFigAVqBUnClgG6JSKPmmRkKO4Ic9REYXRjB65ORPIs3+9kD8lCUBTepe66Hh+O6EGj1rT67CNxawnC3LvRv81gOqCmG16ILpm0gcKlcWh5Cdb9qgSgmgGSQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2017 17:26:59.0596 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0701MB1880 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg00302.txt.bz2 Ping. Antoine Tremblay writes: > ** Note these patches depend on: > https://sourceware.org/ml/gdb-patches/2016-11/msg00914.html > > Before, installing single-step breakpoints was done in proceed_one_lwp as > each thread was started. > > This caused a problem on ARM, which is the only architecture using > software single-step on which it is not safe to modify an instruction > to insert a breakpoint in one thread while the other threads are running. > See the architecture manual section "A3.5.4 Concurrent modification and > execution of instructions": > > "The ARMv7 architecture limits the set of instructions that can be > executed by one thread of execution as they are being modified by another > thread of execution without requiring explicit synchronization. Except > for the instructions identified in this section, the effect of the > concurrent modification and execution of an instruction is UNPREDICTABLE > ." > > Since we want the single-step logic to work for any instruction GDBServer > needs to stop all the threads to install a single-step breakpoint. > > Note that we could introduce arch specific code to check if we can do it > for each particular instruction but I think that introducing 2 run control > paths for single stepping would just add too much complexity to the code > for little benefit. > > This patch fixes the intermittent FAILs for gdb.threads/schedlock.exp on > ARM like discussed here: > https://sourceware.org/ml/gdb-patches/2016-11/msg00132.html > Tested with RACY_ITER=100 on two different boards, -marm/-thumb. > > Note that the FAILs in non-stop-fair-events.exp discussed in that thread > will be fixed in an upcoming patch. They are not caused by what this patch > fixes. > > Here's a few implementation details notes: > > Before in all-stop mode, GDBServer deleted all single-step breakpoints > when reporting an event since it assumed that this canceled all previous > resume requests. > > However, this is not true as GDBServer may hit a breakpoint instruction > written directly in memory so not a GDB breakpoint nor a GDBServer > breakpoint like is the case with displaced-stepping on. > > Considering this, this patch only deletes the current thread single-step > breakpoint even in all-stop mode. > > Also with this patch, single-step breakpoints inserted in proceed_all_lwp > are inserted before GDBServer checks if it needs to step-over. > > This is done in preparation for a patch that allows GDBServer to delay a > step-over. In which case single-step breakpoints need to be inserted > before trying to step-over. > > It may also be more clear that GDBServer always insert single-step > breakpoints when calling proceed_all_lwps rather than delaying this > insertion until a step-over is done. > > No regressions, tested on ubuntu 14.04 ARMv7. > With gdbserver-native/-m{arm,thumb} > > gdb/gdbserver/ChangeLog: > > * linux-low.c (linux_wait_1): Don't remove all single-step > breakpoints in all-stop. > (install_all_software_single_step_breakpoints): New function. > (linux_resume): Install software single-step breakpoints if needed. > (proceed_one_lwp): Don't install software single-step here. > (proceed_all_lwps): Install software single-step breakpoints if needed. > --- > gdb/gdbserver/linux-low.c | 145 ++++++++++++++++++++++++++-------------------- > 1 file changed, 81 insertions(+), 64 deletions(-) > > diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c > index b441ebc..15fb726 100644 > --- a/gdb/gdbserver/linux-low.c > +++ b/gdb/gdbserver/linux-low.c > @@ -3747,64 +3747,14 @@ linux_wait_1 (ptid_t ptid, > > /* Alright, we're going to report a stop. */ > > - /* Remove single-step breakpoints. */ > - if (can_software_single_step ()) > + if (can_software_single_step () > + && has_single_step_breakpoints (current_thread)) > { > - /* Remove single-step breakpoints or not. It it is true, stop all > - lwps, so that other threads won't hit the breakpoint in the > - staled memory. */ > - int remove_single_step_breakpoints_p = 0; > - > - if (non_stop) > - { > - remove_single_step_breakpoints_p > - = has_single_step_breakpoints (current_thread); > - } > - else > - { > - /* In all-stop, a stop reply cancels all previous resume > - requests. Delete all single-step breakpoints. */ > - struct inferior_list_entry *inf, *tmp; > - > - ALL_INFERIORS (&all_threads, inf, tmp) > - { > - struct thread_info *thread = (struct thread_info *) inf; > - > - if (has_single_step_breakpoints (thread)) > - { > - remove_single_step_breakpoints_p = 1; > - break; > - } > - } > - } > - > - if (remove_single_step_breakpoints_p) > - { > - /* If we remove single-step breakpoints from memory, stop all lwps, > - so that other threads won't hit the breakpoint in the staled > - memory. */ > - stop_all_lwps (0, event_child); > - > - if (non_stop) > - { > - gdb_assert (has_single_step_breakpoints (current_thread)); > - delete_single_step_breakpoints (current_thread); > - } > - else > - { > - struct inferior_list_entry *inf, *tmp; > - > - ALL_INFERIORS (&all_threads, inf, tmp) > - { > - struct thread_info *thread = (struct thread_info *) inf; > - > - if (has_single_step_breakpoints (thread)) > - delete_single_step_breakpoints (thread); > - } > - } > - > - unstop_all_lwps (0, event_child); > - } > + /* If we remove single-step breakpoints from memory, stop all lwps, > + so that other threads won't hit invalid memory. */ > + stop_all_lwps (0, event_child); > + delete_single_step_breakpoints (current_thread); > + unstop_all_lwps (0, event_child); > } > > if (!stabilizing_threads) > @@ -4336,6 +4286,52 @@ install_software_single_step_breakpoints (struct lwp_info *lwp) > do_cleanups (old_chain); > } > > +/* Install breakpoints for software single stepping on all threads. > + Install the breakpoints on a thread only if COND returns true. > + Return true if we stopped the threads while doing so and they need to be > + restarted. > +*/ > + > +static bool > +install_all_software_single_step_breakpoints ( > + bool (*cond) (struct lwp_info *lwp)) > +{ > + struct inferior_list_entry *inf, *tmp; > + bool stopped_threads = false; > + > + ALL_INFERIORS (&all_threads, inf, tmp) > + { > + struct thread_info *thread = (struct thread_info *) inf; > + struct lwp_info *lwp = get_thread_lwp (thread); > + > + if (cond (lwp)) > + { > + if (!stopped_threads) > + { > + /* We need to stop all threads to modify the inferior > + instructions safely. */ > + stop_all_lwps (0, NULL); > + > + if (debug_threads) > + debug_printf ("Done stopping all threads.\n"); > + > + stopped_threads = true; > + } > + > + if (!has_single_step_breakpoints (thread)) > + { > + install_software_single_step_breakpoints (lwp); > + > + if (debug_threads) > + debug_printf ("Insert breakpoint for resume_step LWP %ld\n", > + lwpid_of (thread)); > + } > + } > + } > + > + return stopped_threads; > +} > + > /* Single step via hardware or software single step. > Return 1 if hardware single stepping, 0 if software single stepping > or can't single step. */ > @@ -5178,6 +5174,7 @@ linux_resume (struct thread_resume *resume_info, size_t n) > struct thread_info *need_step_over = NULL; > int any_pending; > int leave_all_stopped; > + bool stopped_threads = false; > > if (debug_threads) > { > @@ -5221,12 +5218,29 @@ linux_resume (struct thread_resume *resume_info, size_t n) > debug_printf ("Resuming, no pending status or step over needed\n"); > } > > + /* If resume_step is requested by GDB, install reinsert breakpoints > + when the thread is about to be actually resumed. IOW, we don't > + insert reinsert breakpoints if any thread has pending status. */ > + if (!leave_all_stopped && can_software_single_step ()) > + { > + stopped_threads = install_all_software_single_step_breakpoints > + ([] (struct lwp_info *lwp) > + { > + return (lwp->resume != NULL && lwp->resume->kind == resume_step); > + }); > + > + if (debug_threads) > + debug_printf ("Handle resume_step. Done\n"); > + } > + > /* Even if we're leaving threads stopped, queue all signals we'd > otherwise deliver. */ > find_inferior (&all_threads, linux_resume_one_thread, &leave_all_stopped); > > if (need_step_over) > start_step_over (get_thread_lwp (need_step_over)); > + else if (stopped_threads) > + unstop_all_lwps (0, NULL); > > if (debug_threads) > { > @@ -5323,13 +5337,6 @@ proceed_one_lwp (struct inferior_list_entry *entry, void *except) > debug_printf (" stepping LWP %ld, client wants it stepping\n", > lwpid_of (thread)); > > - /* If resume_step is requested by GDB, install single-step > - breakpoints when the thread is about to be actually resumed if > - the single-step breakpoints weren't removed. */ > - if (can_software_single_step () > - && !has_single_step_breakpoints (thread)) > - install_software_single_step_breakpoints (lwp); > - > step = maybe_hw_step (thread); > } > else if (lwp->bp_reinsert != 0) > @@ -5370,6 +5377,16 @@ proceed_all_lwps (void) > { > struct thread_info *need_step_over; > > + /* Always install software single step breakpoints if any. */ > + if (can_software_single_step ()) > + { > + install_all_software_single_step_breakpoints > + ([] (struct lwp_info *lwp) > + { > + return (get_lwp_thread (lwp)->last_resume_kind == resume_step); > + }); > + } > + > /* If there is a thread which would otherwise be resumed, which is > stopped at a breakpoint that needs stepping over, then don't > resume any threads - have it step over the breakpoint with all