Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: Pedro Alves <palves@redhat.com>, <gdb-patches@sourceware.org>
Cc: Eli Zaretskii <eliz@gnu.org>
Subject: [committed]: [PATCH 2/2] MI notification on record started and stopped
Date: Fri, 21 Sep 2012 01:47:00 -0000	[thread overview]
Message-ID: <505BC704.5030505@codesourcery.com> (raw)
In-Reply-To: <50533B81.2010009@redhat.com>

On 09/14/2012 10:13 PM, Pedro Alves wrote:
> On 09/14/2012 02:13 PM, Yao Qi wrote:
>> On 09/14/2012 08:08 PM, Pedro Alves wrote:
>>> On 09/14/2012 12:44 PM, Yao Qi wrote:
>>>> On 09/14/2012 05:49 PM, Eli Zaretskii wrote:
>>>>>> The notification is like '=record-started,thread-group="i1"'.
>>>>> ?? If this is a thread-group, why does i1 identify a_process_?  Don't
>>>>> you mean "thread group"?
>>>>
>>>> As matter of fact, this is an inferior, but in MI notification, we call "inferior" as "thread group", IIUC.  So i1 identify an inferior.  Your suggestion "the number assigned by @value{GDBN} to the inferior" is good to me.
>>>
>>> In these cases, I'd just go and copy what is written in other similar
>>> cases already in the manual.  Should make the end overall result a bit more
>>> consistent.  For example, borrowing from the "-add-inferior" command's text,
>>> you'd get something like:
>>>
>>> "The notification has a single field, @samp{thread-group}, whose value is the
>>> identifier of the thread group corresponding to the affected inferior."
>>>
>>
>> How about this?
>>
>>   The process record was either started or stopped in thread group
>>   @var{id}.  The @var{id} is the identifier of the thread group
>>   corresponding to the affected inferior.
> 
> Nitpicking at this point, as I think that already conveys the necessary
> info.  But, I think "Execution log recording" would sound more natural
> than "The process record".  The mention of @var{id} twice looks
> redundant, yet disconnected.  So I'd suggest:
> 
> Execution log recording was either started or stopped on an
> inferior.  The @var{id} is the identifier of the thread group
> corresponding to the affected inferior.
> 

OK.  This is what I committed.

> Thanks,
> 


-- 
Yao

gdb/doc:
2012-09-21  Yao Qi  <yao@codesourcery.com>
	    Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (GDB/MI Async Records): Document notification
	'record-started' and 'record-stopped'.
	* observer.texi (GDB Observers): New observer 'record-changed'.
gdb:
2012-09-21  Yao Qi  <yao@codesourcery.com>

	* mi/mi-interp.c: Declare mi_record_changed.
	(mi_interpreter_init): Call observer_attach_record_changed.
	(mi_record_changed): New.
	* record.c (record_open): Call observer_notify_record_changed.
	(cmd_record_stop): Call observer_notify_record_changed.
	* NEWS: Mention it.

gdb/testsuite:
2012-09-21  Yao Qi  <yao@codesourcery.com>

	* gdb.mi/mi-record-changed.exp: New.
	* gdb.mi/mi-reverse.exp: Adjust expected output.
---
 gdb/NEWS                                   |    2 +
 gdb/doc/gdb.texinfo                        |    6 ++++
 gdb/doc/observer.texi                      |    7 ++++
 gdb/mi/mi-interp.c                         |   15 +++++++++
 gdb/record.c                               |    5 +++
 gdb/testsuite/gdb.mi/mi-record-changed.exp |   44 ++++++++++++++++++++++++++++
 gdb/testsuite/gdb.mi/mi-reverse.exp        |    3 +-
 7 files changed, 81 insertions(+), 1 deletions(-)
 create mode 100644 gdb/testsuite/gdb.mi/mi-record-changed.exp

diff --git a/gdb/NEWS b/gdb/NEWS
index 365b2d4..8351467 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -53,6 +53,8 @@ py [command]
      new async record "=traceframe-changed".
   ** The creation and deletion of trace state variables are now notified
      using new async records "=tsv-created" and "=tsv-deleted".
+  ** The start and stop of process record are now notified using new
+     async record "=record-started" and "=record-stopped".
 
 *** Changes in GDB 7.5
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 1c8c1c2..5fcbada 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27658,6 +27658,12 @@ 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}"
+@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.
+
 @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,
diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi
index 09aa91f..a27e983 100644
--- a/gdb/doc/observer.texi
+++ b/gdb/doc/observer.texi
@@ -113,6 +113,13 @@ 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})
+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.
+@end deftypefun
+
 @deftypefun void solib_loaded (struct so_list *@var{solib})
 The shared library specified by @var{solib} has been loaded.  Note that
 when @value{GDBN} calls this observer, the library's symbols probably
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 5c37bc7..d383958 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -60,6 +60,7 @@ static void mi_on_normal_stop (struct bpstats *bs, int print_frame);
 
 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_inferior_added (struct inferior *inf);
 static void mi_inferior_appeared (struct inferior *inf);
 static void mi_inferior_exit (struct inferior *inf);
@@ -124,6 +125,7 @@ mi_interpreter_init (struct interp *interp, int top_level)
       observer_attach_inferior_appeared (mi_inferior_appeared);
       observer_attach_inferior_exit (mi_inferior_exit);
       observer_attach_inferior_removed (mi_inferior_removed);
+      observer_attach_record_changed (mi_record_changed);
       observer_attach_normal_stop (mi_on_normal_stop);
       observer_attach_target_resumed (mi_on_resume);
       observer_attach_solib_loaded (mi_solib_loaded);
@@ -381,6 +383,19 @@ mi_thread_exit (struct thread_info *t, int silent)
   gdb_flush (mi->event_channel);
 }
 
+/* Emit notification on changing the state of record.  */
+
+static void
+mi_record_changed (struct inferior *inferior, int started)
+{
+  struct mi_interp *mi = top_level_interpreter_data ();
+
+  fprintf_unfiltered (mi->event_channel,  "record-%s,thread-group=\"i%d\"",
+		      started ? "started" : "stopped", inferior->num);
+
+  gdb_flush (mi->event_channel);
+}
+
 static void
 mi_inferior_added (struct inferior *inf)
 {
diff --git a/gdb/record.c b/gdb/record.c
index 5cbac00..c98ed32 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -33,6 +33,7 @@
 #include "event-loop.h"
 #include "inf-loop.h"
 #include "gdb_bfd.h"
+#include "observer.h"
 
 #include <signal.h>
 
@@ -1001,6 +1002,8 @@ record_open (char *name, int from_tty)
 				  NULL);
 
   record_init_record_breakpoints ();
+
+  observer_notify_record_changed (current_inferior (),  1);
 }
 
 /* "to_close" target method.  Close the process record target.  */
@@ -2260,6 +2263,8 @@ cmd_record_stop (char *args, int from_tty)
       unpush_target (&record_ops);
       printf_unfiltered (_("Process record is stopped and all execution "
                            "logs are deleted.\n"));
+
+      observer_notify_record_changed (current_inferior (), 0);
     }
   else
     printf_unfiltered (_("Process record is not started.\n"));
diff --git a/gdb/testsuite/gdb.mi/mi-record-changed.exp b/gdb/testsuite/gdb.mi/mi-record-changed.exp
new file mode 100644
index 0000000..bb54248
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-record-changed.exp
@@ -0,0 +1,44 @@
+# Copyright 2012 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+if ![supports_process_record] {
+    return
+}
+
+standard_testfile basics.c
+if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+	  executable {debug nowarnings}] != "" } {
+    untested mi-record-changed.exp
+    return -1
+}
+
+load_lib mi-support.exp
+
+if [mi_gdb_start] {
+    return
+}
+mi_run_to_main
+
+mi_gdb_test "record" ".*=record-started,thread-group=\"i${decimal}\".*\\^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" \
+    "target record"
+
+return 0
diff --git a/gdb/testsuite/gdb.mi/mi-reverse.exp b/gdb/testsuite/gdb.mi/mi-reverse.exp
index f65493d..974a095 100644
--- a/gdb/testsuite/gdb.mi/mi-reverse.exp
+++ b/gdb/testsuite/gdb.mi/mi-reverse.exp
@@ -51,7 +51,8 @@ mi_run_to_main
 if [supports_process_record] {
     # Activate process record/replay
     if [mi_gdb_test "-interpreter-exec console record" \
-	{\^done} "Turn on process record"] {
+	    "=record-started,id=\"1\"\r\n\\^done" \
+	    "Turn on process record"] {
 	warning "Fail to activate process record/replay, tests in this group will not be performed.\n";
 	return -1
     }
-- 
1.7.7.6


  reply	other threads:[~2012-09-21  1:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-12  7:16 [PATCH 0/2] Two MI notifications on TSV and process record Yao Qi
2012-09-12  7:16 ` [PATCH 2/2] MI notification on record started and stopped Yao Qi
2012-09-12 17:52   ` Eli Zaretskii
2012-09-13  8:57     ` Yao Qi
2012-09-13 17:33       ` Eli Zaretskii
2012-09-14  2:54         ` Yao Qi
2012-09-14  9:49           ` Eli Zaretskii
2012-09-14 11:45             ` Yao Qi
2012-09-14 12:09               ` Pedro Alves
2012-09-14 13:14                 ` Yao Qi
2012-09-14 14:13                   ` Pedro Alves
2012-09-21  1:47                     ` Yao Qi [this message]
2012-09-21  6:58                       ` Regression for gdb.mi/mi-reverse.exp [Re: [committed]: [PATCH 2/2] MI notification on record started and stopped] Jan Kratochvil
2012-09-21  7:26                         ` Yao Qi
2012-09-14 13:30               ` [PATCH 2/2] MI notification on record started and stopped Eli Zaretskii
2012-09-12 18:07   ` Tom Tromey
2012-09-12 19:04     ` Pedro Alves
2012-09-12 19:01   ` Pedro Alves
2012-09-12  7:16 ` [PATCH 1/2] MI notification on tsv created and deleted Yao Qi
2012-09-12 17:48   ` Eli Zaretskii
2012-09-18 12:19     ` [committed]: " Yao Qi
2012-09-13 20:17   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=505BC704.5030505@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox