From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14431 invoked by alias); 24 Jul 2012 16:11:58 -0000 Received: (qmail 14317 invoked by uid 22791); 24 Jul 2012 16:11:55 -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:36 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1Sthhv-0006y6-6f from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Tue, 24 Jul 2012 09:11:35 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 24 Jul 2012 09:11:34 -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:33 -0700 From: Yao Qi To: Subject: [PATCH 6/6] new add_setshow_string_cmd_with_notif and trace-notes. Date: Tue, 24 Jul 2012 16:11:00 -0000 Message-ID: <1343146252-22558-7-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/msg00492.txt.bz2 Hi, this patch is to add a new function add_setshow_string_cmd_with_notif, and register command "trace-notes". A new test case is added for it. gdb: 2012-07-24 Yao Qi * cli/cli-decode.c (add_setshow_string_cmd_with_notif): New. * command.h: Declare. * tracepoint.c (_initialize_tracepoint): Call add_setshow_string_cmd_with_notif. gdb/testsuite: 2012-07-24 Yao Qi * gdb.mi/mi-cmd-opt-changed.exp (test_command_option_change): Test for command 'set trace-notes'. --- gdb/cli/cli-decode.c | 24 ++++++++++++++++++++++++ gdb/command.h | 10 ++++++++++ gdb/testsuite/gdb.mi/mi-cmd-opt-changed.exp | 11 +++++++++++ gdb/tracepoint.c | 8 ++++---- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index b8dfb6c..cf36abe 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -575,6 +575,30 @@ add_setshow_string_cmd (char *name, enum command_class class, NULL, NULL); } +/* Same as add_setshow_string_cmd except that observer 'command_option_change' + will be notified if command option is changed. */ + +void +add_setshow_string_cmd_with_notif (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) +{ + 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, + &c, NULL); + + c->notify_observer_p = 1; +} + /* Add element named NAME to both the set and show command LISTs (the list for set/show or some sublist thereof). */ void diff --git a/gdb/command.h b/gdb/command.h index c581997..50901af 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -309,6 +309,16 @@ extern void add_setshow_string_cmd (char *name, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list); +extern void add_setshow_string_cmd_with_notif (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 bedc2d7..5388b72 100644 --- a/gdb/testsuite/gdb.mi/mi-cmd-opt-changed.exp +++ b/gdb/testsuite/gdb.mi/mi-cmd-opt-changed.exp @@ -70,6 +70,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 d09faf8..4eacefa 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -5363,12 +5363,12 @@ 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, _("\ + add_setshow_string_cmd_with_notif ("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); add_setshow_string_cmd ("trace-stop-notes", class_trace, &trace_stop_notes, _("\ -- 1.7.7.6