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: 'show args' -vs- '--args'


I use "gdb --args" a lot, and I've noticed a weird behavior.  If I
start gdb this way, "show args" will initially say that there are no
arguments, even if there are.  However, if I run "show args" twice in
a row, the second one will print the correct answer.

I tracked this down to notice_args_read.  This calls get_inferior_args
to set the correct value, but too late.  This is why it fails the
first time (it uses the old value) but succeeds the second time (the
first call sets the value).

This patch fixes the problem by using the (apparently as-yet-unused)
'pre_show_hook' of the show command.

I checked the other callers of add_setshow_optional_filename_cmd to
make sure they weren't making the same mistake (they weren't).  I
didn't check any other setshow commands, though.

Also, I ran the test suite against this on x86 FC-6.  I forgot to make
a baseline, sorry.. but the results look sane to me.

Tom


ChangeLog:
2008-02-03  Tom Tromey  <tromey@redhat.com>

	* symfile.c (_initialize_symfile): Update.
	* solib.c (_initialize_solib): Update.
	* cli/cli-decode.c (add_setshow_optional_filename_cmd): Set
	pre_show_hook.
	* infcmd.c (notice_args_read): Change arguments.  Don't print
	value.
	(_initialize_infcmd): Update.
	* command.h (add_setshow_optional_filename_cmd): Add
	'pre_show_func' argument.

Index: command.h
===================================================================
RCS file: /cvs/src/src/gdb/command.h,v
retrieving revision 1.58
diff -u -r1.58 command.h
--- command.h	1 Jan 2008 22:53:09 -0000	1.58
+++ command.h	3 Feb 2008 20:24:30 -0000
@@ -297,6 +297,7 @@
 					       const char *show_doc,
 					       const char *help_doc,
 					       cmd_sfunc_ftype *set_func,
+					       void (*pre_show_func) (struct cmd_list_element *),
 					       show_value_ftype *show_func,
 					       struct cmd_list_element **set_list,
 					       struct cmd_list_element **show_list);
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.169
diff -u -r1.169 infcmd.c
--- infcmd.c	31 Jan 2008 13:37:21 -0000	1.169
+++ infcmd.c	3 Feb 2008 20:24:31 -0000
@@ -268,12 +268,10 @@
   inferior_argv = 0;
 }
 
-/* Notice when `show args' is run.  */
+/* Called to compute the value before `show args' is run.  */
 static void
-notice_args_read (struct ui_file *file, int from_tty,
-		  struct cmd_list_element *c, const char *value)
+notice_args_read (struct cmd_list_element *c)
 {
-  deprecated_show_value_hack (file, from_tty, c, value);
   /* Might compute the value.  */
   get_inferior_args ();
 }
@@ -2058,6 +2056,7 @@
 _initialize_infcmd (void)
 {
   struct cmd_list_element *c = NULL;
+  struct cmd_list_element *show_args;
 
   /* add the filename of the terminal connected to inferior I/O */
   add_setshow_filename_cmd ("inferior-tty", class_run,
@@ -2074,6 +2073,7 @@
 Follow this command with any number of args, to be passed to the program."),
 				     notice_args_set,
 				     notice_args_read,
+				     NULL,
 				     &setlist, &showlist);
 
   c = add_cmd ("environment", no_class, environment_info, _("\
Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.101
diff -u -r1.101 solib.c
--- solib.c	7 Jan 2008 15:19:58 -0000	1.101
+++ solib.c	3 Feb 2008 20:24:31 -0000
@@ -1033,6 +1033,7 @@
 Show the search path for loading non-absolute shared library symbol files."), _("\
 This takes precedence over the environment variables PATH and LD_LIBRARY_PATH."),
 				     reload_shared_libraries,
+				     NULL,
 				     show_solib_search_path,
 				     &setlist, &showlist);
 }
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.198
diff -u -r1.198 symfile.c
--- symfile.c	29 Jan 2008 22:47:20 -0000	1.198
+++ symfile.c	3 Feb 2008 20:24:31 -0000
@@ -4181,6 +4181,7 @@
 and lastly at the path of the directory of the binary with\n\
 the global debug-file directory prepended."),
 				     NULL,
+				     NULL,
 				     show_debug_file_directory,
 				     &setlist, &showlist);
 }
Index: cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.63
diff -u -r1.63 cli-decode.c
--- cli/cli-decode.c	1 Jan 2008 22:53:14 -0000	1.63
+++ cli/cli-decode.c	3 Feb 2008 20:24:31 -0000
@@ -523,15 +523,18 @@
 				   const char *set_doc, const char *show_doc,
 				   const char *help_doc,
 				   cmd_sfunc_ftype *set_func,
+				   void (*pre_show_func) (struct cmd_list_element *),
 				   show_value_ftype *show_func,
 				   struct cmd_list_element **set_list,
 				   struct cmd_list_element **show_list)
 {
+  struct cmd_list_element *show_cmd;
   add_setshow_cmd_full (name, class, var_optional_filename, var,
 			set_doc, show_doc, help_doc,
 			set_func, show_func,
 			set_list, show_list,
-			NULL, NULL);
+			NULL, &show_cmd);
+  show_cmd->pre_show_hook = pre_show_func;
 }
 
 /* Add element named NAME to both the set and show command LISTs (the


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