Add method/format information to =record-started
authorSimon Marchi <simon.marchi@ericsson.com>
Mon, 30 May 2016 21:29:39 +0000 (17:29 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Mon, 6 Jun 2016 21:10:18 +0000 (17:10 -0400)
Eclipse CDT now supports enabling execution recording using two methods
(full and btrace) and both formats for btrace (bts and pt).  In the
event that recording is enabled behind the back of the GUI (by the user
on the command line, or a script), we need to know which method/format
are being used, so it can be correctly reflected in the interface.  This
patch adds this information to the =record-started async record.

Before:

  =record-started,thread-group="i1"

After:

  =record-started,thread-group="i1",method="btrace",format="bts"
  =record-started,thread-group="i1",method="btrace",format="pt"
  =record-started,thread-group="i1",method="full"

The "format" field is only present when the current method supports
multiple formats (only the btrace method as of now).

gdb/ChangeLog:

* NEWS: Mention the new fields in =record-started.
* common/btrace-common.h (btrace_format_short_string): New function
declaration.
* common/btrace-common.c (btrace_format_short_string): New
function.
* mi/mi-interp.c (mi_record_changed): Output method and format
fields in the =record-started record.
* record-btrace.c (record_btrace_open): Adapt record_changed
notification.
* record-full.c (record_full_open): Likewise.
* record.c (cmd_record_stop): Likewise.

gdb/doc/ChangeLog:

* gdb.texinfo (GDB/MI Async Records): Document method and
format fields in =record-started.
* observer.texi (record_changed): Add method and format
parameters.

gdb/testsuite/ChangeLog:

* gdb.mi/mi-record-changed.exp: Adjust =record-started output
matching.

13 files changed:
gdb/ChangeLog
gdb/NEWS
gdb/common/btrace-common.c
gdb/common/btrace-common.h
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/doc/observer.texi
gdb/mi/mi-interp.c
gdb/record-btrace.c
gdb/record-full.c
gdb/record.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/mi-record-changed.exp

index af4ddcc447dc8da300d30a271d9dbab428856087..01cc7708aa908135a6bcc647e01a6a7daafbbc40 100644 (file)
@@ -1,3 +1,17 @@
+2016-06-06  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * NEWS: Mention the new fields in =record-started.
+       * common/btrace-common.h (btrace_format_short_string): New function
+       declaration.
+       * common/btrace-common.c (btrace_format_short_string): New
+       function.
+       * mi/mi-interp.c (mi_record_changed): Output method and format
+       fields in the =record-started record.
+       * record-btrace.c (record_btrace_open): Adapt record_changed
+       notification.
+       * record-full.c (record_full_open): Likewise.
+       * record.c (cmd_record_stop): Likewise.
+
 2016-06-02  Jon Turney  <jon.turney@dronecode.org.uk>
 
        * windows-nat.c (handle_output_debug_string): Return type of
index dce79a26a82c8a1d3f5403af3fceb30c3630c9c7..253c8e521371b866f7fd73b2798dbea9096c51d6 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -67,6 +67,11 @@ maint selftest
   including JIT compiling fast tracepoint's conditional expression
   bytecode into native code.
 
+* MI async record =record-started now includes the method and format used for
+  recording.  For example:
+
+    =record-started,thread-group="i1",method="btrace",format="bts"
+
 *** Changes in GDB 7.11
 
 * GDB now supports debugging kernel-based threads on FreeBSD.
index eba3979a2e7f841e98105285319a9d3e414a198b..90aef76c1926054a5a4c894af5199bb0863193d3 100644 (file)
@@ -43,6 +43,26 @@ btrace_format_string (enum btrace_format format)
 
 /* See btrace-common.h.  */
 
+const char *
+btrace_format_short_string (enum btrace_format format)
+{
+  switch (format)
+    {
+    case BTRACE_FORMAT_NONE:
+      return "unknown";
+
+    case BTRACE_FORMAT_BTS:
+      return "bts";
+
+    case BTRACE_FORMAT_PT:
+      return "pt";
+    }
+
+  internal_error (__FILE__, __LINE__, _("Unknown branch trace format"));
+}
+
+/* See btrace-common.h.  */
+
 void
 btrace_data_init (struct btrace_data *data)
 {
index ad208cd79b67b34d70b57a46d6a1e441d3dbc629..d702bb80eea2cf481c5d319e6a694581d14e1132 100644 (file)
@@ -214,6 +214,9 @@ enum btrace_error
 /* Return a string representation of FORMAT.  */
 extern const char *btrace_format_string (enum btrace_format format);
 
+/* Return an abbreviation string representation of FORMAT.  */
+extern const char *btrace_format_short_string (enum btrace_format format);
+
 /* Initialize DATA.  */
 extern void btrace_data_init (struct btrace_data *data);
 
index 9ed044b76f9daf65b13c4c87ff04e3c89b4fdd73..8ef6cbafa360a2ed2c3997828f9e46aea78075b5 100644 (file)
@@ -1,3 +1,10 @@
+2016-06-06  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * gdb.texinfo (GDB/MI Async Records): Document method and
+       format fields in =record-started.
+       * observer.texi (record_changed): Add method and format
+       parameters.
+
 2016-05-27  Eli Zaretskii  <eliz@gnu.org>
 
        * gdb.texinfo (General Query Packets): Move the description of the
index 7e89003345f9f8286a147b1cd297130b3fc874a1..1da81a1e14b49062fbf131740241d432e2c1e22a 100644 (file)
@@ -26423,12 +26423,17 @@ breakpoint commands; @xref{GDB/MI Breakpoint Commands}.  The
 Note that if a breakpoint is emitted in the result record of a
 command, then it will not also be emitted in an async record.
 
-@item =record-started,thread-group="@var{id}"
+@item =record-started,thread-group="@var{id}",method="@var{method}"[,format="@var{format}"]
 @itemx =record-stopped,thread-group="@var{id}"
 Execution log recording was either started or stopped on an
 inferior.  The @var{id} is the @value{GDBN} identifier of the thread
 group corresponding to the affected inferior.
 
+The @var{method} field indicates the method used to record execution.  If the
+method in use supports multiple recording formats, @var{format} will be present
+and contain the currently used format.  @xref{Process Record and Replay}
+for existing method and format values.
+
 @item =cmd-param-changed,param=@var{param},value=@var{value}
 Reports that a parameter of the command @code{set @var{param}} is
 changed to @var{value}.  In the multi-word @code{set} command,
index f4049ad3292e03e27e4ccee169cfb625e4cc80bc..fc7aac43ae31ee692c2adb74bc586d6c0f53c843 100644 (file)
@@ -141,11 +141,16 @@ at the entry-point instruction.  For @samp{attach} and @samp{core},
 inferior, and before any information on the inferior has been printed.
 @end deftypefun
 
-@deftypefun void record_changed (struct inferior *@var{inferior}, int @var{started})
+@deftypefun void record_changed (struct inferior *@var{inferior}, int @var{started}, const char *@var{method}, const char *@var{format})
 The status of process record for inferior @var{inferior} in
 @value{GDBN} has changed.  The process record is started if
 @var{started} is true, and the process record is stopped if
 @var{started} is false.
+
+When @var{started} is true, @var{method} indicates the short name of the method
+used for recording.  If the method supports multiple formats, @var{format}
+indicates which one is being used, otherwise it is NULL.  When @var{started} is
+false, they are both NULL.
 @end deftypefun
 
 @deftypefun void solib_loaded (struct so_list *@var{solib})
index 0fe19af2da30b8cae7da81e86632602a371a45d1..8ce816c215283d84d5cb1da42b60df2976bc9ec7 100644 (file)
@@ -65,7 +65,8 @@ static void mi_on_no_history (void);
 
 static void mi_new_thread (struct thread_info *t);
 static void mi_thread_exit (struct thread_info *t, int silent);
-static void mi_record_changed (struct inferior*, int);
+static void mi_record_changed (struct inferior*, int, const char *,
+                              const char *);
 static void mi_inferior_added (struct inferior *inf);
 static void mi_inferior_appeared (struct inferior *inf);
 static void mi_inferior_exit (struct inferior *inf);
@@ -399,7 +400,8 @@ mi_thread_exit (struct thread_info *t, int silent)
 /* Emit notification on changing the state of record.  */
 
 static void
-mi_record_changed (struct inferior *inferior, int started)
+mi_record_changed (struct inferior *inferior, int started, const char *method,
+                  const char *format)
 {
   struct mi_interp *mi = (struct mi_interp *) top_level_interpreter_data ();
   struct cleanup *old_chain;
@@ -407,8 +409,23 @@ mi_record_changed (struct inferior *inferior, int started)
   old_chain = make_cleanup_restore_target_terminal ();
   target_terminal_ours_for_output ();
 
-  fprintf_unfiltered (mi->event_channel,  "record-%s,thread-group=\"i%d\"",
-                     started ? "started" : "stopped", inferior->num);
+  if (started)
+    {
+      if (format != NULL)
+       fprintf_unfiltered (
+         mi->event_channel,
+         "record-started,thread-group=\"i%d\",method=\"%s\",format=\"%s\"",
+         inferior->num, method, format);
+      else
+       fprintf_unfiltered (
+         mi->event_channel,
+         "record-started,thread-group=\"i%d\",method=\"%s\"",
+         inferior->num, method);
+    }
+  else
+    fprintf_unfiltered (mi->event_channel,
+                       "record-stopped,thread-group=\"i%d\"", inferior->num);
+
 
   gdb_flush (mi->event_channel);
 
index 77b51801e6c4b7b21ce12931b6d75193f8339066..24594a96cfc1bf2f05b43adb365f820b7624a3d0 100644 (file)
@@ -206,6 +206,7 @@ record_btrace_open (const char *args, int from_tty)
 {
   struct cleanup *disable_chain;
   struct thread_info *tp;
+  const char *format;
 
   DEBUG ("open");
 
@@ -234,7 +235,8 @@ record_btrace_open (const char *args, int from_tty)
                                  NULL);
   record_btrace_generating_corefile = 0;
 
-  observer_notify_record_changed (current_inferior (),  1);
+  format = btrace_format_short_string (record_btrace_conf.format);
+  observer_notify_record_changed (current_inferior (), 1, "btrace", format);
 
   discard_cleanups (disable_chain);
 }
index f307b4876fcae111e3c2ae282ac7263be8240e00..0f61bcb69d619fed739a534640720734432f9214 100644 (file)
@@ -869,7 +869,7 @@ record_full_open (const char *name, int from_tty)
 
   record_full_init_record_breakpoints ();
 
-  observer_notify_record_changed (current_inferior (),  1);
+  observer_notify_record_changed (current_inferior (),  1, "full", NULL);
 }
 
 /* "to_close" target method.  Close the process record target.  */
index 6190794492fd73f2b2ba67ab22a08e006b8cf154..1af134f68fe870f06086f260ffcc1b519a995b9d 100644 (file)
@@ -268,7 +268,7 @@ cmd_record_stop (char *args, int from_tty)
   printf_unfiltered (_("Process record is stopped and all execution "
                       "logs are deleted.\n"));
 
-  observer_notify_record_changed (current_inferior (), 0);
+  observer_notify_record_changed (current_inferior (), 0, NULL, NULL);
 }
 
 /* The "set record" command.  */
index 3b305a602b3e69857158990433515c845e133439..98a798b779367d40e4d2c08bf5f9936ae854c7dc 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-06  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * gdb.mi/mi-record-changed.exp: Adjust =record-started output
+       matching.
+
 2016-06-02  Tom Tromey  <tom@tromey.com>
 
        PR python/18984:
index 2b5fcd617e5657ae17b596453195b5a2025f1a65..22cf076ee509b8c3438303bef205b46db48facc5 100644 (file)
@@ -31,14 +31,14 @@ if [mi_gdb_start] {
 }
 mi_run_to_main
 
-mi_gdb_test "record" ".*=record-started,thread-group=\"i${decimal}\".*\\^done" \
+mi_gdb_test "record" ".*=record-started,thread-group=\"i${decimal}\",method=\"full\".*\\^done" \
     "record"
 mi_gdb_test "record stop" \
     ".*=record-stopped,thread-group=\"i${decimal}\".*\\^done" \
     "record end"
 
 mi_gdb_test "target record" \
-    ".*=record-started,thread-group=\"i${decimal}\".*\\^done" \
+    ".*=record-started,thread-group=\"i${decimal}\",method=\"full\".*\\^done" \
     "target record"
 
 return 0
This page took 0.056721 seconds and 4 git commands to generate.