This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Displaced stepping just enable in non-stop mode
Hi teawater,
Thanks again for doing this. I believe your patch is close to being OK. I
took the liberty of adjusting it a bit, mostly re-wording a bit the
comments and the documentation.
I think Joel's suggestion was a good one: By gaining an "auto"
setting, this is as much a maintainer command as
"set breakpoint always-inserted" is. So, I believe it's time we move
the command to the top level "set" command group.
set can-use-displaced-stepping (auto|on|off)
Eli, can I ask you to go over the help strings and the documentation in
the patch below? Do they look OK-ish?
--
Pedro Alves
2008-10-16 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 can-use-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-16 Hui Zhu <teawater@gmail.com>
Pedro Alves <pedro@codesourcery.com>
* gdb.texinfo (can-use-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/doc/gdb.texinfo | 33 ++++++++++++++++++------
gdb/infrun.c | 69 ++++++++++++++++++++++++++++++++++++++--------------
2 files changed, 75 insertions(+), 27 deletions(-)
Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c 2008-10-07 19:08:53.000000000 +0100
+++ src/gdb/infrun.c 2008-10-16 00:58:31.000000000 +0100
@@ -553,26 +553,55 @@ static CORE_ADDR displaced_step_original
/* 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 can-use-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));
}
@@ -4857,16 +4886,20 @@ function is skipped and the step command
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 ("can-use-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);
/* ptid initializations */
null_ptid = ptid_build (0, 0, 0);
Index: src/gdb/doc/gdb.texinfo
===================================================================
--- src.orig/gdb/doc/gdb.texinfo 2008-10-15 23:33:25.000000000 +0100
+++ src/gdb/doc/gdb.texinfo 2008-10-16 01:05:33.000000000 +0100
@@ -23933,18 +23933,33 @@ Shared library events.
@end table
-@kindex maint set can-use-displaced-stepping
-@kindex maint show can-use-displaced-stepping
+@kindex set can-use-displaced-stepping
+@kindex show can-use-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 can-use-displaced-stepping
+@itemx show can-use-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 can-use-displaced-stepping on
+If the target architecture supports it, @value{GDBN} will use
+displaced stepping to step over breakpoints.
+
+@item set can-use-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 can-use-displaced-stepping}
+@item set can-use-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 it.
+@end table
@kindex maint check-symtabs
@item maint check-symtabs