This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 6/7] notify in string_cmd and trace-notes.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]