From patchwork Wed Jul 24 22:18:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1964556 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jQo+wQ2n; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WTpMn4vNlz1ydm for ; Thu, 25 Jul 2024 08:19:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C67D1385DDE3 for ; Wed, 24 Jul 2024 22:19:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 90E91385AC29 for ; Wed, 24 Jul 2024 22:18:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 90E91385AC29 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 90E91385AC29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721859524; cv=none; b=RzMPkwm4oyxPBs7QC7rAZxFoOXtHibfqEVf3RmDQTy8jHxBfJOi8x1dXCtwjUJYJu8o3q4xqy8kwUwRSW29zdFl8jfaabS0+maNJAjLRswbzyznUDqk2df88iGVnD4ZK3b/QAEt6BAonv6ZAmqoPFToRHlqW7gOhMFP1ntI2RgI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721859524; c=relaxed/simple; bh=doFunrOO/Bp9gVuLyDZMYQIxU3utyAgl2PwOFmm3H2s=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=bqa/xLU9zTLOp3rPCud3unuNnhX9GHdLI6KdYd1k43ERWZAULQ2JCAo4W5ZYGgi7LEQYkiM+iJj8ceh74iw0+SsYhiMGLxC7nhQ2QoAJ7oWEEraC/nbdH7fIpXqUG6PUBuWodWLDgPCm6JmPtY+r1i00jrhTh2haDct5UuYzLxw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721859522; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3hbDnd4ctHpjtniIgLnLJeqEiq8LyNW2ecKsY+0neUM=; b=jQo+wQ2nrCKirj60RRLqCFffFT9ih17sXoGINfvdfWUZuZGNjmrC2InRxTQzMENyNLV0QP LI5f4qJLzZjdC9XP/0Uwisz4SXHtSy1QYz98p4ZtMPkPwzKrC1mArS4uCviKTDB9G0t/Q2 fayLFuUkFOZrvguop0uEYqBrGUrUSy8= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-358-ETcpS8GUNz-qehoCkZVPAQ-1; Wed, 24 Jul 2024 18:18:38 -0400 X-MC-Unique: ETcpS8GUNz-qehoCkZVPAQ-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 748BC1955D44 for ; Wed, 24 Jul 2024 22:18:36 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.33.183]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 846821955E80; Wed, 24 Jul 2024 22:18:35 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 01/16] json: add dump overload for easier debugging Date: Wed, 24 Jul 2024 18:18:09 -0400 Message-Id: <20240724221824.585054-2-dmalcolm@redhat.com> In-Reply-To: <20240724221824.585054-1-dmalcolm@redhat.com> References: <20240724221824.585054-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 has saved me a lot of typing in the debugger. gcc/ChangeLog: * json.cc (value::dump): New overload, taking no params. * json.h (value::dump): New decl. Signed-off-by: David Malcolm --- gcc/json.cc | 10 ++++++++++ gcc/json.h | 1 + 2 files changed, 11 insertions(+) diff --git a/gcc/json.cc b/gcc/json.cc index b3106f39cedf..53edca520556 100644 --- a/gcc/json.cc +++ b/gcc/json.cc @@ -90,6 +90,16 @@ value::dump (FILE *outf, bool formatted) const pp_flush (&pp); } +/* A convenience function for debugging. + Dump to stderr with formatting, and a trailing newline. */ + +void +value::dump () const +{ + dump (stderr, true); + fprintf (stderr, "\n"); +} + /* class json::object, a subclass of json::value, representing an ordered collection of key/value pairs. */ diff --git a/gcc/json.h b/gcc/json.h index 97c68116b329..ad4f8c448f8c 100644 --- a/gcc/json.h +++ b/gcc/json.h @@ -83,6 +83,7 @@ class value virtual void print (pretty_printer *pp, bool formatted) const = 0; void dump (FILE *, bool formatted) const; + void DEBUG_FUNCTION dump () const; }; /* Subclass of value for objects: a collection of key/value pairs