From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 798 invoked by alias); 17 Apr 2014 01:09:59 -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 767 invoked by uid 89); 17 Apr 2014 01:09:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Apr 2014 01:09:53 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1Waapp-0005GD-GA from Yao_Qi@mentor.com ; Wed, 16 Apr 2014 18:09:49 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 16 Apr 2014 18:09:49 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.2.247.3; Wed, 16 Apr 2014 18:08:33 -0700 Message-ID: <534F294D.4050907@codesourcery.com> Date: Thu, 17 Apr 2014 01:09:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Daniel Gutson , gdb-patches Subject: Re: [PATCH] Fix alignment of disassemble /r References: In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2014-04/txt/msg00337.txt.bz2 On 04/12/2014 06:24 AM, Daniel Gutson wrote: > when disassembling in raw mode (/r) in a variable-length insn > architecture (i.e. x86), > the output can be completely messed since no alignment takes place. The /r output is messed, but not completely :). > > I am aware of the uiout->table stuff, but it seems an overkill since I > should change > the current_uiout when disassembling in this mode (and I didn't find > any actual use of this > machinery at least for x86). > Therefore, I added a hack in the dump_insns when the /r flag is specified. > This clearly isn't the cutiest thing in the world, and I specified a > hardcoded maximum number > of opcode bytes to align (currently 8) though it is easily changeable. Hard-coded opcode length will affect other targets. For example, without your patch, the disassembly for c6x is like, (gdb) disassemble /r main Dump of assembler code for function main: 0x00000860 <+0>: c2 1b be 07 subah .D2 b15,16,b15 0x00000864 <+4>: f6 02 3d 07 stw .D2T2 b14,*+b15(32) with your patch applied, it becomes (gdb) disassemble /r main Dump of assembler code for function main: 0x00000860 <+0>: c2 1b be 07 subah .D2 b15,16,b15 0x00000864 <+4>: f6 02 3d 07 stw .D2T2 b14,*+b15(32) gdbarch_max_insn_length can tell us the max instruction length, but if we align the instruction to the max length (it is 16 on x86), the text instruction will be far behind the hex code, which is a little ugly. -- Yao (齐尧)