* [PATCH] gdb: remove unnecessary 'dir' commands from gdb-gdb.gdb script
@ 2023-02-08 17:13 Andrew Burgess
2023-02-09 14:01 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2023-02-08 17:13 UTC (permalink / raw)
To: gdb-patches; +Cc: Andrew Burgess
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:
/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
Notice the second, third, and fourth entries in this list, these
should really be:
/tmp/binutils-gdb/build/../src/gdb
/tmp/binutils-gdb/build/../src/gdb/../bfd
/tmp/binutils-gdb/build/../src/gdb/../libiberty
The problem is because I generally run everything from the top level
build directory, not the gdb/ sub-directory, thus, I start GDB like:
./gdb/gdb --data-directory ./gdb/data-directory
If run GDB under GDB, then I end up loading the gdb/gdb-gdb.gdb
script, which contains these lines:
dir ../../src/gdb/../libiberty
dir ../../src/gdb/../bfd
dir ../../src/gdb
dir .
These commands only make sense when running within the gdb/
sub-directory.
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.
The build/gdb/gdb-gdb.gdb script is created from the
src/gdb/gdb-gdb.gdb.in template, which includes the automake @srcdir@
markers.
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.
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.
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@.
---
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
- dir @srcdir@/../libiberty
- dir @srcdir@/../bfd
- dir @srcdir@
- dir .
-
# Commands below are not fully compatible with wrapping into an 'if' block.
end
base-commit: 1947a4a4bb7651a4656edceb1f9b246f96f89ebd
--
2.25.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb: remove unnecessary 'dir' commands from gdb-gdb.gdb script
2023-02-08 17:13 [PATCH] gdb: remove unnecessary 'dir' commands from gdb-gdb.gdb script Andrew Burgess
@ 2023-02-09 14:01 ` Tom Tromey
2023-02-11 17:15 ` Andrew Burgess
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2023-02-09 14:01 UTC (permalink / raw)
To: Andrew Burgess via Gdb-patches; +Cc: Andrew Burgess
>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:
Andrew> While debugging GDB I used 'show directories' and spotted lots of
Andrew> entries that didn't make much sense. Here are all the entries that are
Andrew> in my directories list:
Andrew> However... I'd like to propose that we instead remove all the extra
Andrew> directories completely. My hope is that, with more recent tools, the
Andrew> debug information should allow us to correctly find all of the source
Andrew> files without having to add any extra 'dir' entries. Obviously,
Andrew> commit 67f0714670383a does make me a little nervous, but the
Andrew> gdb-gdb.gdb script isn't something a non-maintainer will be using, so
Andrew> I think we can afford to be a little more aggressive here. If it
Andrew> turns out the 'dir' entries are needed then we can add them back, but
Andrew> actually document why they are needed. Plus, when we add them back we
Andrew> will use @abs_srcdir@ instead of @srcdir@.
Makes sense to me.
Reviewed-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb: remove unnecessary 'dir' commands from gdb-gdb.gdb script
2023-02-09 14:01 ` Tom Tromey
@ 2023-02-11 17:15 ` Andrew Burgess
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2023-02-11 17:15 UTC (permalink / raw)
To: Tom Tromey, Andrew Burgess via Gdb-patches
Tom Tromey <tom@tromey.com> writes:
>>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Andrew> While debugging GDB I used 'show directories' and spotted lots of
> Andrew> entries that didn't make much sense. Here are all the entries that are
> Andrew> in my directories list:
>
> Andrew> However... I'd like to propose that we instead remove all the extra
> Andrew> directories completely. My hope is that, with more recent tools, the
> Andrew> debug information should allow us to correctly find all of the source
> Andrew> files without having to add any extra 'dir' entries. Obviously,
> Andrew> commit 67f0714670383a does make me a little nervous, but the
> Andrew> gdb-gdb.gdb script isn't something a non-maintainer will be using, so
> Andrew> I think we can afford to be a little more aggressive here. If it
> Andrew> turns out the 'dir' entries are needed then we can add them back, but
> Andrew> actually document why they are needed. Plus, when we add them back we
> Andrew> will use @abs_srcdir@ instead of @srcdir@.
>
> Makes sense to me.
Thanks. I've pushed this. I'm sure people will shout if it turns out
these were useful in someway.
Thanks,
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-11 17:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-08 17:13 [PATCH] gdb: remove unnecessary 'dir' commands from gdb-gdb.gdb script Andrew Burgess
2023-02-09 14:01 ` Tom Tromey
2023-02-11 17:15 ` Andrew Burgess
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).