From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24320 invoked by alias); 27 Jul 2012 14:07:48 -0000 Received: (qmail 24024 invoked by uid 22791); 27 Jul 2012 14:07:44 -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; Fri, 27 Jul 2012 14:07:13 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1SulCD-0006Uj-5x from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Fri, 27 Jul 2012 07:07:13 -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); Fri, 27 Jul 2012 07:07:12 -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; Fri, 27 Jul 2012 07:07:05 -0700 From: Yao Qi To: Subject: [PATCH 5/7] notify in boolean_cmd and circular-trace-buffer. Date: Fri, 27 Jul 2012 14:07:00 -0000 Message-ID: <1343397901-15051-6-git-send-email-yao@codesourcery.com> In-Reply-To: <1343397901-15051-1-git-send-email-yao@codesourcery.com> References: <1343397901-15051-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/msg00684.txt.bz2 Hi, Similar to previous patch, this patch is to add a new function add_setshow_boolean_cmd_with_notif, and register command "circular-trace-buffer" as an example to boolean command. A new test case is added for it. gdb: 2012-07-27 Yao Qi * cli/cli-decode.c (add_setshow_auto_boolean_cmd): Move 'boolean_enums' out. Return 'struct cmd_list_element *' for set command. * command.h: Update declaration of add_setshow_auto_boolean_cmd. * tracepoint.c (_initialize_tracepoint): Get the return value of add_setshow_auto_boolean_cmd can call set_cmd_notify. gdb/testsuite: 2012-07-27 Yao Qi * gdb.mi/mi-cmd-opt-changed.exp (test_command_option_change): Test for command 'circular-trace-buffer'. --- gdb/cli/cli-decode.c | 9 ++++++--- gdb/command.h | 19 ++++++++++--------- gdb/testsuite/gdb.mi/mi-cmd-opt-changed.exp | 17 +++++++++++++++++ gdb/tracepoint.c | 13 +++++++------ 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 2dd4b1f..c185575 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -470,11 +470,13 @@ add_setshow_auto_boolean_cmd (char *name, c->enums = auto_boolean_enums; } +static const char *boolean_enums[] = { "on", "off", NULL }; /* Add element named NAME to both the set and show command LISTs (the list for set/show or some sublist thereof). CLASS is as in add_cmd. VAR is address of the variable which will contain the - value. SET_DOC and SHOW_DOC are the documentation strings. */ -void + value. SET_DOC and SHOW_DOC are the documentation strings. Return + the 'set' command handler.*/ +struct cmd_list_element * add_setshow_boolean_cmd (char *name, enum command_class class, int *var, const char *set_doc, const char *show_doc, const char *help_doc, @@ -483,7 +485,6 @@ add_setshow_boolean_cmd (char *name, enum command_class class, int *var, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { - static const char *boolean_enums[] = { "on", "off", NULL }; struct cmd_list_element *c; add_setshow_cmd_full (name, class, var_boolean, var, @@ -492,6 +493,8 @@ add_setshow_boolean_cmd (char *name, enum command_class class, int *var, set_list, show_list, &c, NULL); c->enums = boolean_enums; + + return c; } /* Add element named NAME to both the set and show command LISTs (the diff --git a/gdb/command.h b/gdb/command.h index 3f3703c..692a16f 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -259,15 +259,16 @@ extern void add_setshow_auto_boolean_cmd (char *name, struct cmd_list_element **set_list, struct cmd_list_element **show_list); -extern void add_setshow_boolean_cmd (char *name, - enum command_class class, - int *var, - const char *set_doc, const char *show_doc, - const char *help_doc, - cmd_sfunc_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list); +extern struct cmd_list_element * + add_setshow_boolean_cmd (char *name, + enum command_class class, + int *var, + const char *set_doc, const char *show_doc, + const char *help_doc, + cmd_sfunc_ftype *set_func, + show_value_ftype *show_func, + struct cmd_list_element **set_list, + struct cmd_list_element **show_list); extern void add_setshow_filename_cmd (char *name, enum command_class class, diff --git a/gdb/testsuite/gdb.mi/mi-cmd-opt-changed.exp b/gdb/testsuite/gdb.mi/mi-cmd-opt-changed.exp index c8011a9..e348483 100644 --- a/gdb/testsuite/gdb.mi/mi-cmd-opt-changed.exp +++ b/gdb/testsuite/gdb.mi/mi-cmd-opt-changed.exp @@ -51,6 +51,23 @@ proc test_command_option_change { } { with_test_prefix "cmd option" { "\\&\"set scheduler-locking step\\\\n\"\r\n\\^done" \ "\"set scheduler-locking stepr\" no event" + + foreach command { "circular-trace-buffer" } { + + # The default value of each command option may be different, so we first + # set it to 'off', and this may or may not trigger MI notification. + mi_gdb_test "set ${command} off" ".*\\^done" "\"set ${command}\" warmup" + + foreach boolean_opt { "on" "off" } { + mi_gdb_test "set ${command} ${boolean_opt}" \ + ".*=option-changed,option=\"${command}\",value=\"${boolean_opt}\".*\\^done" \ + "\"set ${command} ${boolean_opt}\"" + } + mi_gdb_test "set ${command} off" \ + "\\&\"set ${command} off\\\\n\"\r\n\\^done" \ + "\"set ${command}\" no event" + } + mi_gdb_exit }} diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 8c8d4a8..e7db0f6 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -5344,17 +5344,18 @@ trace data collected in the meantime."), &setlist, &showlist); - add_setshow_boolean_cmd ("circular-trace-buffer", no_class, - &circular_trace_buffer, _("\ + c = add_setshow_boolean_cmd ("circular-trace-buffer", no_class, + &circular_trace_buffer, _("\ Set target's use of circular trace buffer."), _("\ Show target's use of circular trace buffer."), _("\ Use this to make the trace buffer into a circular buffer,\n\ which will discard traceframes (oldest first) instead of filling\n\ up and stopping the trace run."), - set_circular_trace_buffer, - NULL, - &setlist, - &showlist); + set_circular_trace_buffer, + NULL, + &setlist, + &showlist); + set_cmd_notify (c); add_setshow_string_cmd ("trace-user", class_trace, &trace_user, _("\ -- 1.7.7.6