Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 2/6] attach to command_option-changed observer.
Date: Fri, 27 Jul 2012 15:23:00 -0000	[thread overview]
Message-ID: <1343402543-665-3-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1343402543-665-1-git-send-email-yao@codesourcery.com>

Hi,
'mi_suppress_breakpoint_notifications' is used to suppress mi
breakpoint notifications.  This patch is to change this variable
to an array so that multiple mi notifications can be suppressed.
The following patch will use it to suppress other MI notifications.

This patch is to attach function 'mi_command_option_changed' to
observer 'command_option_changed', so that a MI notification
"=option-changed" is sent to MI frontend.  If the command option
change is requested from MI, the notification is suppressed.

gdb:

2012-07-27  Yao Qi  <yao@codesourcery.com>

	* NEWS: Mention new MI notification.

	* mi/mi-interp.c: Declare mi_command_option_changed.
	(mi_interpreter_init): Attach mi_command_option_changed to
	observer command_option_changed.
	(mi_command_option_changed): New.
	Remove mi_suppress_breakpoint_notifications.
	Define global variable mi_suppress_notification.
	(mi_breakpoint_created): Update.
	(mi_breakpoint_deleted): Likewise.
	(mi_breakpoint_modified): Likewise.
	* mi/mi-main.c (mi_cmd_execute): Likewise.  Check command
	'gdb-set' and set mi_suppress_notification.
	* mi/mi-main.h: (mi_suppress_notification): New struct.

gdb/doc:

2012-07-27  Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (GDB/MI Async Records): Doc for '=option-changed'.
---
 gdb/NEWS            |    5 +++++
 gdb/doc/gdb.texinfo |    3 +++
 gdb/mi/mi-interp.c  |   44 ++++++++++++++++++++++++++++++++++++++------
 gdb/mi/mi-main.c    |    9 +++++++--
 gdb/mi/mi-main.h    |   10 +++++++++-
 5 files changed, 62 insertions(+), 9 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index 3333810..0f73e60 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,11 @@
 
 *** Changes since GDB 7.5
 
+* MI changes
+
+  ** Command option changes are now notified using new async record
+     "=option-changed".
+
 *** Changes in GDB 7.5
 
 * GDB now supports x32 ABI.  Visit <http://sites.google.com/site/x32abi/>
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 68ea817..aa95a91 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27638,6 +27638,9 @@ breakpoint commands; @xref{GDB/MI Breakpoint Commands}.
 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 =option-changed,option=@var{option},value=@var{value}
+Reports that an option of the command @code{set @var{option}} is
+changed to @var{value}.
 @end table
 
 @node GDB/MI Frame Information
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index b487136..58bbfe6 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -71,6 +71,7 @@ static void mi_about_to_proceed (void);
 static void mi_breakpoint_created (struct breakpoint *b);
 static void mi_breakpoint_deleted (struct breakpoint *b);
 static void mi_breakpoint_modified (struct breakpoint *b);
+static void mi_command_option_changed (const char *option, const char *value);
 
 static int report_initial_inferior (struct inferior *inf, void *closure);
 
@@ -128,6 +129,7 @@ mi_interpreter_init (struct interp *interp, int top_level)
       observer_attach_breakpoint_created (mi_breakpoint_created);
       observer_attach_breakpoint_deleted (mi_breakpoint_deleted);
       observer_attach_breakpoint_modified (mi_breakpoint_modified);
+      observer_attach_command_option_changed (mi_command_option_changed);
 
       /* The initial inferior is created before this function is
 	 called, so we need to report it explicitly.  Use iteration in
@@ -501,10 +503,14 @@ mi_about_to_proceed (void)
   mi_proceeded = 1;
 }
 
-/* When non-zero, no MI notifications will be emitted in
-   response to breakpoint change observers.  */
+/* When the element is non-zero, no MI notifications will be emitted in
+   response to the corresponding observers.  */
 
-int mi_suppress_breakpoint_notifications = 0;
+struct mi_suppress_notification mi_suppress_notification =
+  {
+    0,
+    0,
+  };
 
 /* Emit notification about a created breakpoint.  */
 
@@ -515,7 +521,7 @@ mi_breakpoint_created (struct breakpoint *b)
   struct ui_out *mi_uiout = interp_ui_out (top_level_interpreter ());
   volatile struct gdb_exception e;
 
-  if (mi_suppress_breakpoint_notifications)
+  if (mi_suppress_notification.breakpoint)
     return;
 
   if (b->number <= 0)
@@ -546,7 +552,7 @@ mi_breakpoint_deleted (struct breakpoint *b)
 {
   struct mi_interp *mi = top_level_interpreter_data ();
 
-  if (mi_suppress_breakpoint_notifications)
+  if (mi_suppress_notification.breakpoint)
     return;
 
   if (b->number <= 0)
@@ -569,7 +575,7 @@ mi_breakpoint_modified (struct breakpoint *b)
   struct ui_out *mi_uiout = interp_ui_out (top_level_interpreter ());
   volatile struct gdb_exception e;
 
-  if (mi_suppress_breakpoint_notifications)
+  if (mi_suppress_notification.breakpoint)
     return;
 
   if (b->number <= 0)
@@ -730,6 +736,32 @@ mi_solib_unloaded (struct so_list *solib)
   gdb_flush (mi->event_channel);
 }
 
+/* Emit notification about the command option change.  */
+
+static void
+mi_command_option_changed (const char *option, const char *value)
+{
+  struct mi_interp *mi = top_level_interpreter_data ();
+  struct ui_out *mi_uiout = interp_ui_out (top_level_interpreter ());
+
+  if (mi_suppress_notification.option_changed)
+    return;
+
+  target_terminal_ours ();
+
+  fprintf_unfiltered (mi->event_channel,
+		      "option-changed");
+
+  ui_out_redirect (mi_uiout, mi->event_channel);
+
+  ui_out_field_string (mi_uiout, "option", option);
+  ui_out_field_string (mi_uiout, "value", value);
+
+  ui_out_redirect (mi_uiout, NULL);
+
+  gdb_flush (mi->event_channel);
+}
+
 static int
 report_initial_inferior (struct inferior *inf, void *closure)
 {
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index dfb4892..f82b751 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2099,8 +2099,13 @@ mi_cmd_execute (struct mi_parse *parse)
 
   if (strncmp (parse->command, "break-", sizeof ("break-") - 1 ) == 0)
     {
-      make_cleanup_restore_integer (&mi_suppress_breakpoint_notifications);
-      mi_suppress_breakpoint_notifications = 1;
+      make_cleanup_restore_integer (&mi_suppress_notification.breakpoint);
+      mi_suppress_notification.breakpoint = 1;
+    }
+  else if (strncmp (parse->command, "gdb-set", sizeof ("gdb-set") - 1) == 0)
+    {
+      make_cleanup_restore_integer (&mi_suppress_notification.option_changed);
+      mi_suppress_notification.option_changed = 1;
     }
 
   if (parse->cmd->argv_func != NULL)
diff --git a/gdb/mi/mi-main.h b/gdb/mi/mi-main.h
index beac2cd..b940154 100644
--- a/gdb/mi/mi-main.h
+++ b/gdb/mi/mi-main.h
@@ -32,7 +32,15 @@ extern char *current_token;
 
 extern int running_result_record_printed;
 extern int mi_proceeded;
-extern int mi_suppress_breakpoint_notifications;
+
+struct mi_suppress_notification
+{
+  /* Breakpoint notification suppressed? */
+  int breakpoint;
+  /* Command option changed notification suppressed? */
+  int option_changed;
+};
+extern struct mi_suppress_notification mi_suppress_notification;
 
 #endif
 
-- 
1.7.7.6


  parent reply	other threads:[~2012-07-27 15:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-27 15:23 [RCF 0/6 V2] MI notification of command option change Yao Qi
2012-07-27 15:23 ` [PATCH 1/6] new observer command_option_changed Yao Qi
2012-07-27 17:56   ` Tom Tromey
2012-07-27 15:23 ` [PATCH 5/6] notify in string_cmd and trace-notes Yao Qi
2012-07-27 15:23 ` [PATCH 4/6] notify in boolean_cmd and circular-trace-buffer Yao Qi
2012-07-27 15:23 ` Yao Qi [this message]
2012-07-27 17:20   ` [PATCH 2/6] attach to command_option-changed observer Tom Tromey
2012-07-27 17:44   ` Tom Tromey
2012-07-27 15:23 ` [PATCH 6/6] code indentation Yao Qi
2012-07-27 15:23 ` [PATCH 3/6] notify in enum_cmd and scheduler-locking Yao Qi
2012-07-27 17:07 ` [RCF 0/6 V2] MI notification of command option change 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=1343402543-665-3-git-send-email-yao@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /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