This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

set record query <on|off>


Hi,

here is a patch to allow to enable/disable the queries
used in Record.  It is relevant to:

http://sourceware.org/ml/gdb/2009-09/msg00165.html

What do you think?

Sorry, I have to run, but I'll send the Changelog tonight.

Thanks

Marc

P.S. I didn't make the change in record_check_insn_num()
because I got the feeling that function may need review.

ï### Eclipse Workspace Patch 1.0
#P src
Index: gdb/record.c
===================================================================
RCS file: /cvs/src/src/gdb/record.c,v
retrieving revision 1.17
diff -u -r1.17 record.c
--- gdb/record.c        8 Sep 2009 00:50:42 -0000       1.17
+++ gdb/record.c        11 Sep 2009 14:51:48 -0000
@@ -94,6 +94,14 @@
 static int record_insn_max_num = DEFAULT_RECORD_INSN_MAX_NUM;
 static int record_insn_num = 0;

+/* 1 use queries.  0 don't use queries and perform action.
+   Note that when queries are not used, we do not fall back to
+   any specified query default; instead, we perform the action.
+   This is important for frontends that don't handle queries or
+   to allow actions to be performed even if 'set confirm off'
+   is used */
+static int record_enable_queries = 1;
+
 /* The target_ops of process record.  */
 static struct target_ops record_ops;

@@ -443,9 +451,9 @@
   /* Check if record target is already running.  */
   if (current_target.to_stratum == record_stratum)
     {
-      if (!nquery
-         (_("Process record target already running, do you want to delete "
-            "the old record log?")))
+      if (record_enable_queries
+         && !nquery (_("Process record target already running, do you want to "
+                       "delete the old record log?")))
        return;
     }

@@ -961,19 +969,24 @@
          int n;

          /* Let user choose if he wants to write register or not.  */
-         if (regno < 0)
-           n =
-             nquery (_("Because GDB is in replay mode, changing the "
-                       "value of a register will make the execution "
-                       "log unusable from this point onward.  "
-                       "Change all registers?"));
+         if (record_enable_queries)
+           {
+             if (regno < 0)
+               n =
+                 nquery (_("Because GDB is in replay mode, changing the "
+                           "value of a register will make the execution "
+                           "log unusable from this point onward.  "
+                           "Change all registers?"));
+             else
+               n =
+                 nquery (_("Because GDB is in replay mode, changing the value "
+                           "of a register will make the execution log unusable "
+                           "from this point onward.  Change register %s?"),
+                         gdbarch_register_name (get_regcache_arch (regcache),
+                                                  regno));
+           }
          else
-           n =
-             nquery (_("Because GDB is in replay mode, changing the value "
-                       "of a register will make the execution log unusable "
-                       "from this point onward.  Change register %s?"),
-                     gdbarch_register_name (get_regcache_arch (regcache),
-                                              regno));
+           n = 1;

          if (!n)
            {
@@ -1019,10 +1032,11 @@
       if (RECORD_IS_REPLAY)
        {
          /* Let user choose if he wants to write memory or not.  */
-         if (!nquery (_("Because GDB is in replay mode, writing to memory "
-                        "will make the execution log unusable from this "
-                        "point onward.  Write memory at address %s?"),
-                      paddress (target_gdbarch, offset)))
+         if (record_enable_queries
+             && !nquery (_("Because GDB is in replay mode, writing to memory "
+                           "will make the execution log unusable from this "
+                           "point onward.  Write memory at address %s?"),
+                         paddress (target_gdbarch, offset)))
            error (_("Process record canceled the operation."));

          /* Destroy the record from here forward.  */
@@ -1163,9 +1177,11 @@
     {
       if (RECORD_IS_REPLAY)
        {
-         if (!from_tty || query (_("Delete the log from this point forward "
-                                   "and begin to record the running message "
-                                   "at current PC?")))
+         if (!from_tty
+             || !record_enable_queries
+             || query (_("Delete the log from this point forward "
+                         "and begin to record the running message "
+                         "at current PC?")))
            record_list_release_next ();
        }
       else
@@ -1183,8 +1199,10 @@
 {
   if (current_target.to_stratum == record_stratum)
     {
-      if (!record_list || !from_tty || query (_("Delete recorded log and "
-                                               "stop recording?")))
+      if (!record_list
+         || !from_tty
+         || !record_enable_queries
+         || query (_("Delete recorded log and stop recording?")))
        unpush_target (&record_ops);
     }
   else
@@ -1310,4 +1328,18 @@
   add_cmd ("insn-number", class_obscure, show_record_insn_number,
           _("Show the current number of instructions in the "
             "record/replay buffer."), &info_record_cmdlist);
+
+  /* Command to enable/disable the user of queries in Process Record */
+  add_setshow_boolean_cmd ("query", no_class,
+                          &record_enable_queries, _("\
+Set whether record/replay should enable its use of queries."), _("\
+Show whether record/replay should enable its use of queries."), _("\
+Default is ON.\n\
+When ON, record/replay will query the user on how to behave for certain \
+scenarios.\n\
+When OFF, record/replay will never query the user and will assume that \
+all record actions normally requiring a query, should be performed.\n\
+This option is valuable for frontends which cannot handle the use of queries."),
+                          NULL, NULL,
+                          &set_record_cmdlist, &show_record_cmdlist);
 }




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]