From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 103562 invoked by alias); 9 Jan 2017 11:55:36 -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 97875 invoked by uid 89); 9 Jan 2017 11:55:33 -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=proceeds, antoine, tha, resumed 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, 09 Jan 2017 11:55:23 +0000 Received: from ESESSHC008.ericsson.se (Unknown_Domain [153.88.183.42]) by (Symantec Mail Security) with SMTP id 3D.E8.17130.82A73785; Mon, 9 Jan 2017 12:55:20 +0100 (CET) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.42) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 9 Jan 2017 12:54:39 +0100 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=antoine.tremblay@ericsson.com; Received: from elxa4wqvvz1 (192.75.88.130) by VI1PR0701MB1887.eurprd07.prod.outlook.com (10.167.197.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.6; Mon, 9 Jan 2017 11:54:37 +0000 References: <20161209122339.GG13661@E107787-LIN> <20161209124625.31861-1-antoine.tremblay@ericsson.com> User-agent: mu4e 0.9.17; emacs 25.1.2 From: Antoine Tremblay To: CC: Subject: Re: [PATCH v3] Fix inferior memory reading in GDBServer for arm/aarch32 In-Reply-To: <20161209124625.31861-1-antoine.tremblay@ericsson.com> Date: Mon, 09 Jan 2017 11:55:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: YQXPR01CA0053.CANPRD01.PROD.OUTLOOK.COM (10.165.103.21) To VI1PR0701MB1887.eurprd07.prod.outlook.com (10.167.197.23) X-MS-Office365-Filtering-Correlation-Id: e7c8a8bd-6471-451e-b53d-08d4388649f7 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:VI1PR0701MB1887; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0701MB1887;3:tEBz2JwqkTEjMQ4fSP8ec6ngKy5mR2qkZxJraaIThBumtS/tK7q8+Xr5f7VXxpLr710w2kndYUfNl4EQkjU3MZnv2l88CiT+QXXNuSntwkVq6FMmsNn5UqOau68vM37GH+5Z+4b8BkHzbEsvhhEYvOUsY4LLF+VH6HpYp8zRlMQWMSPvNRpPP4XaZnILCHzSErrHXtbaDol10qgQQJpjjbNWz5n9nT3bOjV81HjMp38FLoiwyfaOGgLtH7iwuvwk7o05t8elKj/JkIMxc0bQIg==;25:t6tKvLxHHWoz/x0c7sZtzeGiPBsDWYkSXq5/7MzkHF+nWa0pzhkK5k0R10uKgIGNLKZtQp0g2jJ8jqaryGN9cIMZ2yvGP8ih7V7zDrtyAWG/DEo+fSIDMZ7CjJNOQfKG5TwdmaNnILxjO96cuz8/Yk/llZWqNOUwtfKyp0K07wALBJ5t/yU5oX9EgR3tObSjy6yP5fs8EEQgyqsnxMdRwFhPLDBkvVj3NusVUKajJ+tPdgBmReRKI7t33N190rJJeE4tOzq82YYWHDDeZPHyggQq+zd+CwZbI8Cb4RYlBSkwdWePZl9TvqjVF90DTGCG6pZjGWJdk2sdFt6lZV2l3NcWsEvXvGVVYuWNJjzmmegjfsqO9RyiIuCzmP3sDTsyL9RwJ4QXX/beDhu697EjqzPSY2MJrfmK6cDG7JNqdhtbjh9myi48CWvFeZE+7RQwkk6esQCddj1pfjnbEGWTrg== X-Microsoft-Exchange-Diagnostics: 1;VI1PR0701MB1887;31:kqSLw6NMCPxMlMMMS9WwxAnj4bI//nWjEv2c0b3SxnIttJ8wJlIeCich8hfWq8WlYFooi/9QG/VUb3eGiyrL74s7C5CQGBIm1dHkuEx/eFZVH1Nd7GPQX3VPbhFh60BOBtZ0EINXUvIetuVVUNGfR54YxJzxbaIbcHqCN5U+D/0/f8/ozel85N6HphIS/aO6Pl7aa8HHoqdKvCg5E8a3k7VUpLWe6W4TMfH1zBLM7CbesYwhAQngvbtXok+O1F2ftqeWe3j0mCBI+ET18lyVCrpq3ObCCFapWLH7Ob5++PE=;20:CzBMt0gf2Pff8tXHgLaK89jhIMMnZH9M9ncVme58ZHqkl33gePs4g/1J/n97O87IT1WSRqulR3j/+7bB7T778692+W6gaYe9Wb7e+vGqwRiGLsUHjjWZwoL2aPUsqF1ZdAWi1N1Pyyiz68EoDQcXxzgbL0Cu+TddtKc/hZHPwpPcZGTA61qPhTlrWzAWC9kwvJXXq7naQldUMJJC0xAClfFZjJa0IU0BkhyMOpBDphlN4nETVxCtZPo56L2U07Rz2AJQ3fCEMj2qKEoHRFYN/78EofCx7TiGsn1bZJyadZ7ptKFkK8rbg/nua+Gxo7j+fR/w6pJR0S07H6dUS/vPUfos+36kiN/ujWlQYuN9pd6GGrHjrS87b5UW+F+6Zi7Qlqt4X+nWoVGbZ/GxIxlxSxqyoCmkjZRrb3JzyA12EZ/whDJVU6sbhMchp5E0rzEFk/ny1NgLtNtAMqZdWy+pkfEMaKds5gucFt91wpl0YlhWmpTJA685fv86XJkNyQE7 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)(20161123560025)(20161123558021)(20161123555025)(20161123562025)(20161123564025)(6072148);SRVR:VI1PR0701MB1887;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0701MB1887; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0701MB1887;4:ySjJmXX5fYGYbREfbBA8zjQEhhG+odbKaW5V5fHzHmvkdfztdm3B3j2mbz7bgDwOj92VAehAxC6L2NZdGKnqZ/oBi7HLhDn7+IzLYZqKEUe4mzaTobzaE5MsncYvSNo+xQAqmZ1JhDM+YNAzVib9GcLGzj8r6n4E+KVdCLZZ+TeflbUaesoA/htPvG1jTmVYObdEEO7DyWr2qp5XjF6S56GxsqTuV+iVqcsrG9RI4JZHOr3QNzpVF7KzfR9MNEs5k5ER34CjfDokuGchPJIWj3j3hAgWyznbDJgIvr1iXveFy5Ic1zHB8/WnBZDUlKGl+dnPLUnI8BQ2npZxGJF+TjrNW5c8t9CQ49HFS8msZhi7d2py5w24ntshwR9J6dq+UrNj2qyPBwEzXzT434jHPtZNn6usIGSmZoERzrkkNdD2O7uyILqeYnwPHzGWDpsdVkoEwc66QY6IUQmLbil9ZBPpo4yKsovW6z6tri0vzVPCMBMNiopxjYCkqkp6cv7oY0L24+bbAt2LRNzxkhhbJUIt9MQVw9Y1oEE6/4LUxA8WmKdBRSjES0nYBc2AGRBNBCn/Xs/fgg6GOl6U0xrUZki6vEQahn3GWekSUqH+WmU= X-Forefront-PRVS: 0182DBBB05 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(199003)(54534003)(189002)(36756003)(92566002)(25786008)(5003940100001)(83506001)(39060400001)(189998001)(68736007)(229853002)(3846002)(33646002)(6496003)(6486002)(6116002)(4326007)(50466002)(305945005)(81166006)(81156014)(8676002)(76176999)(2351001)(54356999)(50986999)(66066001)(7736002)(97736004)(5660300001)(48376002)(4001350100001)(110136003)(105586002)(86362001)(106356001)(47776003)(42186005)(2950100002)(6666003)(101416001)(2906002)(6916009)(38730400001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0701MB1887;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;VI1PR0701MB1887;23:fVIqVK3gSqS5htp1nybBDqxC3Dz+IHw0jovuG0n?= =?us-ascii?Q?RsbsI9gTyo7yF1bk5reXTyCn/PdIhSxjNCsftsZu3iaj2YIuaI9Eh7QsaK9E?= =?us-ascii?Q?G1zAevvkUDT06uQbYszTrdsz/DDBUJHMPz7yK8/Xsv3FeAfqKOCzzwNz9phz?= =?us-ascii?Q?J3PX9voxBtBiPyYO5J62HPzp2UInUW1RNDfvA72uxz4kxbi0VR8u07EbqAvz?= =?us-ascii?Q?R8IxjBKzNIp935UH8lLSypEhXZGuKQbA5GqvSEPjeJ7Xrz3MxKqW2Hu/i/2G?= =?us-ascii?Q?xezAapL2Ohz729bKZlllYDxINxBxJ985eYKCO8UUiOT/hCK9UY/a8tJOODtz?= =?us-ascii?Q?fYSzDpnVyXnlWBflj8MR+I+g3tMKSccVG+h0uUGZ7Br6KWB++cP367l8gBCH?= =?us-ascii?Q?fKVBbPmDqzPCoI8UfyB026bQtN7CgubMj7rFRu5TS8m+Tc04oLTYzA65yN3J?= =?us-ascii?Q?JZQYzOW+sfTjqKXunQuROtPYl/qGNZL/+4WRPnvud+vwme583DTW+xi6Fef6?= =?us-ascii?Q?WkQUJOu81LPeFBcgi1EzV0cnF+LCKEI7xssNrJbW/2dHMKPY7r3xxfcUyv32?= =?us-ascii?Q?C8FOXgPjW+bFM2Un3VQKJyVkZdvDuyA6jlVZrZATIE2A85JfWx6G4H7vFuME?= =?us-ascii?Q?tpgUnXAumxnKVT/rhnGJUhvzV+z0DVoNSleraxMP6GmVMYbb0npqyUSsDzWC?= =?us-ascii?Q?yMjMGb7EiLt2IX1tp4RcUd9JrGKag/kLx73Gv/AVsSyQ9g0EfiEjE1gWiRJ5?= =?us-ascii?Q?vBMI2srLh79K/Fir1jXL3BUJA7QWJKEqkwLQHa/Bap2iMBiQZmSkhDQ1cbvS?= =?us-ascii?Q?CFnc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KCNMIiy1ImeR1+t23JVrDQBqjuVEufyDjE1w+X/3xQ0SNH0=;24:SkL8qtn9HlV8NdVW5lGWB/7D0M64C4BJmvbmxf728nNu+froD3GDjV4mp4m8hR0j2rXZtS8IVSqi9o0DWcc7j2CgI4e0m4i2Z2TSkwMK7Y0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;VI1PR0701MB1887;7:auac2vJBEYDFziNsNB7gWneKJWa/AM2iCjGsQ5Xus6Tocb7WvpFRUtrwm6frWFqIzWiBaF0b86ZSY4M1frZkhUo/UU3Mj2fBxRxrcgZM/E51+d50RFOJoJ3pxD4butD7mqc1AzrH4ud2wvxFyqywFVsT/eyMTVUmxjiSdkN+KQzF8xWiKMvjjWIu8LRDj+NxIzxX00D+Td8FMf/FgQuu4Ez0jlyLIeJmb2uGFj6HEPYHRvdGf4zvNFCR5FC3IQsYcyKjTGH/UJ0ChGOwbwyiEEOrXHDVW57ZyGC+8F/Jz3pZWNQvSo1jUdEha45DnkVClRIKdE/LIfmGllrqSaq4DxMxMYlRFZFIMrtHLFcKdIJw1jvHy+xWiIVww3soIdqUXos/x1/lUgYSlrf6Rk4smbjMZOoPz5+clsuhSTRRDDWKnFzjYVrlMDnfF2rKvb25mck3pPH93hTq5KKeS/CPKg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2017 11:54:37.8572 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0701MB1887 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg00125.txt.bz2 Ping. (Sorry I had a mistake in Yao's email on 1st post) Antoine Tremblay writes: > In this v3: > * Stack reads are now done with ->read_memory > * Note tha this invalidated PATH 3/3 about sparc, since it's also a read from stack.. > > 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. > > Here's how this would happen: > > In non-stop: > > the user issues: > > thread 1 > step& > thread 2 > step& > thread 3 > step& > > In a similar way as non-stop-fair-events.exp (threads are looping). > > GDBServer: > > linux_resume is called > GDBServer has pending events, > threads are not resumed and single-step breakpoint for thread 1 not installed. > > linux_wait_1 is called with a pending event on thread 2 at pc A > GDBServer handles the event and calls proceed_all_lwps > This calls proceed_one_lwp and installs single-step breakpoints on all > the threads that need one. > > Now since thread 1 needs to install a single-step breakpoint and is at pc B > (different than thread 2), a step-over is not initiated and get_next_pc > is called to figure out the next instruction from pc B. > > However it may just be that thread 3 as a single step breakpoint at pc > B. And thus get_next_pc fails. > > This situation is tested with non-stop-fair-events.exp. > > In other words, single-step breakpoints are installed in proceed_one_lwp > for each thread. GDBserver proceeds two threads for resume_step, as > requested by GDB, and the thread proceeded later may see the single-step > breakpoints installed for the thread proceeded just now. > > Tested on gdbserver-native/-m{thumb,arm} no regressions. > > gdb/gdbserver/ChangeLog: > > * linux-aarch32-low.c (arm_breakpoint_kind_from_pc): Use > target_read_memory. > * linux-arm-low.c (get_next_pcs_read_memory_unsigned_integer): Likewise. > (get_next_pcs_syscall_next_pc): Likewise. > --- > gdb/gdbserver/linux-aarch32-low.c | 4 ++-- > gdb/gdbserver/linux-arm-low.c | 5 +++-- > 2 files changed, 5 insertions(+), 4 deletions(-) > > diff --git a/gdb/gdbserver/linux-aarch32-low.c b/gdb/gdbserver/linux-aarch32-low.c > index 5547cf6491..4ff34b626b 100644 > --- a/gdb/gdbserver/linux-aarch32-low.c > +++ b/gdb/gdbserver/linux-aarch32-low.c > @@ -237,11 +237,11 @@ arm_breakpoint_kind_from_pc (CORE_ADDR *pcptr) > *pcptr = UNMAKE_THUMB_ADDR (*pcptr); > > /* Check whether we are replacing a thumb2 32-bit instruction. */ > - if ((*the_target->read_memory) (*pcptr, buf, 2) == 0) > + if (target_read_memory (*pcptr, buf, 2) == 0) > { > unsigned short inst1 = 0; > > - (*the_target->read_memory) (*pcptr, (gdb_byte *) &inst1, 2); > + target_read_memory (*pcptr, (gdb_byte *) &inst1, 2); > if (thumb_insn_size (inst1) == 4) > return ARM_BP_KIND_THUMB2; > } > diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c > index ed9b3562a8..930cc34f71 100644 > --- a/gdb/gdbserver/linux-arm-low.c > +++ b/gdb/gdbserver/linux-arm-low.c > @@ -263,7 +263,8 @@ get_next_pcs_read_memory_unsigned_integer (CORE_ADDR memaddr, > ULONGEST res; > > res = 0; > - (*the_target->read_memory) (memaddr, (unsigned char *) &res, len); > + target_read_memory (memaddr, (unsigned char *) &res, len); > + > return res; > } > > @@ -804,7 +805,7 @@ get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self) > unsigned long this_instr; > unsigned long svc_operand; > > - (*the_target->read_memory) (pc, (unsigned char *) &this_instr, 4); > + target_read_memory (pc, (unsigned char *) &this_instr, 4); > svc_operand = (0x00ffffff & this_instr); > > if (svc_operand) /* OABI. */