From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32142 invoked by alias); 29 Mar 2006 15:43:25 -0000 Received: (qmail 32128 invoked by uid 22791); 29 Mar 2006 15:43:24 -0000 X-Spam-Check-By: sourceware.org Received: from fra-del-04.spheriq.net (HELO fra-del-04.spheriq.net) (195.46.51.100) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 29 Mar 2006 15:43:22 +0000 Received: from fra-out-03.spheriq.net (fra-out-03.spheriq.net [195.46.51.131]) by fra-del-04.spheriq.net with ESMTP id k2TFgxJr012738 for ; Wed, 29 Mar 2006 15:43:05 GMT Received: from fra-cus-01.spheriq.net (fra-cus-01.spheriq.net [195.46.51.37]) by fra-out-03.spheriq.net with ESMTP id k2TFgwUP010523 for ; Wed, 29 Mar 2006 15:42:58 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by fra-cus-01.spheriq.net with ESMTP id k2TFglkB012129 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Wed, 29 Mar 2006 15:42:53 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 743DBDA45; Wed, 29 Mar 2006 15:42:47 +0000 (GMT) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 93258474CC; Wed, 29 Mar 2006 15:46:46 +0000 (GMT) Received: from [164.129.15.13] (terrorhawk.bri.st.com [164.129.15.13]) by mail1.bri.st.com (MOS 3.5.8-GR) with ESMTP id CHK15784 (AUTH stubbsa); Wed, 29 Mar 2006 16:42:44 +0100 (BST) Message-ID: <442AAA5F.1010004@st.com> Date: Wed, 29 Mar 2006 16:29:00 -0000 From: Andrew STUBBS User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: Mark Kettenis , gdb-patches@sourceware.org, insight@sourceware.org Subject: Re: [PATCH] Don't call Insight hooks when not appropriate References: <44104BB2.6000108@st.com> <200603091910.k29JAucq014442@elgar.sibelius.xs4all.nl> <20060309191304.GA31165@nevyn.them.org> <44115FE2.4070206@st.com> <20060325000428.GH26748@nevyn.them.org> <4427CCAC.3030800@st.com> <20060328215858.GC10392@nevyn.them.org> In-Reply-To: <20060328215858.GC10392@nevyn.them.org> Content-Type: multipart/mixed; boundary="------------020604010702000601000307" X-O-Spoofed: Not Scanned X-O-General-Status: No X-O-Spam1-Status: Not Scanned X-O-Spam2-Status: Not Scanned X-O-URL-Status: Not Scanned X-O-Virus1-Status: No X-O-Virus2-Status: Not Scanned X-O-Virus3-Status: No X-O-Virus4-Status: No X-O-Virus5-Status: Not Scanned X-O-Image-Status: Not Scanned X-O-Attach-Status: Not Scanned X-SpheriQ-Ver: 4.2.01 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-03/txt/msg00341.txt.bz2 This is a multi-part message in MIME format. --------------020604010702000601000307 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 888 Daniel Jacobowitz wrote: >> I haven't actually tested it, but shouldn't gdbtk_readline() and >> gdbtk_query() return values? In particular, gdbtk_query() should return >> 1 (yes) as the default answer, just as query() does in utils.c. > > You're right; my patch won't work. How about this one instead? Make > input_from_terminal_p do something sensible for Insight. I'm a little confused now. I assume you meant to retain the cli-script.c and top.h patches from your previous posting, but, even so, your patch doesn't even attempt to tackle the problems with query() and read_command_lines(). I think you are getting at the attached patch. I have tested this and it does what I want it to. It produces no extra failures in the test suite. I'm still a little concerned that input_from_terminal_p no longer seems to take 'caution' into account. Is that deliberate? Andrew Stubbs --------------020604010702000601000307 Content-Type: text/plain; name="insight-dialogue-2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="insight-dialogue-2.patch" Content-length: 5946 2006-03-29 Daniel Jacobowitz Andrew Stubbs * top.h: Declare in_user_command variable. * cli/cli-script.c (do_restore_user_call_depth): Unset in_user_command. (execute_user_command): Only set old_chain once. Set in_user_command. Decrement user_call_depth on return. (read_command_lines): Use input_from_terminal_p() to guard the deprecated_readline_begin_hook() call in addition to the non-hook. * top.c (in_user_command): New global variable. (command_line_input): use only input_from_terminal_p() to determine interactive state. (input_from_terminal_p): Take in_user_command into account. * utils.c (query): Move automatic 'yes' test before deprecated_query_hook() call. Index: src/gdb/cli/cli-script.c =================================================================== --- src.orig/gdb/cli/cli-script.c 2006-03-27 13:55:48.000000000 +0100 +++ src/gdb/cli/cli-script.c 2006-03-29 11:25:52.000000000 +0100 @@ -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_el 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_el cmdlines = cmdlines->next; } do_cleanups (old_chain); - - user_call_depth--; } enum command_control_type @@ -920,15 +923,19 @@ read_command_lines (char *prompt_arg, in 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 (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 if (from_tty) + { + printf_unfiltered ("%s\n%s\n", prompt_arg, END_MESSAGE); + gdb_flush (gdb_stdout); + } } head = tail = NULL; Index: src/gdb/top.c =================================================================== --- src.orig/gdb/top.c 2006-02-20 18:39:55.000000000 +0000 +++ src/gdb/top.c 2006-03-29 11:22:47.000000000 +0100 @@ -112,6 +112,10 @@ Whether to confirm potentially dangerous FILE *instream; +/* Flag to indicate whether a user defined command is currently running. */ + +int in_user_command; + /* Current working directory. */ char *current_directory; @@ -909,11 +913,11 @@ command_line_input (char *prompt_arg, in } /* Don't use fancy stuff if not talking to stdin. */ - if (deprecated_readline_hook && instream == NULL) + if (deprecated_readline_hook && input_from_terminal_p ()) { rl = (*deprecated_readline_hook) (local_prompt); } - else if (command_editing_p && instream == stdin && ISATTY (instream)) + else if (command_editing_p && input_from_terminal_p ()) { rl = gdb_readline_wrapper (local_prompt); } @@ -1197,13 +1201,22 @@ quit_force (char *args, int from_tty) exit (exit_code); } -/* Returns whether GDB is running on a terminal and whether the user - desires that questions be asked of them on that terminal. */ +/* Returns whether GDB is running on a terminal and input is + currently coming from that terminal. */ int input_from_terminal_p (void) { - return gdb_has_a_terminal () && (instream == stdin) & caution; + if (gdb_has_a_terminal () && instream == stdin) + return 1; + + /* If INSTREAM is unset, and we are not in a user command, we + must be in Insight. That's like having a terminal, for our + purposes. */ + if (instream == NULL && !in_user_command) + return 1; + + return 0; } static void Index: src/gdb/top.h =================================================================== --- src.orig/gdb/top.h 2005-12-17 22:34:03.000000000 +0000 +++ src/gdb/top.h 2006-03-29 11:22:29.000000000 +0100 @@ -27,6 +27,7 @@ extern char *line; extern int linesize; extern FILE *instream; +extern int in_user_command; extern char gdb_dirbuf[1024]; extern int inhibit_gdbinit; extern int epoch_interface; Index: src/gdb/utils.c =================================================================== --- src.orig/gdb/utils.c 2006-03-27 13:55:48.000000000 +0100 +++ src/gdb/utils.c 2006-03-29 11:26:18.000000000 +0100 @@ -1141,16 +1141,16 @@ query (const char *ctlstr, ...) int ans2; int retval; + /* Automatically answer "yes" if input is not from a terminal. */ + if (!input_from_terminal_p ()) + return 1; + if (deprecated_query_hook) { va_start (args, ctlstr); return deprecated_query_hook (ctlstr, args); } - /* Automatically answer "yes" if input is not from a terminal. */ - if (!input_from_terminal_p ()) - return 1; - while (1) { wrap_here (""); /* Flush any buffered output */ --------------020604010702000601000307--