From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Subject: [RFA/RFC] new setting against auto-answer? (because "input not from terminal")
Date: Sat, 25 Oct 2008 01:05:00 -0000 [thread overview]
Message-ID: <20081025010445.GC29038@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1879 bytes --]
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 <brobecker@adacore.com>
* 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
[-- Attachment #2: top.c.diff --]
[-- Type: text/plain, Size: 2831 bytes --]
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
next reply other threads:[~2008-10-25 1:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-25 1:05 Joel Brobecker [this message]
2008-10-25 1:41 ` Paul Hilfinger
2008-10-25 2:00 ` Joel Brobecker
2008-10-25 8:06 ` Eli Zaretskii
2008-10-25 15:46 ` Joel Brobecker
2008-10-25 16:24 ` Daniel Jacobowitz
2008-10-25 17:46 ` Eli Zaretskii
2008-10-26 18:17 ` Joel Brobecker
2008-10-25 13:57 ` Tom Tromey
2008-11-16 8:17 ` Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081025010445.GC29038@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox