From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22112 invoked by alias); 22 Sep 2009 19:06:43 -0000 Received: (qmail 22103 invoked by uid 22791); 22 Sep 2009 19:06:42 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Sep 2009 19:06:36 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 245F010DC7 for ; Tue, 22 Sep 2009 19:06:34 +0000 (GMT) Received: from caradoc.them.org (209.195.188.212.nauticom.net [209.195.188.212]) by nan.false.org (Postfix) with ESMTP id 0487F10DB3 for ; Tue, 22 Sep 2009 19:06:34 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1MqAh6-0008V9-UQ for gdb-patches@sourceware.org; Tue, 22 Sep 2009 15:06:32 -0400 Date: Tue, 22 Sep 2009 19:06:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sourceware.org Subject: [RFC] Fix source path lookup immediately after substitute-path Message-ID: <20090922190632.GA31949@caradoc.them.org> Mail-Followup-To: gdb-patches@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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: 2009-09/txt/msg00709.txt.bz2 I've been frustrated several times by this routine. For the test I compiled 'main.c' to 'main', then moved main.c into another directory. +list main 1 main.c: No such file or directory. in main.c All is well so far. +set substitute-path /scratch/dan/eabi44 /scratch/dan/eabi44/backup +list main 1 in main.c Where's my file? Maybe if I prod GDB it'll look again. +dir +list main 1 in main.c Nope! Still can't find it! +dir /no Warning: /no: No such file or directory. +list main 1 int main(){} I discovered, by reading the source, that "dir" with a directory or listing another source file would do the trick. There are two different functions to invalidate cached source directory locations. Some places call one but not the other; some call both; some ("set substitute-path" for instance) call neither. This patch combines the two functions and makes them be reliably called. I spent a little while trying to write a portable test case for this and eventually gave up. Any thoughts on this patch? May I include it in 7.0? -- Daniel Jacobowitz CodeSourcery 2009-09-22 Daniel Jacobowitz gdb/ * source.c (forget_cached_source_info): Clear last_source_visited. (init_last_source_visited): Delete. (directory_command): Do not clear last_source_visited. Call forget_cached_source_info only if required. (unset_substitute_path_command, set_substitute_path_command): Call forget_cached_source_info. * mi/mi-cmd-env.c (mi_cmd_env_dir): Do not call init_last_source_visited. * defs.h (init_last_source_visited): Delete declaration. Index: source.c =================================================================== --- source.c (revision 262056) +++ source.c (working copy) @@ -345,6 +345,8 @@ forget_cached_source_info (void) } } } + + last_source_visited = NULL; } void @@ -357,12 +359,6 @@ init_source_path (void) forget_cached_source_info (); } -void -init_last_source_visited (void) -{ - last_source_visited = NULL; -} - /* Add zero or more directories to the front of the source path. */ void @@ -381,11 +377,10 @@ directory_command (char *dirname, int fr else { mod_path (dirname, &source_path); - last_source_visited = NULL; + forget_cached_source_info (); } if (from_tty) show_directories ((char *) 0, from_tty); - forget_cached_source_info (); } /* Add a path given with the -d command line switch. @@ -1884,6 +1879,8 @@ unset_substitute_path_command (char *arg if (from != NULL && !rule_found) error (_("No substitution rule defined for `%s'"), from); + + forget_cached_source_info (); } /* Add a new source path substitution rule. */ @@ -1922,6 +1919,7 @@ set_substitute_path_command (char *args, /* Insert the new substitution rule. */ add_substitute_path_rule (argv[0], argv[1]); + forget_cached_source_info (); } Index: mi/mi-cmd-env.c =================================================================== --- mi/mi-cmd-env.c (revision 262056) +++ mi/mi-cmd-env.c (working copy) @@ -232,7 +232,6 @@ mi_cmd_env_dir (char *command, char **ar for (i = argc - 1; i >= 0; --i) env_mod_path (argv[i], &source_path); - init_last_source_visited (); ui_out_field_string (uiout, "source-path", source_path); forget_cached_source_info (); Index: defs.h =================================================================== --- defs.h (revision 262056) +++ defs.h (working copy) @@ -636,8 +636,6 @@ extern char *source_path; extern void init_source_path (void); -extern void init_last_source_visited (void); - /* From exec.c */ /* Take over the 'find_mapped_memory' vector from exec.c. */