From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 8BB533858D37 for ; Tue, 21 Mar 2023 14:41:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8BB533858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [172.16.0.192] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id D6B601E0D3; Tue, 21 Mar 2023 10:41:23 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1679409684; bh=iXkbNMRc28NHQ9waAgLx9wtKYgETvsTMbC5qLzQgSP0=; h=Date:Subject:To:References:From:In-Reply-To:From; b=eQvp3FyU+mTgrK8NaUIPogwx1ETbmXKjmJktkswlZLZTEpZJsjLMbQIBpmLYO8LKF B5Z+DxAAM9a87Vm4kHnm91RMfFw20idLiLLVhi05zy3TIEA28QSYQzQ4EcoDPQISep 2ThEqznhbouJAMrJkOhGSKlGmI5O3jDTotTyphBI= Message-ID: <8473de37-fa6b-f7ec-e4b6-78b971324804@simark.ca> Date: Tue, 21 Mar 2023 10:41:23 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCHv2 1/4] gdb: more debug output for displaced stepping Content-Language: fr To: Pedro Alves , Andrew Burgess , gdb-patches@sourceware.org References: <09efdbfc7f9f0bf0402c222237c85f837b011082.1678984664.git.aburgess@redhat.com> <15ad53ba-53f0-f26e-8019-f5a543e0beea@palves.net> From: Simon Marchi In-Reply-To: <15ad53ba-53f0-f26e-8019-f5a543e0beea@palves.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 3/21/23 08:29, Pedro Alves wrote: > On 2023-03-16 4:39 p.m., Andrew Burgess via Gdb-patches wrote: >> While investigating a displaced stepping issue I wanted an easy way to >> see what GDB thought the original instruction was, and what >> instruction GDB replaced that with when performing the displaced step. >> >> We do print out the address that is being stepped, so I can track down >> the original instruction. >> >> And we do print out the bytes of the new instruction, so I can figure >> out what the replacement instruction was, but it's not really easy. >> >> In this commit, within displaced_step_buffers::prepare, I add new >> debug output which disassembles both the original instruction, and the >> replacement instruction, and prints both these instructions, along >> with the bytes that make these instructions, to the debug output. >> >> This new debug improved on some debug that was already present in >> infrun.c, however, the old infrun.c debug (a) didn't actually >> disassemble the instruction, it just printed the bytes, and (b) there >> was an assumption that all instructions are 4-bytes long, which >> clearly isn't correct. >> >> I think it makes more sense to have all this debug in the >> displaced-stepping.c file, so I've removed the infrun.c code, and >> added my new debug in displaced-stepping.c. > > A downside of that move is that AMD GPUs (amd-dbgapi-target.c) actually support > displaced stepping (though that part of the port hasn't been upstreamed yet), but > we don't use displaced_step_buffers there. So we'll be losing the debug output > in that target. Adding Simon who may want to look into that. I think that given the current code base in master, Andrew's change makes sense. I like that we get rid of the complex condition in resume_1 (to know when to print debug output), since the debug print is now placed in the code path where the displaced step is actually prepared. But perhaps the same can be achieved by placing the prints in displaced_step_prepare_throw, and everyone is happy? Simon