From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UDpsGOi351/CBAAAWB0awg (envelope-from ) for ; Sat, 26 Dec 2020 17:23:36 -0500 Received: by simark.ca (Postfix, from userid 112) id 622DC1F0AA; Sat, 26 Dec 2020 17:23:36 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 60DD91E590 for ; Sat, 26 Dec 2020 17:23:35 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 61FB0384C005; Sat, 26 Dec 2020 22:23:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61FB0384C005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1609021414; bh=+afFaC1KkH6rm4WXkaR8GCbiymWClCwOuka4DbQDu94=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=fOXvg0cMohUJlvuOlARmwDvUuiPWi1AMJIzT6bYPlAJRFwPBgwnOjLxDgBMPFdk88 3BWTPOkvasH3SltJ63LL+5TfSUFT6yRSbBSHOaoN63STJxSva23WXHk8+b1EUy6TAH p6Qn+luPFJBM0558cE1BYrwek+J7lPi4k2ao8JrY= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 3DFB73864877 for ; Sat, 26 Dec 2020 22:23:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3DFB73864877 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 0BQMNPZN016702 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 26 Dec 2020 17:23:30 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 0BQMNPZN016702 Received: from [10.0.0.213] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id E0DF51E590; Sat, 26 Dec 2020 17:23:24 -0500 (EST) Subject: Re: [PATCH v3 16/24] AArch64: Report tag violation error information To: Luis Machado , gdb-patches@sourceware.org References: <20201109170435.15766-1-luis.machado@linaro.org> <20201109170435.15766-17-luis.machado@linaro.org> Message-ID: <1100c41a-bf9d-a683-a7a8-01f033c93080@polymtl.ca> Date: Sat, 26 Dec 2020 17:23:24 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20201109170435.15766-17-luis.machado@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sat, 26 Dec 2020 22:23:25 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: david.spickett@linaro.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2020-11-09 12:04 p.m., Luis Machado via Gdb-patches wrote: > Whenever a memory tag violation occurs, we get a SIGSEGV. Additional > information can be obtained through the siginfo data structure. > > For AArch64 the Linux kernel may expose the fault address and tag > information, if we have a synchronous event. Otherwise there is > no fault address available. Can you give an example of the end result message? > > gdb/ChangeLog: > > YYYY-MM-DD Luis Machado > > * aarch64-linux-tdep.c > (aarch64_linux_report_signal_info): New function. > (aarch64_linux_init_abi): Register > aarch64_linux_report_signal_info as the report_signal_info hook. > * arch/aarch64-linux.h (SEGV_MTEAERR): Define. > (SEGV_MTESERR): Define. > --- > gdb/aarch64-linux-tdep.c | 64 ++++++++++++++++++++++++++++++++++++ > gdb/arch/aarch64-mte-linux.h | 6 ++++ > 2 files changed, 70 insertions(+) > > diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c > index 39b1790263..70e180e1cb 100644 > --- a/gdb/aarch64-linux-tdep.c > +++ b/gdb/aarch64-linux-tdep.c > @@ -1626,6 +1626,67 @@ aarch64_linux_memtag_to_string (struct gdbarch *gdbarch, > return string_printf ("0x%s", phex_nz (tag, sizeof (tag))); > } > > +/* AArch64 Linux implementation of the report_signal_info gdbarch > + hook. Displays information about possible memory tag violations. */ > + > +static void > +aarch64_linux_report_signal_info (struct gdbarch *gdbarch, > + struct ui_out *uiout, > + enum gdb_signal siggnal) > +{ > + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); > + > + if (!tdep->has_mte () || siggnal != GDB_SIGNAL_SEGV) > + return; > + > + CORE_ADDR fault_addr = 0; > + long si_code = 0; > + > + try > + { > + /* Sigcode tells us if the segfault is actually a memory tag > + violation. */ > + si_code = parse_and_eval_long ("$_siginfo.si_code\n"); Is the \n necessary? > + > + fault_addr > + = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr"); > + } > + catch (const gdb_exception &exception) > + { > + return; > + } I think it's better to catch gdb_exception_error, to avoid catching ^C (gdb_exception_quit). And if there's an error doing the evaluation... do we want to print a warning of some sort? Simon