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

teawater
2008-10-08T06:11:23Z

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

Hi Joel,

According to your mail, I make a new patch.

2008-10-08 Hui Zhu <teawater@gmail.com>

Displaced stepping can be set to
auto (enable in non-stop mode), on, off.

* 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.
(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.
(_initialize_infrun): "can-use-displaced-stepping" function
change to add_setshow_enum_cmd.

Thanks,
Hui

On Tue, Oct 7, 2008 at 20:17, Joel Brobecker <brobecker@adacore.com> wrote:
>> 2008-10-07 Hui Zhu <teawater@gmail.com>
>>
>> * infrun.c (use_displaced_stepping): Displaced stepping just
>> enable in non-stop mode.
>
> There is still a piece missing. Namely, allow the user to force
> displaced-stepping in a mode that is not non-stop. Pedro suggested that
> we either change the maint command, or add a new one. How about changing
> the maint command into a mainstream command that's a tri-state:
>
> set use-displaced-stepping (auto|on|off)
>
> By default, it's "auto" which means that the debugger tries to determine
> from the situation whether it's necessary or not (basically if non-stop).
> But the user can then override the decision either way.
>
> --
> Joel
>

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

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2008-10-08 Hui Zhu <teawater@gmail.com>
+
+ Displaced stepping can be set to
+ auto (enable in non-stop mode), on, off.
+
+ * 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.
+ (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.
+ (_initialize_infrun): "can-use-displaced-stepping" function
+ change to add_setshow_enum_cmd.
+
2008-10-06 Doug Evans <dje@google.com>

* dwarf2read.c (dwarf2_die_debug): New static global.
--- a/infrun.c
+++ b/infrun.c
@@ -553,10 +553,22 @@ 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
+/* When this is auto, we are allowed to use displaced stepping,
+ If the architecture supports it and in non-stop mode.
+ When this is on, we are allowed to use displaced stepping, if
+ the architecture supports it. When this is off, we use
traditional the hold-and-step approach. */
-int can_use_displaced_stepping = 1;
+const char can_use_displaced_stepping_auto[] = "auto";
+const char can_use_displaced_stepping_on[] = "on";
+const char can_use_displaced_stepping_off[] = "off";
+const char *can_use_displaced_stepping_enum[] =
+{
+ can_use_displaced_stepping_auto,
+ can_use_displaced_stepping_on,
+ can_use_displaced_stepping_off,
+ NULL,
+};
+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,
@@ -567,12 +579,16 @@ Debugger's willingness to use displaced
"breakpoints is %s.\n"), value);
}

-/* Return non-zero if displaced stepping is enabled, and can be used
+/* 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. */
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,11 +4873,14 @@ 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,
+ add_setshow_enum_cmd ("can-use-displaced-stepping", class_maintenance,
+ 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\
+If auto, gdb will auto use displaced stepping if it need (in non-stop mode).\n\
+If on, gdb will use displaced stepping if such is supported by the target.\n\
+If off, 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,