From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119265 invoked by alias); 9 Dec 2016 17:02:16 -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 119223 invoked by uid 89); 9 Dec 2016 17:02:14 -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=Hx-spam-relays-external:74.125.83.65, H*RU:74.125.83.65, H*MI:9477 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-pg0-f65.google.com Received: from mail-pg0-f65.google.com (HELO mail-pg0-f65.google.com) (74.125.83.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 Dec 2016 17:02:12 +0000 Received: by mail-pg0-f65.google.com with SMTP id e9so2822227pgc.1; Fri, 09 Dec 2016 09:02:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jELjBHqO5d5g5mCaMKIwP9XPBcR5H81o3diD3HpwZYo=; b=QgTpqabWseWaYlHLx/4ypiTRgUZKm10bNdTubHQRIcJZkwJxuNUOoja/Daj0dy4DTJ RToFQVirT2lIUD0zowwZoukIRuYTN3Cky1qsU7aKLURk0UcjZG4HZHkvyBGyIZkDgjaA qt305+4Xj+Gj6WKLW9K6fNt9mACWNDAvoMA/8uptyNLW6CvsukMt3ktVvfwkqBkZlWN9 xcddF8LNVehEMwjBa3M+CIYPHsAlImiRYLEqndptFhEhqzoKGr24ttdDLl7XGjl1/qx6 FRnfY02zf7dP/c2uBfZWuedlLKREblj7ZmHc9PXkUIXLu2JXAb+Nr+sNK2Y6Ga5IUBNG vT/A== X-Gm-Message-State: AKaTC01sMA8APARiQIESPE9li94OY3UKwIE8l97/sIXqxFg+mH+oJNbzizVeaV/UVmtoMA== X-Received: by 10.98.3.7 with SMTP id 7mr85820430pfd.9.1481302931102; Fri, 09 Dec 2016 09:02:11 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id f23sm58842987pff.59.2016.12.09.09.02.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Dec 2016 09:02:10 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: binutils@sourceware.org Cc: gdb-patches@sourceware.org Subject: [PATCH] Handle memory error in print_insn_rx Date: Fri, 09 Dec 2016 17:02:00 -0000 Message-Id: <1481302917-9477-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes X-SW-Source: 2016-12/txt/msg00250.txt.bz2 Nowadays, memory error in rx disassembly is not handled, so if I start a fresh GDB, and disassemble, (gdb) set architecture rx The target architecture is assumed to be rx (gdb) disassemble 0x0,+4 Dump of assembler code from 0x0 to 0x4: 0x00000000: brk 0x00000001: brk 0x00000002: brk 0x00000003: brk the output is wrong. This patch adds code to call dis->memory_error_func on memory error, and longjmp to print_insn_rx. With this patch applied, (gdb) set architecture rx The target architecture is assumed to be rx (gdb) disassemble 0,+4 Dump of assembler code from 0x0 to 0x4: 0x00000000: Cannot access memory at address 0x0 Regression tested with all targets enabled. Is it OK? opcodes: 2016-12-09 Yao Qi * rx-dis.c: Include (struct private): New. (rx_get_byte): Check return value of read_memory_func, and call memory_error_func and OPCODES_SIGLONGJMP on error. (print_insn_rx): Call OPCODES_SIGSETJMP. --- opcodes/rx-dis.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/opcodes/rx-dis.c b/opcodes/rx-dis.c index b0ff4b3..5f2bf35 100644 --- a/opcodes/rx-dis.c +++ b/opcodes/rx-dis.c @@ -27,22 +27,38 @@ #include "dis-asm.h" #include "opcode/rx.h" +#include + typedef struct { bfd_vma pc; disassemble_info * dis; } RX_Data; +struct private +{ + OPCODES_SIGJMP_BUF bailout; +}; + static int rx_get_byte (void * vdata) { bfd_byte buf[1]; RX_Data *rx_data = (RX_Data *) vdata; + int status; + + status = rx_data->dis->read_memory_func (rx_data->pc, + buf, + 1, + rx_data->dis); + if (status != 0) + { + struct private *priv = (struct private *) rx_data->dis->private_data; - rx_data->dis->read_memory_func (rx_data->pc, - buf, - 1, - rx_data->dis); + rx_data->dis->memory_error_func (status, rx_data->pc, + rx_data->dis); + OPCODES_SIGLONGJMP (priv->bailout, 1); + } rx_data->pc ++; return buf[0]; @@ -92,10 +108,18 @@ print_insn_rx (bfd_vma addr, disassemble_info * dis) RX_Data rx_data; RX_Opcode_Decoded opcode; const char * s; + struct private priv; + dis->private_data = (PTR) &priv; rx_data.pc = addr; rx_data.dis = dis; + if (OPCODES_SIGSETJMP (priv.bailout) != 0) + { + /* Error return. */ + return -1; + } + rv = rx_decode_opcode (addr, &opcode, rx_get_byte, &rx_data); dis->bytes_per_line = 10; -- 1.9.1