From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27853 invoked by alias); 1 Feb 2007 00:23:06 -0000 Received: (qmail 27841 invoked by uid 22791); 1 Feb 2007 00:23:05 -0000 X-Spam-Check-By: sourceware.org Received: from igw2.br.ibm.com (HELO igw2.br.ibm.com) (32.104.18.25) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 01 Feb 2007 00:22:59 +0000 Received: from mailhub1.br.ibm.com (mailhub1 [9.18.232.109]) by igw2.br.ibm.com (Postfix) with ESMTP id BC1825BDF1 for ; Wed, 31 Jan 2007 22:19:11 -0200 (BRST) Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.18.232.47]) by mailhub1.br.ibm.com (8.13.8/8.13.8/NCO v8.2) with ESMTP id l110MrLd1536052 for ; Wed, 31 Jan 2007 22:22:53 -0200 Received: from d24av02.br.ibm.com (loopback [127.0.0.1]) by d24av02.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l110Lnuf002772 for ; Wed, 31 Jan 2007 22:21:49 -0200 Received: from dyn650970.br.ibm.com (dyn650970.br.ibm.com [9.18.226.94]) by d24av02.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id l110LnGs002769 for ; Wed, 31 Jan 2007 22:21:49 -0200 Subject: (not) disassembling power[456] instructions in GDB From: Thiago Jung Bauermann To: gdb-patches Content-Type: multipart/mixed; boundary="=-njNq+TFjk7u2013GQH/v" Date: Thu, 01 Feb 2007 00:23:00 -0000 Message-Id: <1170289373.26944.45.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 X-IsSubscribed: yes 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 X-SW-Source: 2007-02/txt/msg00000.txt.bz2 --=-njNq+TFjk7u2013GQH/v Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 2291 Hi, I found out that GDB is not currently disassembling instructions which are available on power4, power5 or power6 processors even though it has support to do so. GDB copies the disassembler code from binutils, which provides a -M option to let the user specify the dialect to be used, but the problem is that GDB itself doesn't provide a command or option to let the user specify the dialect. The result is that the powerpc_dialect() function in ppc-dis.c will always return the same value, which doesn't include any of the PPC_OPCODE_POWER[456] flags. Example: (gdb) disassemble main Dump of assembler code for function main: 0x1000046c : stwu r1,-48(r1) 0x10000470 : stw r31,44(r1) 0x10000474 : mr r31,r1 0x10000478 : stw r3,24(r31) 0x1000047c : stw r4,28(r31) 0x10000480 : li r0,4 0x10000484 : stw r0,8(r31) 0x10000488 : .long 0x7c284fec 0x1000048c : .long 0xed405834 0x10000490 : lwz r11,0(r1) 0x10000494 : lwz r31,-4(r11) 0x10000498 : mr r1,r11 0x1000049c : blr End of assembler dump. (gdb) In the output above, ".long 0x7c284fec" is an instruction available only in power4 or later processors (dcbzl), and ".long 0xed405834" is available only in power5 or later (frsqrtes). The attached patch makes GDB always use the -Many option of the disassembler, which will make it disassemble every instruction it understands. Here's the output with the patch applied: (gdb) disassemble main Dump of assembler code for function main: 0x1000046c : stwu r1,-48(r1) 0x10000470 : stw r31,44(r1) 0x10000474 : mr r31,r1 0x10000478 : stw r3,24(r31) 0x1000047c : stw r4,28(r31) 0x10000480 : li r0,4 0x10000484 : stw r0,8(r31) 0x10000488 : dcbzl r8,r9 0x1000048c : frsqrtes f10,f11 0x10000490 : lwz r11,0(r1) 0x10000494 : lwz r31,-4(r11) 0x10000498 : mr r1,r11 0x1000049c : blr End of assembler dump. (gdb) Comments? Can this patch be applied? -- []'s Thiago Jung Bauermann Software Engineer IBM Linux Technology Center --=-njNq+TFjk7u2013GQH/v Content-Disposition: attachment; filename=ppc-disassemble-any.diff Content-Type: text/x-patch; name=ppc-disassemble-any.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 440 --- rs6000-tdep.c.orig 2007-01-31 21:10:19.000000000 -0200 +++ rs6000-tdep.c 2007-01-31 21:10:22.000000000 -0200 @@ -2904,6 +2904,9 @@ find_variant_by_arch (enum bfd_architect static int gdb_print_insn_powerpc (bfd_vma memaddr, disassemble_info *info) { + if (!info->disassembler_options) + info->disassembler_options = "any"; + if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) return print_insn_big_powerpc (memaddr, info); else --=-njNq+TFjk7u2013GQH/v Content-Disposition: attachment; filename=ChangeLog Content-Type: text/x-changelog; name=ChangeLog; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 157 2007-01-31 Thiago Jung Bauermann * rs6000-tdep.c (gdb_print_insn_powerpc): ensure info->disassembler_options has the "any" value. --=-njNq+TFjk7u2013GQH/v--