From patchwork Tue Jan 10 12:26:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 18836 Received: (qmail 90061 invoked by alias); 10 Jan 2017 12:26:43 -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 89788 invoked by uid 89); 10 Jan 2017 12:26:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=eaten, interpret, consumed X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-pf0-f195.google.com Received: from mail-pf0-f195.google.com (HELO mail-pf0-f195.google.com) (209.85.192.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Jan 2017 12:26:38 +0000 Received: by mail-pf0-f195.google.com with SMTP id f144so9893172pfa.2; Tue, 10 Jan 2017 04:26:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=XGdlvejmLe8xf2ml/zWcDsg3UZsKiksZHDDjVnx2Ytk=; b=AgylLQNd4E+HxfZvTh//viSXxieF/CwrSZLRzU/eNkfJVYWZliYynwGUEVhU00XhDt blqV0SLhvLO4Hd1ytW/PuFO1f0y6xUQ1HImu9g1Hpt55ACHBpsaLKafbSJholjgwiq0r t+jAv8ejRpoD/Cai52JYkejQKRtMhHRmtkQo7y5qzy1T9FmzyJaHQGeFaRgtQV51pztU VF6ZysFqfgVDG2ZK5TQ3k3PQQ4xP2cXhNUtEJkstwD6CwXKGTWkQpMfRKxANfK2673Wm e2gdkgEKFqhhsLC9rvIIhhcXvOn2ESY0QVqGhPkYGCI38A9H1ia+ersbt+VliQz+3TfP 72eg== X-Gm-Message-State: AIkVDXJoFpmMXNnXDTqYqtEcntai3ogoc97Uo4UFP5f7xTVXkNU9RMbG/x7MwjsQG2oxzA== X-Received: by 10.98.62.153 with SMTP id y25mr3496569pfj.162.1484051196582; Tue, 10 Jan 2017 04:26:36 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id r26sm5450661pgd.42.2017.01.10.04.26.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Jan 2017 04:26:36 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: binutils@sourceware.org, gdb-patches@sourceware.org Subject: [PATCH 6/8] Return -1 on memory error in print_insn_m68k Date: Tue, 10 Jan 2017 12:26:16 +0000 Message-Id: <1484051178-16013-7-git-send-email-yao.qi@linaro.org> In-Reply-To: <1484051178-16013-1-git-send-email-yao.qi@linaro.org> References: <1484051178-16013-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes m68k-dis.c:print_insn_m68k doesn't return -1 on memory error, but GDB expects it returning -1 on memory error. opcodes: 2017-01-10 Yao Qi * m68k-dis.c (match_insn_m68k): Extend comments. Return -1 if FETCH_DATA returns 0. (m68k_scan_mask): Likewise. (print_insn_m68k): Update code to handle -1 return value. --- opcodes/m68k-dis.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/opcodes/m68k-dis.c b/opcodes/m68k-dis.c index 3159a47..c531e2d 100644 --- a/opcodes/m68k-dis.c +++ b/opcodes/m68k-dis.c @@ -1331,7 +1331,8 @@ print_insn_arg (const char *d, } /* Try to match the current instruction to best and if so, return the - number of bytes consumed from the instruction stream, else zero. */ + number of bytes consumed from the instruction stream, else zero. + Return -1 on memory error. */ static int match_insn_m68k (bfd_vma memaddr, @@ -1415,12 +1416,14 @@ match_insn_m68k (bfd_vma memaddr, this because we know exactly what the second word is, and we aren't going to print anything based on it. */ p = buffer + 6; - FETCH_DATA (info, p); + if (!FETCH_DATA (info, p)) + return -1; buffer[2] = buffer[4]; buffer[3] = buffer[5]; } - FETCH_DATA (info, p); + if (!FETCH_DATA (info, p)) + return -1; save_p = p; info->print_address_func = dummy_print_address; @@ -1439,7 +1442,7 @@ match_insn_m68k (bfd_vma memaddr, { info->fprintf_func = save_printer; info->print_address_func = save_print_address; - return 0; + return eaten == PRINT_INSN_ARG_MEMORY_ERROR ? -1 : 0; } else { @@ -1481,7 +1484,8 @@ match_insn_m68k (bfd_vma memaddr, /* Try to interpret the instruction at address MEMADDR as one that can execute on a processor with the features given by ARCH_MASK. If successful, print the instruction to INFO->STREAM and return - its length in bytes. Return 0 otherwise. */ + its length in bytes. Return 0 otherwise. Return -1 on memory + error. */ static int m68k_scan_mask (bfd_vma memaddr, disassemble_info *info, @@ -1523,7 +1527,8 @@ m68k_scan_mask (bfd_vma memaddr, disassemble_info *info, *opc_pointer[(m68k_opcodes[i].opcode >> 28) & 15]++ = &m68k_opcodes[i]; } - FETCH_DATA (info, buffer + 2); + if (!FETCH_DATA (info, buffer + 2)) + return -1; major_opcode = (buffer[0] >> 4) & 15; for (i = 0; i < numopcodes[major_opcode]; i++) @@ -1628,7 +1633,7 @@ print_insn_m68k (bfd_vma memaddr, disassemble_info *info) /* First try printing an m680x0 instruction. Try printing a Coldfire one if that fails. */ val = m68k_scan_mask (memaddr, info, m68k_mask); - if (val == 0) + if (val <= 0) val = m68k_scan_mask (memaddr, info, mcf_mask); } else