From patchwork Fri Jan 14 10:26:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Zissulescu Ianculescu X-Patchwork-Id: 50020 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 15FFA3853812 for ; Fri, 14 Jan 2022 10:27:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 15FFA3853812 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1642156078; bh=iOFxfA0x4XWPystJJHt4xB2cimlUbipXIn3kfpSpCxg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=FPn2CFC6I70DZG4uF2+DmO+aSHsg+gzRkQaxUxN114/ZvV4ibeTCcgTzN4w4UdcLb IJrSvUwOnBzRZfh0DCN3S8OeWbclNRQ1GNfCzeerP6VU8xPTRDfM3OwugIkTu+gZ7K arFAVzBUtyenqcPeJHNB59B8uT5/zQyDQcQlJYuM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id C92873853801 for ; Fri, 14 Jan 2022 10:26:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C92873853801 Received: by mail-ed1-x530.google.com with SMTP id u21so33273155edd.5 for ; Fri, 14 Jan 2022 02:26:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iOFxfA0x4XWPystJJHt4xB2cimlUbipXIn3kfpSpCxg=; b=g9hMElbR3okr1tw6gvlF3lgLtQEeBBNnXWueDyIbtuc3frOoKO66yTJXtdXiE/2CJ6 4eiuiO3xeuUNMk2ctPv1IoDr0NVc3upze5w9KjPp8pXVbi+V6ZIE4m6Jur+UIV7uUcM2 N+mgvLQz6WzxjVnVKMPQRphO4nJSeCkDRVyQGsXbmose2ZS9rk6Suj7nmgtmYmjTeGoL GX6otcfns76UJQXjNg8sv9xTidLH4Z1WGVN1YEw7hHBcIqA+2UcJTatwjjW9TBVcngQo DYNwDhQccBpDuW5SLxMEZPl+Dmm+gubPqJ7tHL2JpXPUATIxL2GVLGc6aMgNDzsVfMdJ 0QtQ== X-Gm-Message-State: AOAM53113fCFU2kS35e9f+cZIC9tT4K/d6Kii6pIyzWLVktA8b9uFhnF XZC2lUIntfXhTctlSPEcQxkBUGThJVY= X-Google-Smtp-Source: ABdhPJypcVqCvcTX7TCtJX98OpKQHrHmCAztERrBbBsNi9SIpd1F6gSRSFPVB8KaJm3KwJxd1cX+hQ== X-Received: by 2002:a17:906:f2c8:: with SMTP id gz8mr5467094ejb.220.1642155990527; Fri, 14 Jan 2022 02:26:30 -0800 (PST) Received: from localhost.localdomain (5-15-221-190.residential.rdsnet.ro. [5.15.221.190]) by smtp.gmail.com with ESMTPSA id f6sm1728582ejf.69.2022.01.14.02.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 02:26:30 -0800 (PST) X-Google-Original-From: Claudiu Zissulescu To: gcc-patches@gcc.gnu.org Subject: [committed] arc: Add DWARF2 alternate CFA column. Date: Fri, 14 Jan 2022 12:26:24 +0200 Message-Id: <20220114102624.179789-2-claziss@synopsys.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220114102624.179789-1-claziss@synopsys.com> References: <20220114102624.179789-1-claziss@synopsys.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Claudiu Zissulescu via Gcc-patches From: Claudiu Zissulescu Ianculescu Reply-To: Claudiu Zissulescu Cc: fbedard@synopsys.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Add DWARF 2 CFA column which tracks the return address from a signal handler context. This value must not correspond to a hard register and must be out of the range of DWARF_FRAME_REGNUM(). gcc/ * config/arc/arc.h (DWARF_FRAME_REGNUM): Update definition. (DWARF_FRAME_RETURN_COLUMN): Use RETURN_ADDR_REGNUM macro. (INCOMING_RETURN_ADDR_RTX): Likewise. (DWARF_ALT_FRAME_RETURN_COLUMN): Define. gcc/testsuite/ * gcc.target/arc/cancel-1.c: New file. libgcc/ * config/arc/linux-unwind.h (arc_fallback_frame_state): Use DWARF_ALT_FRAME_RETURN_COLUMN macro. Signed-off-by: Claudiu Zissulescu --- gcc/config/arc/arc.h | 11 ++++++--- gcc/testsuite/gcc.target/arc/cancel-1.c | 31 +++++++++++++++++++++++++ libgcc/config/arc/linux-unwind.h | 9 +++---- 3 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.target/arc/cancel-1.c diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h index 78b5000eeb7..539a1662084 100644 --- a/gcc/config/arc/arc.h +++ b/gcc/config/arc/arc.h @@ -1356,7 +1356,7 @@ do { \ : (REGNO)) /* Use gcc hard register numbering for eh_frame. */ -#define DWARF_FRAME_REGNUM(REG) (REG) +#define DWARF_FRAME_REGNUM(REG) ((REG) < 144 ? REG : INVALID_REGNUM) /* Map register numbers held in the call frame info that gcc has collected using DWARF_FRAME_REGNUM to those that should be output @@ -1370,9 +1370,14 @@ do { \ : 57 + !!TARGET_MULMAC_32BY16_SET) /* MLO */ \ : (REGNO)) -#define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (31) +/* The DWARF 2 CFA column which tracks the return address. */ +#define DWARF_FRAME_RETURN_COLUMN RETURN_ADDR_REGNUM +#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM) -#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, 31) +/* The DWARF 2 CFA column which tracks the return address from a signal handler + context. This value must not correspond to a hard register and must be out + of the range of DWARF_FRAME_REGNUM(). */ +#define DWARF_ALT_FRAME_RETURN_COLUMN 144 /* Frame info. */ diff --git a/gcc/testsuite/gcc.target/arc/cancel-1.c b/gcc/testsuite/gcc.target/arc/cancel-1.c new file mode 100644 index 00000000000..e050c538157 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/cancel-1.c @@ -0,0 +1,31 @@ +/* Test for cleanups with pthread_cancel. Any issue with libgcc's unwinder + will cause this test to spin in pthread_join. */ + +/* { dg-do run } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-pthread" } */ + +#include +#include +#include + +void *thread_loop (void *) +{ + while (1) + { + printf("worker: loop\n"); + sleep(1); + } +} + +int main () +{ + pthread_t thread; + + pthread_create (&thread, 0, thread_loop, 0); + sleep(5); + pthread_cancel (thread); + pthread_join (thread, 0); + + return 0; +} diff --git a/libgcc/config/arc/linux-unwind.h b/libgcc/config/arc/linux-unwind.h index 1d8c0c55883..be42a3163b2 100644 --- a/libgcc/config/arc/linux-unwind.h +++ b/libgcc/config/arc/linux-unwind.h @@ -120,10 +120,11 @@ arc_fallback_frame_state (struct _Unwind_Context *context, = ((_Unwind_Ptr) &(regs[i])) - new_cfa; } - fs->regs.reg[31].how = REG_SAVED_VAL_OFFSET; - fs->regs.reg[31].loc.offset = ((_Unwind_Ptr) (regs[ret])) - new_cfa; - - fs->retaddr_column = 31; + fs->signal_frame = 1; + fs->retaddr_column = __LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__; + fs->regs.reg[fs->retaddr_column].how = REG_SAVED_VAL_OFFSET; + fs->regs.reg[fs->retaddr_column].loc.offset = + ((_Unwind_Ptr) (regs[ret])) - new_cfa; return _URC_NO_REASON; }