From patchwork Mon Aug 7 14:36:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 21948 Received: (qmail 4149 invoked by alias); 7 Aug 2017 14:36:29 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 3687 invoked by uid 89); 7 Aug 2017 14:36:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.1 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:sk:static. X-HELO: mail-it0-f50.google.com Received: from mail-it0-f50.google.com (HELO mail-it0-f50.google.com) (209.85.214.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Aug 2017 14:36:23 +0000 Received: by mail-it0-f50.google.com with SMTP id 76so4435758ith.0 for ; Mon, 07 Aug 2017 07:36:23 -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:date:message-id; bh=zKTjhguEKBY5F1EZgNRIXYHXIqYC2Hzjrs7nRm8yagI=; b=Hm3zyrpCmaoaEAJ+TeukpAylecuLIPKrNPp9FhpzWNXB+v5HcQc3aL1uxByRTzVbFY j+j70tEgCZ3OcgZQ2mmkt3H7c0QCwCQDAjgE8QmQtmjpQhsa55V9ja4YWLz07uA2MHBp pFgUdawYokilVN7T3v1jRF2wp07RnKc9Ruj1KU0GpRuAtamFkFDZjQjSdU/cAva3cqQr Os59FftUKoeD47DU6nr78Vup4cIGORN5nJVj1a3GVIjttQXiK5BL2zsJws9m4NWDIMG9 ezM1GyRzlZdRrmi2x32pa+srVtu5i0XJU3e1n+yFgvqcdZJ7HsnH7UdQNetH3MxhXGMT 9DTw== X-Gm-Message-State: AIVw111k69tbrkbAaeCRllTfBVwYa4wrtGbezFc7LztBNaHXutXXIhJ8 HVE7+tN3dVXNL2F1 X-Received: by 10.36.167.12 with SMTP id a12mr1253657itf.91.1502116581644; Mon, 07 Aug 2017 07:36:21 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id z7sm3819224iof.64.2017.08.07.07.36.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 07:36:21 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Cc: b7.10110111@gmail.com Subject: [PATCH] [ARM] Mark USER_SPECIFIED_MACHINE_TYPE in disassemble_info.flags Date: Mon, 7 Aug 2017 15:36:12 +0100 Message-Id: <1502116572-24425-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes opcodes/arm-dis.c:print_insn may update disassemble_info.mach to bfd_mach_arm_unknown unless USER_SPECIFIED_MACHINE_TYPE is marked. When default_print_insn is called for the first time, disassemble_info.mach is correctly set in GDB, but arm-dis.c:print_insn sets it to bfd_mach_arm_unknown. Then, when default_print_insn is called again (in a loop), it triggers the assert. The patch fixes the assert by marking USER_SPECIFIED_MACHINE_TYPE so that opcodes won't reset disassemble_info.mach. gdb: 2017-08-03 Yao Qi PR tdep/21818 * arm-tdep.c (gdb_print_insn_arm): Mark USER_SPECIFIED_MACHINE_TYPE if exec_bfd isn't NULL. --- gdb/arm-tdep.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 9943324..eceab55 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -7773,6 +7773,14 @@ gdb_print_insn_arm (bfd_vma memaddr, disassemble_info *info) else info->symbols = NULL; + /* GDB is able to get bfd_mach from the exe_bfd, info->mach is + accurate, so mark USER_SPECIFIED_MACHINE_TYPE bit. Otherwise, + opcodes/arm-dis.c:print_insn reset info->mach, and it will trigger + the assert on the mismatch of info->mach and bfd_get_mach (exec_bfd) + in default_print_insn. */ + if (exec_bfd != NULL) + info->flags |= USER_SPECIFIED_MACHINE_TYPE; + return default_print_insn (memaddr, info); }