From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31465 invoked by alias); 11 Feb 2015 00:25:47 -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 31451 invoked by uid 89); 11 Feb 2015 00:25:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-pa0-f53.google.com Received: from mail-pa0-f53.google.com (HELO mail-pa0-f53.google.com) (209.85.220.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 11 Feb 2015 00:25:45 +0000 Received: by mail-pa0-f53.google.com with SMTP id lf10so367832pab.12 for ; Tue, 10 Feb 2015 16:25:43 -0800 (PST) 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:from:date :message-id:subject:to:cc:content-type; bh=TePqE6HHiMfKmQOIRWXFqjBTBzHdi5jYuWYA0pYQUtM=; b=Z9Cyu/zNz+k4DrZoe23r75/9i10oJ3diBEp+rHhcuTHuWa3a9XUqijxzYwHvtfihTo eXYK2YnLfdnlBhmdAuxlnuiqm+NgoI6i7E9lv9B1zM3SDGOAlxRzKBcelLwb3guApyKS G2P9Gs33o+xG+gV1xDIbG2qdCgbRfeSkVAt/WFvjpBHTdDv0li+/Lb4RixkZTPiDWQ5+ iraB7xb8BVloqvgX0uMhGL1QLn8GLMfhTVKllGgoPsal0Ed28DCVkLG+Oa+dnwfS1UHx VHRW1Pg1qsLwZvUtg0WDlyR0E5heOcW11r5nIPv+RpxW1xULF2ixTGLntKbauqej82o8 4Bsg== X-Gm-Message-State: ALoCoQk25hKg3Zs17BtR18v2JQTD6cRaFn4WgPh66rGyCAMC/YcuEaI6x8DJev27topbYPThL3p4 X-Received: by 10.70.89.129 with SMTP id bo1mr41846015pdb.129.1423614343402; Tue, 10 Feb 2015 16:25:43 -0800 (PST) MIME-Version: 1.0 Received: by 10.70.127.195 with HTTP; Tue, 10 Feb 2015 16:25:23 -0800 (PST) In-Reply-To: <54AE848B.1050606@redhat.com> References: <1420689885-31156-1-git-send-email-patrick@parcs.ath.cx> <1420689885-31156-2-git-send-email-patrick@parcs.ath.cx> <54AE6A19.9070901@redhat.com> <54AE848B.1050606@redhat.com> From: Patrick Palka Date: Wed, 11 Feb 2015 00:25:00 -0000 Message-ID: Subject: Re: [PATCH 2/3] TUI: Don't print KEY_RESIZE keys To: Pedro Alves Cc: "gdb-patches@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2015-02/txt/msg00283.txt.bz2 On Thu, Jan 8, 2015 at 8:22 AM, Pedro Alves wrote: > On 01/08/2015 12:32 PM, Patrick Palka wrote: >> On Thu, Jan 8, 2015 at 6:29 AM, Pedro Alves wrote: >>> On 01/08/2015 04:04 AM, Patrick Palka wrote: >>>> wgetch() sometimes returns KEY_RESIZE when ncurses detects that the >>>> terminal has been resized. >>> >>> I think curses SIGWINCH handler ends up _not_ installed, right? >>> We install our own, and so does readline. >>> So how did a resize manage to be detected/processed while inside >>> wgetch? >> >> I'm pretty sure that the SIGWINCH handlers does not get installed. >> However ncurses may detect a resize event when we exit TUI (exiting >> ncurses), then resize the terminal, then re-enter TUI (restarting >> ncurses). From there a KEY_RESIZE key is added to its internal FIFO. >> And the next call to wgetch will return this KEY_RESIZE key. > > Doesn't that mean then that we're delaying the resize until it's > "too late"? IOW, there's a moment where we show the contents with > the wrong sizes. And trying that out, I do see that happen: if I > disable the TUI, resize the terminal, and then reenable the TUI, > like you say, then until you press _another_ key, the windows > have the wrong size. We should have resized them already when we > re-entered the TUI. I have just pushed the patch that fixes this issue. The screen now gets opportunistically resized when switching from the CLI to the TUI. > > And if I try that when I'm already debugging an inferior, stopped at > a breakpoint, I see nasty things. If I reduce the size of the > window, TUI gets stuck in an infinite loop in tui_show_source_line: > > (top-gdb) bt > #0 0x0000003b46008446 in waddch_literal (win=0x28dfd30, ch=32) at ../../ncurses/base/lib_addch.c:253 > #1 0x0000003b4600859c in waddch_nosync (win=0x28dfd30, ch=32) at ../../ncurses/base/lib_addch.c:437 > #2 0x0000003b46008878 in waddch (win=0x28dfd30, ch=32) at ../../ncurses/base/lib_addch.c:543 > #3 0x0000000000524d08 in tui_show_source_line (win_info=0x28dfc90, lineno=1) at /home/pedro/gdb/mygit/src/gdb/tui/tui-winsource.c:292 > #4 0x0000000000524d8f in tui_show_source_content (win_info=0x28dfc90) at /home/pedro/gdb/mygit/src/gdb/tui/tui-winsource.c:305 > #5 0x00000000005220cb in tui_refresh_all_win () at /home/pedro/gdb/mygit/src/gdb/tui/tui-win.c:633 > #6 0x000000000052611c in tui_enable () at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:486 > #7 0x0000000000525861 in tui_rl_switch_mode (notused1=1, notused2=1) at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:108 > #8 0x0000000000796d6f in _rl_dispatch_subseq (key=1, map=0xd585c0 , got_subseq=0) at /home/pedro/gdb/mygit/src/readline/readline.c:774 > #9 0x0000000000796acb in _rl_dispatch_callback (cxt=0x26e6500) at /home/pedro/gdb/mygit/src/readline/readline.c:686 > #10 0x00000000007af20b in rl_callback_read_char () at /home/pedro/gdb/mygit/src/readline/callback.c:170 > #11 0x000000000063cefd in rl_callback_read_char_wrapper (client_data=0x0) at /home/pedro/gdb/mygit/src/gdb/event-top.c:171 > #12 0x000000000063d366 in stdin_event_handler (error=0, client_data=0x0) at /home/pedro/gdb/mygit/src/gdb/event-top.c:432 > #13 0x000000000063bec6 in handle_file_event (data=...) at /home/pedro/gdb/mygit/src/gdb/event-loop.c:762 > ---Type to continue, or q to quit--- > #14 0x000000000063b3ad in process_event () at /home/pedro/gdb/mygit/src/gdb/event-loop.c:339 > #15 0x000000000063b474 in gdb_do_one_event () at /home/pedro/gdb/mygit/src/gdb/event-loop.c:403 > #16 0x000000000063b4c4 in start_event_loop () at /home/pedro/gdb/mygit/src/gdb/event-loop.c:428 > #17 0x000000000063cf2f in cli_command_loop (data=0x0) at /home/pedro/gdb/mygit/src/gdb/event-top.c:186 > #18 0x0000000000633284 in current_interp_command_loop () at /home/pedro/gdb/mygit/src/gdb/interps.c:317 > #19 0x000000000063444d in captured_command_loop (data=0x0) at /home/pedro/gdb/mygit/src/gdb/main.c:321 > #20 0x0000000000630141 in catch_errors (func=0x634432 , func_args=0x0, errstring=0x9422e1 "", mask=RETURN_MASK_ALL) > at /home/pedro/gdb/mygit/src/gdb/exceptions.c:237 > #21 0x000000000063594b in captured_main (data=0x7fffe05ca000) at /home/pedro/gdb/mygit/src/gdb/main.c:1149 > #22 0x0000000000630141 in catch_errors (func=0x63484a , func_args=0x7fffe05ca000, errstring=0x9422e1 "", mask=RETURN_MASK_ALL) > at /home/pedro/gdb/mygit/src/gdb/exceptions.c:237 > #23 0x0000000000635974 in gdb_main (args=0x7fffe05ca000) at /home/pedro/gdb/mygit/src/gdb/main.c:1157 > #24 0x0000000000464e57 in main (argc=3, argv=0x7fffe05ca108) at /home/pedro/gdb/mygit/src/gdb/gdb.c:32 > > > > If instead I increase the size of the window, GDB aborts. E.g.,: > > (top-gdb) bt > #0 internal_error (file=0x986408 "/home/pedro/gdb/mygit/src/gdb/utils.c", line=1076, fmt=0x986834 "virtual memory exhausted.") > at /home/pedro/gdb/mygit/src/gdb/common/errors.c:54 > #1 0x000000000074b85d in malloc_failure (size=-8) at /home/pedro/gdb/mygit/src/gdb/utils.c:1076 > #2 0x0000000000783616 in xmalloc (size=18446744073709551608) at /home/pedro/gdb/mygit/src/gdb/common/common-utils.c:43 > #3 0x000000000051a13b in tui_alloc_content (num_elements=-1, type=EXEC_INFO_WIN) at /home/pedro/gdb/mygit/src/gdb/tui/tui-data.c:590 > #4 0x00000000005253ee in tui_set_exec_info_content (win_info=0x1a4a6c0) at /home/pedro/gdb/mygit/src/gdb/tui/tui-winsource.c:510 > #5 0x0000000000525672 in tui_update_exec_info (win_info=0x1a4a6c0) at /home/pedro/gdb/mygit/src/gdb/tui/tui-winsource.c:602 > #6 0x00000000005221c8 in tui_refresh_all_win () at /home/pedro/gdb/mygit/src/gdb/tui/tui-win.c:636 > #7 0x000000000051d3b1 in tui_handle_resize_during_io (original_ch=410) at /home/pedro/gdb/mygit/src/gdb/tui/tui-io.c:770 > #8 0x000000000051d251 in tui_getc (fp=0x3b36db8640 <_IO_2_1_stdin_>) at /home/pedro/gdb/mygit/src/gdb/tui/tui-io.c:693 > #9 0x00000000007aed93 in rl_read_key () at /home/pedro/gdb/mygit/src/readline/input.c:448 > #10 0x0000000000796848 in readline_internal_char () at /home/pedro/gdb/mygit/src/readline/readline.c:517 > #11 0x00000000007af375 in rl_callback_read_char () at /home/pedro/gdb/mygit/src/readline/callback.c:201 > #12 0x000000000063cfb9 in rl_callback_read_char_wrapper (client_data=0x0) at /home/pedro/gdb/mygit/src/gdb/event-top.c:171 > #13 0x000000000063d422 in stdin_event_handler (error=0, client_data=0x0) at /home/pedro/gdb/mygit/src/gdb/event-top.c:432 > > Another time: > > (top-gdb) bt > #0 internal_error (file=0x986408 "/home/pedro/gdb/mygit/src/gdb/utils.c", line=1076, fmt=0x986834 "virtual memory exhausted.") > at /home/pedro/gdb/mygit/src/gdb/common/errors.c:54 > #1 0x000000000074b85d in malloc_failure (size=-79) at /home/pedro/gdb/mygit/src/gdb/utils.c:1076 > #2 0x0000000000783616 in xmalloc (size=18446744073709551537) at /home/pedro/gdb/mygit/src/gdb/common/common-utils.c:43 > #3 0x00000000005256c5 in tui_alloc_source_buffer (win_info=0x28abee0) at /home/pedro/gdb/mygit/src/gdb/tui/tui-winsource.c:621 > #4 0x000000000051ff7b in tui_set_source_content (s=0x2299ae0, line_no=1, noerror=1) at /home/pedro/gdb/mygit/src/gdb/tui/tui-source.c:53 > #5 0x0000000000524871 in tui_update_source_window_as_is (win_info=0x28abee0, gdbarch=0x26a2450, s=0x2299ae0, line_or_addr=..., noerror=1) > at /home/pedro/gdb/mygit/src/gdb/tui/tui-winsource.c:96 > #6 0x0000000000524824 in tui_update_source_window (win_info=0x28abee0, gdbarch=0x26a2450, s=0x2299ae0, line_or_addr=..., noerror=1) > at /home/pedro/gdb/mygit/src/gdb/tui/tui-winsource.c:78 > #7 0x000000000052360a in make_visible_with_new_height (win_info=0x28abee0) at /home/pedro/gdb/mygit/src/gdb/tui/tui-win.c:1381 > #8 0x000000000052242c in tui_resize_all () at /home/pedro/gdb/mygit/src/gdb/tui/tui-win.c:723 > #9 0x000000000051d3ac in tui_handle_resize_during_io (original_ch=410) at /home/pedro/gdb/mygit/src/gdb/tui/tui-io.c:769 > #10 0x000000000051d251 in tui_getc (fp=0x3b36db8640 <_IO_2_1_stdin_>) at /home/pedro/gdb/mygit/src/gdb/tui/tui-io.c:693 > #11 0x00000000007aed93 in rl_read_key () at /home/pedro/gdb/mygit/src/readline/input.c:448 > #12 0x0000000000796848 in readline_internal_char () at /home/pedro/gdb/mygit/src/readline/readline.c:517 > #13 0x00000000007af375 in rl_callback_read_char () at /home/pedro/gdb/mygit/src/readline/callback.c:201 > #14 0x000000000063cfb9 in rl_callback_read_char_wrapper (client_data=0x0) at /home/pedro/gdb/mygit/src/gdb/event-top.c:171 > #15 0x000000000063d422 in stdin_event_handler (error=0, client_data=0x0) at /home/pedro/gdb/mygit/src/gdb/event-top.c:432 > #16 0x000000000063bf82 in handle_file_event (data=...) at /home/pedro/gdb/mygit/src/gdb/event-loop.c:762 > #17 0x000000000063b469 in process_event () at /home/pedro/gdb/mygit/src/gdb/event-loop.c:339 > #18 0x000000000063b530 in gdb_do_one_event () at /home/pedro/gdb/mygit/src/gdb/event-loop.c:403 > #19 0x000000000063b580 in start_event_loop () at /home/pedro/gdb/mygit/src/gdb/event-loop.c:428 > #20 0x000000000063cfeb in cli_command_loop (data=0x0) at /home/pedro/gdb/mygit/src/gdb/event-top.c:186 > #21 0x0000000000633340 in current_interp_command_loop () at /home/pedro/gdb/mygit/src/gdb/interps.c:317 > #22 0x0000000000634509 in captured_command_loop (data=0x0) at /home/pedro/gdb/mygit/src/gdb/main.c:321 > #23 0x00000000006301fd in catch_errors (func=0x6344ee , func_args=0x0, errstring=0x942261 "", mask=RETURN_MASK_ALL) > at /home/pedro/gdb/mygit/src/gdb/exceptions.c:237 > ---Type to continue, or q to quit--- > #24 0x0000000000635a07 in captured_main (data=0x7fffeab9cbb0) at /home/pedro/gdb/mygit/src/gdb/main.c:1149 > #25 0x00000000006301fd in catch_errors (func=0x634906 , func_args=0x7fffeab9cbb0, errstring=0x942261 "", mask=RETURN_MASK_ALL) > at /home/pedro/gdb/mygit/src/gdb/exceptions.c:237 > #26 0x0000000000635a30 in gdb_main (args=0x7fffeab9cbb0) at /home/pedro/gdb/mygit/src/gdb/main.c:1157 > #27 0x0000000000464e87 in main (argc=3, argv=0x7fffeab9ccb8) at /home/pedro/gdb/mygit/src/gdb/gdb.c:32 > > Do you see these? > > As a quick try, I added a call to tui_resize_all in tui_enable, and > it seems to fix these, and almost fix the "stale" size when we > reenable the TUI, but a subsequent keypress still changes the > layout, so apparently something more should be done. > > diff --git c/gdb/tui/tui.c w/gdb/tui/tui.c > index 00e505d..f3d0fbf 100644 > --- c/gdb/tui/tui.c > +++ w/gdb/tui/tui.c > @@ -467,6 +467,7 @@ tui_enable (void) > Curses will restore this state when endwin() is called. */ > def_shell_mode (); > clearok (stdscr, TRUE); > + tui_resize_all (); > } > > /* Install the TUI specific hooks. */ The pushed fix was essentially that, but it also sets tui_win_resized to FALSE so that a subsequent keypress does not change the layout. Is this patch now OK? (You have already approved patch #1 and #3 in this series.) > > Thanks, > Pedro Alves