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