From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 958 invoked by alias); 25 Oct 2008 01:05:28 -0000 Received: (qmail 948 invoked by uid 22791); 25 Oct 2008 01:05:27 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 25 Oct 2008 01:04:52 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 680CE2A9677 for ; Fri, 24 Oct 2008 21:04:48 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id jwjDgfq8hIKL for ; Fri, 24 Oct 2008 21:04:48 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 03A382A9675 for ; Fri, 24 Oct 2008 21:04:48 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id C2ECAE7ACD; Fri, 24 Oct 2008 18:04:45 -0700 (PDT) Date: Sat, 25 Oct 2008 01:05:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFA/RFC] new setting against auto-answer? (because "input not from terminal") Message-ID: <20081025010445.GC29038@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="mYCpIKhGyMATD0i+" Content-Disposition: inline User-Agent: Mutt/1.4.2.2i 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 X-SW-Source: 2008-10/txt/msg00626.txt.bz2 --mYCpIKhGyMATD0i+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1879 Hello, I often have to investigate issues on Windows, except that I usually don't work locally on a Windows machine. So, usually, what I do is ssh to a Windows machine where we have a cygwin SSH daemon running. If you have been in that situation, and you use a MinGW debugger, then you probably know that there are a few issues with the "terminal". One of the issues that is causing us some trouble is the fact that GDB automatically assumes the default answer for its y/n queries. For instance: (top-gdb) start The program being debugged has been started already. Start it from the beginning? (y or n) [answered Y; input not from terminal] [...] I propose a new "set/show interactive-mode (auto|on|off)" command to allow the user to override what GDB detects. By default, GDB still probes stdin and determines from there what mode should be used. But if the user knows what he's doing, he can force it in situations where GDB's default behavior is less useful. (top-gdb) set interactive-mode on (top-gdb) start The program being debugged has been started already. Start it from the beginning? (y or n) n Program not restarted. Attached is a patch that implements that. The name of the option can be changed if we find a better one. If others are interested, then I'll work on producing documentation and a little testcase. 2008-10-24 Joel Brobecker * top.c (interactive_mode_auto, interactive_mode_on) (interactive_mode_off, interactive_mode_enum, interactive_mode): New static globals. (show_interactive_mode): New function. (input_from_terminal_p): If interactive_mode is not auto, then use that rather than checking the stdin settings. (init_main): Add "set/show interactive-mode" command. Tested on x86-linux, no regression. Thoughts? -- Joel --mYCpIKhGyMATD0i+ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="top.c.diff" Content-length: 2831 Index: top.c =================================================================== RCS file: /cvs/src/src/gdb/top.c,v retrieving revision 1.154 diff -u -p -r1.154 top.c --- top.c 22 Sep 2008 15:24:51 -0000 1.154 +++ top.c 25 Oct 2008 00:48:15 -0000 @@ -1298,12 +1298,52 @@ quit_force (char *args, int from_tty) exit (exit_code); } +/* Enum strings for "set|show interactive-mode". */ + +static const char interactive_mode_auto[] = "auto"; +static const char interactive_mode_on[] = "on"; +static const char interactive_mode_off[] = "off"; +static const char *interactive_mode_enum[] = +{ + interactive_mode_auto, + interactive_mode_on, + interactive_mode_off, + NULL +}; + +/* If OFF, the debugger will run in non-interactive mode, which means + that it will automatically select the default answer to all the + queries made to the user. If ON, gdb will wait for the user to + answer all queries. If AUTO, gdb will determine whether to run + in interactive mode or not depending on whether stdin is a terminal + or not. */ + +static const char *interactive_mode = interactive_mode_auto; + +/* Implement the "show interactive-mode" option. */ + +static void +show_interactive_mode (struct ui_file *file, int from_tty, + struct cmd_list_element *c, + const char *value) +{ + if (interactive_mode == interactive_mode_auto) + fprintf_filtered (file, "\ +Debugger's interactive mode is %s (currently %s).\n", + value, input_from_terminal_p () ? "on" : "off"); + else + fprintf_filtered (file, "Debugger's interactive mode is %s.\n", value); +} + /* Returns whether GDB is running on a terminal and input is currently coming from that terminal. */ int input_from_terminal_p (void) { + if (interactive_mode != interactive_mode_auto) + return interactive_mode == interactive_mode_on; + if (gdb_has_a_terminal () && instream == stdin) return 1; @@ -1633,6 +1673,20 @@ Use \"on\" to enable the notification, a NULL, show_exec_done_display_p, &setlist, &showlist); + + add_setshow_enum_cmd ("interactive-mode", class_support, + interactive_mode_enum, &interactive_mode, + _("\ +Set whether gdb should run in interactive mode or not"), _("\ +Show whether gdb runs in interactive mode"), _("\ +If on, gdb runs in interactive mode and waits for the user to answer\n\ +all its queries. If off, gdb runs in non-interactive mode and\n\ +automatically assumes the default answer to all its queries. If auto\n\ +(which is the default), automatically determine which mode to use based\n\ +on the standard input settings"), + NULL, + show_interactive_mode, + &setlist, &showlist); } void --mYCpIKhGyMATD0i+--