From patchwork Wed Apr 22 23:49:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 6398 Received: (qmail 16700 invoked by alias); 22 Apr 2015 23:49:33 -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 16687 invoked by uid 89); 22 Apr 2015 23:49:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail-qg0-f43.google.com Received: from mail-qg0-f43.google.com (HELO mail-qg0-f43.google.com) (209.85.192.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 22 Apr 2015 23:49:30 +0000 Received: by qgdy78 with SMTP id y78so1052613qgd.0 for ; Wed, 22 Apr 2015 16:49:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5C3ESVG9CtIPmTz+DU/OubJgCYGxZhfQCkfzVHhzEJY=; b=cJtbl8ip7cAvkyVL/gOOZK6oh9z+n/Ez9kXIE2FDsjKvFYXeQDmN24ny9SDzJpAyPp LrFz10VP7r3e2reKHKtvQnAmMzQYq850KywtmFrfGSwCxGIjzBcdjCo1X+gb89ZjMvQ5 ogXkGm1MP0v99/FkVFRcQEACcAkDM693KSn7YGmwU7xjFvyzrnwFCYRvVNkgpiRsuQ3M 2HYnK+wuSUetdZgv00j312lENo+YKtIMJaArVer+SR9LVly1Gk683HF62YVZc1AKBnxM s9Qz+L1jgaXPnjPDSKJ1IzQnAeMU3L2DsUTc6hwS5PEc6cxDycyg0kZL0hyX6CrbRDgk lCYA== X-Gm-Message-State: ALoCoQkVQGPdfuWrSNDjiJXhar3Wpa6F7X4Jrslktg50jVtu1tGuZS2rjuS4Svidvl8pCwPbbcUH X-Received: by 10.55.23.33 with SMTP id i33mr155530qkh.70.1429746567892; Wed, 22 Apr 2015 16:49:27 -0700 (PDT) Received: from localhost.localdomain (ool-4353acd8.dyn.optonline.net. [67.83.172.216]) by mx.google.com with ESMTPSA id j81sm4798358qge.33.2015.04.22.16.49.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Apr 2015 16:49:26 -0700 (PDT) From: Patrick Palka To: gdb-patches@sourceware.org Cc: Patrick Palka Subject: [PATCH] Explicitly call rl_resize_terminal() in TUI's SIGWINCH handler Date: Wed, 22 Apr 2015 19:49:20 -0400 Message-Id: <1429746560-16979-1-git-send-email-patrick@parcs.ath.cx> (I am looking into syncing our copy of readline to the latest version, 6.3.) In readline 6.3, the semantics of SIGWINCH handling has changed. When a SIGWINCH signal is raised, readline's rl_sigwinch_handler() now does not immediately call rl_resize_terminal(). Instead it sets a flag that is checked by RL_CHECK_SIGNALS() at a point where readline has control, and calls rl_resize_terminal() if said flag is set. This change is item (c) in https://cnswww.cns.cwru.edu/php/chet/readline/CHANGES c. Fixed a bug that caused readline to try and run code to modify its idea of the screen size in a signal handler context upon receiving a SIGWINCH. This change in behavior is important to us because TUI's tui_sigwinch_handler() relies on the assumption that by the time it's called, readline will have updated its knowledge of the terminal dimensions via rl_resize_terminal(). Since this assumption no longer holds true, TUI's SIGWINCH handling does not work correctly with readline 6.3. To fix this issue this patch makes TUI explicitly call rl_resize_terminal() in tui_async_resize_screen() at the point where current terminal dimensions are needed. (We could call it in tui_sigwinch_handler too, but since readline avoids doing it, we are probably safer off avoiding to call it in signal handler context as well.) After this change, SIGWINCH handling continues to work properly with both readline 6.2 and 6.3. Since we no longer need it, we could now explicitly disable readline's SIGWINCH handler by setting rl_handle_sigwinch to zero early on in the program startup but I can't seem to find a good spot to place this assignment (the first call to rl_initialize() occurs in tui_initialize_readline() so the assignment should occur before then), and the handler is harmless anyway. --- gdb/tui/tui-win.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 77218e8..3cf38fc 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -848,6 +848,7 @@ tui_async_resize_screen (gdb_client_data arg) if (!tui_active) return; + rl_resize_terminal (); tui_resize_all (); tui_refresh_all_win (); tui_update_gdb_sizes ();