[RFC,7/7] gdb/infcmd: add replay diversion commands

Message ID 2qudlv4/sc4sfymu&ea072jz.67uc_reia5ojmi2wxnm&f7ks/fb@mail.bob131.so
State New
Headers show
Series
  • gdb: replay diversion support
Related show

Commit Message

Simon Marchi via Gdb-patches June 1, 2021, 7:11 p.m.
Adds commands 'replay-diversion start', 'replay-diversion end' and
'show replay-diversion' to make diversion state of the target
inspectable/manipulable by the user.

gdb/ChangeLog:

2021-06-01  George Barrett  <bob@bob131.so>

	* infcmd.c (replay_diversion_start_command)
	(replay_diversion_end_command, show_replay_diversion_command):
	Implement commands.
	(_initialize_infcmd): Add commands: 'replay-diversion start',
	'replay-diversion end' and 'show replay-diversion'.
---
 gdb/infcmd.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 58 insertions(+), 1 deletion(-)

-- 
2.31.1

Comments

Simon Marchi via Gdb-patches June 22, 2021, 9:57 p.m. | #1
On Wed, Jun 02, 2021 at 05:11:25AM +1000, George Barrett via Gdb-patches wrote:
> Adds commands 'replay-diversion start', 'replay-diversion end' and

> 'show replay-diversion' to make diversion state of the target

> inspectable/manipulable by the user.

> 

> gdb/ChangeLog:

> 

> 2021-06-01  George Barrett  <bob@bob131.so>

> 

> 	* infcmd.c (replay_diversion_start_command)

> 	(replay_diversion_end_command, show_replay_diversion_command):

> 	Implement commands.

> 	(_initialize_infcmd): Add commands: 'replay-diversion start',

> 	'replay-diversion end' and 'show replay-diversion'.

> ---

>  gdb/infcmd.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++-

>  1 file changed, 58 insertions(+), 1 deletion(-)

> 

> diff --git a/gdb/infcmd.c b/gdb/infcmd.c

> index 38947ca265e..92aa164a992 100644

> --- a/gdb/infcmd.c

> +++ b/gdb/infcmd.c

> @@ -3001,6 +3001,45 @@ show_print_finish (struct ui_file *file, int from_tty,

>  Printing of return value after `finish' is %s.\n"),

>  		    value);

>  }

> +

> +/* Implement `replay-diversion start'.  */

> +

> +static void

> +replay_diversion_start_command (const char *args, int from_tty)

> +{

> +  if (inferior_ptid == null_ptid)

> +    error (_("The program is not being run."));

> +  if (target_in_replay_diversion ())

> +    error (_("Already in a replay diversion."));

> +  target_start_replay_diversion ();

> +}

> +

> +/* Implement `replay-diversion end'.  */

> +

> +static void

> +replay_diversion_end_command (const char *args, int from_tty)

> +{

> +  if (inferior_ptid == null_ptid)

> +    error (_("The program is not being run."));

> +  if (!target_in_replay_diversion ())

> +    error (_("Not in a replay diversion."));

> +  if (current_inferior ()->wants_replay_diversion_p ())

> +    error (_("Attempt to end a replay diversion in use."));

> +  target_end_replay_diversion ();

> +}

> +

> +/* Implement `show replay-diversion'.  */

> +

> +static void

> +show_replay_diversion_command (const char *args, int from_tty)

> +{

> +  if (target_in_replay_diversion ())

> +    puts_filtered ("Inferior in replay diversion.\n");

> +  else if (target_needs_replay_diversion ())

> +    puts_filtered ("Inferior in deterministic replay.\n");

> +  else

> +    puts_filtered ("Inferior doesn't support replay diversion.\n");

> +}

> 


Hi,

You forgot to wrap the messages in '_()' in this function.

Best,
Lancelot.

>  

>  /* This help string is used for the run, start, and starti commands.

> @@ -3023,7 +3062,8 @@ void _initialize_infcmd ();

>  void

>  _initialize_infcmd ()

>  {

> -  static struct cmd_list_element *info_proc_cmdlist;

> +  static struct cmd_list_element *info_proc_cmdlist,

> +                                 *replay_diversion_cmdlist;

>    struct cmd_list_element *c = NULL;

>    const char *cmd_name;

>  

> @@ -3347,4 +3387,21 @@ Show whether `finish' prints the return value."), NULL,

>  			   NULL,

>  			   show_print_finish,

>  			   &setprintlist, &showprintlist);

> +

> +  add_basic_prefix_cmd ("replay-diversion", class_obscure, _("\

> +Enter and exit diversions of trace replay."),

> +			&replay_diversion_cmdlist,

> +			0 /* allow-unknown */, &cmdlist);

> +

> +  add_cmd ("start", class_obscure, replay_diversion_start_command,

> +	   _("Start a replay diversion."),

> +	   &replay_diversion_cmdlist);

> +

> +  add_cmd ("end", class_obscure, replay_diversion_end_command,

> +	   _("End a replay diversion."),

> +	   &replay_diversion_cmdlist);

> +

> +  add_cmd ("replay-diversion", no_class, show_replay_diversion_command,

> +	   _("Show whether the inferior is currently in a replay diversion."),

> +	   &showlist);

>  }

> -- 

> 2.31.1

Patch

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 38947ca265e..92aa164a992 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -3001,6 +3001,45 @@  show_print_finish (struct ui_file *file, int from_tty,
 Printing of return value after `finish' is %s.\n"),
 		    value);
 }
+
+/* Implement `replay-diversion start'.  */
+
+static void
+replay_diversion_start_command (const char *args, int from_tty)
+{
+  if (inferior_ptid == null_ptid)
+    error (_("The program is not being run."));
+  if (target_in_replay_diversion ())
+    error (_("Already in a replay diversion."));
+  target_start_replay_diversion ();
+}
+
+/* Implement `replay-diversion end'.  */
+
+static void
+replay_diversion_end_command (const char *args, int from_tty)
+{
+  if (inferior_ptid == null_ptid)
+    error (_("The program is not being run."));
+  if (!target_in_replay_diversion ())
+    error (_("Not in a replay diversion."));
+  if (current_inferior ()->wants_replay_diversion_p ())
+    error (_("Attempt to end a replay diversion in use."));
+  target_end_replay_diversion ();
+}
+
+/* Implement `show replay-diversion'.  */
+
+static void
+show_replay_diversion_command (const char *args, int from_tty)
+{
+  if (target_in_replay_diversion ())
+    puts_filtered ("Inferior in replay diversion.\n");
+  else if (target_needs_replay_diversion ())
+    puts_filtered ("Inferior in deterministic replay.\n");
+  else
+    puts_filtered ("Inferior doesn't support replay diversion.\n");
+}
 
 
 /* This help string is used for the run, start, and starti commands.
@@ -3023,7 +3062,8 @@  void _initialize_infcmd ();
 void
 _initialize_infcmd ()
 {
-  static struct cmd_list_element *info_proc_cmdlist;
+  static struct cmd_list_element *info_proc_cmdlist,
+                                 *replay_diversion_cmdlist;
   struct cmd_list_element *c = NULL;
   const char *cmd_name;
 
@@ -3347,4 +3387,21 @@  Show whether `finish' prints the return value."), NULL,
 			   NULL,
 			   show_print_finish,
 			   &setprintlist, &showprintlist);
+
+  add_basic_prefix_cmd ("replay-diversion", class_obscure, _("\
+Enter and exit diversions of trace replay."),
+			&replay_diversion_cmdlist,
+			0 /* allow-unknown */, &cmdlist);
+
+  add_cmd ("start", class_obscure, replay_diversion_start_command,
+	   _("Start a replay diversion."),
+	   &replay_diversion_cmdlist);
+
+  add_cmd ("end", class_obscure, replay_diversion_end_command,
+	   _("End a replay diversion."),
+	   &replay_diversion_cmdlist);
+
+  add_cmd ("replay-diversion", no_class, show_replay_diversion_command,
+	   _("Show whether the inferior is currently in a replay diversion."),
+	   &showlist);
 }