From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53142 invoked by alias); 16 Jan 2017 10:03:25 -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 53052 invoked by uid 89); 16 Jan 2017 10:03:22 -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,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=nowadays, switched, thrown, armtdepc 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; Mon, 16 Jan 2017 10:03:11 +0000 Received: by mail-pg0-f65.google.com with SMTP id 75so5045313pgf.3 for ; Mon, 16 Jan 2017 02:03:11 -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=GWpldZ8OL96+kP5QBipzJ8o9mEfLyzo8YPzn/Vh3kbE=; b=fDT5fb5Nv6Wh5Z6uBRk8n6uflUZ59it3m1YlOXAtUS+Uivz3e5NGfhJxlNYAoSUtOt RLDRaDI4xX9xM4mG7FO/lV6BRGlwCU4lFb4oSAaSDcobYEykTq0a3vmNvyhAArv4RoKn ZBjwNYpTvd/wSKqsYu+7pVJUeq1bQqQDG+rgrtvHo4YNnUanfuaQgyKXOAEFVFwG8oyv 0HYb9+t0lHsMbSGCar9xZqJ0+itPmWfvCFdj0BaddbZbMiauN1jowsIGE2bebEYi84k6 bB2jhNX3c2U8iocs/MqjsFJe2O92gCEyctjjIR9iZgkzYo1iIbvKjM4DpW3hPrvZWQo1 wIwQ== X-Gm-Message-State: AIkVDXJ+tradpKw77xpkwkgGicSJ37ffY2aQBe0a6HTLMEvWiVf4gS715x1/TXs09MyXVA== X-Received: by 10.84.218.11 with SMTP id q11mr49312843pli.138.1484560990072; Mon, 16 Jan 2017 02:03:10 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id g28sm9695206pgn.3.2017.01.16.02.03.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Jan 2017 02:03:09 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 0/6 v2] Handle memory error on disassemble Date: Mon, 16 Jan 2017 10:03:00 -0000 Message-Id: <1484560977-8693-1-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 X-SW-Source: 2017-01/txt/msg00288.txt.bz2 Hi, Nowadays, we can set function pointer disassemble_info.memory_error_func to throw error or exception when disassembler gets an error, and the caller can/may catch the exception. Both gdb and objdump use this interface for many years. After GDB is switched to C++, this stops working due to the "foreign frame" from opcodes. That is to say, a C++ program calls a C function (print_insn_XXX from opcodes) and this function calls a C++ code which throws exception. DW2 C++ exception unwinder can unwind across the C function frame, unless the C code is compiled with -fexceptions. As a result, GDB aborts on memory error during disassembly on some hosts. This is the V2 of the patch series, and V1 can be found https://sourceware.org/ml/gdb-patches/2017-01/msg00146.html All opcodes patches are already committed, and V2 addressed all the comments from the review. Patch 1 and 2 are refactor patch. Patch 4 and 5 add unit tests to disassembly. Patch 6 fixes PR 20939 by stopping throwing exception in disassemble_info.memory_error_func from gdb, but record the failed memory address. Exception is thrown when it is returned from opcodes function and return value is -1. Note that PR 20939 needs to be fixed on GDB 7.12 branch, which still can be built as a C program, so I need to rewrite the patch using C for 7.12 branch in next step. Tested gdb for {x86_64, aarch64}-linux. Yao Qi (6): New function null_stream Refactor disassembly code Call print_insn_mep in mep_gdb_print_insn Disassembly unit test: disassemble one instruction Disassembly unit test: memory error Don't throw exception in dis_asm_memory_error gdb/Makefile.in | 5 + gdb/arm-tdep.c | 5 +- gdb/disasm-selftests.c | 221 ++++++++++++++++++++++++ gdb/disasm.c | 177 ++++++++++--------- gdb/disasm.h | 54 ++++-- gdb/guile/scm-disasm.c | 77 +++------ gdb/mep-tdep.c | 10 +- gdb/mips-tdep.c | 5 +- gdb/record-btrace.c | 5 +- gdb/selftest-arch.c | 103 +++++++++++ gdb/selftest-arch.h | 26 +++ gdb/spu-tdep.c | 20 +-- gdb/testsuite/gdb.base/all-architectures.exp.in | 3 + gdb/utils.c | 13 ++ gdb/utils.h | 4 + 15 files changed, 551 insertions(+), 177 deletions(-) create mode 100644 gdb/disasm-selftests.c create mode 100644 gdb/selftest-arch.c create mode 100644 gdb/selftest-arch.h -- 1.9.1