From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id BgJFIv7O619CcwAAWB0awg (envelope-from ) for ; Tue, 29 Dec 2020 19:51:10 -0500 Received: by simark.ca (Postfix, from userid 112) id 7D5171F0AA; Tue, 29 Dec 2020 19:51:10 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [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 EB44B1E99A for ; Tue, 29 Dec 2020 19:51:06 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 65B693858022; Wed, 30 Dec 2020 00:51:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 65B693858022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1609289466; bh=JOvgNaVJEa/aUpiE9/feJs6Gr86kLUhzY0gInFQj2Dk=; 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=Vk4nTY3H3AdOhTrD5HZI9u1HvckoXOzdBZyt78R8TLP1D6Rd28IVDcK2lYlMvs1Vx Q0b1SYMLkphT8KOtGv3m6Jf5xc0oDb4tyW3BGUVsigc2TUxxx7GO9rzCnYoSBfqqep vnbqnatgMik78uIBvShSZSYx5rt4LOhcVZH3VKAU= Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by sourceware.org (Postfix) with ESMTPS id 433A63858022 for ; Wed, 30 Dec 2020 00:51:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 433A63858022 Received: by mail-qk1-x72f.google.com with SMTP id c7so12883966qke.1 for ; Tue, 29 Dec 2020 16:51:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=JOvgNaVJEa/aUpiE9/feJs6Gr86kLUhzY0gInFQj2Dk=; b=afvzNAZV+u3zt44mSqUOrOgrFJRgDo9KqGmBZyk0o9qR2HaQIZw0Kdc1OKuFjqF3RE UT9UnTWirAvPSvURyltCMUcU1FLHkpo0PyhcYJXzvPaG87xvhDL96hLF9NZzlf0oSxr8 +LSzNSXLDvrrTENZEG1Tp0M7FDGgLh0Yshbi+tdeRuheXBqXGTChBHqWMlh/LvX5eZjG L97D7uI/jJCSm4YQP6i2l3UhjGCFk8A3BzU/eh/JUksdr8T9OIabSLiZPKf72xllxGoY ALnsyy0CD4CdCKuIgpAKieUv5V+50k2qB9Ej3rmzeBvQUiRfM91/d9JL8WCisRTcXlFa reJw== X-Gm-Message-State: AOAM5306ZssaVQTbYaZG85OSUjV7Hr7as1ndRxfwxuJN8q/Nz1eHJf9K pFjWRRcOfaR8OaF42XY4o0S+iA== X-Google-Smtp-Source: ABdhPJwlUYEfdRrDXgaYy+8jYBVUQhRhkZ12HuRA7OpltXhQMMjU5Bp2RLEY2isfwIjLKUG2hYtIbg== X-Received: by 2002:a37:86c2:: with SMTP id i185mr29998782qkd.477.1609289460690; Tue, 29 Dec 2020 16:51:00 -0800 (PST) Received: from ?IPv6:2804:7f0:8284:370e:891:588d:2ac2:dc7e? ([2804:7f0:8284:370e:891:588d:2ac2:dc7e]) by smtp.gmail.com with ESMTPSA id x20sm26854297qkj.18.2020.12.29.16.50.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Dec 2020 16:51:00 -0800 (PST) Subject: Re: [PATCH v3 16/24] AArch64: Report tag violation error information To: Simon Marchi , gdb-patches@sourceware.org References: <20201109170435.15766-1-luis.machado@linaro.org> <20201109170435.15766-17-luis.machado@linaro.org> <1100c41a-bf9d-a683-a7a8-01f033c93080@polymtl.ca> Message-ID: <1a0e5518-4f3f-f8ce-437c-c318d70a6c57@linaro.org> Date: Tue, 29 Dec 2020 21:50:56 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1100c41a-bf9d-a683-a7a8-01f033c93080@polymtl.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Luis Machado via Gdb-patches Reply-To: Luis Machado Cc: david.spickett@linaro.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 12/26/20 7:23 PM, Simon Marchi wrote: > > > 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? > I've attached it to the commit message. The synchronous event looks like this: -- (gdb) continue Continuing. Program received signal SIGSEGV, Segmentation fault Memory tag violation while accessing address 0x0000fffff7ff8000 Allocation tag 0x1. -- The asynchronous event looks like this: -- (gdb) continue Continuing. Program received signal SIGSEGV, Segmentation fault Memory tag violation Fault address unavailable. -- >> >> 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? > No. Fixed now. >> + >> + 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? > I went with printing the exception with... exception_print (gdb_stderr, exception); > Simon >