From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21718 invoked by alias); 4 Sep 2014 11:58:08 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 21707 invoked by uid 89); 4 Sep 2014 11:58:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-pd0-f176.google.com Received: from mail-pd0-f176.google.com (HELO mail-pd0-f176.google.com) (209.85.192.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 04 Sep 2014 11:58:06 +0000 Received: by mail-pd0-f176.google.com with SMTP id w10so4015159pde.7 for ; Thu, 04 Sep 2014 04:58:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=KzWbQiLiPNPPfJIDWuOB2YrdBIFMNpwdKGj0pa3e2zw=; b=HV7BPZzjYJ21jDnAMszoPVxnd6kxShmsL6BLChxGthCjQ3k36zFg7/gWKzHMO0WCfK 84y8idgRp4OFcTV44awwt/p2t40Qkrg8ebIiLriwQeVcnl7c2afHjzOLhQFtdF59N3my SaPOMvcfaJgBZeZAtXovD0FIWvsEvHq2tTm4G/yishlVwZKlIZb38nK/bzyxCnr26A7V bb0S8t8oLV91DZH/RYBz3Ace8fU07j2YzLc14OjgCKAj+6w8ainNA8QGDsaUIp1xQCKz +QaMU7hf0AZr/AoXsYczSY12P+dPcN8d5fCB3fZQ3eWk5uxoT7zCKBR1ipvr9WwxT1cE ApKA== X-Gm-Message-State: ALoCoQmeApStjaa0vgowV1Ia7LuHmWterhrUN7h8sAN3isnOiMoWNxORooBNS/LOXeMppDxl1BPH MIME-Version: 1.0 X-Received: by 10.70.93.8 with SMTP id cq8mr7943370pdb.160.1409831882505; Thu, 04 Sep 2014 04:58:02 -0700 (PDT) Received: by 10.70.118.134 with HTTP; Thu, 4 Sep 2014 04:58:02 -0700 (PDT) In-Reply-To: <54084454.5060207@redhat.com> References: <1409534708-31981-1-git-send-email-patrick@parcs.ath.cx> <54084361.1020906@redhat.com> <54084454.5060207@redhat.com> Date: Thu, 04 Sep 2014 11:58:00 -0000 Message-ID: Subject: Re: [PATCH] Ensure rl_get_screen_size() returns the actual terminal dimensions From: Patrick Palka To: Pedro Alves Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-09/txt/msg00115.txt.bz2 On Thu, Sep 4, 2014 at 6:52 AM, Pedro Alves wrote: > On 09/04/2014 11:48 AM, Pedro Alves wrote: >> On 09/01/2014 02:25 AM, Patrick Palka wrote: >>> We should call rl_resize_terminal() before calling rl_get_screen_size() >>> to help ensure that rl_get_screen_size() will return the correct >>> terminal dimensions. Doing so fixes a couple issues where TUI does not >>> correctly resize itself due to rl_get_screen_size() returning stale >>> terminal dimensions. >>> >>> * tui/tui-win.c (tui_resize_all): Call rl_resize_terminal before >>> calling rl_get_screen_size. >> >> OK. > > Actually, I take that back, for a moment. > > readline's rl_sigwinch_handler already call rl_resize_terminal, and then > chains into the TUI's handler. So, why do we need this? > > Thanks, > Pedro Alves > Sometimes we overwrite readline's screen size by calling tui_update_gdb_sizes() like done in tui_enable(). When that's done rl_get_screen_size() will not return the real terminal dimensions, but rather the dimensions that were set by tui_update_gdb_sizes(). So in the following scenario the TUI will get resized to the wrong dimensions: 0. Run GDB. 1. Enter TUI mode. 2. Exit TUI mode. 3. Resize the terminal. 4. Enter TUI mode again. 5. Press a key so that the TUI will resize itself. Here we resize the terminal (causing RL's SIGWINCH handler to run, updating RL's idea of the terminal size). Then we enter TUI mode which calls tui_update_gdb_sizes() which resets RL's idea of the terminal size. Then we call rl_get_screen_size() in tui_getc() which returns not the terminal dimensions but the dimensions of the TUI's command window as set by tui_update_gdb_sizes(). So in the end the TUI gets resized to incorrect dimensions. Also, when we are blocking inside a secondary prompt, readline's SIGWINCH handler does not seem to trigger for some reason. So when we resize the window during a secondary prompt, our SIGWINCH handler gets triggered but readline's handler doesn't which means that the dimensions returned by rl_get_screen_size() will be wrong. I'm not really sure why this happens. Explicitly calling rl_resize_terminal() fixes both of these issues. Patrick