From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13693 invoked by alias); 24 Jul 2012 16:11:42 -0000 Received: (qmail 13540 invoked by uid 22791); 24 Jul 2012 16:11:37 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 Jul 2012 16:11:17 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1Sthhc-0006pb-GX from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Tue, 24 Jul 2012 09:11:16 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 24 Jul 2012 09:11:18 -0700 Received: from qiyao.dyndns.org.dyndns.org (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.1.289.1; Tue, 24 Jul 2012 09:11:15 -0700 From: Yao Qi To: Subject: [PATCH 3/6] attach to command_option-changed observer. Date: Tue, 24 Jul 2012 16:11:00 -0000 Message-ID: <1343146252-22558-4-git-send-email-yao@codesourcery.com> In-Reply-To: <1343146252-22558-1-git-send-email-yao@codesourcery.com> References: <1343146252-22558-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-07/txt/msg00491.txt.bz2 Hi, 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-24 Yao Qi * 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. * mi/mi-main.c (mi_cmd_execute): Check command 'gdb-set' and set mi_suppress_notification. * mi/mi-main.h: New enum 'MI_SUPPRESS_COMMAND'. gdb/doc: 2012-07-24 Yao Qi * gdb.texinfo (GDB/MI Async Records): Doc for '=option-changed'. --- gdb/NEWS | 5 +++++ gdb/doc/gdb.texinfo | 3 +++ gdb/mi/mi-interp.c | 21 ++++++++++++++++++++- gdb/mi/mi-main.c | 7 +++++++ gdb/mi/mi-main.h | 2 +- 5 files changed, 36 insertions(+), 2 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 diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 68ea817..5ad8c9d 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{command},value=@var{value} +Reports that an option of the command @var{set command} 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 885d08b..b45b43e 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 @@ -504,7 +506,7 @@ mi_about_to_proceed (void) /* When the element is non-zero, no MI notifications will be emitted in response to the corresponding observers. */ -int mi_suppress_notification[] = { 0 }; +int mi_suppress_notification[] = { 0, 0 }; /* Emit notification about a created breakpoint. */ @@ -730,6 +732,23 @@ mi_solib_unloaded (struct so_list *solib) gdb_flush (mi->event_channel); } +static void +mi_command_option_changed (const char *option, const char *value) +{ + struct mi_interp *mi = top_level_interpreter_data (); + + if (mi_suppress_notification[MI_SUPPRESS_COMMAND]) + return; + + target_terminal_ours (); + + fprintf_unfiltered (mi->event_channel, + "option-changed,option=\"%s\",value=\"%s\"", + option, value); + + 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 0ae867d..82a1890 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -2104,6 +2104,13 @@ mi_cmd_execute (struct mi_parse *parse) make_cleanup_restore_integer (p); *p = 1; } + else if (strncmp (parse->command, "gdb-set", sizeof ("gdb-set") - 1 ) == 0) + { + int *p = &mi_suppress_notification[MI_SUPPRESS_COMMAND]; + + make_cleanup_restore_integer (p); + *p = 1; + } if (parse->cmd->argv_func != NULL) { diff --git a/gdb/mi/mi-main.h b/gdb/mi/mi-main.h index 1c7bf00..93c0692 100644 --- a/gdb/mi/mi-main.h +++ b/gdb/mi/mi-main.h @@ -33,7 +33,7 @@ extern char *current_token; extern int running_result_record_printed; extern int mi_proceeded; -enum MI_SUPRESS_NOTIFICATION { MI_SUPPRESS_BREAKPOINT }; +enum MI_SUPRESS_NOTIFICATION { MI_SUPPRESS_BREAKPOINT, MI_SUPPRESS_COMMAND }; extern int mi_suppress_notification[]; #endif -- 1.7.7.6