From patchwork Mon Apr 29 18:40:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 1929134 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=golang-org.20230601.gappssmtp.com header.i=@golang-org.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=cZ0q3wU6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VSsc15Sy9z1ymX for ; Tue, 30 Apr 2024 04:41:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D6E0E3858C31 for ; Mon, 29 Apr 2024 18:41:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by sourceware.org (Postfix) with ESMTPS id 82AF73858410 for ; Mon, 29 Apr 2024 18:40:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 82AF73858410 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=golang.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=golang.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 82AF73858410 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b36 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714416055; cv=none; b=ukalYlAGS9MQpVvpoIqrOP5RSbKYAWfgFVNCgiX/3l/QyctsZUdUCK9FiP1NOLY/K5QtcWH0afo+uh9YKaLuT1bbpn36botdvMenLLHlaVHZKmA2DJTXBBC7kAA70CgNf4CgvP8TqbFuOMyNvz5qEIgDju6e2ZAYT9fr9cqHdSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714416055; c=relaxed/simple; bh=H4+NxxOvBmZ92duyjwHIhcoTkN3y0Y2ml397EGEpHyo=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=N9XYv+AylnVfJcOSbRNpnDjmDZe+XidL7TKPpTxf6u+RBgx5KSiC+pb3w8peLPn9Rg6ob1gkSZ87PnDUGJ7ykFhjpv1HQb0lkRhrdAR59wzddTQ6RurQlX39f0hCShzf6kwW5EKvwf8z11gp5SiBJKnnNxzha3BCA2vlFpx3JIw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yb1-xb36.google.com with SMTP id 3f1490d57ef6-de45dba157cso4519082276.3 for ; Mon, 29 Apr 2024 11:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golang-org.20230601.gappssmtp.com; s=20230601; t=1714416052; x=1715020852; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=EJRSIcwNvNfq9uvVtVrIRybSKmryHtjZKF/8dMs+pgQ=; b=cZ0q3wU69tbvmMNDMrcsCv/vhcgkv+frudGllXpMftPbjqAPAClt6kDKSmdOXuDu5q S+m+IVrLfhDtlu2GemlLzoycOUddXwi5berg82X5C2/m4giYwMorNACEh+jyXbScymKu zTzkphXRwdXEMy9r0aJN9pO3SxzKqc5Mt2FIOpCVZDDk1cCR5KtN8PMj2zUqiPRxwI82 INs/0UxF5x71Jknw1vS95wnPfESUq5bXCMGszvDM+pF2Dgema8OVISX5rWPmO46Y6mXI 7xlu1/6hUBXrEqgeoB0I5Vwmgx1k3tspEXp4zXjrrSENh3I/LRLPjtqWYxEUM6P+el56 rrTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714416052; x=1715020852; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=EJRSIcwNvNfq9uvVtVrIRybSKmryHtjZKF/8dMs+pgQ=; b=SF1gITaqA0mT2IgI2R2TA8P40GectW8hQUkYfpj5AWXlou6VQUMFA7lqpVBdNp19mX CD3X45Aa9YAapjYR/MFARb+YyG2JObCsibVIsZiVd0zEMNWFyZys4oN9PSsyUQlG29JY 6/bDsSg831zSWMq6opuNF3Du/jMnxekCWhspaj+JWiievg8dl7P1Ps3iK4oi/aluFL72 cQcluZ5MyRS36ry16W3CrIvYsFYA5kFe7MuimlP9Ycip0DWdFpQTfxKVIy6Fg7b72c35 7RCbsjZj03Axck+KBD6iDk0CRuQY47brSfsdT/LQvFQJuLTp1q0QiY+nF1t8k0pF0QCI BEQA== X-Gm-Message-State: AOJu0YzHnIg4rkJzJ19CjhH4ZYjGvnwLUM1NWxL4UBjSWuOa1+IVbI8a FCU9TcgfAp8ae8tjNb4VdFzVjUiGM5blOiGEz3lP1I2VchHJe4j0t9D9O/hHXEWES3O6lf6Vwye UZ7oNYlB9tagf3wQNwQUXFjyOnhNlguve7i8+MUSUeFhBVpD7EYM= X-Google-Smtp-Source: AGHT+IE3k477vtYp2L8WqDjuWdg8qB2LnlAZH+ZwAm/MrA1fZrSphkLROhtGAYiZD50RdwkfTsF0wB18cAiLE25Psn0= X-Received: by 2002:a25:dfca:0:b0:dcc:1c6c:430d with SMTP id w193-20020a25dfca000000b00dcc1c6c430dmr12748104ybg.12.1714416052517; Mon, 29 Apr 2024 11:40:52 -0700 (PDT) MIME-Version: 1.0 From: Ian Lance Taylor Date: Mon, 29 Apr 2024 11:40:41 -0700 Message-ID: Subject: libgo patch commited: Dump register on Solaris To: gcc-patches , gofrontend-dev Cc: Rainer Orth X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org This libgo patch, by Rainer Orth, dumps register values on Solaris on a crash. This fixes GC PR 106813. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian a05efc8bf5ed329ea7d9b1740c326bdc6b04e37a diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 8a2810d5b2d..9a4b402573a 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -1f0c8364cd35026a647aa4e66ee4d8563c8a5d27 +60f985a7852632834936b4b859aa75d9df88f038 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c index aa1b6305ad0..c48c8ee58e3 100644 --- a/libgo/runtime/go-signal.c +++ b/libgo/runtime/go-signal.c @@ -216,6 +216,10 @@ getSiginfoCode(siginfo_t *info) return (uintptr)(info->si_code); } +#if defined(__sparc__) && defined(__arch64__) && defined(__linux__) + #define gregs mc_gregs +#endif + struct getSiginfoRet { uintptr sigaddr; uintptr sigpc; @@ -242,9 +246,9 @@ getSiginfo(siginfo_t *info, void *context __attribute__((unused))) // Use unportable code to pull it from context, and if that fails // try a stack backtrace across the signal handler. -#if defined(__x86_64__) && defined(__linux__) +#if defined(__x86_64__) && (defined(__linux__) || (defined(__sun__) && defined(__svr4__))) ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.gregs[REG_RIP]; -#elif defined(__i386__) && defined(__linux__) +#elif defined(__i386__) && (defined(__linux__) || (defined(__sun__) && defined(__svr4__))) ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.gregs[REG_EIP]; #elif defined(__alpha__) && defined(__linux__) ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.sc_pc; @@ -263,6 +267,9 @@ getSiginfo(siginfo_t *info, void *context __attribute__((unused))) #elif defined(__NetBSD__) ret.sigpc = _UC_MACHINE_PC(((ucontext_t*)(context))); #endif +#if defined(__sparc__) && (defined(__linux__) || (defined(__sun__) && defined(__svr4__))) + ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.gregs[REG_PC]; +#endif if (ret.sigpc == 0) { // Skip getSiginfo/sighandler/sigtrampgo/sigtramp/handler. @@ -285,7 +292,7 @@ void dumpregs(siginfo_t *, void *) void dumpregs(siginfo_t *info __attribute__((unused)), void *context __attribute__((unused))) { -#if defined(__x86_64__) && defined(__linux__) +#if defined(__x86_64__) && (defined(__linux__) || (defined(__sun__) && defined(__svr4__))) { mcontext_t *m = &((ucontext_t*)(context))->uc_mcontext; @@ -306,12 +313,22 @@ dumpregs(siginfo_t *info __attribute__((unused)), void *context __attribute__((u runtime_printf("r14 %X\n", m->gregs[REG_R14]); runtime_printf("r15 %X\n", m->gregs[REG_R15]); runtime_printf("rip %X\n", m->gregs[REG_RIP]); +#if defined(REG_EFL) runtime_printf("rflags %X\n", m->gregs[REG_EFL]); +#elif defined(REG_RFL) + runtime_printf("rflags %X\n", m->gregs[REG_RFL]); +#endif +#if defined(REG_CSGSFS) runtime_printf("cs %X\n", m->gregs[REG_CSGSFS] & 0xffff); runtime_printf("fs %X\n", (m->gregs[REG_CSGSFS] >> 16) & 0xffff); runtime_printf("gs %X\n", (m->gregs[REG_CSGSFS] >> 32) & 0xffff); +#elif defined(REG_CS) && defined(REG_FS) && defined(REG_GS) + runtime_printf("cs %X\n", m->gregs[REG_CS]); + runtime_printf("fs %X\n", m->gregs[REG_FS]); + runtime_printf("gs %X\n", m->gregs[REG_GS]); +#endif } -#elif defined(__i386__) && defined(__linux__) +#elif defined(__i386__) && (defined(__linux__) || (defined(__sun__) && defined(__svr4__))) { mcontext_t *m = &((ucontext_t*)(context))->uc_mcontext; @@ -423,5 +440,43 @@ dumpregs(siginfo_t *info __attribute__((unused)), void *context __attribute__((u runtime_printf("pc %X\n", m->pc); runtime_printf("pstate %X\n", m->pstate); } +#elif defined(__sparc__) && (defined(__linux__) || (defined(__sun__) && defined(__svr4__))) + { + mcontext_t *m = &((ucontext_t*)(context))->uc_mcontext; + +#ifdef __sparcv9 + #define REG_FMT "%X" +#else + #define REG_FMT "%x" +#endif + +#ifdef REG_CCR + runtime_printf("ccr " REG_FMT "\n", m->gregs[REG_CCR]); +#else + runtime_printf("psr " REG_FMT "\n", m->gregs[REG_PSR]); +#endif + runtime_printf("pc " REG_FMT "\n", m->gregs[REG_PC]); + runtime_printf("npc " REG_FMT "\n", m->gregs[REG_nPC]); + runtime_printf("y " REG_FMT "\n", m->gregs[REG_Y]); + runtime_printf("g1 " REG_FMT "\n", m->gregs[REG_G1]); + runtime_printf("g2 " REG_FMT "\n", m->gregs[REG_G2]); + runtime_printf("g3 " REG_FMT "\n", m->gregs[REG_G3]); + runtime_printf("g4 " REG_FMT "\n", m->gregs[REG_G4]); + runtime_printf("g5 " REG_FMT "\n", m->gregs[REG_G5]); + runtime_printf("g6 " REG_FMT "\n", m->gregs[REG_G6]); + runtime_printf("g7 " REG_FMT "\n", m->gregs[REG_G7]); + runtime_printf("o0 " REG_FMT "\n", m->gregs[REG_O0]); + runtime_printf("o1 " REG_FMT "\n", m->gregs[REG_O1]); + runtime_printf("o2 " REG_FMT "\n", m->gregs[REG_O2]); + runtime_printf("o3 " REG_FMT "\n", m->gregs[REG_O3]); + runtime_printf("o4 " REG_FMT "\n", m->gregs[REG_O4]); + runtime_printf("o5 " REG_FMT "\n", m->gregs[REG_O5]); + runtime_printf("o6 " REG_FMT "\n", m->gregs[REG_O6]); + runtime_printf("o7 " REG_FMT "\n", m->gregs[REG_O7]); +#if defined(REG_ASI) && defined(REG_FPRS) && !defined(__linux__) + runtime_printf("asi " REG_FMT "\n", m->gregs[REG_ASI]); + runtime_printf("fprs " REG_FMT "\n", m->gregs[REG_FPRS]); +#endif + } #endif }