From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7432 invoked by alias); 27 Jul 2012 15:23:32 -0000 Received: (qmail 7334 invoked by uid 22791); 27 Jul 2012 15:23:28 -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 15:23:13 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1SumNb-0007Bt-95 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Fri, 27 Jul 2012 08:23:03 -0700 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 27 Jul 2012 08:23:03 -0700 Received: from qiyao.dyndns.org.dyndns.org (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.1.289.1; Fri, 27 Jul 2012 08:23:02 -0700 From: Yao Qi To: Subject: [PATCH 5/6] notify in string_cmd and trace-notes. Date: Fri, 27 Jul 2012 15:23:00 -0000 Message-ID: <1343402543-665-6-git-send-email-yao@codesourcery.com> In-Reply-To: <1343402543-665-1-git-send-email-yao@codesourcery.com> References: <1343402543-665-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/msg00694.txt.bz2 Hi, this patch is to change function add_setshow_string_cmd to return 'struct cmd_list_element *', and register command "trace-notes". A new test case is added for it. gdb: 2012-07-27 Yao Qi * cli/cli-decode.c (add_setshow_string_cmd): Return 'struct cmd_list_element *'. * command.h: Update declaration. * tracepoint.c (_initialize_tracepoint): Get the return value of add_setshow_string_cmd and 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 'set trace-notes'. --- gdb/cli/cli-decode.c | 11 ++++++++--- gdb/command.h | 21 +++++++++++---------- gdb/testsuite/gdb.mi/mi-cmd-opt-changed.exp | 11 +++++++++++ gdb/tracepoint.c | 9 +++++---- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index c185575..1778030 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -520,8 +520,9 @@ add_setshow_filename_cmd (char *name, enum command_class class, } /* Add element named NAME to both the set and show command LISTs (the - list for set/show or some sublist thereof). */ -void + list for set/show or some sublist thereof). Return the 'set' + command handler. */ +struct cmd_list_element * add_setshow_string_cmd (char *name, enum command_class class, char **var, const char *set_doc, const char *show_doc, @@ -531,11 +532,15 @@ add_setshow_string_cmd (char *name, enum command_class class, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { + struct cmd_list_element *c; + add_setshow_cmd_full (name, class, var_string, var, set_doc, show_doc, help_doc, set_func, show_func, set_list, show_list, - NULL, NULL); + &c, NULL); + + 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 692a16f..4f92d8e 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -281,16 +281,17 @@ extern void add_setshow_filename_cmd (char *name, struct cmd_list_element **set_list, struct cmd_list_element **show_list); -extern void add_setshow_string_cmd (char *name, - enum command_class class, - char **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_string_cmd (char *name, + enum command_class class, + char **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_string_noescape_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 e348483..adb3265 100644 --- a/gdb/testsuite/gdb.mi/mi-cmd-opt-changed.exp +++ b/gdb/testsuite/gdb.mi/mi-cmd-opt-changed.exp @@ -68,6 +68,17 @@ proc test_command_option_change { } { with_test_prefix "cmd option" { "\"set ${command}\" no event" } + + foreach command { "trace-notes" } { + foreach str_opt { "foo" "bar" } { + mi_gdb_test "set ${command} ${str_opt}" \ + ".*=option-changed,option=\"${command}\",value=\"${str_opt}\".*\\^done" \ + "\"set ${command} ${str_opt}\"" + } + mi_gdb_test "set ${command} bar" \ + "\\&\"set ${command} bar\\\\n\"\r\n(\\&\"warning.*)\\^done" \ + "\"set ${command} bar\" no event" + } mi_gdb_exit }} diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index e7db0f6..61335b7 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -5364,12 +5364,13 @@ Show the user name to use for current and future trace runs"), NULL, set_trace_user, NULL, &setlist, &showlist); - add_setshow_string_cmd ("trace-notes", class_trace, - &trace_notes, _("\ + c = add_setshow_string_cmd ("trace-notes", class_trace, + &trace_notes, _("\ Set notes string to use for current and future trace runs"), _("\ Show the notes string to use for current and future trace runs"), NULL, - set_trace_notes, NULL, - &setlist, &showlist); + set_trace_notes, NULL, + &setlist, &showlist); + set_cmd_notify (c); add_setshow_string_cmd ("trace-stop-notes", class_trace, &trace_stop_notes, _("\ -- 1.7.7.6