From patchwork Sat Jan 28 04:06:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Merey X-Patchwork-Id: 63843 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 C677E3858C20 for ; Sat, 28 Jan 2023 04:06:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C677E3858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674878803; bh=xAEhyF/3SFd4NHzv4eJqa+M3+aNU0f8xXFZ6RqIO9Qw=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=TExi7hEDErF7PH8/3d/moRA7JLmjfUGMwXnYSb8rVZc+E5bQZSsuKFG+LhPOG5PcX mDgGhC/7HxuvysUevdiAu4prJZXdRi/rxji2P53WRn0qjGEEyIReA9zI+Ukz8BZhvt dihmslBK6IRIjC5HdgdLDAHKEMH7e+mcx2WiUWO0= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 6F1203858D20 for ; Sat, 28 Jan 2023 04:06:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F1203858D20 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-399-l81BtXYDOPeDraVvlBIE0g-1; Fri, 27 Jan 2023 23:06:17 -0500 X-MC-Unique: l81BtXYDOPeDraVvlBIE0g-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 46243185A78B for ; Sat, 28 Jan 2023 04:06:17 +0000 (UTC) Received: from localhost.localdomain (unknown [10.22.9.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1422B492C14; Sat, 28 Jan 2023 04:06:16 +0000 (UTC) To: gdb-patches@sourceware.org Cc: Aaron Merey Subject: [PATCH] gdb/debuginfod: Prevent prompt for continue during downloading. Date: Fri, 27 Jan 2023 23:06:01 -0500 Message-Id: <20230128040601.2927632-1-amerey@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.2 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_H2, 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Aaron Merey via Gdb-patches From: Aaron Merey Reply-To: Aaron Merey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" In some cases the prompt "--Type for more, q to quit, c to continue without paging--" can appear during a large series of debuginfod downloads when lines_printed exceeds lines_allowed. This is inconvenient plus ctrl-c during this prompt could leave some of gdb's internal structures in a broken state. Fix this by adding a bool count_lines_printed to control whether lines_printed is incremented when a newline is printed. Set this value to false when performing a download. --- gdb/debuginfod-support.c | 6 ++++++ gdb/utils.c | 10 ++++++++-- gdb/utils.h | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index 04d254a1601..d5fb6153ee4 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -293,6 +293,8 @@ debuginfod_source_query (const unsigned char *build_id, user_data data ("source file", srcpath); debuginfod_set_user_data (c, &data); + scoped_restore save_count_lines_printed + = make_scoped_restore (&count_lines_printed, false); gdb::optional term_state; if (target_supports_terminal_ours ()) { @@ -334,6 +336,8 @@ debuginfod_debuginfo_query (const unsigned char *build_id, user_data data ("separate debug info for", filename); debuginfod_set_user_data (c, &data); + scoped_restore save_count_lines_printed + = make_scoped_restore (&count_lines_printed, false); gdb::optional term_state; if (target_supports_terminal_ours ()) { @@ -372,6 +376,8 @@ debuginfod_exec_query (const unsigned char *build_id, user_data data ("executable for", filename); debuginfod_set_user_data (c, &data); + scoped_restore save_count_lines_printed + = make_scoped_restore (&count_lines_printed, false); gdb::optional term_state; if (target_supports_terminal_ours ()) { diff --git a/gdb/utils.c b/gdb/utils.c index 95adbe58e4a..cb6f7276ab3 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1166,6 +1166,10 @@ show_chars_per_line (struct ui_file *file, int from_tty, /* Current count of lines printed on this page, chars on this line. */ static unsigned int lines_printed, chars_printed; +/* Controls whether to increment lines_printed. */ + +bool count_lines_printed = true; + /* True if pagination is disabled for just one command. */ static bool pagination_disabled_for_command; @@ -1675,7 +1679,8 @@ pager_file::puts (const char *linebuffer) bool did_paginate = false; chars_printed = 0; - lines_printed++; + if (count_lines_printed) + lines_printed++; if (m_wrap_column) { /* We are about to insert a newline at an historic @@ -1736,7 +1741,8 @@ pager_file::puts (const char *linebuffer) { chars_printed = 0; wrap_here (0); /* Spit out chars, cancel further wraps. */ - lines_printed++; + if (count_lines_printed) + lines_printed++; m_stream->puts ("\n"); lineptr++; } diff --git a/gdb/utils.h b/gdb/utils.h index 7865812998e..fdac3e03211 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -167,6 +167,8 @@ extern int get_chars_per_line (); extern bool pagination_enabled; +extern bool count_lines_printed; + /* A flag indicating whether to timestamp debugging messages. */ extern bool debug_timestamp;