From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2416 invoked by alias); 28 Feb 2008 16:41:06 -0000 Received: (qmail 2405 invoked by uid 22791); 28 Feb 2008 16:41:05 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 28 Feb 2008 16:40:46 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 626A5983A2; Thu, 28 Feb 2008 16:40:44 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id 2CD9D98140; Thu, 28 Feb 2008 16:40:44 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1JUloJ-0000BU-B2; Thu, 28 Feb 2008 11:40:43 -0500 Date: Thu, 28 Feb 2008 16:50:00 -0000 From: Daniel Jacobowitz To: Tom Tromey Cc: gdb-patches@sources.redhat.com Subject: Re: Patch: 'show args' -vs- '--args' Message-ID: <20080228164043.GD31695@caradoc.them.org> Mail-Followup-To: Tom Tromey , gdb-patches@sources.redhat.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-12-11) 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/msg00476.txt.bz2 On Sun, Feb 03, 2008 at 01:03:10PM -0700, Tom Tromey wrote: > 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. This is from your original --args patch as posted on gdb-patches: @@ -1785,8 +1836,10 @@ "Set argument list to give program being debugged when it is started.\n\ Follow this command with any number of args, to be passed to the program.", &setlist); - add_show_from_set (c, &showlist); c->completer = filename_completer; + c->function.sfunc = notice_args_set; + c = add_show_from_set (c, &showlist); + c->pre_show_hook = notice_args_read; c = add_cmd ("environment", no_class, environment_info, It was removed in a typo later and eventually ended up readded as a show_func rather than a pre_show_hook. Anyway, now that it's a show_func... > +notice_args_read (struct cmd_list_element *c) > { > - deprecated_show_value_hack (file, from_tty, c, value); > /* Might compute the value. */ > get_inferior_args (); > } wouldn't just swapping those two function calls fix it? -- Daniel Jacobowitz CodeSourcery