From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 9E56A3858D32; Sat, 11 Feb 2023 17:14:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E56A3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676135698; bh=2+41vwlV8TiRh6df+mVYCQPMyMigUG7HlgnQhXIh7z4=; h=From:To:Subject:Date:From; b=ooDO532IUeGNNiXk8OYDgSz0+qFOqukdzc7AfsKERKh0AqKnTPAWQYAoxwh5jHgIo 7ehG6M1viV5CjTguiKKl98WjNEH5qtcXbnNwPWNpJkxqYOhoG1G/jK+CN28r2dAACQ mQH4KaNlfaTZPzMpMI9KXNXTDGMdcBZKeiHcXl7w= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: remove unnecessary 'dir' commands from gdb-gdb.gdb script X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: af0d0f34d8bf7482e598308b54e7ba0ae9b0c349 X-Git-Newrev: b9c05fc03d313d8505df2c1265481faf6594b62a Message-Id: <20230211171458.9E56A3858D32@sourceware.org> Date: Sat, 11 Feb 2023 17:14:58 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db9c05fc03d31= 3d8505df2c1265481faf6594b62a commit b9c05fc03d313d8505df2c1265481faf6594b62a Author: Andrew Burgess Date: Wed Feb 8 16:47:34 2023 +0000 gdb: remove unnecessary 'dir' commands from gdb-gdb.gdb script =20 While debugging GDB I used 'show directories' and spotted lots of entries that didn't make much sense. Here are all the entries that are in my directories list: =20 /tmp/binutils-gdb/build /tmp/binutils-gdb/build/../../src/gdb /tmp/binutils-gdb/build/../../src/gdb/../bfd /tmp/binutils-gdb/build/../../src/gdb/../libiberty $cdir $cwd =20 Notice the second, third, and fourth entries in this list, these should really be: =20 /tmp/binutils-gdb/build/../src/gdb /tmp/binutils-gdb/build/../src/gdb/../bfd /tmp/binutils-gdb/build/../src/gdb/../libiberty =20 The problem is because I generally run everything from the top level build directory, not the gdb/ sub-directory, thus, I start GDB like: =20 ./gdb/gdb --data-directory ./gdb/data-directory =20 If run GDB under GDB, then I end up loading the gdb/gdb-gdb.gdb script, which contains these lines: =20 dir ../../src/gdb/../libiberty dir ../../src/gdb/../bfd dir ../../src/gdb dir . =20 These commands only make sense when running within the gdb/ sub-directory. =20 However, my debugging experience doesn't seem to be degraded at all, I can still see the GDB source code just fine; which is because the directory list still contains $cdir. =20 The build/gdb/gdb-gdb.gdb script is created from the src/gdb/gdb-gdb.gdb.in template, which includes the automake @srcdir@ markers. =20 The 'dir' commands have mostly been around since the sourceware repository was first created, though this commit 67f0714670383a did reorder some of the 'dir' commands, which would seem to indicate these commands were important to some people, at some time. =20 One possible fix would be to replace @srcdir@ with @abs_srcdir@, this would ensure that the entries added were all valid, no matter the user's current directory when debugging GDB. =20 However... I'd like to propose that we instead remove all the extra directories completely. My hope is that, with more recent tools, the debug information should allow us to correctly find all of the source files without having to add any extra 'dir' entries. Obviously, commit 67f0714670383a does make me a little nervous, but the gdb-gdb.gdb script isn't something a non-maintainer will be using, so I think we can afford to be a little more aggressive here. If it turns out the 'dir' entries are needed then we can add them back, but actually document why they are needed. Plus, when we add them back we will use @abs_srcdir@ instead of @srcdir@. =20 Reviewed-By: Tom Tromey Diff: --- gdb/gdb-gdb.gdb.in | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gdb/gdb-gdb.gdb.in b/gdb/gdb-gdb.gdb.in index 8d97c95a70e..b9fd457d069 100644 --- a/gdb/gdb-gdb.gdb.in +++ b/gdb/gdb-gdb.gdb.in @@ -16,11 +16,6 @@ if !$gdb_init_done return end =20 - dir @srcdir@/../libiberty - dir @srcdir@/../bfd - dir @srcdir@ - dir . - # Commands below are not fully compatible with wrapping into an 'if' blo= ck. end