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 5/6] notify in string_cmd and trace-notes.
Date: Fri, 27 Jul 2012 15:23:00 -0000	[thread overview]
Message-ID: <1343402543-665-6-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1343402543-665-1-git-send-email-yao@codesourcery.com>

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  <yao@codesourcery.com>

	* 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  <yao@codesourcery.com>

	* 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


  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 3/6] notify in enum_cmd and scheduler-locking Yao Qi
2012-07-27 15:23 ` [PATCH 6/6] code indentation Yao Qi
2012-07-27 15:23 ` [PATCH 2/6] attach to command_option-changed observer Yao Qi
2012-07-27 17:20   ` Tom Tromey
2012-07-27 17:44   ` Tom Tromey
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 15:23 ` [PATCH 1/6] new observer command_option_changed Yao Qi
2012-07-27 17:56   ` Tom Tromey
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-6-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