From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9885 invoked by alias); 14 Sep 2009 02:38:20 -0000 Received: (qmail 9876 invoked by uid 22791); 14 Sep 2009 02:38:19 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL,BAYES_50,J_CHICKENPOX_37,SPF_PASS X-Spam-Check-By: sourceware.org Received: from imr1.ericy.com (HELO imr1.ericy.com) (198.24.6.9) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Sep 2009 02:38:15 +0000 Received: from eusrcmw750.eamcs.ericsson.se (eusrcmw750.exu.ericsson.se [138.85.77.50]) by imr1.ericy.com (8.13.1/8.13.1) with ESMTP id n8E2cCUD018099 for ; Sun, 13 Sep 2009 21:38:12 -0500 Received: from eusrcmw750.eamcs.ericsson.se ([138.85.77.53]) by eusrcmw750.eamcs.ericsson.se with Microsoft SMTPSVC(6.0.3790.3959); Sun, 13 Sep 2009 21:37:51 -0500 Received: from eusaamw0706.eamcs.ericsson.se ([147.117.20.31]) by eusrcmw750.eamcs.ericsson.se with Microsoft SMTPSVC(6.0.3790.3959); Sun, 13 Sep 2009 21:37:51 -0500 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.1.20]) by eusaamw0706.eamcs.ericsson.se ([147.117.20.31]) with mapi; Sun, 13 Sep 2009 22:37:50 -0400 From: Marc Khouzam To: "gdb-patches@sourceware.org" Date: Mon, 14 Sep 2009 02:38:00 -0000 Subject: Another proposal for frontends and queries. Message-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-09/txt/msg00390.txt.bz2 Hi, I'm starting a new thread in an attempt to get this issue resolved before 7= .0. Three-line recap of the issue: For some frontends queries are answered automatically by GDB. Because of this, some actions that the frontends wants to trigger are automatically cancelled by GDB. More details, for those less familiar: When using Eclipse, our connection through GDB is done so that the method input_from_terminal_p() returns false. Because of this, all queries are answered automatically by GDB. Queries with no default answer, as well as queries with a default of 'y' are both automatically answered 'y'; but queries that default to 'n' are automatically answered 'n'. The problem is that in some cases (specifically for PRecord), an automatic answer of "no" will prevent an operation that the frontend wants to do, from being performed. To my knowledge, there is=20 currently no way for a frontend to get around this limitation. The issue if further complicated in the fact that a specific query can be triggered by different commands. Specifically, one of the PRecord queries gets triggered when we attempt to change memory, which can be from different MI or CLI commands. Proposals: One proposal was to add a way to turn off queries for PRecord. http://sourceware.org/ml/gdb-patches/2009-09/msg00318.html This was based on the fact that the only other nquery() was for pending breakpoints, which has its own option to deal with that query. This solves the current problem but is not future-proof. Another proposal that was thrown out there was to disable queries when having started GDB with the MI interpreter. The idea is that it would be frontends that would start GDB like that, and frontends know what they are doing and don't need queries. http://sourceware.org/ml/gdb/2009-07/msg00113.html This seems too drastic to me. Another solution was that when "set confirm" was "off" all queries would be answered 'y' instead of using their respective default answer. http://sourceware.org/ml/gdb/2009-07/msg00150.html This did not seem very popular. My latest idea, based on the reactions to the previous suggestions is to extend "set confirm" and add a new "force" option. set confirm on/off would remain as before set confirm force would automatically answer 'y' to all queries. The patch below illustrates this latest suggestion. I did the doc changes and NEWS, to help with making this clear. I will add a Changelog if this solution is selected for inclusion. (I'm not very comfortable with the declaration of new variables in this patch, but the patch does illustrates things.) Thanks for any help to get this resolved. Marc ### Eclipse Workspace Patch 1.0 #P src Index: gdb/top.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/top.h,v retrieving revision 1.19 diff -u -r1.19 top.h --- gdb/top.h 31 Aug 2009 20:18:45 -0000 1.19 +++ gdb/top.h 14 Sep 2009 02:27:12 -0000 @@ -27,7 +27,11 @@ extern int linesize; extern FILE *instream; extern int in_user_command; -extern int caution; +extern const char *confirm_mode_string; +extern const char confirm_on[]; +extern const char confirm_off[]; +extern const char confirm_force[]; + extern char gdb_dirbuf[1024]; extern int inhibit_gdbinit; extern int epoch_interface; Index: gdb/top.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/top.c,v retrieving revision 1.171 diff -u -r1.171 top.c --- gdb/top.c 10 Sep 2009 18:56:45 -0000 1.171 +++ gdb/top.c 14 Sep 2009 02:27:12 -0000 @@ -96,13 +96,25 @@ =20 /* Flag for whether we want all the "from_tty" gubbish printed. */ =20 -int caution =3D 1; /* Default is yes, sigh. */ +const char confirm_on[] =3D "on"; +const char confirm_off[] =3D "off"; +const char confirm_force[] =3D "force"; + +static const char *confirm_kind_names[] =3D { + confirm_on, + confirm_off, + confirm_force, + NULL=20 +}; + +const char *confirm_mode_string =3D confirm_on; /* Default is on, 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 dangerous operations is %s.\n"), +Whether to confirm potentially dangerous operations is set to %s.\n"), value); } =20 @@ -293,8 +305,8 @@ /* static */ int quit_cover (void *s) { - caution =3D 0; /* Throw caution to the wind -- we're exiting. - This prevents asking the user dumb questions. */ + confirm_mode_string =3D confirm_off; /* Throw caution to the wind -- we'= re exiting. + This prevents asking the user dumb questions. */ quit_command ((char *) 0, 0); return 0; } @@ -444,13 +456,13 @@ if (c->class =3D=3D class_user) execute_user_command (c, arg); else if (c->type =3D=3D set_cmd || c->type =3D=3D show_cmd) - do_setshow_command (arg, from_tty & caution, c); + do_setshow_command (arg, from_tty && (confirm_mode_string =3D=3D confirm_= on), 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 && (confirm_mode_string = =3D=3D confirm_on)); else - cmd_func (c, arg, from_tty & caution); + cmd_func (c, arg, from_tty && (confirm_mode_string =3D=3D confirm_on)); =20=20=20=20=20=20=20=20 /* If this command has been post-hooked, run the hook last. */ execute_cmd_post_hook (c); @@ -1656,12 +1668,19 @@ show_history_filename, &sethistlist, &showhistlist); =20 - add_setshow_boolean_cmd ("confirm", class_support, &caution, _("\ + add_setshow_enum_cmd ("confirm", class_support, + confirm_kind_names, + &confirm_mode_string, _("\ Set whether to confirm potentially dangerous operations."), _("\ -Show whether to confirm potentially dangerous operations."), NULL, - NULL, - show_caution, - &setlist, &showlist); +Show whether to confirm potentially dangerous operations."), _("\ +confirm can be one of:\n\ + on - confirm potentially dangerous operations with a query\n\ + off - automatically answer queries with the query's default value\n\ + force - automatically answer queries in the affirmative, so as to perfor= m the operation\n\ +By default, confirm is on."), + NULL, + show_confirm, + &setlist, &showlist); =20 add_setshow_zinteger_cmd ("annotate", class_obscure, &annotation_level, = _("\ Set annotation_level."), _("\ Index: gdb/NEWS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/NEWS,v retrieving revision 1.330 diff -u -r1.330 NEWS --- gdb/NEWS 10 Sep 2009 21:02:46 -0000 1.330 +++ gdb/NEWS 14 Sep 2009 02:27:11 -0000 @@ -416,6 +416,15 @@ answer. When set to auto (the default), GDB determines which mode to use based on the stdin settings. =20 +set confirm (on|off|force) +show confirm + Controls whether GDB should confirm potentially dangerous operations. + The 'on' and 'off' settings remain as for the previous release; the + new 'force' option is added which will cause GDB to automatically + answer 'y' to all queries. This differs from the 'off' setting in the + fact that in the 'off' setting, queries are answered as per their + default answer. + * Removed commands =20 info forks Index: gdb/utils.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/utils.c,v retrieving revision 1.219 diff -u -r1.219 utils.c --- gdb/utils.c 18 Aug 2009 16:17:16 -0000 1.219 +++ gdb/utils.c 14 Sep 2009 02:27:13 -0000 @@ -932,7 +932,7 @@ /* 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 =3D=3D 0) + if (confirm_mode_string !=3D confirm_on) { /* Emit the message and quit. */ fputs_unfiltered (reason, gdb_stderr); @@ -1440,9 +1440,13 @@ n_string =3D "[n]"; } =20 + /* Automatically answer 'y' if the confirm option is set to 'force' */ + if (confirm_mode_string =3D=3D confirm_force) + return 1; + /* 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_mode_string =3D=3D confirm_off) || server_command) return def_value; =20 /* If input isn't coming from the user directly, just say what Index: gdb/doc/gdb.texinfo =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.622 diff -u -r1.622 gdb.texinfo --- gdb/doc/gdb.texinfo 10 Sep 2009 21:03:07 -0000 1.622 +++ gdb/doc/gdb.texinfo 14 Sep 2009 02:27:30 -0000 @@ -3805,7 +3805,8 @@ Delete the breakpoints, watchpoints, or catchpoints of the breakpoint ranges specified as arguments. If no argument is specified, delete all breakpoints (@value{GDBN} asks confirmation, unless you have @code{set -confirm off}). You can abbreviate this command as @code{d}. +confirm off} or @code{set confirm force}). You can abbreviate this=20 +command as @code{d}. @end table =20 @node Disabling @@ -18062,11 +18063,14 @@ @cindex confirmation @cindex stupid questions @item set confirm off -Disables confirmation requests. +Disables confirmation requests and answers with the default answer for tha= t confirmation. =20 @item set confirm on Enables confirmation requests (the default). =20 +@item set confirm force +Disables confirmation requests and always answers with the affirmative. + @kindex show confirm @item show confirm Displays state of confirmation requests. =20=20