From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36497 invoked by alias); 25 Nov 2016 13:13:23 -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 36451 invoked by uid 89); 25 Nov 2016 13:13:20 -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=opinions 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; Fri, 25 Nov 2016 13:13:10 +0000 Received: from ESESSHC002.ericsson.se (Unknown_Domain [153.88.183.24]) by (Symantec Mail Security) with SMTP id A9.03.32482.3E838385; Fri, 25 Nov 2016 14:13:07 +0100 (CET) Received: from EUR03-VE1-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; Fri, 25 Nov 2016 14:13:05 +0100 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=antoine.tremblay@ericsson.com; Received: from elxa4wqvvz1 (192.75.88.130) by VI1PR0701MB1886.eurprd07.prod.outlook.com (10.167.197.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.5; Fri, 25 Nov 2016 13:12:56 +0000 References: <1467295765-3457-1-git-send-email-yao.qi@linaro.org> <20161121120822.GA28605@E107787-LIN> <20161124215510.pbsobdtj6niycjhd@localhost> User-agent: mu4e 0.9.17; emacs 24.5.50.1 From: Antoine Tremblay To: Yao Qi CC: Pedro Alves , , "Antoine Tremblay" Subject: Re: [PATCH 0/9 V3] Use reinsert breakpoint for vCont;s In-Reply-To: Date: Fri, 25 Nov 2016 13:13:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: CY1PR13CA0072.namprd13.prod.outlook.com (10.163.230.168) To VI1PR0701MB1886.eurprd07.prod.outlook.com (10.167.197.22) X-MS-Office365-Filtering-Correlation-Id: a41335ac-6e9e-4ded-9e06-08d41534c98e X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:VI1PR0701MB1886; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0701MB1886;3:BtKXmQ9ZGQp5X4VUOINPngNW+ViX3oJQSjd1erN3tgxEdEbwgO7UYq9w0Qzd9NxUn8osIPHL80wSJSzilYkB5QlJmORhdBqs8gYMjPU94Czf666rKlN2BCOWCn6tUNa4BVRwc9dr68igNDGbLHuybSbOdn9Fq8gnIejgmFFAmmEU+BbUOTx39dPyjQU0hitZrgMGW4dh5wJz/juqANfnlO4BbKHhBxTbS/4LyRH58S1VI2DfMl++QeQvDLteBbsiB4Ix+6Z7dMsAHZ4OdTYEpQ== X-Microsoft-Exchange-Diagnostics: 1;VI1PR0701MB1886;25:KiX3ev7T4OV784CeOaGi0QB8iWKNlnaYnTXok2W2UmILUfQrOMiy/BBTDzTW+Hw9YQ3wuZmr1EwxuK0bGxQRrWkp6lPcY+6AIIFOAOHyCftxAZ+LJcXQZhh3VA5ApDlkv3jDLH3VdhVEVsYWzBUF4KroWwkx+U7ld8L2fNVemHPMvRfc3jDVN/Gwj+vyYVdWkoQIhwnS6iwaK8Ntk8nuerOCjEEo1DUdNyKmGvLTtqlu33qHMRQ/tTdNbvGJD7A1Q1DM9/lkEeWtnZz+t+bc1OyHoTV6Eq7Cr5M/2aIQ/NGmnSbRww1XPJNx9RdvAs/chFZhpRLpEAzcQX+v1vZk8p6mYjs4ghIdVUQz2BFdlWI1kt+Nct+KakOIj4dNFzChSs7wlOb31Y+0DKyJ6iJmL5GYCWcwtvfc3wg0vvZLFAaR1tXwT3Bbtu9qvn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zf795K0VoTxr+T32CAliacCYHq2q1bFLOJj4yXsVmrp26gPYCEPSIpSdcfDO9W2eeEj2g1VUZ48OH6B6vFJJhgLvAIX3k8rYC0D3VxNm6ucly13Jb2OUZxXAjiJpgCCw1z5g57AatDKwvinez4A+QLsCbxtwItmohLRKLnCxLEQfNae X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6060326)(6045199)(6040361)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6061324)(6041248)(20161123560025)(20161123555025)(20161123562025)(20161123564025);SRVR:VI1PR0701MB1886;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0701MB1886; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0701MB1886;4:9t7FAOiTaivQN3d6YDct0nr/gHQFFyJwN6K4OPuG43nSg9OY6tYKCjFWQNgUEswk0EZ66cL2zlts9bce9Chb8Amp22ZWfD1b/qqoL0vyp3iMGYii2AYWq2YWpi9goM4H95PEhc6KSp7AArXi6YejcKy1SHEf86vAOYO2dD1uTQodoK9M0cWepxttad0bl5sQ16GMTS0zyOzziDfsLRL0fAQDA7PYMVWJe7a9ZLbG1gp69krgWuqmSXFCbWtVjRof6bodKcwdNclwRd+4FWY4/kROwtMgmGPkPouVSlkOmCP6woNQrKw7oa9cifXB2hR5GJgAzxrTNFCOCZ2qRUPZInof+LB5v0p/8DlvRDfjgmxNRDY9kzprZINzYLNQDOIyOUqii8/FuK8Dcwf3H6Nr2w07zHiH9RA9lgPMXisPTeGVhtD1FGLVRCwngvcHeU0gvwMZT1MGPv/t2CVTjZcw7+Js6Xb+xL0XQwWpHFgdN8r8suhI2OKOnOC7wEUTGtb5nqvvRQjNb8nsbCXFUWAsWiGoR3qzOJ6nRwkpA1ukEw/Jz0xGJtgVhyPe3ZgQ3XpRuEcaHchlF671m46TWsfXq+KUfvGS9g+6127KZ/eiY8g= X-Forefront-PRVS: 01371B902F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(52314003)(43544003)(199003)(189002)(24454002)(105586002)(106356001)(101416001)(54356999)(93886004)(50986999)(42186005)(33646002)(36756003)(76176999)(86362001)(3846002)(1411001)(47776003)(68736007)(6116002)(92566002)(110136003)(81166006)(8676002)(2906002)(81156014)(6666003)(2950100002)(39400400001)(39410400001)(4326007)(39380400001)(5660300001)(7846002)(305945005)(66066001)(6916009)(39060400001)(38730400001)(7736002)(4001350100001)(48376002)(50466002)(107886002)(189998001)(97736004)(229853002)(77096005)(4001430100002)(5003940100001)(83506001)(39450400002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0701MB1886;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;VI1PR0701MB1886;23:npYWs6qbLspwERrCliTQh2ih2cEANKzthT4+fbH?= =?us-ascii?Q?bJN5AzzV97cEk32d+Rlm58TjqKVFj+6v+KNvfRLf7pQm9NBX14zNu0gM8+el?= =?us-ascii?Q?CG17TY/Q8afTQzSj84Tuv9w8BUEv5G/x4oAApmz+wilPQgPs5Buya+aYk9Cz?= =?us-ascii?Q?6+4YYmIxq5R/hVih1wcyZnYLh6doTyq5UjDOyI+lbXN5SMm1yjbIfyubIPrR?= =?us-ascii?Q?XGMi17JOZu3FeI10rpzEDf5BvV7ak5Iwy14UyZjU88nGbPWkpy8+r4xe28FQ?= =?us-ascii?Q?fsxrWv60sDYkyQwgtWLbfChoKwJOpZAshH5LyEe3nwfcwIdN7j2TXKmxVnbz?= =?us-ascii?Q?ggCniJodr3JwrW/BlTJH5IlwQY3RNeDR9Th5O2wxcgGKm6MTRMq+GQcCGn1o?= =?us-ascii?Q?FNWoaSoVTGuhB0CwIcabzBdX9XCapmfkr1Ts4LTxzHsiN1SUZgpOVqBr1QmM?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ZGpAffx2DBJVm0pmOSFyFd7?= =?us-ascii?Q?M+kUSfNHppnbPomDDYEnKVIfVnsU=3D?= X-Microsoft-Exchange-Diagnostics: 1;VI1PR0701MB1886;6:sy6xgInJ6/ZQzcntGjcb2rxfmtfJruaA58cT39LV+1I0SaPKtWtXl/P4HzwYHLRzFC+qfvJs6WYAZH14E2+IQACVZB/QUPNVMUVi7Ax8/mWK7cva90U5sSom5O2ITrHB/YjKMyIxBbpuBSsO3pqDFMtTbS/BHNdJVUI3AZxUwzzw/TIlVOY5comKmtQM8KtWC92ewwkyq/e8TgZtyU9KnP7WDICqyCDAZAfb4M/sL8uA0gax/fwI9628og8n982k9Afo1coajmYRrFodBJ78CpoQ1sJTQsQsjnqdnIlbIU3pzZ/Opj8+hcDl84Emmb6mDID9ChBugmK+NgQ6kTfUAO5oHIC0M6/jc+jp71z4S4peMUVWbmqlK99Iy/jpcFlh6Zig1VsF2X3JVFg2zBY5yMIUyZO1oIRZuItpVUhfI4wHl3kiiaqhgMGLR4c0UatWMqGlZR8SluxYuZ2TJ74oiQ==;5:q5n3gljA4HH8cENHBBJnnwowrWcFiO3N2BCC8VWD4Lsmt7ka31Qj+YsxDaF1vEtfpSCsZdBu5i8clv0w9lYMkfaGE/AWEfIfn7PmKTfa84GAKfxoDJ3K7aa8lrehBE0AiwGL47kCTbMcZLY/PYgC0g==;24:O/FWdHQBK5Pupm/eFA0VdgzS3dzbQ93eMhRfcO7RlS3sZMX2pBMiqG4QVemM1AvSjgD5toFsC4E++NXfhTg+TqX2YCOVciIXAo1tPrnlQXM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;VI1PR0701MB1886;7:z6Z3viykL8yeV4x/ZAj2tWjYdKMFpZqADb40ENBnHhOJpaxeG1oUvmj4ygO1exzHye/2B6BWxZjSyPziCYGEewqh/sifvEtnUp0qcy8ANUkudlQ4F2xr5B7IBaoCgQVt7kKuAGqCykJxAR7rEnq7KaIBzUAdFIyyR1U+O795cQsIzbrhxpzOkFeO9Cl+JyDbL/VNkP9MTUGmHuOWSaLHCxu9UPtmAomtORvz4RHTExBrjd/aL5B6hqtyGKJNrFzIQ3v2TZF1PUs42CS/9LvV4rqFGQiowjj+s5e195UMfhnw1TIpaIuUGW23rGGdY+ZZcRzmQcFlSFNTqhE7MhL3JkxOvGU1Blj974Ehfn6g8qrGeyqV7hUpOLrqRk1gf+9y/tDt1hJwrQRavpQIMIM9INIcclsC7YQTslmSnAyF8ASXWsal3AliXnn7hRa1blcFtnOgLtMSyw7tB0CqcIWIcQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2016 13:12:56.0595 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0701MB1886 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00804.txt.bz2 Antoine Tremblay writes: > Yao Qi writes: > >> On Mon, Nov 21, 2016 at 10:34:44AM -0500, Antoine Tremblay wrote: >>> > Thread 1 either sees the original instruction on address A or the >>> > breakpoint instruction. Unless ptrace read/write 32-bit is not >>> > atomic, IOW, partial ptrace write result is visible to other >>> > threads, I don't see why we get SIGILL here. >>> >>> I think this is the problem, ptrace read/write doesn't seem to be >>> atomic, and thread 1 sees some half written memory. (Given that we get >>> SIGILL/SIGSEGV issues) >> >> We need to check in linux-arm-kernel@. >> >>> >>> Did you have any reference suggesting it was atomic ? >>> >> >> No. >> >>> While testing it seems to be atomic for 32bit writes but in thumb mode >>> with a 16 byte write, it is not. >> >> I think you meant "16 bit write". Why is that? >> > > Yes 16 bit write sorry, because it can write a thumb breakpoint : > 0xde01. > >>> >>> Given the SIGILL/SIGSEG I get maybe that one is 2 writes of 1 byte ? >>> I'll have to dig in the ptrace code I guess. >>> >> >> It is good to get some a clear answer instead of ambiguous speculation. >> I think we need to ask in linux-arm-kernel@ > > Did you see my follow up email ? : > https://sourceware.org/ml/gdb-patches/2016-11/msg00681.html > > Also, I think this will become a moot point in the patch I'm about to > post since: > > To install a single step breakpoint on a thread GDBServer needs to make sure > that there is not a breakpoint at the thread's current pc, since it > can't determine what is the next_pc of a breakpoint instruction. > > Usually for stepping over it's OK since it's stopped at pc X and it > will install a single-step breakpoint at pc X + next_pc_offset. > > So need_step_over returns true and GDBServer starts a step_over process, > which removes all breakpoints, installs a single-step breakpoint on the > nextpc and resumes. > > But in this case it is installing single-step breakpoints in threads at > different pcs then the one we're stopped, so the step-over process is > not triggered and it should not be. > > So GDBSever does not take care to remove all breakpoints like is the > case in the step-over process. Because of that it can try to install a > single-step breakpoint where there is already a breakpoint in memory and > thus break get_next_pc and install a breakpoint at an invalid location. > > Consider this case: > > in non-stop, thread 1-3 are stepping in a loop similar to > non-stop-fair-events test. > > - thread 1 hits its single-step breakpoint at pc A. > - delete its single-step breakpoint. > - a check for need_step_over is done, but there's no breakpoint at pc A > anymore, and nobody is stopped there anyway so it returns false. > - proceed_one_lwp is called on each thread. > > Now here is the problem: > > thread 1 is at pc A > thread 2 is at pc B > > B is a branch to A. > > thread 1 installs a single-step breakpoint at pc B since it's range stepping. > thread 2 does not have a single step breakpoint but needs one installed. > > - proceed_one_lwp finds that it needs to install a single-step > breakpoint on thread 2. > > - It calls install_single_step_breakpoints, which calls get_next_pc. > > - get_next_pc reads the current instruction in memory at pc B, but > since it's a breakpoint, it missinterprets the instruction, you can't > step over a breakpoint like that anyway, but this is what happens > now. > > A single-step breakpoint is now inserted at an invalid location. > > So my approch in my patch is to fix this by always removing all > breakpoints and fast_tracepoints_jumps, like we do in start_step_over > before calling install_software_single_step. > > This makes the breakpoint installation a multiple steps process and thus > can't be atomic. > > WDYT ? > > Thanks, > Antoine In fact thinking more about this we may need to remove all breakpoints at any pc since get_next_pc may read memory in other places then the current pc to deal with atomic sequences for example or for other instructions too. If it reads a breakpoint in memory there it may come-up with an invalid next pc. This is a problem with the current step-over logic too. So we would either need to be able to read past any breakpoint/fast_tracepoint_jump... anywhere or uninstall everything before calling get_next_pc. I'm not sure which one is best at the moment, opinions on this are welcome. Thanks, Antoine