aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli/cli-script.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2006-03-29 22:53:33 +0000
committerDaniel Jacobowitz <drow@false.org>2006-03-29 22:53:33 +0000
commit698ba9341ed2a509079635b532aa3593d86aa047 (patch)
tree5c212d9af6dba536a1d4624988f3df206be050cb /gdb/cli/cli-script.c
parent2f00de94cba65aea58efe910d1b4970220d0bb5f (diff)
downloadgdb-698ba9341ed2a509079635b532aa3593d86aa047.zip
gdb-698ba9341ed2a509079635b532aa3593d86aa047.tar.gz
gdb-698ba9341ed2a509079635b532aa3593d86aa047.tar.bz2
* Makefile.in (utils.o): Update.
* top.c (in_user_command): New. (command_line_input): Use input_from_terminal_p. (input_from_terminal_p): Don't check caution. Handle stdin == NULL for Insight. * top.h (in_user_command, caution): New declarations. * utils.c: Include "top.h". (query, defaulted_query): Check caution here. Move the call to input_from_terminal_p higher. * cli/cli-script.c (do_restore_user_call_depth): Only decrement the depth. Update in_user_command if necessary. (execute_user_command): Don't clobber old_chain. Set in_user_command. Let do_restore_user_call_depth handle user_call_depth. (read_command_lines): Check whether to prompt before calling Insight hooks. * tui/tui-hooks.c (tui_query_hook): Remove newly unnecessary input_from_terminal_p check.
Diffstat (limited to 'gdb/cli/cli-script.c')
-rw-r--r--gdb/cli/cli-script.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index ee986d1..b8e9d4f 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -1,8 +1,8 @@
/* GDB CLI command scripting.
Copyright (c) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005 Free
- Software Foundation, Inc.
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006
+ Free Software Foundation, Inc.
This file is part of GDB.
@@ -241,9 +241,9 @@ static void
do_restore_user_call_depth (void * call_depth)
{
int * depth = call_depth;
- /* We will be returning_to_top_level() at this point, so we want to
- reset our depth. */
- (*depth) = 0;
+ (*depth)--;
+ if ((*depth) == 0)
+ in_user_command = 0;
}
@@ -266,12 +266,17 @@ execute_user_command (struct cmd_list_element *c, char *args)
if (++user_call_depth > max_user_call_depth)
error (_("Max user call depth exceeded -- command aborted."));
- old_chain = make_cleanup (do_restore_user_call_depth, &user_call_depth);
+ make_cleanup (do_restore_user_call_depth, &user_call_depth);
/* Set the instream to 0, indicating execution of a
user-defined function. */
- old_chain = make_cleanup (do_restore_instream_cleanup, instream);
+ make_cleanup (do_restore_instream_cleanup, instream);
instream = (FILE *) 0;
+
+ /* Also set the global in_user_command, so that NULL instream is
+ not confused with Insight. */
+ in_user_command = 1;
+
while (cmdlines)
{
ret = execute_control_command (cmdlines);
@@ -283,8 +288,6 @@ execute_user_command (struct cmd_list_element *c, char *args)
cmdlines = cmdlines->next;
}
do_cleanups (old_chain);
-
- user_call_depth--;
}
enum command_control_type
@@ -920,15 +923,19 @@ read_command_lines (char *prompt_arg, int from_tty)
enum misc_command_type val;
control_level = 0;
- if (deprecated_readline_begin_hook)
- {
- /* Note - intentional to merge messages with no newline */
- (*deprecated_readline_begin_hook) ("%s %s\n", prompt_arg, END_MESSAGE);
- }
- else if (from_tty && input_from_terminal_p ())
+
+ if (from_tty && input_from_terminal_p ())
{
- printf_unfiltered ("%s\n%s\n", prompt_arg, END_MESSAGE);
- gdb_flush (gdb_stdout);
+ if (deprecated_readline_begin_hook)
+ {
+ /* Note - intentional to merge messages with no newline */
+ (*deprecated_readline_begin_hook) ("%s %s\n", prompt_arg, END_MESSAGE);
+ }
+ else
+ {
+ printf_unfiltered ("%s\n%s\n", prompt_arg, END_MESSAGE);
+ gdb_flush (gdb_stdout);
+ }
}
head = tail = NULL;
@@ -989,7 +996,7 @@ read_command_lines (char *prompt_arg, int from_tty)
do_cleanups (old_chain);
}
- if (deprecated_readline_end_hook)
+ if (deprecated_readline_end_hook && from_tty && input_from_terminal_p ())
{
(*deprecated_readline_end_hook) ();
}