public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
From: Andrew STUBBS <andrew.stubbs@st.com>
To: GDB Patches <gdb-patches@sourceware.org>, insight@sourceware.org
Subject: [PATCH] Don't call Insight hooks when not appropriate
Date: Thu, 09 Mar 2006 15:42:00 -0000	[thread overview]
Message-ID: <44104BB2.6000108@st.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 887 bytes --]

Hi all,

I'm not really sure whether this should go to GDB patches or Insight so 
you've both got it.

The attached patch prevents annoying messages and dialogue boxes when 
sourcing command scripts and running user-defined commands. It stops all 
yes/no questions and all 'Type commands for ...' messages.

Output and prompts from these scripts are normally suppressed by GDB, 
but not by Insight.

In order to achieve this I had to find a way to tell the difference 
between the normal Insight input state, and the state when executing 
user commands - both were previously identified by instream==NULL. I 
have changed instream to -1 when running user-defined commands. An 
inspection of the uses of instream suggests this will not have any 
detrimental affects, but it is hard to be totally sure.

I know these hooks are marked deprecated, but we're still using them.

Andrew Stubbs

[-- Attachment #2: insight-dialogue.patch --]
[-- Type: text/plain, Size: 2185 bytes --]

2006-03-09  Andrew Stubbs  <andrew.stubbs@st.com>

	* cli/cli-script.c (execute_user_command): Set instream to -1, not 0.
	(read_command_lines): Check instream before calling the prompt hook.
	* utils.c: Include top.h.
	(query): Check instream before calling the query hook.

Index: src/gdb/cli/cli-script.c
===================================================================
--- src.orig/gdb/cli/cli-script.c	2006-02-20 18:19:58.000000000 +0000
+++ src/gdb/cli/cli-script.c	2006-03-09 15:21:40.000000000 +0000
@@ -268,10 +268,11 @@ execute_user_command (struct cmd_list_el
 
   old_chain = make_cleanup (do_restore_user_call_depth, &user_call_depth);
 
-  /* Set the instream to 0, indicating execution of a
-     user-defined function.  */
+  /* Set the instream to -1, indicating execution of a
+     user-defined function.  Don't use 0 any more, because this is
+     the same as NULL, which is the instream value used by insight.  */
   old_chain = make_cleanup (do_restore_instream_cleanup, instream);
-  instream = (FILE *) 0;
+  instream = (FILE *) -1;
   while (cmdlines)
     {
       ret = execute_control_command (cmdlines);
@@ -920,7 +921,7 @@ read_command_lines (char *prompt_arg, in
   enum misc_command_type val;
 
   control_level = 0;
-  if (deprecated_readline_begin_hook)
+  if ((instream == stdin || instream == NULL) && deprecated_readline_begin_hook)
     {
       /* Note - intentional to merge messages with no newline */
       (*deprecated_readline_begin_hook) ("%s  %s\n", prompt_arg, END_MESSAGE);
Index: src/gdb/utils.c
===================================================================
--- src.orig/gdb/utils.c	2006-02-20 18:12:38.000000000 +0000
+++ src/gdb/utils.c	2006-03-09 15:17:43.000000000 +0000
@@ -54,6 +54,7 @@
 #include "filenames.h"
 #include "symfile.h"
 #include "gdb_obstack.h"
+#include "top.h"
 
 #include "inferior.h"		/* for signed_pointer_to_address */
 
@@ -1141,7 +1142,7 @@ query (const char *ctlstr, ...)
   int ans2;
   int retval;
 
-  if (deprecated_query_hook)
+  if ((instream == stdin || instream == NULL) && deprecated_query_hook)
     {
       va_start (args, ctlstr);
       return deprecated_query_hook (ctlstr, args);

             reply	other threads:[~2006-03-09 15:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-09 15:42 Andrew STUBBS [this message]
2006-03-09 19:11 ` Mark Kettenis
2006-03-09 19:13   ` Daniel Jacobowitz
2006-03-09 19:14     ` Daniel Jacobowitz
2006-03-09 20:20     ` Michael Snyder
2006-03-10 11:15       ` Andrew STUBBS
2006-03-10 11:18     ` Andrew STUBBS
2006-03-25  0:04       ` Daniel Jacobowitz
2006-03-27 11:32         ` Andrew STUBBS
2006-03-28 21:59           ` Daniel Jacobowitz
2006-03-29 15:43             ` Andrew STUBBS
2006-03-29 15:49               ` Daniel Jacobowitz
2006-03-29 15:58                 ` Andrew STUBBS
2006-03-29 16:29                   ` Daniel Jacobowitz
2006-03-29 16:38                     ` Andrew STUBBS
2006-03-29 16:45                       ` Dave Korn
2006-03-29 18:01                       ` Eli Zaretskii
2006-03-29 22:53                       ` Daniel Jacobowitz

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=44104BB2.6000108@st.com \
    --to=andrew.stubbs@st.com \
    --cc=gdb-patches@sourceware.org \
    --cc=insight@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).