Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA/commit/doco] move handing of "set interactive-mode" to gdb_has_a_terminal
Date: Mon, 31 Jan 2011 03:15:00 -0000	[thread overview]
Message-ID: <20110131031408.GD2384@adacore.com> (raw)
In-Reply-To: <000001cbbd47$1d831a50$58894ef0$@muller@ics-cnrs.unistra.fr>

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

>   I suppose that the correct code should be:
> +  if (interactive_mode != AUTO_BOOLEAN_AUTO)
> +    return (interactive_mode == AUTO_BOOLEAN_TRUE);

This is absolutely correct - horrible typo.

I just checked in the following patch to correct the problem, together
with added tests that demonstrate the effect of this bug.  In the
future, don't hesitate to fix the problem yourself too.

-- 
Joel

[-- Attachment #2: interact.diff --]
[-- Type: text/x-diff, Size: 3835 bytes --]

commit 9610bd83ed7d0c5bfd28fbc46c4f8828ab10c473
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Mon Jan 31 06:28:48 2011 +0400

    fix typo during interactive_mode check in gdb_has_a_terminal
    
    Discovered by Pierre Muller.
    
    gdb/ChangeLog:
    
            * inflow.c (gdb_has_a_terminal): Fix typo in interactive_mode
            value test.
    
    gdb/testsuite/ChangeLog:
    
            * gdb.base/interact.exp: Add extra tests that verify that
            the value of the interactive-mode setting does not change
            after the script is sourced.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 373ccfc..9c18a83 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2011-01-31  Joel Brobecker  <brobecker@adacore.com>
+
+	* inflow.c (gdb_has_a_terminal): Fix typo in interactive_mode
+	value test.
+
 2011-01-31  Yao Qi  <yao@codesourcery.com>
 
 	* arm-linux-nat.c: Update calls to regcache_register_status
diff --git a/gdb/inflow.c b/gdb/inflow.c
index 859c74e..9975904 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -165,7 +165,7 @@ int
 gdb_has_a_terminal (void)
 {
   if (interactive_mode != AUTO_BOOLEAN_AUTO)
-    return interactive_mode = AUTO_BOOLEAN_TRUE;
+    return interactive_mode == AUTO_BOOLEAN_TRUE;
 
   switch (gdb_has_a_terminal_flag)
     {
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 1b63bff..d05b6e6 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2011-01-31  Joel Brobecker  <brobecker@adacore.com>
+
+	* gdb.base/interact.exp: Add extra tests that verify that
+	the value of the interactive-mode setting does not change
+	after the script is sourced.
+
 2011-01-29  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
 	* gdb.cp/noparam.exp: New file.
diff --git a/gdb/testsuite/gdb.base/interact.exp b/gdb/testsuite/gdb.base/interact.exp
index 1f15fd8..59caf1b 100644
--- a/gdb/testsuite/gdb.base/interact.exp
+++ b/gdb/testsuite/gdb.base/interact.exp
@@ -28,21 +28,36 @@ set script_output "\\$\[0-9\]+ = 1\[\r\n\]+\\$\[0-9\]+ = 2.*"
 gdb_exit
 gdb_start
 
-# Test sourcing of the script with interactive mode `auto'
+# Test sourcing of the script with interactive mode `auto'.
+# Verify that evaluating the script does not cause an unexpected
+# change of the interactive-mode setting.
 gdb_test_no_output "set interactive-mode auto"
 gdb_test "source zzz-gdbscript" "$script_output" \
          "source script with interactive-mode auto"
 gdb_test "print 3" "= 3" "sanity check with interactive-mode auto"
+gdb_test "show interactive-mode" \
+         "Debugger's interactive mode is auto \\(currently .*\\)\\." \
+         "show interactive-mode (auto)"
 
-# Test sourcing of the script with interactive mode `on'
+# Test sourcing of the script with interactive mode `on'.
+# Verify that evaluating the script does not cause an unexpected
+# change of the interactive-mode setting.
 gdb_test_no_output "set interactive-mode on"
 gdb_test "source zzz-gdbscript" "$script_output" \
          "source script with interactive-mode on"
 gdb_test "print 4" "= 4" "sanity check with interactive-mode on"
+gdb_test "show interactive-mode" \
+         "Debugger's interactive mode is on\\." \
+         "show interactive-mode (on)"
 
-# Test sourcing of the script with interactive mode `of'
+# Test sourcing of the script with interactive mode `off'.
+# Verify that evaluating the script does not cause an unexpected
+# change of the interactive-mode setting.
 gdb_test_no_output "set interactive-mode off"
 gdb_test "source zzz-gdbscript" "$script_output" \
          "source script with interactive-mode off"
 gdb_test "print 5" "= 5" "sanity check with interactive-mode off"
+gdb_test "show interactive-mode" \
+         "Debugger's interactive mode is off\\." \
+         "show interactive-mode (off)"
 

      reply	other threads:[~2011-01-31  3:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-18 23:42 Joel Brobecker
2011-01-19 15:01 ` Eli Zaretskii
2011-01-19 17:27   ` Joel Brobecker
2011-01-20  0:46     ` Eli Zaretskii
2011-01-21 19:48 ` Joel Brobecker
2011-01-26 15:21   ` Pierre Muller
2011-01-31  3:15     ` Joel Brobecker [this message]

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=20110131031408.GD2384@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pierre.muller@ics-cnrs.unistra.fr \
    /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