From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22576 invoked by alias); 16 Sep 2002 20:37:30 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 22569 invoked from network); 16 Sep 2002 20:37:30 -0000 Received: from unknown (HELO msgbas1.cos.agilent.com) (192.25.240.36) by sources.redhat.com with SMTP; 16 Sep 2002 20:37:30 -0000 Received: from relcos2.cos.agilent.com (relcos2.cos.agilent.com [130.29.152.237]) by msgbas1.cos.agilent.com (Postfix) with ESMTP id 97953D14A; Mon, 16 Sep 2002 14:37:29 -0600 (MDT) Received: from websvr.canada.agilent.com (websvr.canada.agilent.com [141.184.122.102]) by relcos2.cos.agilent.com (Postfix) with ESMTP id 9E64D51C; Mon, 16 Sep 2002 14:36:42 -0600 (MDT) Received: from agilent.com (dhcp6burnaby.canada.agilent.com [141.184.123.147]) by websvr.canada.agilent.com (8.9.3 (PHNE_25183)/8.9.3 SMKit7.1.1_Agilent) with ESMTP id NAA09283; Mon, 16 Sep 2002 13:37:23 -0700 (PDT) Message-ID: <3D864101.2A0BCA85@agilent.com> Date: Mon, 16 Sep 2002 13:37:00 -0000 From: Earl Chew Organization: Agilent Technologies X-Accept-Language: en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com, cgf@redhat.com Subject: [RFC PATCH] Finding files in source trees (was Re: Finding source files under Cygwin) References: <3D82897C.81376AD6@agilent.com> <3D862BD0.A5298600@agilent.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2002-09/txt/msg00319.txt.bz2 Christopher Faylor wrote: > I'm sorry but it is rarely a good idea to mix functionality like this. > You're mixing an (arguable) bug fix with an (arguable) gdb enhancement. > > Please submit each as a separate patch. Ok. This patch allows files to be found in source trees. The motivation for this addition is to accommodate large projects where source files are scattered in large source trees. I want to be able to point gdb at the root of the source tree, rather than have to specify each leaf directory. Thus I can write: gdb> dir /myproject/source instead of: gdb> dir /myproject/source/a/b/c:/myproject/source/z/b/d: etc Earl ChangeLog: * source.c: Source file lookup changes. (open_source_file): If the source file /w/x/y/z.c cannot be found, try using w/x/y/z.c, x/y/z.c, y/z.c in addition to z.c (the basename). --- gdb-5.2.1\gdb\source.c 2002-09-16 13:08:17.000000000 -0700 +++ source.c 2002-09-16 13:09:31.000000000 -0700 @@ -753,6 +753,25 @@ result = openp_1 (path, pathlen, sep, 0, p, OPEN_MODE, 0, &s->fullname); } + if (result < 0) + { + /* Didn't work. Try lopping off prefixes from the full name. */ + p = s->filename; + + do + { + while (*p && ! IS_DIR_SEPARATOR (*p)) + p++; + if (*p && *++p) + { + result = openp_1 (path, pathlen, sep, 0, + p, OPEN_MODE, 0, &s->fullname); + if (result >= 0) + break; + } + } while (*p); + } + if (result >= 0) { fullname = s->fullname;