Message ID | 86pocc3oam.fsf@gmail.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 19119 invoked by alias); 3 Aug 2017 11:04:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 18974 invoked by uid 89); 3 Aug 2017 11:04:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:U*amodra, Hx-languages-length:1663, H*r:sk:static. X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-it0-f66.google.com Received: from mail-it0-f66.google.com (HELO mail-it0-f66.google.com) (209.85.214.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 03 Aug 2017 11:04:53 +0000 Received: by mail-it0-f66.google.com with SMTP id t78so1035604ita.1; Thu, 03 Aug 2017 04:04:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=13ELSwY5a+sJWvy+lrIcFAQm8kWP6954V/1q1C2zyTw=; b=SZs3AE9GLtKvz6CLlpT3jx44GzFyof4jX0ULzk9WAPBK7LuP72Fz3sGCeLT+VgS/WN yhKiJzcxYE6bptE73Zfl+fEvU0RixAxqDtSoxjhwv8Beq8xEGDoYGWgJrtuiIKBXP/we ec+3SehsDWs12xWQP1pZmugkpTFwpCN9t8ccqZTcur8xYJPzIIB98idP6dlSVK1zyE9x 17PjKmKamC5ENlBs5fsVDzi0mK3fa3nuJpcM4O35JqI6H/x7zv0xx2YAQoy5pj6XOtwq 9Wy9t5Zoaw/tD/c1zol/c8O23lbCY5aDvTYWLbiCwS9TOg+CHfzaJRGoI6SkgMIhustI JtQA== X-Gm-Message-State: AIVw113T7AhG8+Z90aKLL9BDrazHUjz4qmoK2U2q/zR8tOofc6cUg/bL mAcrbiJvFj/68Q== X-Received: by 10.36.244.3 with SMTP id d3mr1351272iti.62.1501758292033; Thu, 03 Aug 2017 04:04:52 -0700 (PDT) Received: from E107787-LIN (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id 71sm11701042iog.52.2017.08.03.04.04.50 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 04:04:51 -0700 (PDT) From: Yao Qi <qiyaoltc@gmail.com> To: "Maciej W. Rozycki" <macro@imgtec.com> Cc: <binutils@sourceware.org>, <gdb-patches@sourceware.org>, Alan Modra <amodra@gmail.com> Subject: Re: [PATCH] GDB/opcodes: Remove arch/mach/endian disassembler assertions References: <alpine.DEB.2.00.1708010044560.29991@tp.orcam.me.uk> Date: Thu, 03 Aug 2017 12:04:33 +0100 In-Reply-To: <alpine.DEB.2.00.1708010044560.29991@tp.orcam.me.uk> (Maciej W. Rozycki's message of "Tue, 1 Aug 2017 17:39:33 +0100") Message-ID: <86pocc3oam.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes |
Commit Message
Yao Qi
Aug. 3, 2017, 11:04 a.m. UTC
"Maciej W. Rozycki" <macro@imgtec.com> writes: Hi Maciej, > @@ -971,13 +971,6 @@ default_print_insn (bfd_vma memaddr, dis > { > disassembler_ftype disassemble_fn; > > - if (exec_bfd != NULL) > - { > - gdb_assert (info->arch == bfd_get_arch (exec_bfd)); > - gdb_assert (info->endian == (bfd_big_endian (exec_bfd) > - ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE)); > - gdb_assert (info->mach == bfd_get_mach (exec_bfd)); > - } > disassemble_fn = disassembler (info->arch, info->endian == BFD_ENDIAN_BIG, > info->mach, exec_bfd); I prefer to keep these asserts, as they could check the inconsistent uses of disassemble_info between gdb and opcodes. There is another assert for target armv5te, PR 21818, but the assert exposes an improper or unexpected usage of disassemble_info.mach in opcodes/arm-dis.c. I am fixing it. If these asserts make few sense to mips, gdb_print_insn_mips doesn't have to call default_print_insn. You can just do this at the end of gdb_print_insn_mips,
Comments
On Thu, 3 Aug 2017, Yao Qi wrote: > I prefer to keep these asserts, as they could check the inconsistent > uses of disassemble_info between gdb and opcodes. There is another > assert for target armv5te, PR 21818, but the assert exposes an improper > or unexpected usage of disassemble_info.mach in opcodes/arm-dis.c. I am > fixing it. How does the retaining of these assertions interact with `set architecture' and `set endian' then? Maciej
On Thu, 3 Aug 2017, Maciej W. Rozycki wrote: > > I prefer to keep these asserts, as they could check the inconsistent > > uses of disassemble_info between gdb and opcodes. There is another > > assert for target armv5te, PR 21818, but the assert exposes an improper > > or unexpected usage of disassemble_info.mach in opcodes/arm-dis.c. I am > > fixing it. > > How does the retaining of these assertions interact with `set > architecture' and `set endian' then? E.g.: $ x86_64-linux-gnu-gdb GNU gdb (GDB) 8.0.50.20170729-git Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word". (gdb) file main86 Reading symbols from main86...(no debugging symbols found)...done. (gdb) show architecture The target architecture is set automatically (currently i386:x86-64) (gdb) disassemble main Dump of assembler code for function main: 0x0000000000400450 <+0>: xor %eax,%eax 0x0000000000400452 <+2>: retq End of assembler dump. (gdb) set architecture i386 The target architecture is assumed to be i386 (gdb) disassemble main Dump of assembler code for function main: 0x00400450 <+0>: .../gdb/arch-utils.c:979: internal-error: int default_print_insn(bfd_vma, disassemble_info*): Assertion `info->mach == bfd_get_mach (exec_bfd)' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) n This is a bug, please report it. For instructions, see: <http://www.gnu.org/software/gdb/bugs/>. .../gdb/arch-utils.c:979: internal-error: int default_print_insn(bfd_vma, disassemble_info*): Assertion `info->mach == bfd_get_mach (exec_bfd)' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? (y or n) n Command aborted. (gdb) A change applied to the MIPS backend obviously won't do anything here. Maciej
"Maciej W. Rozycki" <macro@imgtec.com> writes: > (gdb) set architecture i386 > The target architecture is assumed to be i386 > (gdb) disassemble main > Dump of assembler code for function main: > 0x00400450 <+0>: > .../gdb/arch-utils.c:979: internal-error: int default_print_insn(bfd_vma, disassemble_info*): Assertion `info->mach == bfd_get_mach (exec_bfd)' failed. > A problem internal to GDB has been detected, > further debugging may prove unreliable. > Quit this debugging session? (y or n) n I didn't notice this example in your email. The gdb patch is good to me.
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index c1800e4..8ab7886 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -7025,7 +7025,13 @@ gdb_print_insn_mips (bfd_vma memaddr, struct disassemble_info *info) register naming conventions specified by the user. */ info->disassembler_options = "gpr-names=32"; - return default_print_insn (memaddr, info); + disassembler_ftype disassemble_fn; + + disassemble_fn = disassembler (info->arch, info->endian == BFD_ENDIAN_BIG, + info->mach, exec_bfd); + + gdb_assert (disassemble_fn != NULL); + return (*disassemble_fn) (memaddr, info); } static int