From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 75112 invoked by alias); 1 Dec 2016 16:18:46 -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 75002 invoked by uid 89); 1 Dec 2016 16:18:35 -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=supplement, HX-Exchange-Antispam-Report-CFA-Test:6042181 X-HELO: sesbmg22.ericsson.net Received: from sesbmg22.ericsson.net (HELO sesbmg22.ericsson.net) (193.180.251.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 01 Dec 2016 16:18:25 +0000 Received: from ESESSHC021.ericsson.se (Unknown_Domain [153.88.183.81]) by (Symantec Mail Security) with SMTP id 6A.05.03096.E4D40485; Thu, 1 Dec 2016 17:18:23 +0100 (CET) Received: from EUR01-VE1-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; Thu, 1 Dec 2016 17:18:22 +0100 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=antoine.tremblay@ericsson.com; Received: from elxa4wqvvz1 (192.75.88.130) by HE1PR0701MB1883.eurprd07.prod.outlook.com (10.167.247.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.771.4; Thu, 1 Dec 2016 16:18:19 +0000 References: <20161128122758.7762-1-antoine.tremblay@ericsson.com> <20161201144401.GA19289@E107787-LIN> User-agent: mu4e 0.9.17; emacs 24.5.50.1 From: Antoine Tremblay To: Yao Qi CC: Antoine Tremblay , Subject: Re: [PATCH 1/3] Fix inferior memory reading in GDBServer for arm/aarch32. In-Reply-To: Date: Thu, 01 Dec 2016 16:18:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: BN6PR16CA0018.namprd16.prod.outlook.com (10.172.212.156) To HE1PR0701MB1883.eurprd07.prod.outlook.com (10.167.247.23) X-MS-Office365-Filtering-Correlation-Id: 3586fc96-0847-4b48-764e-08d41a05aa4d X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:HE1PR0701MB1883; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0701MB1883;3:UH81c2b60V+aUGLzMVFRotQDkjQf2tGrpzhH0G5Xl9Xnqen9uSXpwi+6zZ2fT377mebiJAzMt+lrqsi2RDLyjjxLXR/LBuW57RN8ZZC2khOtofyx3B7R/+lZOwSRdlD9rnsjzT0z2h2h3+yLmyk+skl5keNEMEbqMJ97lKRsT2LMq/7CbVSZCddUEzInqTRQMwfW2Fx4mYZ1X5OC2WUZ2cb/TT/aCMiWwlS6LuqmNXVkEldZchT0+CWlX4PZUIVCivbbtfrgrvnChCELgMx0lA==;25:NYaDEYW39mC38qsxzbhxPdAnro1g1gZpp0HMuVgtoC4Z8qaycOgkUvflKlrKFJPqVjbMUL+vTYa4ixVy5ubBa7OIgRuaQAxL2Bq5poVNH+22lYPEwEB9Q5Hr3kHHmFDeMfx3FB7dARqmqSVNhJqDy+Pwmg89TJUKyrbCwG5YsCNDGjvXAZkly0DNxSrZFntRurEodptKTH210zhdPe7aRQgEjIwLNQyKGJqWWIWpQnced0792wl/ZxvKnYy++JN0wb6JCFh5vP9ZktTyA/qFNYZhQEH2z0oRSomoQw45j2qvNYOy1TOTdUNP7hoOtDX6aYxHoFoW9iWe+fDBA6EGRjcKIoPax5hcJ8uloqKeKSfBzdPUmfXlgtEyCil54xUT/6+FZQ5PFpSFGojUfec1E2JIUJFSptlSPgMXPqKEDvzQvbVQ8M/V82y6uFPExhMdMbGeGj0LtSwwxYI7gefMIQ== X-Microsoft-Exchange-Diagnostics: 1;HE1PR0701MB1883;31:afStnJfHW37QXw9vmFw3LUwAwT4aRSUoiDqbRBBHD9cc+X8JE+y1d6YjqLEmVaYgnZc4jlioUAkBuCJqaqb4wYoUYeAaekA5C5e7olJ8T8UdA51Y3sLTeAOUK3A/3SVKeunWiLrq1teLAAFSNTA/vnthHo4X7hB1rtGHMg2oc6nlvKaKQXBUMovzwcp1wURmCQp7tf7N6R189FnxN/tFeQSsTaE7FXrMg0xhmFAX4wOrMgEnXB/NTtoGGtZzT72MDlHi6GkbVhlk+4o/6FQBMQ==;20:QSAy08gziAbaNwu9OjVj31CXdMufH7GFPFP1cLmnwtWkFwoXDZwVObaJQTyBTaIv2I/69lZK9mQbcAfbPLrbszE3mDcOr560sg9+CIrI4B6wTcvcMPKXxE58cKdMjX0A2ZpePdxyJoyzv/jgS6/jXe9lma+HR0+aO6VKnHQX/H5OR1FzsBu8tJs4XG8lSRyFFyI0JXXIYBJN4HLRkYPZ1eJAa8tEAF/vzt2lzY1zBvWRn6t5g1Srffd3NI3DDv7HmUuZBf5BPBwM9TFXOaZcTP8R82uWlXmXJrzgsLWM/gduyWUz4Zl5wGW/ZTaZvm2pL39OKYdx/jFJEmerVK5g3ht7wePUo9uDIm4pFHwTYabHswZYpnCoWqtg5m0fm/ZpRlbByn+Oax8czUypp+ppqNvqT5Jm+AcX//vSUc3F+e28rWSLaPKVKbN3Aiy4HlmVdDxdKvnYf1Qvk06HZ9ojZ32umrjhGygrPZrzO2jzrD+NzXkAlsy2R1q+6Q5ndb2I X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123564025)(20161123560025)(20161123562025)(20161123555025)(6042181)(6072148);SRVR:HE1PR0701MB1883;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0701MB1883; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0701MB1883;4:dXU8BPUx7LXzIzdKnU0NyA1RZqnYOypUojSDgPGZNHFoH8I27oVlAPpp5Dw1QjCgZfiZUu7rDu1hu0XNeFQM9bF69Q2iw7puf32t0gdGUbACE7KJQy/tsNwQ/bFH2ykRB7g0cKLhjZ6s1dObJECPfrWkVppvsLBNLhVLO3JFzkEhzmo7M0BmmqHwJjjOVyPzK08G3fKg7TSOlIEruiormz9cK+Ne/7A8Tt65fUFoESpJWIOwVXZg0ZjZEDpUEMJM1fU6/6iKYySZTB+xduAKeGVOGb0wMpvdskP+yD0DCBix7blUfHPqvWkPuz9oGuKsyyYyRaryUbpwiflzd2ZigoKrzdEz1Cou2c76BbF3DNfBeUzDClNAShCS7yCnJWO2iMtbQQJWLRgwWpsxTnhljboaCWlOrt41PmPh1yuLrEev/pCNasNFysdn6mlQpSW89W16bJT2O6aUPaz1Z4eO6J6qluwi1ds1S9+aNsAQTOlFsvUmwP8Vy/qVKieH9uz/viZbmPfhWBbnuHiwxKICyfiyx0GzA7FEopJsIIIRfT7REQ57ydNREaCwwvA5RgY0MJchbgp8E1MpCLSWNCM7Ng== X-Forefront-PRVS: 014304E855 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(189002)(24454002)(105586002)(5003940100001)(110136003)(42186005)(305945005)(93886004)(6116002)(83506001)(106356001)(86362001)(3846002)(92566002)(36756003)(50466002)(81156014)(189998001)(8676002)(81166006)(7846002)(33646002)(39060400001)(97736004)(229853002)(76176999)(54356999)(50986999)(48376002)(66066001)(4001350100001)(68736007)(47776003)(6496003)(733004)(5660300001)(38730400001)(1411001)(101416001)(2950100002)(6916009)(6486002)(6666003)(4326007)(7736002)(2906002)(4226002);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR0701MB1883;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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pnWCHfIe7yfBbncGREAPzDcvG5S6R00fFhJ73Cq+9mjhS8ZqlXrXCRoAg6A2cIqMy+fnDgFQ==;24:INS3GHauOWF0Sxdf259QlKx5e4SxJv5Bv4+c0umDx4mVSuMLks24TkmnRu/mQ3IKtjLGsfY06Jmvwwc/Z/zpFBGgQnZXHxDpZEDf7z+8j8Q= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0701MB1883;7:zegZ3mqQMaAbwmVBVYagyhLClhGcdGIWrns7SQYD4VxUy1X/5R09fX5DIEPrp7DQ4v3Do0M+zMs8bPBJT71g8rmuOG/77HJqPutiNpX+xfL5fb1eboVd/LfbcxX52LpkIMXJtbVGenmzaTlpW5fZYNtXYuLR6RWu2fL8v2rspNSUEB4QAUoMwT9n0wI4uEpErpm+/pmLD20wbVKPHXGuZ1bakzrMC5IxLQOpPaz6GZvfVR3YVpjdPzgBXabUd1809hjQVGNn4QWNekjC2/Fu6JvECbNI1UC+NQPKonKi5Xe0r39A8wmg+VLAoscDy8v0CpT/NDU1LkpkHtT1+wnVtKvq2tRD4nRX7XRFqz78VcZupxZuj6Wh8JQIJkYJlT7EJ0Yeaz6aMbrJ/c5256bnk39+WJIJDsn/mZCqQQExkAwMqTnbDIo9TWb58mVhcZsslNV7X9PPcTKgGtXWiqu7+A== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2016 16:18:19.2277 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0701MB1883 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes X-SW-Source: 2016-12/txt/msg00045.txt.bz2 Antoine Tremblay writes: > Antoine Tremblay writes: > >> Yao Qi writes: >> >>> On Mon, Nov 28, 2016 at 07:27:56AM -0500, Antoine Tremblay wrote: >>>> Before this patch, some functions would read the inferior memory with >>>> (*the_target)->read_memory, which returns the raw memory, rather than the >>>> shadowed memory. >>>> >>>> This is wrong since these functions do not expect to read a breakpoint >>>> instruction and can lead to invalid behavior. >>>> >>>> Use of raw memory in get_next_pcs_read_memory_unsigned_integer for example >>>> could lead to get_next_pc returning an invalid pc. >>> >>> Can you elaborate under what circumstance breakpoints are still in memory >>> when these functions are called? Can we have a test case? >>> >> >> Here is an example: >> >> In non-stop mode multiple threads are stepping, like in the >> non-stop-fair-events.exp test. >> >> GDB: >> thread 1 >> step& >> >> GDBServer: >> thread 1 is at instruction A >> installs single step breakpoint on instruction B >> >> GDB: >> thread 2 >> step& >> >> GDBServer: >> >> thread 2 is at instruction B >> >> GDBServer needs to install a single step breakpoint at the next >> instruction from B. >> >> To do so get_next_pc is called, but since the single step >> breakpoint for thread 1 at instruction B is there. get_next_pc >> reads the current instruction as a breakpoint instruction and fails. >> >> Note that I used a user driven example here to make it more clear but >> this is also true while range-stepping in a loop for example: >> >> - thread 1 hits its single-step breakpoint deletes it >> - it's not out of a range-step so >> - tries to install a single-step breakpoint at the next >> instruction >> - but thread 2 has a breakpoint at thread 1's current >> instruction and get_next_pc fails. >> >> This is already tested by non-stop-fair-events.exp, the test will fail >> without this patch. >> >> Note that this test is testing both range-stepping and the user >> stepping. >> > > Sorry I got confused with the code patched with the latest 2 patches I > sent refactoring the single stepping code. > > Considering the current code this is handled by the step-over process, > and should not be an issue as it will always step-over before installing > any single-step breakpoints. > > And step-over removes all breakpoints when stepping over thus > get_next_pc is ok. > > This becomes an issue like I said before with > https://sourceware.org/ml/gdb-patches/2016-11/msg00939.html > > Since with this it's possible to install single-step breakpoints without > a step-over check. > > We could consider this patch a preparation for > https://sourceware.org/ml/gdb-patches/2016-11/msg00939.html > > or just a good pratice to use target_read_memory. > > Thanks, > Antoine Just to supplement about: https://sourceware.org/ml/gdb-patches/2016-11/msg00939.html If we consider this patch the is 2 reasons we can't install step over breakpoints. One is to be able to delay a step-over. The other is since GDBServer inserts single-step breakpoints when it processes the resume requests and threads are about to be resumed. If threads still have pending status, single-step breakpoints are not installed, so it needs to install them in proceed_all_lwp. And in this case the single-step breakpoints are inserted outside of a step-over process.