From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28917 invoked by alias); 16 Jan 2017 17:27:58 -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 28908 invoked by uid 89); 16 Jan 2017 17:27:57 -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 autolearn=ham version=3.3.2 spammy=Starts, UD:id, Delay, ptid_t X-HELO: sessmg23.ericsson.net Received: from sessmg23.ericsson.net (HELO sessmg23.ericsson.net) (193.180.251.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Jan 2017 17:27:47 +0000 Received: from ESESSHC021.ericsson.se (Unknown_Domain [153.88.183.81]) by (Symantec Mail Security) with SMTP id 3E.14.25710.0920D785; Mon, 16 Jan 2017 18:27:44 +0100 (CET) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.81) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 16 Jan 2017 18:27:31 +0100 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=antoine.tremblay@ericsson.com; Received: from elxa4wqvvz1 (192.75.88.130) by AM5PR0701MB1873.eurprd07.prod.outlook.com (10.167.216.22) 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:27:30 +0000 References: <20161129120702.9490-1-antoine.tremblay@ericsson.com> <20161129120702.9490-2-antoine.tremblay@ericsson.com> User-agent: mu4e 0.9.19; emacs 25.1.1 From: Antoine Tremblay To: Yao Qi CC: Subject: Re: [PATCH 2/2] Avoid step-over infinite loop in GDBServer In-Reply-To: <20161129120702.9490-2-antoine.tremblay@ericsson.com> Date: Mon, 16 Jan 2017 17:27:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: BN6PR03CA0071.namprd03.prod.outlook.com (10.173.137.33) To AM5PR0701MB1873.eurprd07.prod.outlook.com (10.167.216.22) X-MS-Office365-Filtering-Correlation-Id: 40fbddac-4e0d-410a-0521-08d43e34f351 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:AM5PR0701MB1873; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0701MB1873;3:m8pSIRkeSyqRuFw71MDrgB90O1Q/J+6M+x7TxX/QN3P0nIITtmudZCaOjB7+TFP3dwqdmb+yveAPTpFrUQpGZP7sbJ7rT4Pl5x3hf8CQnYMY3qXFEOZNTdL1qtUSq4RWC7srQCBL4nvltSy/MkmHqkAWkragALnNBzlnmpPQO1KccD50M8oSkxiK14v1S8+SM/eOuxpCePoAosl0YLy//cDPHvJL2kbudEUUAg90nx4yZXQy5J9GnJ08hrsWTAnl4WEWBPebJTqhg0bcIVoAQA== X-Microsoft-Exchange-Diagnostics: 1;AM5PR0701MB1873;25:DsCWs4ofaNxl57K6+vEUrVNzp5neF5g8uf7vAGpMFsphUKoJEm56SIIqE9LNjfyqWP2XvuIR+7ZXGh/ceXyUPFPSBtq+FZgQonfE9q3kAJCnShjz4I82yckvipci0hu3zVofDu8Gu3IwgY8bxkf0LjrkPXKaGLdrzAWWlggEUQrkin/i1WfKFF/5QoLgCgQwSgZtUBv4ZnD3xp2zNoD6J+ORX4jfcbHtEYRJ94Do1ptTRfPwvCgwDTJy+5aaeLp5jVp9Dii1RHC888IVL6pmGFFGDx5fo8O1UxI+HoYejx42crBPWY7bkoEnabNbDjKeXnAQmTOe8TRAUGfFWpMxfqbsV2PCqcYt+vIoLVsz81/jlvjZa+oQ6mCyrW7/mNHgLv1WphRUV331atjcbsiD6CtLgR05uwIs0kRU3bOVYRA/tGlhNuEl9WdAtLymnzzl4TpQ1KexCn+mntVQcoljhs5yWKgw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aSClz+Gje9IAg9VSFU6Mnj+zREoMM/SDNq5UlmkgKZwKManAeDQZjUpr/ACdP4Vrt87UFu2bK9d6dmIH0hMkqTBoSqoyhPACfqkQzegGOQxd3Qv3JNlV/7N09r8gJKqShioKWHeCS460hb7a16f8b3P X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; 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:AM5PR0701MB1873;BCL:0;PCL:0;RULEID:;SRVR:AM5PR0701MB1873; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0701MB1873;4:3HmM4DlD3IV+0Ooh+L98J2mlyqEm0CN2ahhHn0Q7aHTAuIpOIUX1kbOU5zuvebXeuAjbcor4k9m7oILK57gPxFw45wDonvEsWoX/1mWOeI8X+MG7EZdgNsdUavlz3hQG8z+WdMtX1S6Vs9qmAkZbWSTgfoHMNsBohd9at8Lj4/5MzdHqVJl0czFieMWnOxyCqXIouV60vzY4blN2Qkxsq02Us9/zbC/t/KnIaSdL6Hmh6ovhW9GSXyPpxuJ66NnwBtjcUbIcpVoZ+VVty6MQC7EpDLmYC7crhvBd3/wt3nh/Ss9kJqhTE/QIpIFkHo/dPVuEYL0A5x53FeARtVQEUj8pq2rfv8G5mI3rgqnPO5x3kC4ST4RDxdG+Xyl+Lztf41ZA0c8PV7k+2tYd0nhQBBgkiugbaW+wXudClhGh+4B32UqdZDmWXx0+MSiFKqwU2dHWEUvYnuDNKzVRmRIfPjvtlbdwengYpeRTEv2yEBFGclQs+AjzLfXLLxbZoLUvKcXoqiRhtzmZtd076OTYwv+WFHSS1JcZC++VV+N6nvlL5P5dnNXUv00nhiZCX4Nwk+mJAmslf2U77ZX7lSSqFQ== X-Forefront-PRVS: 01894AD3B8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(199003)(54534003)(189002)(2950100002)(42186005)(47776003)(6916009)(1411001)(4001350100001)(92566002)(105586002)(6666003)(106356001)(97736004)(38730400001)(39060400001)(110136003)(36756003)(189998001)(6496003)(5660300001)(50466002)(229853002)(66066001)(50986999)(6486002)(25786008)(76176999)(54356999)(8676002)(101416001)(4326007)(305945005)(81156014)(83506001)(3846002)(6116002)(48376002)(33646002)(81166006)(2906002)(68736007)(27001)(7736002)(5003940100001)(86362001)(6306002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0701MB1873;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;AM5PR0701MB1873;23:S+/TG7AsonzhqGx7QPhEJVrhQ6MBKzpc4ooFTYT?= =?us-ascii?Q?zNyN/83gepvFDc0zwIXtabI1AxMsCY7vEemVWvKjBx083KXQVlZgEJMugTYL?= =?us-ascii?Q?feGOLy/FBeBII9tz6SEeqx2yXsphdt0Pw5BoZxfFLRGL9h/KpnGyfcEuqKwl?= =?us-ascii?Q?5iDCamSMNCfWjep38CP5iQ224P/pB2tNkIltdwiwxPjZP29v7NdsIfj2usWg?= =?us-ascii?Q?OpgSKSnf4QZqLYngLrznFXdGtHB3PEJ+0UwlUokT+GQoyOt3cVCnFDc2h+Jg?= =?us-ascii?Q?Q+3k6AVQzLZitiLgJpMHdi6tp/6SVpX+8npwc0dcHGu+srQcLpKNIMTD55P9?= =?us-ascii?Q?HwITq+Nyapv0Fbca/FuOjPYZh4QlEgTAFTm9CsAW0a4AAoMWUh4YWHZDzXBd?= =?us-ascii?Q?luHosvKShATmIUh0/y1FHnGEIqTfmlTb8PFcEUnPt0Vxq9DDr9+EaFoBwdyB?= =?us-ascii?Q?Og4rwS+k3YCvnmPLgpctgmkBlr0s/NMmN8W4O3VEwpdpHIpg8hfKs5gvMHIy?= =?us-ascii?Q?Zbx153JIPWMyedlHssqUdrbQD0QIzYJTUkDSuj0Ewtv+N4OEBFuz/NwmZWtj?= =?us-ascii?Q?B624ub52t4Jj8GF/rM/I1/q4UJqha37fw3iY8G0JKMmYhG3G+hikKQ72JSuu?= =?us-ascii?Q?V0YVi5HszCiqNDT/Jd+8OXwKOodDbP4d3NZBKtbHjI0EKmYGO70/wyha5PYF?= =?us-ascii?Q?q3GGVLpagWuWm9UPX5U43p++lVeBfUjtp3ZsNRScaeZ+K0DxGFwCD6rukHk1?= =?us-ascii?Q?xJ2nsac/8lHH0HpJBVXNu3vq4iHbMJ06rKg+8/Xu5SvungFKrkBD1JADBOQx?= =?us-ascii?Q?ylEMMAABc0VeBX/Is5Mi4VwjqsCcl4DNpTJtQSt/7E3URaqvF3G0XzgDp5aH?= =?us-ascii?Q?xKKxSebllS7bqQlgE4Y8kTX78Sloa04ydtEuMS4/6tSUoUe+HccpzIVueEFo?= =?us-ascii?Q?wrnj4noY6wLy2QhIDwAFH0udlQY/JTjE/RiqmIooxPBn/+ofraWYtoXphNkH?= =?us-ascii?Q?SQRa6xHTNqq5YmY5IrmJ2m8hl2whubgVLN2EpZw/LOWC0UnUSRr0F2MJdEUD?= =?us-ascii?Q?yyeEpyRarQcQWnvoPSmvbamWei2L9fee3IT46KG/pfrqbHsZVf0mwNQervNS?= =?us-ascii?Q?dzgIumjiPxd03DXgkc6IpgfpVx0gszGQ5CNU1l1WOiuWZflvPC8hfIT8z8sJ?= =?us-ascii?Q?hQ2QrPryjQ3m7vbIWTVCdIAdtkE6/a58fFZrLSvn9ODJHceRnX1qKYY4vmg?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;AM5PR0701MB1873;6:CHtxvlhazAfoct7xN1x+f1HMX2whhLOJ0VC+BBC8QIdkEpOdkzbVaPsU9g34HjQZWaVHcotGRq+rYugBBetyf8c+6U/eewdN+e4rwf1Q28qt8arSIqE+se/9fH+85MvKBLnFlLt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GBOzXs3ruJ/29Sa4ou/xPO/hJW+ZqCh+Qc+mpHWZdJpg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2017 17:27:30.2682 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0701MB1873 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg00301.txt.bz2 Ping. Antoine Tremblay writes: > Before this patch, GDBServer always executed a step-over if it found a > thread that needed one. > > This could be a problem in a situation exposed by non-stop-fair-events.exp > where the code and the breakpoint placement is like so: > > instruction A : has a single-step breakpoint installed for thread 1 and 2 > instruction B : has a single-step breakpoint installed for thread 3 > and is a branch to A. > > In this particular case: > > - GDBServer stops on instruction A in thread 1. > - Deletes thread 1 single-step breakpoint. > - Starts a step-over of thread 1 to step-over the thread 2 breakpoint. > - GDBServer finishes a step-over and is at instruction B. > - GDBserver starts a step-over of thread 1 to step-over the thread 3 > breakpoint at instruction B. > - GDBServer stops on instuction A in thread 1. > - GDBServer is now in an infinite loop. > > This patch avoids this issue by counting the number of times a thread does > a step-over consecutively. If the thread reaches a threshold, which is > currently 32, GDBServer will not step-over but rather restart all the > threads. > > I chose a threshold of 32, so to trigger this there needs to be 32 > consecutive instructions with breakpoints installed that one thread needs > to step over. I think this should be rare enought to trigger only in this > case but suggestions on the threshold value are welcome. > > If the threshold is hit and the step-over is delayed, when the thread > that needed a step-over runs it will simply hit the breakpoint it needed > to step-over and retry to start a step-over. > > This makes it possible for other threads to run and start a step-over > dance of their own or pending events like signals to be handled. > > This patch fixes the intermittent FAILs for > gdb.threads/non-stop-fair-events.exp on ARM like discussed here: > https://sourceware.org/ml/gdb-patches/2016-11/msg00132.html > > No regressions, tested on ubuntu 14.04 ARMv7. > With gdbserver-native/-m{arm,thumb} > > gdb/gdbserver/ChangeLog: > > * linux-low.c (class step_over_limiter): New class. > (_step_over_limiter): New global variable. > (linux_wait_1): Count step-overs. > (proceed_all_lwps): Delay step-over if threshold is reached. > --- > gdb/gdbserver/linux-low.c | 76 +++++++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 70 insertions(+), 6 deletions(-) > > diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c > index 15fb726..b84b62a 100644 > --- a/gdb/gdbserver/linux-low.c > +++ b/gdb/gdbserver/linux-low.c > @@ -282,6 +282,53 @@ static int proceed_one_lwp (struct inferior_list_entry *entry, void *except); > being stepped. */ > ptid_t step_over_bkpt; > > +/* Class limiting the number of consecutive step-overs for a thread. */ > + > +class step_over_limiter > +{ > + public: > + > + step_over_limiter () : m_ptid (null_ptid), m_count (0), m_max_count (32) {} > + > + void step_over_done (struct lwp_info *lwp) > + { > + ptid_t ptid = lwp->thread->entry.id; > + > + if (!ptid_equal (ptid, m_ptid)) > + { > + m_ptid = ptid; > + m_count = 0; > + } > + > + m_count++; > + } > + > + bool can_step_over (struct lwp_info *lwp) > + { > + if (!ptid_equal(lwp->thread->entry.id, m_ptid) > + || m_count < m_max_count) > + return true; > + else > + { > + /* Reset here so that the step_over is retried. */ > + m_ptid = null_ptid; > + m_count = 0; > + return false; > + } > + } > + > + private: > + > + ptid_t m_ptid; > + int m_count; > + > + /* Maximum step overs for a thread, before all threads are run instead of > + stepping over. */ > + const int m_max_count; > +}; > + > +step_over_limiter _step_over_limiter; > + > /* True if the low target can hardware single-step. */ > > static int > @@ -3607,6 +3654,8 @@ linux_wait_1 (ptid_t ptid, > doesn't lose it. */ > enqueue_pending_signal (event_child, WSTOPSIG (w), info_p); > > + _step_over_limiter.step_over_done (event_child); > + > proceed_all_lwps (); > } > else > @@ -3694,6 +3743,8 @@ linux_wait_1 (ptid_t ptid, > We're going to keep waiting, so use proceed, which > handles stepping over the next breakpoint. */ > unsuspend_all_lwps (event_child); > + > + _step_over_limiter.step_over_done (event_child); > } > else > { > @@ -5400,13 +5451,26 @@ proceed_all_lwps (void) > > if (need_step_over != NULL) > { > - if (debug_threads) > - debug_printf ("proceed_all_lwps: found " > - "thread %ld needing a step-over\n", > - lwpid_of (need_step_over)); > + /* Don't step over if we're looping too much. */ > + if (_step_over_limiter.can_step_over > + (get_thread_lwp (need_step_over))) > + { > + if (debug_threads) > + debug_printf ("proceed_all_lwps: found " > + "thread %ld needing a step-over\n", > + lwpid_of (need_step_over)); > > - start_step_over (get_thread_lwp (need_step_over)); > - return; > + start_step_over (get_thread_lwp (need_step_over)); > + return; > + } > + else > + { > + if (debug_threads) > + debug_printf ("proceed_all_lwps: found " > + "thread %ld needing a step-over " > + "but max consecutive step-overs reached\n", > + lwpid_of (need_step_over)); > + } > } > }