From patchwork Tue Feb 14 02:33:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 56609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2715160wrn; Mon, 13 Feb 2023 18:34:39 -0800 (PST) X-Google-Smtp-Source: AK7set9Vcc+W00UJfLCGHtdZxEW42NC7rArgyrkIcwyLkG5lH+KaOLOS+rcek/RAgAMrEnuMkbAJ X-Received: by 2002:a17:906:b0c:b0:8aa:c0a4:2aa5 with SMTP id u12-20020a1709060b0c00b008aac0a42aa5mr1111073ejg.16.1676342079008; Mon, 13 Feb 2023 18:34:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676342078; cv=none; d=google.com; s=arc-20160816; b=D8T5jctlT67Gwh4C7CicKd8uN4vP33L7yQq5b++m/i7uecUtE60obiQl+bN3MewO1f Q+wmA498ImolKtc9Bf+Oi6mq0iHFXixJaC+nRKUKvXYiBn05tGkWDoJSkKCDFQg0NBD4 ythEN0MDH9X7KfDc7xo6HFGXlHH9Mn373oVq+SUKsku2r+Cyru8G218dANzIg8ls93sA Q7GA75e0FUu0sgQ0aRsxesNs1xEybnKpUn0Z5zKAi0uz3p7T6pEday0IuXUUOIpDmSgD x1egoJlizdcmGMn7G0yQtSarAIACr4d7TjIlpGGunHxUxH1xpXCC9kv9XkM1SE3/sBoT iU+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:date:message-id :content-transfer-encoding:mime-version:subject:to:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=HkKq02ReNJQaFQk+rSTwmlkfeJNroX5o51i+418kwnQ=; b=cacm6++Gh89SSHJRNMKndSafYDy5HJjhSaixbXWLwydgHL8sDa7ujUZGDgjY8vPALc SqDCs6LfAVP0DN9anv08T2hNk9qRNGCpxpEqdH1iyCvUHBqlJ+1okPO5xryEq/rI5xVA 7uw2QxJXPv39a7Vsu7xIjnaf2fj1G5Mg9FmU35TSZDX4U7rGaVDxngILYqEaEV0xgvep 4M98kCxGySccrSZ2/zDlpe7Xe1/3mNh4i6LGBhEdrn7257GirPGkTpAN1BsmM+k6nS+Z nhbkSchqmjSdXRswZQXScmEqubBFATIZTDvIebMuG2/qxstVKFFPO5oPnYgZwSZS0gzL HZSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=stq0ABki; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id t21-20020aa7d715000000b004acb31af1e8si8693554edq.561.2023.02.13.18.34.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 18:34:38 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=stq0ABki; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09C68385840C for ; Tue, 14 Feb 2023 02:34:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09C68385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676342078; bh=HkKq02ReNJQaFQk+rSTwmlkfeJNroX5o51i+418kwnQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=stq0ABkiylP0SVvnSEF12p4fEGiEkQwlp556FH/+DvibUK5MXF9UEG9sW0nv+0kmb zu6N2UProPw1T2PLj6KUiKlFIByRE06HEpkVhKw9gUILo9/Szw96xJzjGDeMfKQsmb kFCr0QKFf714AOmTg1GorxuwsU+4Zxd14FcGLsJ8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by sourceware.org (Postfix) with ESMTPS id 12CFE385843D for ; Tue, 14 Feb 2023 02:33:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 12CFE385843D To: Subject: [PATCH] debug: Support "phrs" for dumping a HARD_REG_SET MIME-Version: 1.0 Message-ID: <20230214023346.2A85B20423@pchp3.se.axis.com> Date: Tue, 14 Feb 2023 03:33:46 +0100 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Hans-Peter Nilsson via Gcc-patches From: Hans-Peter Nilsson Reply-To: Hans-Peter Nilsson Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757772072036213403?= X-GMAIL-MSGID: =?utf-8?q?1757772072036213403?= Ok to commit? It survived both a cris-elf regtest and a x86_64-linux-gnu native regtest. :) ---- 8< ---- The debug-function in sel-sched-dump.cc that would be suitable for a hookup to a command in gdb is guarded by #ifdef INSN_SCHEDULING, thus can't be used for all targets. Better move the function marked DEBUG_FUNCTION elsewhere, here to a file with a suitable static function to call. There are multiple sets of similar functions dumping HARD_REG_SETs, but cleaning that up is better left to a separate commit. gcc: * gdbinit.in (phrs): New command. * sel-sched-dump.cc (debug_hard_reg_set): Remove debug-function. * ira-color.cc (debug_hard_reg_set): New, calling print_hard_reg_set. --- gcc/gdbinit.in | 12 ++++++++++++ gcc/ira-color.cc | 7 +++++++ gcc/sel-sched-dump.cc | 10 ---------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/gcc/gdbinit.in b/gcc/gdbinit.in index 1f7592b0e26a..a76079a46af7 100644 --- a/gcc/gdbinit.in +++ b/gcc/gdbinit.in @@ -31,6 +31,7 @@ GCC gdbinit file introduces several debugging shorthands: pdd [dw_die_ref], pbm [bitmap], pel [location_t], + phrs [HARD_REG_SET] pp, pbs, pcfun They are generally implemented by calling a function that prints to stderr, @@ -145,6 +146,17 @@ Print given GENERIC expression in C syntax. See also 'help-gcc-hooks'. end +define phrs +eval "set $debug_arg = $%s", $argc ? "arg0" : "" +call debug_hard_reg_set ($debug_arg) +end + +document phrs +GCC hook: debug_hard_reg_set (HARD_REG_SET) +Print given HARD_REG_SET. +See also 'help-gcc-hooks'. +end + define pmz eval "set $debug_arg = $%s", $argc ? "arg0" : "" call mpz_out_str(stderr, 10, $debug_arg) diff --git a/gcc/ira-color.cc b/gcc/ira-color.cc index fe6dfc6e7692..1fb2958bddd0 100644 --- a/gcc/ira-color.cc +++ b/gcc/ira-color.cc @@ -512,6 +512,13 @@ print_hard_reg_set (FILE *f, HARD_REG_SET set, bool new_line_p) fprintf (f, "\n"); } +/* Dump a hard reg set SET to stderr. */ +DEBUG_FUNCTION void +debug_hard_reg_set (HARD_REG_SET set) +{ + print_hard_reg_set (stderr, set, true); +} + /* Print allocno hard register subforest given by ROOTS and its LEVEL to F. */ static void diff --git a/gcc/sel-sched-dump.cc b/gcc/sel-sched-dump.cc index b4eef8803df9..05de98409375 100644 --- a/gcc/sel-sched-dump.cc +++ b/gcc/sel-sched-dump.cc @@ -986,16 +986,6 @@ debug_blist (blist_t bnds) restore_dump (); } -/* Dump a hard reg set SET to stderr. */ -DEBUG_FUNCTION void -debug_hard_reg_set (HARD_REG_SET set) -{ - switch_dump (stderr); - dump_hard_reg_set ("", set); - sel_print ("\n"); - restore_dump (); -} - /* Debug a cfg region with default flags. */ void sel_debug_cfg (void)