2008-10-24 Hui Zhu <teawater@gmail.com>
authorHui Zhu <teawater@gmail.com>
Fri, 24 Oct 2008 02:31:41 +0000 (02:31 +0000)
committerHui Zhu <teawater@gmail.com>
Fri, 24 Oct 2008 02:31:41 +0000 (02:31 +0000)
    Pedro Alves  <pedro@codesourcery.com>

* infrun.c (can_use_displaced_stepping): Change type to
const char pointer.
(can_use_displaced_stepping_auto): New string.
(can_use_displaced_stepping_on): New string.
(can_use_displaced_stepping_off): New string.
(can_use_displaced_stepping_enum): New array.
(show_can_use_displaced_stepping): In auto mode, also show
the current effect of the option.
(use_displaced_stepping): Return non-zero if displaced
stepping is auto, and can be used with GDBARCH, and in
non-stop mode.  Return non-zero if displaced stepping is on,
and can be used with GDBARCH.  Return zero otherwise.
(_initialize_infrun): Make the "set displaced-stepping"
command an enum command.  Change its class to class_run.
Place it in the top level set list.  Extend help to describe
the auto mode.

2008-10-24  Hui Zhu  <teawater@gmail.com>
    Pedro Alves  <pedro@codesourcery.com>

* gdb.texinfo (displaced-stepping): Describe the auto mode
setting, and say it's the default.  This is now a mainstream
setting instead of a maintenance setting.

gdb/ChangeLog
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/infrun.c

index b8003a4..ff4264b 100644 (file)
@@ -1,3 +1,23 @@
+2008-10-24  Hui Zhu  <teawater@gmail.com>
+           Pedro Alves  <pedro@codesourcery.com>
+
+       * infrun.c (can_use_displaced_stepping): Change type to
+       const char pointer.
+       (can_use_displaced_stepping_auto): New string.
+       (can_use_displaced_stepping_on): New string.
+       (can_use_displaced_stepping_off): New string.
+       (can_use_displaced_stepping_enum): New array.
+       (show_can_use_displaced_stepping): In auto mode, also show
+       the current effect of the option.
+       (use_displaced_stepping): Return non-zero if displaced
+       stepping is auto, and can be used with GDBARCH, and in
+       non-stop mode.  Return non-zero if displaced stepping is on,
+       and can be used with GDBARCH.  Return zero otherwise.
+       (_initialize_infrun): Make the "set displaced-stepping"
+       command an enum command.  Change its class to class_run.
+       Place it in the top level set list.  Extend help to describe
+       the auto mode.
+
 2008-10-23  Pedro Alves  <pedro@codesourcery.com>
 
        * defs.h: Mention ptid_is_pid.
index 56a0496..7e350a7 100644 (file)
@@ -1,3 +1,10 @@
+2008-10-24  Hui Zhu  <teawater@gmail.com>
+           Pedro Alves  <pedro@codesourcery.com>
+
+       * gdb.texinfo (displaced-stepping): Describe the auto mode
+       setting, and say it's the default.  This is now a mainstream
+       setting instead of a maintenance setting.
+
 2008-10-23  Pedro Alves  <pedro@codesourcery.com>
 
        * observer.texi (thread_stop_requested): New.
index c003cd4..6b5c2a5 100644 (file)
@@ -24296,18 +24296,33 @@ Shared library events.
 
 @end table
 
-@kindex maint set can-use-displaced-stepping
-@kindex maint show can-use-displaced-stepping
+@kindex set displaced-stepping
+@kindex show displaced-stepping
 @cindex displaced stepping support
 @cindex out-of-line single-stepping
-@item maint set can-use-displaced-stepping
-@itemx maint show can-use-displaced-stepping
+@item set displaced-stepping
+@itemx show displaced-stepping
 Control whether or not @value{GDBN} will do @dfn{displaced stepping}
-if the target supports it.  The default is on.  Displaced stepping is
-a way to single-step over breakpoints without removing them from the
-inferior, by executing an out-of-line copy of the instruction that was
-originally at the breakpoint location.  It is also known as
-out-of-line single-stepping.
+if the target supports it.  Displaced stepping is a way to single-step
+over breakpoints without removing them from the inferior, by executing
+an out-of-line copy of the instruction that was originally at the
+breakpoint location.  It is also known as out-of-line single-stepping.
+
+@table @code
+@item set displaced-stepping on
+If the target architecture supports it, @value{GDBN} will use
+displaced stepping to step over breakpoints.
+
+@item set displaced-stepping off
+@value{GDBN} will not use displaced stepping to step over breakpoints,
+even if such is supported by the target architecture.
+
+@cindex non-stop mode, and @samp{set displaced-stepping}
+@item set displaced-stepping auto
+This is the default mode.  @value{GDBN} will use displaced stepping
+only if non-stop mode is active (@pxref{Non-Stop Mode}) and the target
+architecture supports displaced stepping.
+@end table
 
 @kindex maint check-symtabs
 @item maint check-symtabs
index a6d4244..552c91f 100644 (file)
@@ -553,26 +553,55 @@ static CORE_ADDR displaced_step_original, displaced_step_copy;
 /* Saved contents of copy area.  */
 static gdb_byte *displaced_step_saved_copy;
 
-/* When this is non-zero, we are allowed to use displaced stepping, if
-   the architecture supports it.  When this is zero, we use
-   traditional the hold-and-step approach.  */
-int can_use_displaced_stepping = 1;
+/* Enum strings for "set|show displaced-stepping".  */
+
+static const char can_use_displaced_stepping_auto[] = "auto";
+static const char can_use_displaced_stepping_on[] = "on";
+static const char can_use_displaced_stepping_off[] = "off";
+static const char *can_use_displaced_stepping_enum[] =
+{
+  can_use_displaced_stepping_auto,
+  can_use_displaced_stepping_on,
+  can_use_displaced_stepping_off,
+  NULL,
+};
+
+/* If ON, and the architecture supports it, GDB will use displaced
+   stepping to step over breakpoints.  If OFF, or if the architecture
+   doesn't support it, GDB will instead use the traditional
+   hold-and-step approach.  If AUTO (which is the default), GDB will
+   decide which technique to use to step over breakpoints depending on
+   which of all-stop or non-stop mode is active --- displaced stepping
+   in non-stop mode; hold-and-step in all-stop mode.  */
+
+static const char *can_use_displaced_stepping =
+  can_use_displaced_stepping_auto;
+
 static void
 show_can_use_displaced_stepping (struct ui_file *file, int from_tty,
                                 struct cmd_list_element *c,
                                 const char *value)
 {
-  fprintf_filtered (file, _("\
-Debugger's willingness to use displaced stepping to step over "
-"breakpoints is %s.\n"), value);
+  if (can_use_displaced_stepping == can_use_displaced_stepping_auto)
+    fprintf_filtered (file, _("\
+Debugger's willingness to use displaced stepping to step over \
+breakpoints is %s (currently %s).\n"),
+                     value, non_stop ? "on" : "off");
+  else
+    fprintf_filtered (file, _("\
+Debugger's willingness to use displaced stepping to step over \
+breakpoints is %s.\n"), value);
 }
 
-/* Return non-zero if displaced stepping is enabled, and can be used
-   with GDBARCH.  */
+/* Return non-zero if displaced stepping can/should be used to step
+   over breakpoints.  */
+
 static int
 use_displaced_stepping (struct gdbarch *gdbarch)
 {
-  return (can_use_displaced_stepping
+  return (((can_use_displaced_stepping == can_use_displaced_stepping_auto
+           && non_stop)
+          || can_use_displaced_stepping == can_use_displaced_stepping_on)
          && gdbarch_displaced_step_copy_insn_p (gdbarch));
 }
 
@@ -5241,16 +5270,20 @@ function is skipped and the step command stops at a different source line."),
                           show_step_stop_if_no_debug,
                           &setlist, &showlist);
 
-  add_setshow_boolean_cmd ("can-use-displaced-stepping", class_maintenance,
-                          &can_use_displaced_stepping, _("\
+  add_setshow_enum_cmd ("displaced-stepping", class_run,
+                       can_use_displaced_stepping_enum,
+                       &can_use_displaced_stepping, _("\
 Set debugger's willingness to use displaced stepping."), _("\
 Show debugger's willingness to use displaced stepping."), _("\
-If zero, gdb will not use displaced stepping to step over\n\
-breakpoints, even if such is supported by the target."),
-                          NULL,
-                          show_can_use_displaced_stepping,
-                          &maintenance_set_cmdlist,
-                          &maintenance_show_cmdlist);
+If on, gdb will use displaced stepping to step over breakpoints if it is\n\
+supported by the target architecture.  If off, gdb will not use displaced\n\
+stepping to step over breakpoints, even if such is supported by the target\n\
+architecture.  If auto (which is the default), gdb will use displaced stepping\n\
+if the target architecture supports it and non-stop mode is active, but will not\n\
+use it in all-stop mode (see help set non-stop)."),
+                       NULL,
+                       show_can_use_displaced_stepping,
+                       &setlist, &showlist);
 
   add_setshow_enum_cmd ("exec-direction", class_run, exec_direction_names,
                        &exec_direction, _("Set direction of execution.\n\