From patchwork Wed Jan 7 21:59:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 4556 Received: (qmail 26617 invoked by alias); 7 Jan 2015 21:59:14 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 26545 invoked by uid 89); 7 Jan 2015 21:59:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-ob0-f202.google.com Received: from mail-ob0-f202.google.com (HELO mail-ob0-f202.google.com) (209.85.214.202) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 07 Jan 2015 21:59:10 +0000 Received: by mail-ob0-f202.google.com with SMTP id va2so871834obc.1 for ; Wed, 07 Jan 2015 13:59:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:subject:in-reply-to :references; bh=jSXQ9U0aR3EH8xc8OzQitg9+P+LBzDGVQNQm5bv9bW0=; b=mwjJptk8RL0DoJ3ko0p8CXltoMVf21YXmYwSInQ8YjTaN12kZECeHGK5ZUiy8HTYGN WwiP9DgbvkntEDvvwWqGSBHP0b7z5hquHS3xhSZpREj/N6QWAlY1kwQDuTta9atoEYNs zj12YRidVLbIVa8tPqqwNddvz4I1pJ3IljnKeKcVW0IGPnNMkHw9sIpFOlXvHELN7FFg m3xqfUYFfRqKGw0xTqt/mFOJ9JzC4CR8JtHAd0pEYQ0sLw45y6b5m3SgtlxsGHz1TgKh Gniov1s5r5I2O0Dhdkhcu0H7pvS+R5LmDiKvfoKQkE960ZYzxkj3RHwIBzXHiNJ5hV7a RMbw== X-Gm-Message-State: ALoCoQm1iWGi32p7yhcL03NUb3wNAtwhi3beaP0ZHL/cB7flGXdSOPMcE0sWS+ve9KJr/8/S4T/xonDcVHuuZAxxWRmzwbBEaVzu2nJPzfwkCT2WozKHOs5dXDkFUMdHpesR2Z2R/06zw9XiVXsOG4Vk5gT5MvdViK8/ghPDyfSM2lbax4GdLGk= X-Received: by 10.182.91.49 with SMTP id cb17mr4292879obb.11.1420667948238; Wed, 07 Jan 2015 13:59:08 -0800 (PST) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id t7si125594yho.3.2015.01.07.13.59.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jan 2015 13:59:08 -0800 (PST) Received: from ruffy2.mtv.corp.google.com ([172.17.128.107]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id AIQS5SAl.1; Wed, 07 Jan 2015 13:59:08 -0800 From: Doug Evans MIME-Version: 1.0 Message-ID: <21677.44074.982761.250152@ruffy2.mtv.corp.google.com> Date: Wed, 7 Jan 2015 13:59:06 -0800 To: Eli Zaretskii , gdb-patches Subject: Re: [PATCH] Speed up "gdb -tui" output In-Reply-To: References: <83zj9v7urq.fsf@gnu.org> <83sifn7mpt.fsf@gnu.org> <83h9w278a9.fsf@gnu.org> <83bnma75yt.fsf@gnu.org> <837fwy74ny.fsf@gnu.org> X-IsSubscribed: yes Doug Evans writes: > Seems like the main source of the problem would be gdb_stdout, > so let's try to fix that first and go from there. Here's a prototype. I left fflush (stdout) in to be conservative. Does this resolve the performance issues you're seeing well enough? 2015-01-07 Doug Evans PR tui/17810 * tui/tui-command.c (tui_refresh_cmd_win): New function. * tui/tui-command.c (tui_refresh_cmd_win): Declare. * tui/tui-file.c: #include tui/tui-command.h. (tui_file_fputs): Refresh command window if stream is not gdb_stdout. (tui_file_flush): Refresh command window if stream is gdb_stdout or gdb_stderr. * tui/tui-io.c (tui_puts): Remove call to wrefresh, fflush. (tui_readline_output): Call tui_refresh_cmd_win. (print_filename): Ditto. (tui_rl_display_match_list): Ditto. diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c index d1a5ddb..6d98db2 100644 --- a/gdb/tui/tui-command.c +++ b/gdb/tui/tui-command.c @@ -129,3 +129,18 @@ tui_dispatch_ctrl_char (unsigned int ch) return c; } } + +/* Refresh the command window. */ + +void +tui_refresh_cmd_win (void) +{ + WINDOW *w = TUI_CMD_WIN->generic.handle; + + wrefresh (w); + + /* FIXME: It's not clear why this is here. + It was present in the original tui_puts code and is kept in order to + not introduce some subtle breakage. */ + fflush (stdout); +} diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h index 8cc5be4..174ba58 100644 --- a/gdb/tui/tui-command.h +++ b/gdb/tui/tui-command.h @@ -24,4 +24,6 @@ extern unsigned int tui_dispatch_ctrl_char (unsigned int); +extern void tui_refresh_cmd_win (void); + #endif diff --git a/gdb/tui/tui-file.c b/gdb/tui/tui-file.c index b32cfa6..02d9082 100644 --- a/gdb/tui/tui-file.c +++ b/gdb/tui/tui-file.c @@ -20,7 +20,7 @@ #include "ui-file.h" #include "tui/tui-file.h" #include "tui/tui-io.h" - +#include "tui/tui-command.h" #include "tui.h" /* A ``struct ui_file'' that is compatible with all the legacy @@ -179,6 +179,10 @@ tui_file_fputs (const char *linebuffer, struct ui_file *file) else { tui_puts (linebuffer); + /* gdb_stdout is buffered, and the caller must gdb_flush it at + appropriate times. Other streams are not so buffered. */ + if (file != gdb_stdout) + tui_refresh_cmd_win (); } } @@ -239,6 +243,12 @@ tui_file_flush (struct ui_file *file) case astring: break; case afile: + /* There is also gdb_stdlog, gdb_stdtarg, gdb_stdtargerr, but + tui_setup_io maps those to gdb_stderr. OTOH, do we need to make + this conditional? */ + if (file == gdb_stdout + || file == gdb_stderr) + tui_refresh_cmd_win (); fflush (stream->ts_filestream); break; } diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index 233e7a6..c3ab612 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -158,7 +158,10 @@ tui_putc (char c) tui_puts (buf); } -/* Print the string in the curses command window. */ +/* Print the string in the curses command window. + The output is buffered. It is up to the caller to refresh the screen + if necessary. */ + void tui_puts (const char *string) { @@ -187,10 +190,6 @@ tui_puts (const char *string) TUI_CMD_WIN->detail.command_info.curch); TUI_CMD_WIN->detail.command_info.start_line = TUI_CMD_WIN->detail.command_info.cur_line; - - /* We could defer the following. */ - wrefresh (w); - fflush (stdout); } /* Readline callback. @@ -316,6 +315,7 @@ tui_readline_output (int error, gdb_client_data data) { buf[size] = 0; tui_puts (buf); + tui_refresh_cmd_win (); } } #endif @@ -367,6 +367,7 @@ print_filename (const char *to_print, const char *full_pathname) { PUTX (*s); } + tui_refresh_cmd_win (); return printed_len; } @@ -425,6 +426,7 @@ tui_rl_display_match_list (char **matches, int len, int max) if (get_y_or_n () == 0) { tui_puts ("\n"); + tui_refresh_cmd_win (); return; } }