From patchwork Mon Sep 30 16:03:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1991079 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=QPHqFqI/; 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 4XHQrD5WTGz1xsc for ; Tue, 1 Oct 2024 02:04:44 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8D3D13865453 for ; Mon, 30 Sep 2024 16:04:42 +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.129.124]) by sourceware.org (Postfix) with ESMTP id 2BFD3384DEE3 for ; Mon, 30 Sep 2024 16:03:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2BFD3384DEE3 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 2BFD3384DEE3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727712192; cv=none; b=jlwyZ8bbnPsLI6D+S1V7Vt3ZUuVZ1GCltgURtHxIS7tabjhX5640oPwQ53ifJ67toJm+lBSmnhonUsIZVVSuIXtdVVdSsBcvXF/mZB7qEY08xj9fSSq4qZW+ZCjF8hOJuDZ7+7TFluMvyx9seFsPjGNN33nXUUGZVmfi1zOvoFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727712192; c=relaxed/simple; bh=OuxUK+AHDilw/Yew/5ADAJYjWFe+LeqzKWLDHD/7x9E=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=JeVHBbijULBNk+58wxurnFPYmw6+ZM6/kXexIkFHbi+L623+ru2RWbDhFsmstlC7A1Ru0ALmXUXYISIx4v7fuLVQWzj+jZ5BzB390Z+HFVcHgR9D/RrOXLnHnd70qaPdi+fTB3WQZuRBQJzkhAvybfdRIUH0YQ8mQSdJbrzDa0o= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727712187; 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; bh=G5SIn7SzhtW80NP0hqVE80B3ciVfYVx+hQZDeRbgn/s=; b=QPHqFqI/bMp3ucvbYopSx6ghvacYZLnmhvvrbrYRhnRuHzSTpiiiDayyNa/SLNzSw27UUn qFlFO1bIZoHznK9sXGioiw1ue5zSpIXCl495zNWV1jvTd/iBUyf8apF/Yz48LctlEZyVIx ONL/z+ZbnE73mqyHqDDOHjJBUMhQZI4= Received: from mx-prod-mc-04.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-601-entpDjO2N7-ncZ_SKuUWpQ-1; Mon, 30 Sep 2024 12:03:06 -0400 X-MC-Unique: entpDjO2N7-ncZ_SKuUWpQ-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.4]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B5E8919560AD for ; Mon, 30 Sep 2024 16:03:05 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.17.150]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EDDA63003E4D; Mon, 30 Sep 2024 16:03:04 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [pushed: r15-3973] diagnostics: add "dump" to pretty_printer and output_buffer Date: Mon, 30 Sep 2024 12:03:03 -0400 Message-ID: <20240930160303.2857103-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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_H3, 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 No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r15-3973-g4c7a58ac2617e2. gcc/ChangeLog: * pretty-print.cc (output_buffer::dump): New. (pretty_printer::dump): New. * pretty-print.h (output_buffer::dump): New decls. (pretty_printer::dump): New decls. Signed-off-by: David Malcolm --- gcc/pretty-print.cc | 23 +++++++++++++++++++++++ gcc/pretty-print.h | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/gcc/pretty-print.cc b/gcc/pretty-print.cc index 998e06e155f7..2b865212ac55 100644 --- a/gcc/pretty-print.cc +++ b/gcc/pretty-print.cc @@ -790,6 +790,21 @@ output_buffer::pop_formatted_chunks () obstack_free (&m_chunk_obstack, old_top); } +/* Dump state of this output_buffer to OUT, for debugging. */ + +void +output_buffer::dump (FILE *out) const +{ + int depth = 0; + for (pp_formatted_chunks *iter = m_cur_formatted_chunks; + iter; + iter = iter->m_prev, depth++) + { + fprintf (out, "pp_formatted_chunks: depth %i\n", depth); + iter->dump (out); + } +} + #ifndef PTRDIFF_MAX #define PTRDIFF_MAX INTTYPE_MAXIMUM (ptrdiff_t) #endif @@ -3013,6 +3028,14 @@ pretty_printer::end_url () pp_string (this, get_end_url_string (this)); } +/* Dump state of this pretty_printer to OUT, for debugging. */ + +void +pretty_printer::dump (FILE *out) const +{ + m_buffer->dump (out); +} + /* class pp_markup::context. */ void diff --git a/gcc/pretty-print.h b/gcc/pretty-print.h index b5ded5cdd5e0..ec64a167327b 100644 --- a/gcc/pretty-print.h +++ b/gcc/pretty-print.h @@ -93,6 +93,9 @@ public: pp_formatted_chunks *push_formatted_chunks (); void pop_formatted_chunks (); + void dump (FILE *out) const; + void DEBUG_FUNCTION dump () const { dump (stderr); } + /* Obstack where the text is built up. */ struct obstack m_formatted_obstack; @@ -313,6 +316,9 @@ public: void set_real_maximum_length (); int remaining_character_count_for_line (); + void dump (FILE *out) const; + void DEBUG_FUNCTION dump () const { dump (stderr); } + private: /* Where we print external representation of ENTITY. */ output_buffer *m_buffer;