* Decouple "set confirm" from `from_tty'.
@ 2012-01-20 11:33 Pedro Alves
2012-01-20 14:31 ` Joel Brobecker
2012-01-23 16:30 ` Jan Kratochvil
0 siblings, 2 replies; 5+ messages in thread
From: Pedro Alves @ 2012-01-20 11:33 UTC (permalink / raw)
To: GDB Patches
Short version: I'd like to stop "set confirm off" from also disabling from_tty.
I got confused yesterday because I did (without realizing I specified
the wrong path):
...
(gdb) source /wrong/path/to/file.py
(gdb)
...
...
and then bits that were supposedly loaded from file.py
weren't working. I then got really surprised when I realized
that I had used the wrong path to the file, but GDB hadn't
complained. Restarting GDB, and retrying the source command,
I got the expected error back:
(gdb) source /wrong/path/to/file.py
/wrong/path/to/file.py: No such file or directory.
Eventually, I figured out this was caused by having done
"set confirm off" before the source command.
(gdb) source /wrong/path/to/file.py
/wrong/path/to/file.py: No such file or directory.
(gdb) set confirm off
(gdb) source /wrong/path/to/file.py
(gdb)
This was very surprising to me, and I assume to surprise other
users too. Turns out that "set confirm off" also has the
side-effect of running commands with from_tty == 0, which
silences many things. E.g.,
(gdb) attach 10203
Attaching to process 10203
Reading symbols from /bin/sleep...(no debugging symbols found)...done.
Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libc.so.6
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
0x000000339e6bbcd0 in __nanosleep_nocancel () from /lib64/libc.so.6
(gdb)
vs
(gdb) set confirm off
(gdb) attach 10203
0x000000339e6bbcd0 in __nanosleep_nocancel () from /lib64/libc.so.6
(gdb)
I couldn't find anything in the documentation mentioning
this. I can't think of why this is done this way, other than an
historic accident of the command's evolution.
Sat Dec 22 02:51:40 1990 John Gilmore (gnu at cygint)
* main.c: Replace "stupid" with "caution"; you now "set caution
on or off".
Mon Apr 15 21:45:35 1991 Jim Kingdon (kingdon at cygint.cygnus.com)
* main.c (initialize_main): Rename "set caution" to
"set confirm".
So I'd like to stop it doing that.
Comments?
gdb/
2012-01-19 Pedro Alves <palves@redhat.com>
* top.c (caution): Rename to ...
(confirm): ... this.
(show_caution): Rename to ...
(show_confirm): ... this.
(quit_cover): Adjust.
(execute_command): Don't consider the current value of `caution'.
(_initialize_command): Adjust.
* top.h (caution): Rename to ...
(confirm): ... this.
(internal_vproblem, defaulted_query): Adjust.
gdb/testsuite/
2012-01-19 Pedro Alves <palves@redhat.com>
* call-signal-resume.exp: Allow output after "return".
---
gdb/testsuite/gdb.base/call-signal-resume.exp | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/testsuite/gdb.base/call-signal-resume.exp b/gdb/testsuite/gdb.base/call-signal-resume.exp
index 1c4517d..d383f5c 100644
--- a/gdb/testsuite/gdb.base/call-signal-resume.exp
+++ b/gdb/testsuite/gdb.base/call-signal-resume.exp
@@ -99,7 +99,7 @@ if { "$frame_number" == "" } {
# Pop the dummy frame.
gdb_test "frame $frame_number" ".*"
gdb_test_no_output "set confirm off"
-gdb_test_no_output "return"
+gdb_test "return" ""
# Resume execution, the program should continue without any signal.
@@ -132,7 +132,7 @@ if { "$frame_number" == "" } {
# Pop the dummy frame.
gdb_test "frame $frame_number" ".*"
gdb_test_no_output "set confirm off"
-gdb_test_no_output "return"
+gdb_test "return" ""
# Continue again, this time we should get to the signal handler.
diff --git a/gdb/top.c b/gdb/top.c
index c4e913d..e41f56c 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -98,11 +98,13 @@ int use_windows = 0;
extern char lang_frame_mismatch_warn[]; /* language.c */
-/* Flag for whether we want all the "from_tty" gubbish printed. */
+/* Flag for whether we want to confirm potentially dangerous
+ operations. Default is yes. */
+
+int confirm = 1;
-int caution = 1; /* Default is yes, sigh. */
static void
-show_caution (struct ui_file *file, int from_tty,
+show_confirm (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
fprintf_filtered (file, _("Whether to confirm potentially "
@@ -289,9 +291,9 @@ void (*deprecated_context_hook) (int id);
/* static */ void
quit_cover (void)
{
- caution = 0; /* Throw caution to the wind -- we're exiting.
- This prevents asking the user dumb
- questions. */
+ /* Stop asking user for confirmation --- we're exiting. This
+ prevents asking the user dumb questions. */
+ confirm = 0;
quit_command ((char *) 0, 0);
}
#endif /* defined SIGHUP */
@@ -471,13 +473,13 @@ execute_command (char *p, int from_tty)
if (c->class == class_user)
execute_user_command (c, arg);
else if (c->type == set_cmd || c->type == show_cmd)
- do_setshow_command (arg, from_tty & caution, c);
+ do_setshow_command (arg, from_tty, c);
else if (!cmd_func_p (c))
error (_("That is not a command, just a help topic."));
else if (deprecated_call_command_hook)
- deprecated_call_command_hook (c, arg, from_tty & caution);
+ deprecated_call_command_hook (c, arg, from_tty);
else
- cmd_func (c, arg, from_tty & caution);
+ cmd_func (c, arg, from_tty);
/* If the interpreter is in sync mode (we're running a user
command's list, running command hooks or similars), and we
@@ -1633,11 +1635,11 @@ Show the filename in which to record the command history"), _("\
show_history_filename,
&sethistlist, &showhistlist);
- add_setshow_boolean_cmd ("confirm", class_support, &caution, _("\
+ add_setshow_boolean_cmd ("confirm", class_support, &confirm, _("\
Set whether to confirm potentially dangerous operations."), _("\
Show whether to confirm potentially dangerous operations."), NULL,
NULL,
- show_caution,
+ show_confirm,
&setlist, &showlist);
add_setshow_zinteger_cmd ("annotate", class_obscure, &annotation_level, _("\
diff --git a/gdb/top.h b/gdb/top.h
index 55ce104..6f74233 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -26,7 +26,7 @@ extern char *saved_command_line;
extern int saved_command_line_size;
extern FILE *instream;
extern int in_user_command;
-extern int caution;
+extern int confirm;
extern char gdb_dirbuf[1024];
extern int inhibit_gdbinit;
extern int epoch_interface;
diff --git a/gdb/utils.c b/gdb/utils.c
index 4863e41..39ec254 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -970,7 +970,7 @@ internal_vproblem (struct internal_problem *problem,
/* Default (yes/batch case) is to quit GDB. When in batch mode
this lessens the likelihood of GDB going into an infinite
loop. */
- if (caution == 0)
+ if (!confirm)
{
/* Emit the message and quit. */
fputs_unfiltered (reason, gdb_stderr);
@@ -1384,7 +1384,7 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
/* Automatically answer the default value if the user did not want
prompts or the command was issued with the server prefix. */
- if (! caution || server_command)
+ if (!confirm || server_command)
return def_value;
/* If input isn't coming from the user directly, just say what
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Decouple "set confirm" from `from_tty'.
2012-01-20 11:33 Decouple "set confirm" from `from_tty' Pedro Alves
@ 2012-01-20 14:31 ` Joel Brobecker
2012-01-23 17:36 ` Pedro Alves
2012-01-23 16:30 ` Jan Kratochvil
1 sibling, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2012-01-20 14:31 UTC (permalink / raw)
To: Pedro Alves; +Cc: GDB Patches
> Eventually, I figured out this was caused by having done
> "set confirm off" before the source command.
>
> (gdb) source /wrong/path/to/file.py
> /wrong/path/to/file.py: No such file or directory.
> (gdb) set confirm off
> (gdb) source /wrong/path/to/file.py
> (gdb)
>
> This was very surprising to me, and I assume to surprise other
> users too. Turns out that "set confirm off" also has the
> side-effect of running commands with from_tty == 0, which
> silences many things. E.g.,
I agree this is very surprising! I'm even amazed that we did not
realize this until now....
> So I'd like to stop it doing that.
> Comments?
Sounds good to me. To me, "set confirm off" means do everything
the same except auto-answer "y" when I said to do something that
GDB think might be questionable.
No problem spotted with the patch.
--
Joel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Decouple "set confirm" from `from_tty'.
2012-01-20 14:31 ` Joel Brobecker
@ 2012-01-23 17:36 ` Pedro Alves
0 siblings, 0 replies; 5+ messages in thread
From: Pedro Alves @ 2012-01-23 17:36 UTC (permalink / raw)
To: Joel Brobecker; +Cc: GDB Patches
On 01/20/2012 11:33 AM, Joel Brobecker wrote:
>> Eventually, I figured out this was caused by having done
>> "set confirm off" before the source command.
>>
>> (gdb) source /wrong/path/to/file.py
>> /wrong/path/to/file.py: No such file or directory.
>> (gdb) set confirm off
>> (gdb) source /wrong/path/to/file.py
>> (gdb)
>>
>> This was very surprising to me, and I assume to surprise other
>> users too. Turns out that "set confirm off" also has the
>> side-effect of running commands with from_tty == 0, which
>> silences many things. E.g.,
>
> I agree this is very surprising! I'm even amazed that we did not
> realize this until now....
Yeah...
> Sounds good to me. To me, "set confirm off" means do everything
> the same except auto-answer "y" when I said to do something that
> GDB think might be questionable.
Yeah.
> No problem spotted with the patch.
Thanks. The patch is now in, committed in two pieces.
--
Pedro Alves
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Decouple "set confirm" from `from_tty'.
2012-01-20 11:33 Decouple "set confirm" from `from_tty' Pedro Alves
2012-01-20 14:31 ` Joel Brobecker
@ 2012-01-23 16:30 ` Jan Kratochvil
2012-01-23 17:15 ` Pedro Alves
1 sibling, 1 reply; 5+ messages in thread
From: Jan Kratochvil @ 2012-01-23 16:30 UTC (permalink / raw)
To: Pedro Alves; +Cc: GDB Patches
On Fri, 20 Jan 2012 12:13:51 +0100, Pedro Alves wrote:
> Comments?
Just that I would prefer renaming to be a separate commit, otherwise it
somehow complicates later regressions analysis etc. Sure very minor note.
The real change here is negligible in size compared to the renaming.
Thanks,
Jan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Decouple "set confirm" from `from_tty'.
2012-01-23 16:30 ` Jan Kratochvil
@ 2012-01-23 17:15 ` Pedro Alves
0 siblings, 0 replies; 5+ messages in thread
From: Pedro Alves @ 2012-01-23 17:15 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: GDB Patches
On 01/23/2012 04:25 PM, Jan Kratochvil wrote:
> On Fri, 20 Jan 2012 12:13:51 +0100, Pedro Alves wrote:
>> Comments?
>
> Just that I would prefer renaming to be a separate commit, otherwise it
> somehow complicates later regressions analysis etc. Sure very minor note.
>
> The real change here is negligible in size compared to the renaming.
Sure. I've now committed the patch below, which is the same, but
without the renaming.
gdb/
2012-01-23 Pedro Alves <palves@redhat.com>
* top.c (caution): Update comment.
(execute_command): Don't consider the current value of `caution'.
gdb/testsuite/
2012-01-23 Pedro Alves <palves@redhat.com>
* gdb.base/call-signal-resume.exp: Allow output after "return".
---
gdb/testsuite/gdb.base/call-signal-resume.exp | 4 ++--
gdb/top.c | 12 +++++++-----
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/gdb/testsuite/gdb.base/call-signal-resume.exp b/gdb/testsuite/gdb.base/call-signal-resume.exp
index 1c4517d..d383f5c 100644
--- a/gdb/testsuite/gdb.base/call-signal-resume.exp
+++ b/gdb/testsuite/gdb.base/call-signal-resume.exp
@@ -99,7 +99,7 @@ if { "$frame_number" == "" } {
# Pop the dummy frame.
gdb_test "frame $frame_number" ".*"
gdb_test_no_output "set confirm off"
-gdb_test_no_output "return"
+gdb_test "return" ""
# Resume execution, the program should continue without any signal.
@@ -132,7 +132,7 @@ if { "$frame_number" == "" } {
# Pop the dummy frame.
gdb_test "frame $frame_number" ".*"
gdb_test_no_output "set confirm off"
-gdb_test_no_output "return"
+gdb_test "return" ""
# Continue again, this time we should get to the signal handler.
diff --git a/gdb/top.c b/gdb/top.c
index c4e913d..346d73b 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -98,9 +98,11 @@ int use_windows = 0;
extern char lang_frame_mismatch_warn[]; /* language.c */
-/* Flag for whether we want all the "from_tty" gubbish printed. */
+/* Flag for whether we want to confirm potentially dangerous
+ operations. Default is yes. */
+
+int caution = 1;
-int caution = 1; /* Default is yes, sigh. */
static void
show_caution (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
@@ -471,13 +473,13 @@ execute_command (char *p, int from_tty)
if (c->class == class_user)
execute_user_command (c, arg);
else if (c->type == set_cmd || c->type == show_cmd)
- do_setshow_command (arg, from_tty & caution, c);
+ do_setshow_command (arg, from_tty, c);
else if (!cmd_func_p (c))
error (_("That is not a command, just a help topic."));
else if (deprecated_call_command_hook)
- deprecated_call_command_hook (c, arg, from_tty & caution);
+ deprecated_call_command_hook (c, arg, from_tty);
else
- cmd_func (c, arg, from_tty & caution);
+ cmd_func (c, arg, from_tty);
/* If the interpreter is in sync mode (we're running a user
command's list, running command hooks or similars), and we
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-01-23 17:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-20 11:33 Decouple "set confirm" from `from_tty' Pedro Alves
2012-01-20 14:31 ` Joel Brobecker
2012-01-23 17:36 ` Pedro Alves
2012-01-23 16:30 ` Jan Kratochvil
2012-01-23 17:15 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox