From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6437 invoked by alias); 3 Feb 2008 20:50:28 -0000 Received: (qmail 6428 invoked by uid 22791); 3 Feb 2008 20:50:27 -0000 X-Spam-Check-By: sourceware.org Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 03 Feb 2008 20:50:07 +0000 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1JLlms-0002Ke-G5 for gdb-patches@sources.redhat.com; Sun, 03 Feb 2008 20:50:02 +0000 Received: from 207.189.196.151 ([207.189.196.151]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 03 Feb 2008 20:50:02 +0000 Received: from tromey by 207.189.196.151 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 03 Feb 2008 20:50:02 +0000 To: gdb-patches@sources.redhat.com From: Tom Tromey Subject: Patch: 'show args' -vs- '--args' Date: Sun, 03 Feb 2008 20:50:00 -0000 Message-ID: Reply-To: tromey@redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Attribution: Tom User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.990 (gnu/linux) 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: 2008-02/txt/msg00058.txt.bz2 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 * 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