From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 98417 invoked by alias); 17 Jan 2017 14:38:07 -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 98380 invoked by uid 89); 17 Jan 2017 14:38:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=exerror, 16348, sk:see_mem, UD:.ad2b4eb X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Jan 2017 14:37:55 +0000 Received: from svr-orw-mbx-03.mgc.mentorg.com ([147.34.90.203]) by relay1.mentorg.com with esmtp id 1cTUtV-0006iD-Uj from Luis_Gustavo@mentor.com ; Tue, 17 Jan 2017 06:37:53 -0800 Received: from [172.30.8.199] (147.34.91.1) by svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Tue, 17 Jan 2017 06:37:49 -0800 Subject: Re: [PATCH 5/6] Disassembly unit test: memory error References: <1484051178-16013-1-git-send-email-yao.qi@linaro.org> <1484560977-8693-1-git-send-email-yao.qi@linaro.org> <1484560977-8693-6-git-send-email-yao.qi@linaro.org> To: Yao Qi , Reply-To: Luis Machado From: Luis Machado Message-ID: Date: Tue, 17 Jan 2017 14:38:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1484560977-8693-6-git-send-email-yao.qi@linaro.org> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: svr-orw-mbx-02.mgc.mentorg.com (147.34.90.202) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg00325.txt.bz2 On 01/16/2017 04:02 AM, Yao Qi wrote: > This patch adds a unit test about memory error occurs on reading > memory, and check MEMORY_ERROR exception is always thrown. > > v2: > - use null_stream, > > gdb: > > 2017-01-10 Yao Qi > > * disasm-selftests.c (gdb_disassembler_memory_error_test): New function. > (_initialize_disasm_test): Register > gdb_disassembler_memory_error_test. > --- > gdb/disasm-selftests.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > > diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c > index 46a0a21..ad2b4eb 100644 > --- a/gdb/disasm-selftests.c > +++ b/gdb/disasm-selftests.c > @@ -163,6 +163,48 @@ gdb_disassembler_print_one_insn_test (struct gdbarch *gdbarch) > SELF_CHECK (di.print_insn (0) == len); > } > > +/* Test disassembly on memory error. */ > + > +static void > +gdb_disassembler_memory_error_test (struct gdbarch *gdbarch) Same comment as the other patch. Do we need to repeat the context of the test in the function name? > +{ > + class gdb_disassembler_test : public gdb_disassembler > + { > + public: > + gdb_disassembler_test (struct gdbarch *gdbarch) > + : gdb_disassembler (gdbarch, null_stream (), > + gdb_disassembler_test::read_memory) > + { > + } > + > + static int read_memory (bfd_vma memaddr, gdb_byte *myaddr, > + unsigned int len, > + struct disassemble_info *info) > + { > + /* Always get an error. */ /* Always return an error. */ Also, should we return an explicit error like TARGET_XFER_E_IO or MEMORY_ERROR? > + return -1; > + } > + }; > + > + gdb_disassembler_test di (gdbarch); > + bool see_memory_error = false; > + > + TRY > + { > + di.print_insn (0); > + } > + CATCH (ex, RETURN_MASK_ERROR) > + { > + if (ex.error == MEMORY_ERROR) > + see_memory_error = true; > + } > + END_CATCH > + > + /* Expect MEMORY_ERROR. */ Too many spaces after period. > + SELF_CHECK (see_memory_error); > + Spurious newline? > +} > + > } // namespace selftests > #endif /* GDB_SELF_TEST */ > > @@ -174,5 +216,6 @@ _initialize_disasm_test (void) > { > #if GDB_SELF_TEST > register_self_test (selftests::gdb_disassembler_print_one_insn_test); > + register_self_test (selftests::gdb_disassembler_memory_error_test); > #endif > } > Otherwise OK.