From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 527 invoked by alias); 17 Apr 2014 14:37:15 -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 518 invoked by uid 89); 17 Apr 2014 14:37:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: mail-lb0-f179.google.com Received: from mail-lb0-f179.google.com (HELO mail-lb0-f179.google.com) (209.85.217.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 17 Apr 2014 14:37:11 +0000 Received: by mail-lb0-f179.google.com with SMTP id p9so457863lbv.10 for ; Thu, 17 Apr 2014 07:37:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=QvHBHb2++/Jc0Gqpmp1hX6W8Y18EXMxJDC1dk89eq+8=; b=ge3A+UP61OojyOveCNSIL4S6jLzV8c19pyQsp7XFWtkmROgfnmDkYH5rVBuNJDaSGF zK8mqhRkPpzH8VKvTkd/WAEb1HcKvTjKevTrrV6K72Lyjj5c3hPRrFp1NTg85R7if/Y+ 3p+Leo3xt4yeCvbrAyWVf2yKakmauuoPeah3qMSBFiLg/IOtSaILdGVqy2oSdz41qsXz 0W0C+t90hXVuVwX9DJc0D3zgllXP1Zomk++NnNda8UQjyLc4nw9I5oJkLEnMo3G7D1HZ ITmSfu267TzYkRf6g2oFpyLcEDjl7BkBHr+4PwploK8iiphr1743Z54p+bjnpMkxzWQq 07lQ== X-Gm-Message-State: ALoCoQlOY2QFjZkEjtTwVSrp7YpFW/zpvE2thRVBkU5P00VceKo2l9qjq9jeuWCJE8rNRpC3rOlL MIME-Version: 1.0 X-Received: by 10.153.4.134 with SMTP id ce6mr10053207lad.21.1397745427772; Thu, 17 Apr 2014 07:37:07 -0700 (PDT) Received: by 10.112.9.40 with HTTP; Thu, 17 Apr 2014 07:37:07 -0700 (PDT) In-Reply-To: <534F294D.4050907@codesourcery.com> References: <534F294D.4050907@codesourcery.com> Date: Thu, 17 Apr 2014 14:37:00 -0000 Message-ID: Subject: Re: [PATCH] Fix alignment of disassemble /r From: Daniel Gutson To: Yao Qi Cc: gdb-patches Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2014-04/txt/msg00368.txt.bz2 On Wed, Apr 16, 2014 at 10:07 PM, Yao Qi wrote: > 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 specifie= d. >> 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. Hi Yao, thanks for answering. So what if I add a new configuration variable, such as set disassemble-raw-alignment with "off" as default, and if set to on, pad to gdbarch_max_insn_length ? > > -- > Yao (=E9=BD=90=E5=B0=A7) --=20 Daniel F. Gutson Chief Engineering Officer, SPD San Lorenzo 47, 3rd Floor, Office 5 C=C3=B3rdoba, Argentina Phone: +54 351 4217888 / +54 351 4218211 Skype: dgutson