From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oOGZNAzIHGCeFAAAWB0awg (envelope-from ) for ; Thu, 04 Feb 2021 23:22:36 -0500 Received: by simark.ca (Postfix, from userid 112) id D58F91EFCB; Thu, 4 Feb 2021 23:22: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 237B71E945 for ; Thu, 4 Feb 2021 23:22:36 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 740A1393FC29; Fri, 5 Feb 2021 04:22:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 740A1393FC29 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1612498955; bh=3eGmtUIdC3k8V7UHjuqElQ+GgTgU/lhZBDiWkXXohEg=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=y2MjPzrV2+X0mduDscEKAbsoUOQNJ7FjZ6cc0oxGk9z33ZJhHjMeJ5lfBpMD45fZS Ix7Q4BZFdr3VermNOHB3+dr36aM4i6K07qTnN4U37dVPX+R0Xxf2p/EI1vNyG6kFIF TKx6KUZXC6uPJ4V7VXmnGVIykHYUaR5RrqyBdPTQ= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id E4F80393FC29 for ; Fri, 5 Feb 2021 04:22:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E4F80393FC29 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 1154MQZM005339 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 4 Feb 2021 23:22:31 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 1154MQZM005339 Received: from [10.0.0.11] (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)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id BD0B31E945; Thu, 4 Feb 2021 23:22:26 -0500 (EST) Subject: Re: [PATCH v5 17/25] AArch64: Report tag violation error information To: Luis Machado , gdb-patches@sourceware.org References: <20210127202112.2485702-1-luis.machado@linaro.org> <20210127202112.2485702-18-luis.machado@linaro.org> Message-ID: <1bd853e9-00ce-9856-7bd6-f5ab0af88475@polymtl.ca> Date: Thu, 4 Feb 2021 23:22:26 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210127202112.2485702-18-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 Fri, 5 Feb 2021 04:22:27 +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 Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" > diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c > index 1063dd7a82..4ccee9c34e 100644 > --- a/gdb/aarch64-linux-tdep.c > +++ b/gdb/aarch64-linux-tdep.c > @@ -1700,6 +1700,69 @@ 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"); > + > + fault_addr > + = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr"); > + } > + catch (const gdb_exception_error &exception) > + { > + exception_print (gdb_stderr, exception); > + return; > + } > + > + /* If this is not a memory tag violation, just return. */ > + if (si_code != SEGV_MTEAERR && si_code != SEGV_MTESERR) > + return; > + > + uiout->text ("\n"); > + > + uiout->field_string ("sigcode-meaning", _("Memory tag violation")); > + > + /* For synchronous faults, show additional information. */ > + if (si_code == SEGV_MTESERR) > + { > + uiout->text (_(" while accessing address ")); > + uiout->field_core_addr ("fault-addr", gdbarch, fault_addr); > + uiout->text ("\n"); I guess there's no easy way of getting the logical address that was used to attempt the memory access? I think it would be nice to say something like "Your pointer had logical tag X, but the pointed memory has allocation tag Y". But if we can't, we can't. > + > + gdb::optional atag = aarch64_mte_get_atag (fault_addr); > + > + if (!atag.has_value ()) > + uiout->text (_("Allocation tag unavailable")); > + else > + { > + uiout->text (_("Allocation tag ")); > + uiout->field_string ("allocation-tag", hex_string (*atag)); > + } > + } > + else > + { > + uiout->text ("\n"); > + uiout->text (_("Fault address unavailable")); > + } > +} I guess all of the `uiout->field_*` will appear as the stop event in MI? I suppose that's fine, but we need to be careful to treat it as API and not change it in a backwards-incompatible way. Can you give it a try with MI to see the result, see if it makes sense (if you haven't already)? And if this indeed adds new MI fields, they should be documented, in theory. Although I realize that there are equivalent fields in i386-linux-tdep.c and sparc64-linux-tdep.c which aren't. But otherwise, that LGTM. Simon