Re: [RFA] Displaced stepping just enable in non-stop mode

teawater
2008-10-22T03:16:42Z

[-- Attachment #1: Type: text/plain, Size: 2330 bytes --]

Hi all,

I make a new patch that change "can-use-displaced-stepping" to
"displaced-stepping" and change some part according to Eli's idea in
doc.

2008-10-22 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-22 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.

Thanks,
Hui

On Thu, Oct 16, 2008 at 10:59, Pedro Alves <pedro@codesourcery.com> wrote:
> On Thursday 16 October 2008 03:38:37, Daniel Jacobowitz wrote:
>> On Thu, Oct 16, 2008 at 01:07:42AM +0100, Pedro Alves wrote:
>
>> > 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?
>>
>> That's a pretty long name. Do you think there are any other useful
>> stepping related settings? If so, maybe we should have a "set step"
>> prefix.
>>
>
> Hmm, not offhand. I'd have to think about it.
> What would you call the setting then, if not "set step can-use-displaced-stepping" ?
>
> The name was actually modeled on "set can-use-hw-watchpoints" in the first place.
>
> --
> Pedro Alves
>

[-- Attachment #2: displaced_step_non_step.txt --]
[-- Type: text/plain, Size: 5784 bytes --]

--- a/infrun.c
+++ b/infrun.c
@@ -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 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));
}

@@ -5107,16 +5136,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 ("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\
--- a/gdb.texinfo
+++ b/gdb.texinfo
@@ -24113,18 +24113,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