* [PATCH] New MI notification "=tsv-modified"
@ 2013-01-30 15:44 Yao Qi
2013-01-30 17:17 ` Eli Zaretskii
2013-02-01 20:38 ` Pedro Alves
0 siblings, 2 replies; 10+ messages in thread
From: Yao Qi @ 2013-01-30 15:44 UTC (permalink / raw)
To: gdb-patches
Hi,
I added MI notifications "=tsv-created" and "=tsv-deleted" in this
patch, http://sourceware.org/ml/gdb-patches/2012-09/msg00191.html
We think it is still necessary to add another MI notification
"=tsv-modified" for the changes of the initial value of a tsv. This
is what this patch does.
gdb/doc:
2013-01-30 Yao Qi <yao@codesourcery.com>
* gdb.texinfo (GDB/MI Async Records): Document new MI
notification '=tsv-modified'.
* observer.texi (GDB Observers): New observer tsv_modified.
gdb:
2013-01-30 Yao Qi <yao@codesourcery.com>
* mi/mi-interp.c (mi_tsv_modified): Declare.
(mi_interpreter_init): Call observer_attach_tsv_modified.
(mi_tsv_modified): New.
* tracepoint.c (trace_variable_command): Call
observer_notify_tsv_modified if the initial value of tsv is
changed.
* NEWS: Mention the new MI notification.
gdb/testsuite:
2013-01-30 Yao Qi <yao@codesourcery.com>
* gdb.trace/mi-tsv-changed.exp (test_create_delete_tsv): Rename
to ...
(test_create_delete_modify_tsv): New. New test on modifying
the initial value of a tsv.
---
gdb/NEWS | 5 +++--
gdb/doc/gdb.texinfo | 4 ++++
gdb/doc/observer.texi | 5 +++++
gdb/mi/mi-interp.c | 18 ++++++++++++++++++
gdb/testsuite/gdb.trace/mi-tsv-changed.exp | 13 ++++++++++---
gdb/tracepoint.c | 6 +++++-
6 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index 539ceb9..0e01deb 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -121,8 +121,9 @@ show print type typedefs
"=cmd-param-changed".
** Trace frame changes caused by command "tfind" are now notified using
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 creation, deletion and modification of trace state variables
+ are now notified using new async records "=tsv-created",
+ "=tsv-deleted" and "=tsv-modified".
** The start and stop of process record are now notified using new
async record "=record-started" and "=record-stopped".
** Memory changes are now notified using new async record
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 4b51228..b6b0439 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27954,6 +27954,10 @@ value @var{value}.
Reports that the trace state variable @var{name} is deleted or all
trace state variables are deleted.
+@item =tsv-modified,name=@var{name},value=@var{value}
+Reports that the trace state variable @var{name} is modified with
+value @var{value}.
+
@item =breakpoint-created,bkpt=@{...@}
@itemx =breakpoint-modified,bkpt=@{...@}
@itemx =breakpoint-deleted,id=@var{number}
diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi
index 87c08e1..11fdc87 100644
--- a/gdb/doc/observer.texi
+++ b/gdb/doc/observer.texi
@@ -246,6 +246,11 @@ The trace state variable @var{name} is deleted. If @var{name} is
@code{NULL}, all trace state variables are deleted.
@end deftypefun
+@deftypefun void tsv_modified (const char *@var{name}, LONGEST @var{value})
+The trace state value @var{name} is modified with value
+@var{value}.
+@end deftypefun
+
@deftypefun void test_notification (int @var{somearg})
This observer is used for internal testing. Do not use.
See testsuite/gdb.gdb/observer.exp.
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 6617647..c8ec3f1 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -73,6 +73,7 @@ static void mi_about_to_proceed (void);
static void mi_traceframe_changed (int tfnum, int tpnum);
static void mi_tsv_created (const char *name, LONGEST value);
static void mi_tsv_deleted (const char *name);
+static void mi_tsv_modified (const char *name, LONGEST value);
static void mi_breakpoint_created (struct breakpoint *b);
static void mi_breakpoint_deleted (struct breakpoint *b);
static void mi_breakpoint_modified (struct breakpoint *b);
@@ -137,6 +138,7 @@ mi_interpreter_init (struct interp *interp, int top_level)
observer_attach_traceframe_changed (mi_traceframe_changed);
observer_attach_tsv_created (mi_tsv_created);
observer_attach_tsv_deleted (mi_tsv_deleted);
+ observer_attach_tsv_modified (mi_tsv_modified);
observer_attach_breakpoint_created (mi_breakpoint_created);
observer_attach_breakpoint_deleted (mi_breakpoint_deleted);
observer_attach_breakpoint_modified (mi_breakpoint_modified);
@@ -594,6 +596,22 @@ mi_tsv_deleted (const char *name)
gdb_flush (mi->event_channel);
}
+/* Emit notification on modifying a trace state variable. */
+
+static void
+mi_tsv_modified (const char *name, LONGEST value)
+{
+ struct mi_interp *mi = top_level_interpreter_data ();
+
+ target_terminal_ours ();
+
+ fprintf_unfiltered (mi->event_channel, "tsv-modified,"
+ "name=\"%s\",value=\"%s\"\n",
+ name, plongest (value));
+
+ gdb_flush (mi->event_channel);
+}
+
/* Emit notification about a created breakpoint. */
static void
diff --git a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
index 4e7d5a4..03adbcb 100644
--- a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
@@ -23,9 +23,9 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
return -1
}
-# Test notifications on creating and deleting TSV.
+# Test notifications on creating, deleting and modifying TSV.
-proc test_create_delete_tsv { } {with_test_prefix "create delete" {
+proc test_create_delete_modify_tsv { } {with_test_prefix "create delete modify" {
global binfile
global decimal
@@ -37,6 +37,9 @@ proc test_create_delete_tsv { } {with_test_prefix "create delete" {
mi_gdb_test "tvariable \$tvar1" \
".*=tsv-created,name=\"tvar1\",value=\"0\"\\\\n.*\\^done" \
"tvariable \$tvar1"
+ mi_gdb_test "tvariable \$tvar1 = 1" \
+ ".*=tsv-modified,name=\"tvar1\",value=\"1\"\\\\n.*\\^done" \
+ "tvariable \$tvar1 modified"
mi_gdb_test "tvariable \$tvar2 = 45" \
".*=tsv-created,name=\"tvar2\",value=\"45\"\\\\n.*\\^done" \
"tvariable \$tvar2"
@@ -81,6 +84,10 @@ proc test_upload_tsv { } { with_test_prefix "upload" {
gdb_test "tvariable \$tvar2 = 45" \
"Trace state variable \\\$tvar2 created, with initial value 45." \
"Create a trace state variable with initial value"
+
+ gdb_test "tvariable \$tvar3 = 1" \
+ "Trace state variable \\\$tvar3 created, with initial value 1." \
+ "Create a trace state variable \$tvar3 with initial value 1"
# Define a tracepoint otherwise tracing cannot be started.
gdb_test "trace main" "Tracepoint $decimal at .*"
gdb_test_no_output "tstart" "start trace experiment"
@@ -148,7 +155,7 @@ proc test_upload_tsv { } { with_test_prefix "upload" {
set gdbserver_reconnect_p 0
}}
- test_create_delete_tsv
+ test_create_delete_modify_tsv
# Test target supports tracepoints or not.
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index be45cb4..8345ac6 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -408,7 +408,11 @@ trace_variable_command (char *args, int from_tty)
tsv = find_trace_state_variable (internalvar_name (intvar));
if (tsv)
{
- tsv->initial_value = initval;
+ if (tsv->initial_value != initval)
+ {
+ tsv->initial_value = initval;
+ observer_notify_tsv_modified (tsv->name, initval);
+ }
printf_filtered (_("Trace state variable $%s "
"now has initial value %s.\n"),
tsv->name, plongest (tsv->initial_value));
--
1.7.7.6
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] New MI notification "=tsv-modified"
2013-01-30 15:44 [PATCH] New MI notification "=tsv-modified" Yao Qi
@ 2013-01-30 17:17 ` Eli Zaretskii
2013-02-01 20:38 ` Pedro Alves
1 sibling, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2013-01-30 17:17 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
> From: Yao Qi <yao@codesourcery.com>
> Date: Wed, 30 Jan 2013 23:43:00 +0800
>
> I added MI notifications "=tsv-created" and "=tsv-deleted" in this
> patch, http://sourceware.org/ml/gdb-patches/2012-09/msg00191.html
> We think it is still necessary to add another MI notification
> "=tsv-modified" for the changes of the initial value of a tsv. This
> is what this patch does.
OK for the documentation parts. Thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] New MI notification "=tsv-modified"
2013-01-30 15:44 [PATCH] New MI notification "=tsv-modified" Yao Qi
2013-01-30 17:17 ` Eli Zaretskii
@ 2013-02-01 20:38 ` Pedro Alves
2013-02-02 8:29 ` Yao Qi
1 sibling, 1 reply; 10+ messages in thread
From: Pedro Alves @ 2013-02-01 20:38 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On 01/30/2013 03:43 PM, Yao Qi wrote:
> Hi,
> I added MI notifications "=tsv-created" and "=tsv-deleted" in this
> patch, http://sourceware.org/ml/gdb-patches/2012-09/msg00191.html
> We think it is still necessary to add another MI notification
> "=tsv-modified" for the changes of the initial value of a tsv. This
> is what this patch does.
Should we emit a notification when GDB detects the target
changes the variable too?
> 2013-01-30 Yao Qi <yao@codesourcery.com>
>
> * mi/mi-interp.c (mi_tsv_modified): Declare.
> (mi_interpreter_init): Call observer_attach_tsv_modified.
> (mi_tsv_modified): New.
> * tracepoint.c (trace_variable_command): Call
> observer_notify_tsv_modified if the initial value of tsv is
> changed.
>
> * NEWS: Mention the new MI notification.
Please spell out the notification. Nothing else in the GDB
ChangeLog entry indicates what is "the new".
>
> gdb/testsuite:
>
> 2013-01-30 Yao Qi <yao@codesourcery.com>
>
> * gdb.trace/mi-tsv-changed.exp (test_create_delete_tsv): Rename
> to ...
> (test_create_delete_modify_tsv): New.
It's a rename, or a new function?
> @@ -37,6 +37,9 @@ proc test_create_delete_tsv { } {with_test_prefix "create delete" {
> mi_gdb_test "tvariable \$tvar1" \
> ".*=tsv-created,name=\"tvar1\",value=\"0\"\\\\n.*\\^done" \
> "tvariable \$tvar1"
> + mi_gdb_test "tvariable \$tvar1 = 1" \
> + ".*=tsv-modified,name=\"tvar1\",value=\"1\"\\\\n.*\\^done" \
> + "tvariable \$tvar1 modified"
It would be thorough to test that another "tvariable \$tvar1 = 1"
_doesn't_ emit a modified notification.
> mi_gdb_test "tvariable \$tvar2 = 45" \
> ".*=tsv-created,name=\"tvar2\",value=\"45\"\\\\n.*\\^done" \
> "tvariable \$tvar2"
> @@ -81,6 +84,10 @@ proc test_upload_tsv { } { with_test_prefix "upload" {
> gdb_test "tvariable \$tvar2 = 45" \
> "Trace state variable \\\$tvar2 created, with initial value 45." \
> "Create a trace state variable with initial value"
> +
> + gdb_test "tvariable \$tvar3 = 1" \
> + "Trace state variable \\\$tvar3 created, with initial value 1." \
> + "Create a trace state variable \$tvar3 with initial value 1"
I couldn't figure out what motivated this addition.
--
Pedro Alves
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] New MI notification "=tsv-modified"
2013-02-01 20:38 ` Pedro Alves
@ 2013-02-02 8:29 ` Yao Qi
2013-02-04 17:55 ` Pedro Alves
0 siblings, 1 reply; 10+ messages in thread
From: Yao Qi @ 2013-02-02 8:29 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On 02/02/2013 04:38 AM, Pedro Alves wrote:
> Should we emit a notification when GDB detects the target
> changes the variable too?
>
Yes, we should, but I am still evaluating the pros vs. cons. of using
async remote notification on tsv changes in the target or let GDB to
check the tsv changes. I need more time to get the answer, but in
parallel, I'd like the "=tsv-modified" notification goes in to notify
MI front-end that a tsv is modified by command.
>> >2013-01-30 Yao Qi<yao@codesourcery.com>
>> >
>> > * mi/mi-interp.c (mi_tsv_modified): Declare.
>> > (mi_interpreter_init): Call observer_attach_tsv_modified.
>> > (mi_tsv_modified): New.
>> > * tracepoint.c (trace_variable_command): Call
>> > observer_notify_tsv_modified if the initial value of tsv is
>> > changed.
>> >
>> > * NEWS: Mention the new MI notification.
> Please spell out the notification. Nothing else in the GDB
> ChangeLog entry indicates what is "the new".
>
because "what is the new" is added into the changelog entry in gdb/doc/ChangeLog, don't have to replicate it again in gdb/ChangeLog to mention it again for NEWS.
>> >
>> >gdb/testsuite:
>> >
>> >2013-01-30 Yao Qi<yao@codesourcery.com>
>> >
>> > * gdb.trace/mi-tsv-changed.exp (test_create_delete_tsv): Rename
>> > to ...
>> > (test_create_delete_modify_tsv): New.
> It's a rename, or a new function?
>
It is a rename, from test_create_delete_tsv to test_create_delete_modify_tsv, which is new (in terms of name, at least).
>> >@@ -37,6 +37,9 @@ proc test_create_delete_tsv { } {with_test_prefix "create delete" {
>> > mi_gdb_test "tvariable \$tvar1" \
>> > ".*=tsv-created,name=\"tvar1\",value=\"0\"\\\\n.*\\^done" \
>> > "tvariable \$tvar1"
>> >+ mi_gdb_test "tvariable \$tvar1 = 1" \
>> >+ ".*=tsv-modified,name=\"tvar1\",value=\"1\"\\\\n.*\\^done" \
>> >+ "tvariable \$tvar1 modified"
> It would be thorough to test that another "tvariable \$tvar1 = 1"
> _doesn't_ emit a modified notification.
>
Added.
>> > mi_gdb_test "tvariable \$tvar2 = 45" \
>> > ".*=tsv-created,name=\"tvar2\",value=\"45\"\\\\n.*\\^done" \
>> > "tvariable \$tvar2"
>> >@@ -81,6 +84,10 @@ proc test_upload_tsv { } { with_test_prefix "upload" {
>> > gdb_test "tvariable \$tvar2 = 45" \
>> > "Trace state variable \\\$tvar2 created, with initial value 45." \
>> > "Create a trace state variable with initial value"
>> >+
>> >+ gdb_test "tvariable \$tvar3 = 1" \
>> >+ "Trace state variable \\\$tvar3 created, with initial value 1." \
>> >+ "Create a trace state variable \$tvar3 with initial value 1"
> I couldn't figure out what motivated this addition.
It was used to test "=tsv-modified" happened when GDB reconnects to the
stub. This chunk should be removed.
Here is the new version below, to address your comments. I don't
insist on my original changelog entry, as either is OK to me.
--
Yao (é½å°§)
gdb/doc:
2013-02-02 Yao Qi <yao@codesourcery.com>
* gdb.texinfo (GDB/MI Async Records): Document new MI
notification "=tsv-modified".
* observer.texi (GDB Observers): New observer tsv_modified.
gdb:
2013-02-02 Yao Qi <yao@codesourcery.com>
* mi/mi-interp.c (mi_tsv_modified): Declare.
(mi_interpreter_init): Call observer_attach_tsv_modified.
(mi_tsv_modified): New.
* tracepoint.c (trace_variable_command): Call
observer_notify_tsv_modified if the initial value of tsv is
changed.
* NEWS: Mention the new MI notification "=tsv-modified".
gdb/testsuite:
2013-02-02 Yao Qi <yao@codesourcery.com>
* gdb.trace/mi-tsv-changed.exp (test_create_delete_tsv): Rename
to ...
(test_create_delete_modify_tsv): ... here. New test on modifying
the initial value of a tsv.
---
gdb/NEWS | 5 +++--
gdb/doc/gdb.texinfo | 4 ++++
gdb/doc/observer.texi | 5 +++++
gdb/mi/mi-interp.c | 18 ++++++++++++++++++
gdb/testsuite/gdb.trace/mi-tsv-changed.exp | 15 ++++++++++++---
gdb/tracepoint.c | 6 +++++-
6 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index 539ceb9..0e01deb 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -121,8 +121,9 @@ show print type typedefs
"=cmd-param-changed".
** Trace frame changes caused by command "tfind" are now notified using
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 creation, deletion and modification of trace state variables
+ are now notified using new async records "=tsv-created",
+ "=tsv-deleted" and "=tsv-modified".
** The start and stop of process record are now notified using new
async record "=record-started" and "=record-stopped".
** Memory changes are now notified using new async record
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 4b51228..b6b0439 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27954,6 +27954,10 @@ value @var{value}.
Reports that the trace state variable @var{name} is deleted or all
trace state variables are deleted.
+@item =tsv-modified,name=@var{name},value=@var{value}
+Reports that the trace state variable @var{name} is modified with
+value @var{value}.
+
@item =breakpoint-created,bkpt=@{...@}
@itemx =breakpoint-modified,bkpt=@{...@}
@itemx =breakpoint-deleted,id=@var{number}
diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi
index 87c08e1..11fdc87 100644
--- a/gdb/doc/observer.texi
+++ b/gdb/doc/observer.texi
@@ -246,6 +246,11 @@ The trace state variable @var{name} is deleted. If @var{name} is
@code{NULL}, all trace state variables are deleted.
@end deftypefun
+@deftypefun void tsv_modified (const char *@var{name}, LONGEST @var{value})
+The trace state value @var{name} is modified with value
+@var{value}.
+@end deftypefun
+
@deftypefun void test_notification (int @var{somearg})
This observer is used for internal testing. Do not use.
See testsuite/gdb.gdb/observer.exp.
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 6617647..c8ec3f1 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -73,6 +73,7 @@ static void mi_about_to_proceed (void);
static void mi_traceframe_changed (int tfnum, int tpnum);
static void mi_tsv_created (const char *name, LONGEST value);
static void mi_tsv_deleted (const char *name);
+static void mi_tsv_modified (const char *name, LONGEST value);
static void mi_breakpoint_created (struct breakpoint *b);
static void mi_breakpoint_deleted (struct breakpoint *b);
static void mi_breakpoint_modified (struct breakpoint *b);
@@ -137,6 +138,7 @@ mi_interpreter_init (struct interp *interp, int top_level)
observer_attach_traceframe_changed (mi_traceframe_changed);
observer_attach_tsv_created (mi_tsv_created);
observer_attach_tsv_deleted (mi_tsv_deleted);
+ observer_attach_tsv_modified (mi_tsv_modified);
observer_attach_breakpoint_created (mi_breakpoint_created);
observer_attach_breakpoint_deleted (mi_breakpoint_deleted);
observer_attach_breakpoint_modified (mi_breakpoint_modified);
@@ -594,6 +596,22 @@ mi_tsv_deleted (const char *name)
gdb_flush (mi->event_channel);
}
+/* Emit notification on modifying a trace state variable. */
+
+static void
+mi_tsv_modified (const char *name, LONGEST value)
+{
+ struct mi_interp *mi = top_level_interpreter_data ();
+
+ target_terminal_ours ();
+
+ fprintf_unfiltered (mi->event_channel, "tsv-modified,"
+ "name=\"%s\",value=\"%s\"\n",
+ name, plongest (value));
+
+ gdb_flush (mi->event_channel);
+}
+
/* Emit notification about a created breakpoint. */
static void
diff --git a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
index 4e7d5a4..9ab15ce 100644
--- a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
@@ -23,9 +23,9 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
return -1
}
-# Test notifications on creating and deleting TSV.
+# Test notifications on creating, deleting and modifying TSV.
-proc test_create_delete_tsv { } {with_test_prefix "create delete" {
+proc test_create_delete_modify_tsv { } {with_test_prefix "create delete modify" {
global binfile
global decimal
@@ -37,6 +37,14 @@ proc test_create_delete_tsv { } {with_test_prefix "create delete" {
mi_gdb_test "tvariable \$tvar1" \
".*=tsv-created,name=\"tvar1\",value=\"0\"\\\\n.*\\^done" \
"tvariable \$tvar1"
+ mi_gdb_test "tvariable \$tvar1 = 1" \
+ ".*=tsv-modified,name=\"tvar1\",value=\"1\"\\\\n.*\\^done" \
+ "tvariable \$tvar1 modified"
+ # No "=tsv-modified" notification is emitted, because the initial
+ # value is not changed.
+ mi_gdb_test "tvariable \$tvar1 = 1" \
+ ".*\\\$tvar1 = 1\\\\n\"\r\n~\"Trace state .*\\\\n.*\\^done" \
+ "tvariable \$tvar1 modified without notification"
mi_gdb_test "tvariable \$tvar2 = 45" \
".*=tsv-created,name=\"tvar2\",value=\"45\"\\\\n.*\\^done" \
"tvariable \$tvar2"
@@ -81,6 +89,7 @@ proc test_upload_tsv { } { with_test_prefix "upload" {
gdb_test "tvariable \$tvar2 = 45" \
"Trace state variable \\\$tvar2 created, with initial value 45." \
"Create a trace state variable with initial value"
+
# Define a tracepoint otherwise tracing cannot be started.
gdb_test "trace main" "Tracepoint $decimal at .*"
gdb_test_no_output "tstart" "start trace experiment"
@@ -148,7 +157,7 @@ proc test_upload_tsv { } { with_test_prefix "upload" {
set gdbserver_reconnect_p 0
}}
- test_create_delete_tsv
+ test_create_delete_modify_tsv
# Test target supports tracepoints or not.
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index be45cb4..8345ac6 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -408,7 +408,11 @@ trace_variable_command (char *args, int from_tty)
tsv = find_trace_state_variable (internalvar_name (intvar));
if (tsv)
{
- tsv->initial_value = initval;
+ if (tsv->initial_value != initval)
+ {
+ tsv->initial_value = initval;
+ observer_notify_tsv_modified (tsv->name, initval);
+ }
printf_filtered (_("Trace state variable $%s "
"now has initial value %s.\n"),
tsv->name, plongest (tsv->initial_value));
--
1.7.7.6
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] New MI notification "=tsv-modified"
2013-02-02 8:29 ` Yao Qi
@ 2013-02-04 17:55 ` Pedro Alves
2013-02-05 15:05 ` Yao Qi
0 siblings, 1 reply; 10+ messages in thread
From: Pedro Alves @ 2013-02-04 17:55 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On 02/02/2013 08:28 AM, Yao Qi wrote:
> On 02/02/2013 04:38 AM, Pedro Alves wrote:
>> Should we emit a notification when GDB detects the target
>> changes the variable too?
>>
>
> Yes, we should, but I am still evaluating the pros vs. cons. of using
> async remote notification on tsv changes in the target or let GDB to
> check the tsv changes. I need more time to get the answer, but in
> parallel, I'd like the "=tsv-modified" notification goes in to notify
> MI front-end that a tsv is modified by command.
Ack. Hmm. This makes me realize that I think all three =tsv
notifications should be changed in one aspect.
> because "what is the new" is added into the changelog entry in gdb/doc/ChangeLog, don't have to replicate it again in gdb/ChangeLog to mention it again for NEWS.
But those are different ChangeLog files. Reading gdb/ChangeLog
in isolation should make sense. More below.
> Here is the new version below, to address your comments. I don't
> insist on my original changelog entry, as either is OK to me.
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 4b51228..b6b0439 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -27954,6 +27954,10 @@ value @var{value}.
> Reports that the trace state variable @var{name} is deleted or all
> trace state variables are deleted.
>
> +@item =tsv-modified,name=@var{name},value=@var{value}
> +Reports that the trace state variable @var{name} is modified with
> +value @var{value}.
> +@deftypefun void tsv_modified (const char *@var{name}, LONGEST @var{value})
> +The trace state value @var{name} is modified with value
> +@var{value}.
> +@end deftypefun
_Which_ value is being talked about here is not explicit.
Trace state variables have _two_ values. The initial value,
and the current value (omitted if doesn't exist yet).
If we list tsvs with MI's -trace-list-variables, we'll indeed
see an "init" and a "current" attribute, for each tsv, and no
attribute named "value". So I think it'd be very good to fix this
before the release, and make the output of the notifications
consistent with the tsv listing output, and the docs clearer.
E.g.:
(gdb) interpreter-exec mi "-trace-list-variables"
^done,trace-variables={nr_rows="1",nr_cols="3",
hdr=[{width="15",alignment="-1",col_name="name",colhdr="Name"},
{width="11",alignment="-1",col_name="initial",colhdr="Initial"},
{width="11",alignment="-1",col_name="current",colhdr="Current"}],
body=[variable={name="$a",initial="1"},
variable={name="$b",initial="2",current="3"}]
SO IOW, =tsv-created should be
=tsv-created,name=@var{name},initial=@var{value}
instead of the current
=tsv-created,name=@var{name},value=@var{value}
and =tsv-modified should be
=tsv-modified,name=@var{name},initial=@var{value}
instead of the proposed
=tsv-modified,name=@var{name},value=@var{value}
Maybe it'd be a good idea to factor out the bits in
tvariables_info_1 that dump a tsv into a separate
function to use the in modify case as well? We'd also
output a "current" attribute as well in the =tsv-modified
case, but I'd argue that actually makes sense? Then this is
very much like the breakpoint-modified notification, and
interface consistency, at all the levels, is good all around.
--
Pedro Alves
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] New MI notification "=tsv-modified"
2013-02-04 17:55 ` Pedro Alves
@ 2013-02-05 15:05 ` Yao Qi
2013-02-05 15:41 ` Pedro Alves
0 siblings, 1 reply; 10+ messages in thread
From: Yao Qi @ 2013-02-05 15:05 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On 02/05/2013 01:30 AM, Pedro Alves wrote:
> _Which_ value is being talked about here is not explicit.
> Trace state variables have_two_ values. The initial value,
> and the current value (omitted if doesn't exist yet).
I meant the initial value here.
> If we list tsvs with MI's -trace-list-variables, we'll indeed
> see an "init" and a "current" attribute, for each tsv, and no
> attribute named "value". So I think it'd be very good to fix this
> before the release, and make the output of the notifications
> consistent with the tsv listing output, and the docs clearer.
>
> E.g.:
> (gdb) interpreter-exec mi "-trace-list-variables"
> ^done,trace-variables={nr_rows="1",nr_cols="3",
> hdr=[{width="15",alignment="-1",col_name="name",colhdr="Name"},
> {width="11",alignment="-1",col_name="initial",colhdr="Initial"},
> {width="11",alignment="-1",col_name="current",colhdr="Current"}],
> body=[variable={name="$a",initial="1"},
> variable={name="$b",initial="2",current="3"}]
>
> SO IOW, =tsv-created should be
>
> =tsv-created,name=@var{name},initial=@var{value}
>
> instead of the current
>
> =tsv-created,name=@var{name},value=@var{value}
>
>
> and =tsv-modified should be
>
> =tsv-modified,name=@var{name},initial=@var{value}
>
> instead of the proposed
>
> =tsv-modified,name=@var{name},value=@var{value}
The patch below implements these MI notifications with suggested
attributes. "=tsv-modified" is implemented like:
=tsv-modified,name=@var{name},initial=@var{initial},current=@var{current}
I don't refactor function tvariables_info_1 in this patch, and I'd like
to defer this change to next one.
Is it OK if no test regression?
--
Yao (é½å°§)
gdb/doc:
2013-02-05 Yao Qi <yao@codesourcery.com>
* gdb.texinfo (GDB/MI Async Records): Document new MI
notification "=tsv-modified". Update the document of MI
notification "=tsv-created".
* observer.texi (GDB Observers): New observer tsv_modified.
Update observer tsv_created and tsv_deleted.
gdb:
2013-02-05 Yao Qi <yao@codesourcery.com>
* mi/mi-interp.c: Include "tracepoint.h".
(mi_tsv_modified): Declare.
(mi_tsv_created, mi_tsv_deleted): Update declaration.
(mi_interpreter_init): Call observer_attach_tsv_modified.
(mi_tsv_modified): New.
(mi_tsv_created, mi_tsv_deleted): Update.
* tracepoint.c (trace_variable_command): Call
observer_notify_tsv_modified if the initial value of tsv is
changed.
(delete_trace_state_variable): Call
observer_notify_tsv_deleted earlier.
(trace_variable_command): Caller update.
(create_tsv_from_upload): Likewise.
* observer.sh: Declare "struct trace_state_variable".
* NEWS: Mention the new MI notification "=tsv-modified".
gdb/testsuite:
2013-02-05 Yao Qi <yao@codesourcery.com>
* gdb.trace/mi-tsv-changed.exp (test_create_delete_tsv): Rename
to ...
(test_create_delete_modify_tsv): ... here. New test on modifying
the initial value of a tsv.
---
gdb/NEWS | 5 ++-
gdb/doc/gdb.texinfo | 8 ++++-
gdb/doc/observer.texi | 13 ++++++----
gdb/mi/mi-interp.c | 36 +++++++++++++++++++++------
gdb/observer.sh | 1 +
gdb/testsuite/gdb.trace/mi-tsv-changed.exp | 22 +++++++++++-----
gdb/tracepoint.c | 14 +++++++----
7 files changed, 70 insertions(+), 29 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index 539ceb9..0e01deb 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -121,8 +121,9 @@ show print type typedefs
"=cmd-param-changed".
** Trace frame changes caused by command "tfind" are now notified using
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 creation, deletion and modification of trace state variables
+ are now notified using new async records "=tsv-created",
+ "=tsv-deleted" and "=tsv-modified".
** The start and stop of process record are now notified using new
async record "=record-started" and "=record-stopped".
** Memory changes are now notified using new async record
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index a8a7284..6762cc9 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27945,15 +27945,19 @@ Reports that the trace frame was changed and its new number is
@var{tfnum}. The number of the tracepoint associated with this trace
frame is @var{tpnum}.
-@item =tsv-created,name=@var{name},value=@var{value}
+@item =tsv-created,name=@var{name},initial=@var{initial}
Reports that the new trace state variable @var{name} is created with
-value @var{value}.
+initial value @var{initial}.
@item =tsv-deleted,name=@var{name}
@itemx =tsv-deleted
Reports that the trace state variable @var{name} is deleted or all
trace state variables are deleted.
+@item =tsv-modified,name=@var{name},initial=@var{initial},current=@var{current}
+Reports that the trace state variable @var{name} is modified with
+the initial value @var{initial} and the current value @var{current}.
+
@item =breakpoint-created,bkpt=@{...@}
@itemx =breakpoint-modified,bkpt=@{...@}
@itemx =breakpoint-deleted,id=@var{number}
diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi
index 87c08e1..adb7085 100644
--- a/gdb/doc/observer.texi
+++ b/gdb/doc/observer.texi
@@ -236,16 +236,19 @@ method is called after a command @code{set @var{param} @var{value}}.
is the value of changed parameter.
@end deftypefun
-@deftypefun void tsv_created (const char *@var{name}, LONGEST @var{value})
-The new trace state variable @var{name} is created with value
-@var{value}.
+@deftypefun void tsv_created (const struct trace_state_variable *@var{tsv})
+The new trace state variable @var{tsv} is created.
@end deftypefun
-@deftypefun void tsv_deleted (const char *@var{name})
-The trace state variable @var{name} is deleted. If @var{name} is
+@deftypefun void tsv_deleted (const struct trace_state_variable *@var{tsv})
+The trace state variable @var{tsv} is deleted. If @var{tsv} is
@code{NULL}, all trace state variables are deleted.
@end deftypefun
+@deftypefun void tsv_modified (const struct trace_state_variable *@var{tsv})
+The trace state value @var{tsv} is modified.
+@end deftypefun
+
@deftypefun void test_notification (int @var{somearg})
This observer is used for internal testing. Do not use.
See testsuite/gdb.gdb/observer.exp.
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 6617647..6e8ec3f 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -36,6 +36,7 @@
#include "solist.h"
#include "gdb.h"
#include "objfiles.h"
+#include "tracepoint.h"
/* These are the interpreter setup, etc. functions for the MI
interpreter. */
@@ -71,8 +72,9 @@ static void mi_solib_loaded (struct so_list *solib);
static void mi_solib_unloaded (struct so_list *solib);
static void mi_about_to_proceed (void);
static void mi_traceframe_changed (int tfnum, int tpnum);
-static void mi_tsv_created (const char *name, LONGEST value);
-static void mi_tsv_deleted (const char *name);
+static void mi_tsv_created (const struct trace_state_variable *tsv);
+static void mi_tsv_deleted (const struct trace_state_variable *tsv);
+static void mi_tsv_modified (const struct trace_state_variable *tsv);
static void mi_breakpoint_created (struct breakpoint *b);
static void mi_breakpoint_deleted (struct breakpoint *b);
static void mi_breakpoint_modified (struct breakpoint *b);
@@ -137,6 +139,7 @@ mi_interpreter_init (struct interp *interp, int top_level)
observer_attach_traceframe_changed (mi_traceframe_changed);
observer_attach_tsv_created (mi_tsv_created);
observer_attach_tsv_deleted (mi_tsv_deleted);
+ observer_attach_tsv_modified (mi_tsv_modified);
observer_attach_breakpoint_created (mi_breakpoint_created);
observer_attach_breakpoint_deleted (mi_breakpoint_deleted);
observer_attach_breakpoint_modified (mi_breakpoint_modified);
@@ -563,15 +566,15 @@ mi_traceframe_changed (int tfnum, int tpnum)
/* Emit notification on creating a trace state variable. */
static void
-mi_tsv_created (const char *name, LONGEST value)
+mi_tsv_created (const struct trace_state_variable *tsv)
{
struct mi_interp *mi = top_level_interpreter_data ();
target_terminal_ours ();
fprintf_unfiltered (mi->event_channel, "tsv-created,"
- "name=\"%s\",value=\"%s\"\n",
- name, plongest (value));
+ "name=\"%s\",initial=\"%s\"\n",
+ tsv->name, plongest (tsv->initial_value));
gdb_flush (mi->event_channel);
}
@@ -579,21 +582,38 @@ mi_tsv_created (const char *name, LONGEST value)
/* Emit notification on deleting a trace state variable. */
static void
-mi_tsv_deleted (const char *name)
+mi_tsv_deleted (const struct trace_state_variable *tsv)
{
struct mi_interp *mi = top_level_interpreter_data ();
target_terminal_ours ();
- if (name != NULL)
+ if (tsv != NULL)
fprintf_unfiltered (mi->event_channel, "tsv-deleted,"
- "name=\"%s\"\n", name);
+ "name=\"%s\"\n", tsv->name);
else
fprintf_unfiltered (mi->event_channel, "tsv-deleted\n");
gdb_flush (mi->event_channel);
}
+/* Emit notification on modifying a trace state variable. */
+
+static void
+mi_tsv_modified (const struct trace_state_variable *tsv)
+{
+ struct mi_interp *mi = top_level_interpreter_data ();
+
+ target_terminal_ours ();
+
+ fprintf_unfiltered (mi->event_channel, "tsv-modified,"
+ "name=\"%s\",initial=\"%s\",current=\"\%s\"\n",
+ tsv->name, plongest (tsv->initial_value),
+ plongest (tsv->value));
+
+ gdb_flush (mi->event_channel);
+}
+
/* Emit notification about a created breakpoint. */
static void
diff --git a/gdb/observer.sh b/gdb/observer.sh
index 3ff28a8..7b9e70c 100755
--- a/gdb/observer.sh
+++ b/gdb/observer.sh
@@ -64,6 +64,7 @@ struct so_list;
struct objfile;
struct thread_info;
struct inferior;
+struct trace_state_variable;
EOF
;;
esac
diff --git a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
index 4e7d5a4..5151216 100644
--- a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
@@ -23,9 +23,9 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
return -1
}
-# Test notifications on creating and deleting TSV.
+# Test notifications on creating, deleting and modifying TSV.
-proc test_create_delete_tsv { } {with_test_prefix "create delete" {
+proc test_create_delete_modify_tsv { } {with_test_prefix "create delete modify" {
global binfile
global decimal
@@ -35,10 +35,18 @@ proc test_create_delete_tsv { } {with_test_prefix "create delete" {
mi_gdb_load ${binfile}
mi_gdb_test "tvariable \$tvar1" \
- ".*=tsv-created,name=\"tvar1\",value=\"0\"\\\\n.*\\^done" \
+ ".*=tsv-created,name=\"tvar1\",initial=\"0\"\\\\n.*\\^done" \
"tvariable \$tvar1"
+ mi_gdb_test "tvariable \$tvar1 = 1" \
+ ".*=tsv-modified,name=\"tvar1\",initial=\"1\",current=\"0\"\\\\n.*\\^done" \
+ "tvariable \$tvar1 modified"
+ # No "=tsv-modified" notification is emitted, because the initial
+ # value is not changed.
+ mi_gdb_test "tvariable \$tvar1 = 1" \
+ ".*\\\$tvar1 = 1\\\\n\"\r\n~\"Trace state .*\\\\n.*\\^done" \
+ "tvariable \$tvar1 modified without notification"
mi_gdb_test "tvariable \$tvar2 = 45" \
- ".*=tsv-created,name=\"tvar2\",value=\"45\"\\\\n.*\\^done" \
+ ".*=tsv-created,name=\"tvar2\",initial=\"45\"\\\\n.*\\^done" \
"tvariable \$tvar2"
mi_gdb_test "delete tvariable \$tvar2" \
@@ -121,11 +129,11 @@ proc test_upload_tsv { } { with_test_prefix "upload" {
set tsv1_created 0
set tsv2_created 0
gdb_expect {
- -re "=tsv-created,name=\"tvar1\",value=\"0\"" {
+ -re "=tsv-created,name=\"tvar1\",initial=\"0\"" {
set tsv1_created 1
exp_continue
}
- -re "=tsv-created,name=\"tvar2\",value=\"45\"" {
+ -re "=tsv-created,name=\"tvar2\",initial=\"45\"" {
set tsv2_created 1
exp_continue
}
@@ -148,7 +156,7 @@ proc test_upload_tsv { } { with_test_prefix "upload" {
set gdbserver_reconnect_p 0
}}
- test_create_delete_tsv
+ test_create_delete_modify_tsv
# Test target supports tracepoints or not.
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index be45cb4..d0a360a 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -351,11 +351,11 @@ delete_trace_state_variable (const char *name)
for (ix = 0; VEC_iterate (tsv_s, tvariables, ix, tsv); ++ix)
if (strcmp (name, tsv->name) == 0)
{
+ observer_notify_tsv_deleted (tsv);
+
xfree ((void *)tsv->name);
VEC_unordered_remove (tsv_s, tvariables, ix);
- observer_notify_tsv_deleted (name);
-
return;
}
@@ -408,7 +408,11 @@ trace_variable_command (char *args, int from_tty)
tsv = find_trace_state_variable (internalvar_name (intvar));
if (tsv)
{
- tsv->initial_value = initval;
+ if (tsv->initial_value != initval)
+ {
+ tsv->initial_value = initval;
+ observer_notify_tsv_modified (tsv);
+ }
printf_filtered (_("Trace state variable $%s "
"now has initial value %s.\n"),
tsv->name, plongest (tsv->initial_value));
@@ -420,7 +424,7 @@ trace_variable_command (char *args, int from_tty)
tsv = create_trace_state_variable (internalvar_name (intvar));
tsv->initial_value = initval;
- observer_notify_tsv_created (tsv->name, initval);
+ observer_notify_tsv_created (tsv);
printf_filtered (_("Trace state variable $%s "
"created, with initial value %s.\n"),
@@ -3586,7 +3590,7 @@ create_tsv_from_upload (struct uploaded_tsv *utsv)
tsv->initial_value = utsv->initial_value;
tsv->builtin = utsv->builtin;
- observer_notify_tsv_created (tsv->name, tsv->initial_value);
+ observer_notify_tsv_created (tsv);
do_cleanups (old_chain);
--
1.7.7.6
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] New MI notification "=tsv-modified"
2013-02-05 15:05 ` Yao Qi
@ 2013-02-05 15:41 ` Pedro Alves
2013-02-06 13:12 ` Yao Qi
0 siblings, 1 reply; 10+ messages in thread
From: Pedro Alves @ 2013-02-05 15:41 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On 02/05/2013 03:04 PM, Yao Qi wrote:
> On 02/05/2013 01:30 AM, Pedro Alves wrote:
>> _Which_ value is being talked about here is not explicit.
>> Trace state variables have_two_ values. The initial value,
>> and the current value (omitted if doesn't exist yet).
>
> I meant the initial value here.
>
>> If we list tsvs with MI's -trace-list-variables, we'll indeed
>> see an "init" and a "current" attribute, for each tsv, and no
>> attribute named "value". So I think it'd be very good to fix this
>> before the release, and make the output of the notifications
>> consistent with the tsv listing output, and the docs clearer.
>>
>> E.g.:
>> (gdb) interpreter-exec mi "-trace-list-variables"
>> ^done,trace-variables={nr_rows="1",nr_cols="3",
>> hdr=[{width="15",alignment="-1",col_name="name",colhdr="Name"},
>> {width="11",alignment="-1",col_name="initial",colhdr="Initial"},
>> {width="11",alignment="-1",col_name="current",colhdr="Current"}],
>> body=[variable={name="$a",initial="1"},
>> variable={name="$b",initial="2",current="3"}]
>>
>> SO IOW, =tsv-created should be
>>
>> =tsv-created,name=@var{name},initial=@var{value}
>>
>> instead of the current
>>
>> =tsv-created,name=@var{name},value=@var{value}
>>
>>
>> and =tsv-modified should be
>>
>> =tsv-modified,name=@var{name},initial=@var{value}
>>
>> instead of the proposed
>>
>> =tsv-modified,name=@var{name},value=@var{value}
>
> The patch below implements these MI notifications with suggested
> attributes. "=tsv-modified" is implemented like:
>
> =tsv-modified,name=@var{name},initial=@var{initial},current=@var{current}
>
> I don't refactor function tvariables_info_1 in this patch, and I'd like
> to defer this change to next one.
>
> Is it OK if no test regression?
I think that even without refactoring, we should
do what tvariables_info_1 does and omit "current" if the value
is not known. The -trace-list-variables docs explain this
suppression -- we should probably copy that bit into the
notification docs.
--
Pedro Alves
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] New MI notification "=tsv-modified"
2013-02-05 15:41 ` Pedro Alves
@ 2013-02-06 13:12 ` Yao Qi
2013-02-06 14:31 ` Pedro Alves
0 siblings, 1 reply; 10+ messages in thread
From: Yao Qi @ 2013-02-06 13:12 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On 02/05/2013 11:41 PM, Pedro Alves wrote:
> I think that even without refactoring, we should
> do what tvariables_info_1 does and omit "current" if the value
> is not known. The -trace-list-variables docs explain this
> suppression -- we should probably copy that bit into the
> notification docs.
OK, that makes sense to me. A new test case is added in this version
to verify that "current=XXX" appeared in the MI notification.
Regression tested on x86_64-linux.
--
Yao (é½å°§)
gdb/doc:
2013-02-06 Yao Qi <yao@codesourcery.com>
* gdb.texinfo (GDB/MI Async Records): Document new MI
notification "=tsv-modified". Update the document of MI
notification "=tsv-created".
* observer.texi (GDB Observers): New observer tsv_modified.
Update observer tsv_created and tsv_deleted.
gdb:
2013-02-06 Yao Qi <yao@codesourcery.com>
* mi/mi-interp.c: Include "tracepoint.h".
(mi_tsv_modified): Declare.
(mi_tsv_created, mi_tsv_deleted): Update declaration.
(mi_interpreter_init): Call observer_attach_tsv_modified.
(mi_tsv_modified): New.
(mi_tsv_created, mi_tsv_deleted): Update.
* tracepoint.c (trace_variable_command): Call
observer_notify_tsv_modified if the initial value of tsv is
changed.
(delete_trace_state_variable): Call
observer_notify_tsv_deleted earlier.
(trace_variable_command): Caller update.
(create_tsv_from_upload): Likewise.
* observer.sh: Declare "struct trace_state_variable".
* NEWS: Mention the new MI notification "=tsv-modified".
gdb/testsuite:
2013-02-06 Yao Qi <yao@codesourcery.com>
* gdb.trace/mi-tsv-changed.exp (test_create_delete_tsv): Rename
to ...
(test_create_delete_modify_tsv): ... here. New test on modifying
the initial value of a tsv.
---
gdb/NEWS | 5 +-
gdb/doc/gdb.texinfo | 10 +++-
gdb/doc/observer.texi | 13 +++--
gdb/mi/mi-interp.c | 45 ++++++++++++---
gdb/observer.sh | 1 +
gdb/testsuite/gdb.trace/mi-tsv-changed.exp | 88 +++++++++++++++++++++++++--
gdb/tracepoint.c | 14 +++--
7 files changed, 147 insertions(+), 29 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index 539ceb9..0e01deb 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -121,8 +121,9 @@ show print type typedefs
"=cmd-param-changed".
** Trace frame changes caused by command "tfind" are now notified using
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 creation, deletion and modification of trace state variables
+ are now notified using new async records "=tsv-created",
+ "=tsv-deleted" and "=tsv-modified".
** The start and stop of process record are now notified using new
async record "=record-started" and "=record-stopped".
** Memory changes are now notified using new async record
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index a8a7284..7e9b2ba 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27945,15 +27945,21 @@ Reports that the trace frame was changed and its new number is
@var{tfnum}. The number of the tracepoint associated with this trace
frame is @var{tpnum}.
-@item =tsv-created,name=@var{name},value=@var{value}
+@item =tsv-created,name=@var{name},initial=@var{initial}
Reports that the new trace state variable @var{name} is created with
-value @var{value}.
+initial value @var{initial}.
@item =tsv-deleted,name=@var{name}
@itemx =tsv-deleted
Reports that the trace state variable @var{name} is deleted or all
trace state variables are deleted.
+@item =tsv-modified,name=@var{name},initial=@var{initial}[,current=@var{current}]
+Reports that the trace state variable @var{name} is modified with
+the initial value @var{initial}. The current value @var{current} of
+trace state variable is optional and is reported if the current
+value of trace state variable is known.
+
@item =breakpoint-created,bkpt=@{...@}
@itemx =breakpoint-modified,bkpt=@{...@}
@itemx =breakpoint-deleted,id=@var{number}
diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi
index 87c08e1..adb7085 100644
--- a/gdb/doc/observer.texi
+++ b/gdb/doc/observer.texi
@@ -236,16 +236,19 @@ method is called after a command @code{set @var{param} @var{value}}.
is the value of changed parameter.
@end deftypefun
-@deftypefun void tsv_created (const char *@var{name}, LONGEST @var{value})
-The new trace state variable @var{name} is created with value
-@var{value}.
+@deftypefun void tsv_created (const struct trace_state_variable *@var{tsv})
+The new trace state variable @var{tsv} is created.
@end deftypefun
-@deftypefun void tsv_deleted (const char *@var{name})
-The trace state variable @var{name} is deleted. If @var{name} is
+@deftypefun void tsv_deleted (const struct trace_state_variable *@var{tsv})
+The trace state variable @var{tsv} is deleted. If @var{tsv} is
@code{NULL}, all trace state variables are deleted.
@end deftypefun
+@deftypefun void tsv_modified (const struct trace_state_variable *@var{tsv})
+The trace state value @var{tsv} is modified.
+@end deftypefun
+
@deftypefun void test_notification (int @var{somearg})
This observer is used for internal testing. Do not use.
See testsuite/gdb.gdb/observer.exp.
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 6617647..d1fe33c 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -36,6 +36,7 @@
#include "solist.h"
#include "gdb.h"
#include "objfiles.h"
+#include "tracepoint.h"
/* These are the interpreter setup, etc. functions for the MI
interpreter. */
@@ -71,8 +72,9 @@ static void mi_solib_loaded (struct so_list *solib);
static void mi_solib_unloaded (struct so_list *solib);
static void mi_about_to_proceed (void);
static void mi_traceframe_changed (int tfnum, int tpnum);
-static void mi_tsv_created (const char *name, LONGEST value);
-static void mi_tsv_deleted (const char *name);
+static void mi_tsv_created (const struct trace_state_variable *tsv);
+static void mi_tsv_deleted (const struct trace_state_variable *tsv);
+static void mi_tsv_modified (const struct trace_state_variable *tsv);
static void mi_breakpoint_created (struct breakpoint *b);
static void mi_breakpoint_deleted (struct breakpoint *b);
static void mi_breakpoint_modified (struct breakpoint *b);
@@ -137,6 +139,7 @@ mi_interpreter_init (struct interp *interp, int top_level)
observer_attach_traceframe_changed (mi_traceframe_changed);
observer_attach_tsv_created (mi_tsv_created);
observer_attach_tsv_deleted (mi_tsv_deleted);
+ observer_attach_tsv_modified (mi_tsv_modified);
observer_attach_breakpoint_created (mi_breakpoint_created);
observer_attach_breakpoint_deleted (mi_breakpoint_deleted);
observer_attach_breakpoint_modified (mi_breakpoint_modified);
@@ -563,15 +566,15 @@ mi_traceframe_changed (int tfnum, int tpnum)
/* Emit notification on creating a trace state variable. */
static void
-mi_tsv_created (const char *name, LONGEST value)
+mi_tsv_created (const struct trace_state_variable *tsv)
{
struct mi_interp *mi = top_level_interpreter_data ();
target_terminal_ours ();
fprintf_unfiltered (mi->event_channel, "tsv-created,"
- "name=\"%s\",value=\"%s\"\n",
- name, plongest (value));
+ "name=\"%s\",initial=\"%s\"\n",
+ tsv->name, plongest (tsv->initial_value));
gdb_flush (mi->event_channel);
}
@@ -579,21 +582,47 @@ mi_tsv_created (const char *name, LONGEST value)
/* Emit notification on deleting a trace state variable. */
static void
-mi_tsv_deleted (const char *name)
+mi_tsv_deleted (const struct trace_state_variable *tsv)
{
struct mi_interp *mi = top_level_interpreter_data ();
target_terminal_ours ();
- if (name != NULL)
+ if (tsv != NULL)
fprintf_unfiltered (mi->event_channel, "tsv-deleted,"
- "name=\"%s\"\n", name);
+ "name=\"%s\"\n", tsv->name);
else
fprintf_unfiltered (mi->event_channel, "tsv-deleted\n");
gdb_flush (mi->event_channel);
}
+/* Emit notification on modifying a trace state variable. */
+
+static void
+mi_tsv_modified (const struct trace_state_variable *tsv)
+{
+ struct mi_interp *mi = top_level_interpreter_data ();
+ struct ui_out *mi_uiout = interp_ui_out (top_level_interpreter ());
+
+ target_terminal_ours ();
+
+ fprintf_unfiltered (mi->event_channel,
+ "tsv-modified");
+
+ ui_out_redirect (mi_uiout, mi->event_channel);
+
+ ui_out_field_string (mi_uiout, "name", tsv->name);
+ ui_out_field_string (mi_uiout, "initial",
+ plongest (tsv->initial_value));
+ if (tsv->value_known)
+ ui_out_field_string (mi_uiout, "current", plongest (tsv->value));
+
+ ui_out_redirect (mi_uiout, NULL);
+
+ gdb_flush (mi->event_channel);
+}
+
/* Emit notification about a created breakpoint. */
static void
diff --git a/gdb/observer.sh b/gdb/observer.sh
index 3ff28a8..7b9e70c 100755
--- a/gdb/observer.sh
+++ b/gdb/observer.sh
@@ -64,6 +64,7 @@ struct so_list;
struct objfile;
struct thread_info;
struct inferior;
+struct trace_state_variable;
EOF
;;
esac
diff --git a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
index 4e7d5a4..0b9475e 100644
--- a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
@@ -23,11 +23,14 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
return -1
}
-# Test notifications on creating and deleting TSV.
+# Test notifications on creating, deleting and modifying TSV.
-proc test_create_delete_tsv { } {with_test_prefix "create delete" {
+proc test_create_delete_modify_tsv { } {with_test_prefix "create delete modify" {
global binfile
global decimal
+ global testfile
+ global srcdir subdir
+ global mi_gdb_prompt
if [mi_gdb_start] {
return
@@ -35,10 +38,18 @@ proc test_create_delete_tsv { } {with_test_prefix "create delete" {
mi_gdb_load ${binfile}
mi_gdb_test "tvariable \$tvar1" \
- ".*=tsv-created,name=\"tvar1\",value=\"0\"\\\\n.*\\^done" \
+ ".*=tsv-created,name=\"tvar1\",initial=\"0\"\\\\n.*\\^done" \
"tvariable \$tvar1"
+ mi_gdb_test "tvariable \$tvar1 = 1" \
+ ".*=tsv-modified,name=\"tvar1\",initial=\"1\".*\\^done" \
+ "tvariable \$tvar1 modified"
+ # No "=tsv-modified" notification is emitted, because the initial
+ # value is not changed.
+ mi_gdb_test "tvariable \$tvar1 = 1" \
+ ".*\\\$tvar1 = 1\\\\n\"\r\n~\"Trace state .*\\\\n.*\\^done" \
+ "tvariable \$tvar1 modified without notification"
mi_gdb_test "tvariable \$tvar2 = 45" \
- ".*=tsv-created,name=\"tvar2\",value=\"45\"\\\\n.*\\^done" \
+ ".*=tsv-created,name=\"tvar2\",initial=\"45\"\\\\n.*\\^done" \
"tvariable \$tvar2"
mi_gdb_test "delete tvariable \$tvar2" \
@@ -49,6 +60,69 @@ proc test_create_delete_tsv { } {with_test_prefix "create delete" {
".*=tsv-deleted\\\\n.*\\^done" \
"delete all tvariables"
+ # Test target supports tracepoints or not.
+ clean_restart $testfile
+
+ if ![runto_main] {
+ fail "Can't run to main to check for trace support"
+ return -1
+ }
+
+ if ![gdb_target_supports_trace] {
+ unsupported "Current target does not support trace"
+ return -1;
+ }
+ gdb_exit
+ if [mi_gdb_start] {
+ continue
+ }
+
+ mi_gdb_reinitialize_dir $srcdir/$subdir
+ mi_gdb_load ${binfile}
+
+ mi_gdb_test "tvariable \$tvar3 = 3" \
+ ".*=tsv-created,name=\"tvar3\",initial=\"3\".*\\^done" \
+ "tvariable \$tvar3 modified"
+ mi_gdb_test "-break-insert -a gdb_c_test" \
+ {.*\^done,bkpt=.*} \
+ "insert tracepoint on gdb_c_test"
+ # Define an action that increases $tvar3
+ send_gdb "actions\n"
+ gdb_expect {
+ -re "End with" {
+ }
+ }
+ send_gdb "collect \$tvar3 += 3\nend\n"
+ set test "define actions"
+ gdb_expect {
+ -re ".*${mi_gdb_prompt}$" {
+ pass $test
+ }
+ timeout {
+ fail "$test (timeout)"
+ }
+ }
+
+ mi_gdb_test "-break-insert begin" \
+ {.*\^done,bkpt=.*} \
+ "insert tracepoint on begin"
+ mi_gdb_test "-break-insert end" \
+ {.*\^done,bkpt=.*} \
+ "insert tracepoint on end"
+ mi_run_cmd
+
+ mi_expect_stop "breakpoint-hit" "begin" ""\
+ ".*" ".*" {"" "disp=\"keep\""} \
+ "continue to begin breakpoint"
+ mi_gdb_test "-trace-start" {.*\^done} "trace start"
+ mi_send_resuming_command "exec-continue" "continuing to end"
+ mi_gdb_test "-trace-stop" {.*} "trace stop"
+ # Force GDB to get the current value of trace state variable.
+ mi_gdb_test "-trace-list-variables" ".*" "list trace variables"
+ mi_gdb_test "tvariable \$tvar3 = 2" \
+ ".*=tsv-modified,name=\"tvar3\",initial=\"2\",current=\"6\".*\\^done" \
+ "tvariable \$tvar3 modified"
+
}}
@@ -121,11 +195,11 @@ proc test_upload_tsv { } { with_test_prefix "upload" {
set tsv1_created 0
set tsv2_created 0
gdb_expect {
- -re "=tsv-created,name=\"tvar1\",value=\"0\"" {
+ -re "=tsv-created,name=\"tvar1\",initial=\"0\"" {
set tsv1_created 1
exp_continue
}
- -re "=tsv-created,name=\"tvar2\",value=\"45\"" {
+ -re "=tsv-created,name=\"tvar2\",initial=\"45\"" {
set tsv2_created 1
exp_continue
}
@@ -148,7 +222,7 @@ proc test_upload_tsv { } { with_test_prefix "upload" {
set gdbserver_reconnect_p 0
}}
- test_create_delete_tsv
+ test_create_delete_modify_tsv
# Test target supports tracepoints or not.
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index be45cb4..d0a360a 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -351,11 +351,11 @@ delete_trace_state_variable (const char *name)
for (ix = 0; VEC_iterate (tsv_s, tvariables, ix, tsv); ++ix)
if (strcmp (name, tsv->name) == 0)
{
+ observer_notify_tsv_deleted (tsv);
+
xfree ((void *)tsv->name);
VEC_unordered_remove (tsv_s, tvariables, ix);
- observer_notify_tsv_deleted (name);
-
return;
}
@@ -408,7 +408,11 @@ trace_variable_command (char *args, int from_tty)
tsv = find_trace_state_variable (internalvar_name (intvar));
if (tsv)
{
- tsv->initial_value = initval;
+ if (tsv->initial_value != initval)
+ {
+ tsv->initial_value = initval;
+ observer_notify_tsv_modified (tsv);
+ }
printf_filtered (_("Trace state variable $%s "
"now has initial value %s.\n"),
tsv->name, plongest (tsv->initial_value));
@@ -420,7 +424,7 @@ trace_variable_command (char *args, int from_tty)
tsv = create_trace_state_variable (internalvar_name (intvar));
tsv->initial_value = initval;
- observer_notify_tsv_created (tsv->name, initval);
+ observer_notify_tsv_created (tsv);
printf_filtered (_("Trace state variable $%s "
"created, with initial value %s.\n"),
@@ -3586,7 +3590,7 @@ create_tsv_from_upload (struct uploaded_tsv *utsv)
tsv->initial_value = utsv->initial_value;
tsv->builtin = utsv->builtin;
- observer_notify_tsv_created (tsv->name, tsv->initial_value);
+ observer_notify_tsv_created (tsv);
do_cleanups (old_chain);
--
1.7.7.6
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] New MI notification "=tsv-modified"
2013-02-06 13:12 ` Yao Qi
@ 2013-02-06 14:31 ` Pedro Alves
2013-02-06 14:46 ` Yao Qi
0 siblings, 1 reply; 10+ messages in thread
From: Pedro Alves @ 2013-02-06 14:31 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On 02/06/2013 01:11 PM, Yao Qi wrote:
> gdb:
>
> 2013-02-06 Yao Qi <yao@codesourcery.com>
>
> * mi/mi-interp.c: Include "tracepoint.h".
> (mi_tsv_modified): Declare.
> (mi_tsv_created, mi_tsv_deleted): Update declaration.
> (mi_interpreter_init): Call observer_attach_tsv_modified.
> (mi_tsv_modified): New.
> (mi_tsv_created, mi_tsv_deleted): Update.
> * tracepoint.c (trace_variable_command): Call
> observer_notify_tsv_modified if the initial value of tsv is
> changed.
> (delete_trace_state_variable): Call
> observer_notify_tsv_deleted earlier.
> (trace_variable_command): Caller update.
> (create_tsv_from_upload): Likewise.
> * observer.sh: Declare "struct trace_state_variable".
>
> gdb/testsuite:
>
> 2013-02-06 Yao Qi <yao@codesourcery.com>
>
> * gdb.trace/mi-tsv-changed.exp (test_create_delete_tsv): Rename
> to ...
> (test_create_delete_modify_tsv): ... here. New test on modifying
> the initial value of a tsv.
Thanks. These parts are OK.
--
Pedro Alves
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] New MI notification "=tsv-modified"
2013-02-06 14:31 ` Pedro Alves
@ 2013-02-06 14:46 ` Yao Qi
0 siblings, 0 replies; 10+ messages in thread
From: Yao Qi @ 2013-02-06 14:46 UTC (permalink / raw)
Cc: gdb-patches
On 02/06/2013 10:31 PM, Pedro Alves wrote:
> Thanks. These parts are OK.
Committed.
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-02-06 14:46 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-30 15:44 [PATCH] New MI notification "=tsv-modified" Yao Qi
2013-01-30 17:17 ` Eli Zaretskii
2013-02-01 20:38 ` Pedro Alves
2013-02-02 8:29 ` Yao Qi
2013-02-04 17:55 ` Pedro Alves
2013-02-05 15:05 ` Yao Qi
2013-02-05 15:41 ` Pedro Alves
2013-02-06 13:12 ` Yao Qi
2013-02-06 14:31 ` Pedro Alves
2013-02-06 14:46 ` Yao Qi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox